instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I have a problem with IIS 6.0 ceasing to work for an ASP.NET application after installing Service Pack 1 for <code>.NET 3.5</code>.</p>
<p>I have 2 identical virtual dedicated servers. Installing SP1 on the first had no adverse effect. Installing it on the second caused ASP.NET pages to start returning 404 page not found.</p>
<p>Static .html pages working okay on both servers.</p>
<p>Has anybody else experienced this?</p>
|
<p>This is broad problem, so let's start by asking some troubleshooting questions:</p>
<blockquote>
<ul>
<li>Based on your description, the ASP.NET runtime is not catching your request and processing the aspx files. You may need to register the asp.net pipeline with IIS again using ASPNET_REGIIS -i.</li>
<li>Have you made sure that the app_offline.htm file has been removed
from the directory of the application?
I have had this happen before after an
update.</li>
<li>Have you setup <a href="http://www.fiddlertool.com/fiddler/" rel="nofollow noreferrer">fiddler</a> for instance to follow the request to see what is
exactly being requested?</li>
<li>Make sure ASP.NET is enabled in the IIS Administration Console under "Web
Service Extensions." <a href="http://www.dotnetjunkies.com/WebLog/photos/davetrux/images/295487/original.aspx" rel="nofollow noreferrer">Make sure everything is set to allowed for your different versions of the framework.</a></li>
</ul>
</blockquote>
<p>Well, let's start with those and hopefully we can guide you to the problem.</p>
|
<p>No-one did before, so I'll point to the trivial solution:<br>
Have you already de-installed the Service Pack and re-installed it again (or the whole framework)?</p>
<p>Edit: @Kev:<br>
Easy explanation: He said the update works on one machine, but not on the other. I had similar problems in the past and re-installing helped to solve some of them. And it is trivial to do.<br>
That's my approach:<br>
1. trivial<br>
2. easy<br>
3. headache </p>
<p>You are right, on productive systems you must be careful, but that's his decision. And because it is a virtual server, maybe it is easy for him to copy it and try as a test environment first.</p>
| 3,574
|
<p>As a general rule, I prefer using value rather than pointer semantics in C++ (ie using <code>vector<Class></code> instead of <code>vector<Class*></code>). Usually the slight loss in performance is more than made up for by not having to remember to delete dynamically allocated objects.</p>
<p>Unfortunately, value collections don't work when you want to store a variety of object types that all derive from a common base. See the example below.</p>
<pre><code>#include <iostream>
using namespace std;
class Parent
{
public:
Parent() : parent_mem(1) {}
virtual void write() { cout << "Parent: " << parent_mem << endl; }
int parent_mem;
};
class Child : public Parent
{
public:
Child() : child_mem(2) { parent_mem = 2; }
void write() { cout << "Child: " << parent_mem << ", " << child_mem << endl; }
int child_mem;
};
int main(int, char**)
{
// I can have a polymorphic container with pointer semantics
vector<Parent*> pointerVec;
pointerVec.push_back(new Parent());
pointerVec.push_back(new Child());
pointerVec[0]->write();
pointerVec[1]->write();
// Output:
//
// Parent: 1
// Child: 2, 2
// But I can't do it with value semantics
vector<Parent> valueVec;
valueVec.push_back(Parent());
valueVec.push_back(Child()); // gets turned into a Parent object :(
valueVec[0].write();
valueVec[1].write();
// Output:
//
// Parent: 1
// Parent: 2
}
</code></pre>
<p>My question is: Can I have have my cake (value semantics) and eat it too (polymorphic containers)? Or do I have to use pointers?</p>
|
<p>Since the objects of different classes will have different sizes, you would end up running into the slicing problem if you store them as values.</p>
<p>One reasonable solution is to store container safe smart pointers. I normally use boost::shared_ptr which is safe to store in a container. Note that std::auto_ptr is not.</p>
<pre><code>vector<shared_ptr<Parent>> vec;
vec.push_back(shared_ptr<Parent>(new Child()));
</code></pre>
<p>shared_ptr uses reference counting so it will not delete the underlying instance until all references are removed.</p>
|
<p>I'm using my own templated collection class with exposed value type semantics, but internally it stores pointers. It's using a custom iterator class that when dereferenced gets a value reference instead of a pointer. Copying the collection makes deep item copies, instead of duplicated pointers, and this is where most overhead lies (a really minor issue, considered what I get instead).</p>
<p>That's an idea that could suit your needs.</p>
| 6,234
|
<p>Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when using it via putty/ssh where you cannot use the mouse?</p>
<p>I can easily yank-to-the-end-of-line or yank-to-the-end-of-code-block but if the text extends over many screens, or has lots of blank lines in it, I feel like my hands are tied in Vim. Any solutions?</p>
<p>And a related question: is there a way to somehow select 40 lines, and then comment them all out (with "#" or "//"), as is common in most IDEs?</p>
|
<p>Well, first of all, you can set <code>vim</code> to work with the mouse, which would allow you to select text just like you would in <code>Eclipse</code>.</p>
<p>You can also use the Visual selection - <kbd>v</kbd>, by default. Once selected, you can <code>yank</code>, <code>cut</code>, etc.</p>
<p>As far as commenting out the block, I usually select it with <code>VISUAL</code>, then do</p>
<pre><code>:'<,'>s/^/# /
</code></pre>
<p>Replacing the beginning of each line with a <code>#</code>. (The <code>'<</code> and <code>'></code> markers are the beginning and and of the visual selection.</p>
|
<p>v enters visual block mode, where you can select as if with shift in most common editors, later you can do anything you can normally do with normal commands (substitution :'<,'>s/^/#/ to prepend with a comment, for instance) where '<,'> means the selected visual block instead of all the text.</p>
| 8,298
|
<p>I'm trying to create a custom workflow action with an output parameter for error handling. Working from various examples, I can't get Parameter Direction="Out" to work. Everything seems right, but when I try to assign the output to the "error" variable in SharePoint Designer, it places asterisks around it and flags it as a workflow error. Here is what the action XML looks like:</p>
<pre><code><Action Name="Create Folder"
ClassName="ActivityLibrary.CreateFolderActivityTest"
Assembly="ActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxx"
AppliesTo="all"
CreatesInList="ListId"
Category="Custom">
<RuleDesigner Sentence="Create a folder %1 in the %2 base folder. If an error occurs it will be output to %3.">
<FieldBind Field="FolderName" Text="folder name" Id="1" />
<FieldBind Field="BaseFolderPath" Text="folder path" Id="2"/>
<FieldBind Field="OutError" DesignerType="ParameterNames" Text="out error" Id="3"/>
</RuleDesigner>
<Parameters>
<Parameter Name="FolderName" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="BaseFolderPath" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="OutError" Type="System.String, mscorlib" Direction="Out" />
</Parameters>
</Action>
</code></pre>
|
<p>I think you may want Direction="InOut" from the looks of the binding</p>
|
<p>Are you sure the issue is with the parameters and not maybe the variable in SPD? Certainly nothing looks wrong with your XML.</p>
<p>I always hated the way SPD and workflows make you create a variable within the workflow and another within the page to assign to the same value as the workflow variable.</p>
| 3,583
|
<p>As of the fall of 2008 I'm about to embark on a new development cycle for a major product that has a winforms and an asp.net interface. We use Telerik, DevExpress and Infragistics components in it and all are going to have a release within a month or so which will be the one I target for our spring release of our product. </p>
<p>They all support VS2005 and we will continue to target .net 2+ so I can't see any compelling reason so far to upgrade to VS2008.</p>
<p>Has anyone found a compelling reason for upgrading to VS2008?</p>
|
<p>It's worth it. It's faster, the designer is vastly improved (split view, faster context switching), it has better support for javascript and when you're ready to target 3.5, you'll be ready to go.</p>
|
<p>It is worth the upgrade for me for the main reason that I can target different .NET versions (2, 3, 3.5) from the same IDE whereas in the past, one version of Visual Studio supported one version of .NET.</p>
<p>The UI seems much more responsive now, but the core set of tools and processes hasn't changed that much.</p>
| 9,047
|
<p>I have the following webform:</p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestWebApp.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtMultiLine" runat="server"
Width="400px" Height="300px" TextMode="MultiLine"></asp:TextBox>
<br />
<asp:Button ID="btnSubmit" runat="server"
Text="Do A Postback" OnClick="btnSubmitClick" />
</div>
</form>
</body>
</html>
</code></pre>
<p>and each time I post-back the leading line feeds in the textbox are being removed. Is there any way that I can prevent this behavior? </p>
<p>I was thinking of creating a custom-control that inherited from the textbox but I wanted to get a sanity check here first.</p>
|
<p>can't help with VB6 solution, can help with .net or java solution on the server.<br>
Get iText or iTextSharp from <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">http://www.lowagie.com/iText/</a>.<br>
It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate FDF files, get field names out of PDF files, etc... </p>
|
<p>Take my advice. Ditch PDF for XPS. I am working on two apps, both server based. One displays image-based documents as PDFs in a browser. The second uses FixedPage templates to construct XPS documents bound to data sources. </p>
<p>My conclusion after working on both projects is that PDFs suck; XPS documents less so. You have to pay cash money for a decent PDF library, whereas XPS comes with the framework. PDF document generation is a memory hog, has lots of potholes and isn't very server friendly. XPS docs have a much smaller footprint and less chances of shooting yourself in the foot. </p>
| 7,845
|
<p>I'm working on a WinCE 6.0 system with a touchscreen that stores its calibration data (x-y location, offset, etc.) in the system registry (HKLM\HARDWARE\TOUCH). Right now, I'm placing the cal values into registry keys that get put into the OS image at build time. That works fine for the monitor that I get the original cal values from, but when I load this image into another system with a different monitor, the touchscreen pointer location is (understandably) off, because the two monitors do not have the same cal values.</p>
<p>My problem is that I don't know how to properly store values into the registry so that they persist after a power cycle. See, I can recalibrate the screen on the second system, but the new values only exist in volatile memory. I suggested to my boss that we could just tell our customer to leave the power on the unit at all times -- that didn't go over well.</p>
<p>I need advice on how to save the new constants into the registry, so that we can calibrate the monitors once before shipping them out to our customer, and not have to make separate OS images for each unit we build.</p>
<p>A C# method that is known to work in CE6.0 would be helpful. Thanks.</p>
<p>-Odbasta</p>
|
<p>I think what you're probably looking for is the Flush function of the RegistryKey class. This is normally not necessary (the registry is lazily-flushed by default), but if the power is turned off on the device before the system has a chance to do this, changes will be discarded:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.flush.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.flush.aspx</a></p>
<p>This function is available in .NET Compact Framework version 2.0 and better.</p>
|
<p>As I understood you need to know how to set a value to the registry during runtime. I hope the codes bellow can help you.</p>
<p>using Microsoft.Win32; </p>
<pre><code> /// <summary>
/// store a key value in registry. if it don't exist it will be created.
/// </summary>
/// <param name="mainKey">the main key of key path</param>
/// <param name="subKey">the path below the main key</param>
/// <param name="keyName">the key name</param>
/// <param name="value">the value to be stored</param>
public static void SetRegistry(int mainKey, String subKey, String keyName, object value)
{
if (mainKey != CURRENT_USER && mainKey != LOCAL_MACHINE)
{
throw new ArgumentOutOfRangeException("mainKey", "\'mainKey\' argument can only be AppUtils.CURRENT_USER or AppUtils.LOCAL_MACHINE values");
}
if (subKey == null)
{
throw new ArgumentNullException("subKey", "\'subKey\' argument cannot be null");
}
if (keyName == null)
{
throw new ArgumentNullException("keyName", "\'keyName\' argument cannot be null");
}
const Boolean WRITABLE = true;
RegistryKey key = null;
if (mainKey == CURRENT_USER)
{
key = Registry.CurrentUser.OpenSubKey(subKey, WRITABLE);
if (key == null)
{
key = Registry.CurrentUser.CreateSubKey(subKey);
}
}
else if (mainKey == LOCAL_MACHINE)
{
key = Registry.LocalMachine.OpenSubKey(subKey, WRITABLE);
if (key == null)
{
key = Registry.LocalMachine.CreateSubKey(subKey);
}
}
key.SetValue(keyName, value);
}
/// <summary>
/// find a key value in registry. if it don't exist the default value will be returned.
/// </summary>
/// <param name="mainKey">the main key of key path</param>
/// <param name="subKey">the path below the main key</param>
/// <param name="keyName">the key name</param>
/// <param name="defaultValue">the value to be stored</param>
public static object GetRegistry(int mainKey, String subKey, String keyName, object defaultValue)
{
if (mainKey != CURRENT_USER && mainKey != LOCAL_MACHINE)
{
throw new ArgumentOutOfRangeException("mainKey", "\'mainKey\' argument can only be AppUtils.CURRENT_USER or AppUtils.LOCAL_MACHINE values");
}
if (subKey == null)
{
throw new ArgumentNullException("subKey", "\'subKey\' argument cannot be null");
}
if (keyName == null)
{
throw new ArgumentNullException("keyName", "\'keyName\' argument cannot be null");
}
RegistryKey key = Registry.CurrentUser.OpenSubKey(subKey);
if (mainKey == CURRENT_USER)
{
key = Registry.CurrentUser.OpenSubKey(subKey);
}
else if (mainKey == LOCAL_MACHINE)
{
key = Registry.LocalMachine.OpenSubKey(subKey);
}
object result = defaultValue;
if (key != null)
{
result = key.GetValue(keyName, defaultValue);
}
return result;
}
</code></pre>
| 8,195
|
<p>A lot of consumer desktop F.D.M. printers comes with a 0.4mm nozzle. I'm looking to print fine details objects and I was considering trying to use a smaller size nozzle. But before I do so I would like to establish a list of downsides and unwanted consequences.</p>
|
<p>Here are some things to look out for when switching to a smaller nozzle size:</p>
<ul>
<li><strong>Curling</strong> (out of the nozzle): Make sure the nozzle is clear of any debris to avoid the extruded filament from catching and therefore curling around the nozzle.</li>
<li><strong>Warping</strong>: You might experience more warping on the build plate and delamination between layers as a result of the smaller surface area of the layers.</li>
<li><strong>Reduce speeds</strong>: You should reduce your print speeds anyways when printing fine-detail objects. However, the smaller nozzle size will need a bit more time to adhere to other objects (see above).</li>
<li><strong>Standoff distance</strong>: The distance between the nozzle and build plate, a.k.a standoff, should be a bit smaller with the nozzle size. Typically people use the paper reference (using a piece of paper to "calibrate" the standoff), which is about 0.004".</li>
<li><strong>Make sure your slicing engine knows the change!</strong> Most slicing software will allow you to adjust the nozzle size. This can also be used to fine-tune your machine.</li>
<li><strong>Beware of clogging</strong>: Clogging is usually a result of poor cooling between your heater block and your drive gear, poor filament quality, and/or incorrect extrusion rates. You might want to perform a benchmark print with the new nozzle to "rediscover" which temperatures work best with the new "basin" volume in the nozzle.</li>
</ul>
<p>I'm sure there are many others, but this should help get you started.</p>
|
<p>In addition to the <a href="https://3dprinting.stackexchange.com/a/2974/5740">answer</a> of <a href="https://3dprinting.stackexchange.com/users/98/tbm0115">tbm0115</a>; special care has to be given to the strength and stiffness of the model. Lines are thinner and thus when using the same amount of walls and infill percentage, the walls will be less stiff. This requires a higher percentage of infill or more walls to counteract this phenomenon. Obviously, this will cause the print to take longer.</p>
| 414
|
<p>Reading through <a href="https://stackoverflow.com/questions/39879/why-doesnt-javascript-support-multithreading">this question</a> on multi-threaded javascript, I was wondering if there would be any security implications in allowing javascript to spawn mutliple threads. For example, would there be a risk of a malicious script repeatedly spawning thread after thread in an attempt to overwhelm the operating system or interpreter and trigger entrance into "undefined behavior land", or is it pretty much a non-issue? Any other ways in which an attack might exploit a hypothetical implementation of javascript that supports threads that a non-threading implementation would be immune to?</p>
<p><strong>Update:</strong> Note that locking up a browser isn't the same as creating an undefined behavior exploit. </p>
|
<p>No, multiple threads would not add extra security problems in a perfect implementation. Threaded javascript would add complexity to the javascript interpreter which makes it more likely to have an exploitable bug. But threads alone are not going to add any security issues. </p>
<p>Threads are not present in javascript because "Threads Suck" - read more from the language designer (<a href="http://weblogs.mozillazine.org/roadmap/archives/2007/02/threads_suck.html" rel="nofollow noreferrer">http://weblogs.mozillazine.org/roadmap/archives/2007/02/threads_suck.html</a>)</p>
|
<p>Well I think that the only major example of multi-threaded javascript is Google's chrome (WOULD THEY RELEASE IT ALREADY JEEZ) and if I understand it the javascript will only one process per tab, so unless it started spawning tabs (popups) I would assume this would be a null issue, but I think that Google has that under wraps anyway, the are running all the javascript in a sandbox.</p>
| 6,117
|
<p>Looking for books or other references that discuss actually <em>how</em> to write a code coverage tool in Java; some of the various techniques or tricks - source vs. byte code instrumentation. </p>
<p>This is for a scripting language that generates Java byte code under the hood.</p>
|
<p>Does your scripting language generate bytecode? Does it generate debug metadata? If so, bytecode instrumentation is probably the way to go. In fact existing tools will probably work (perhaps with minimal modification).</p>
<p>The typical problem with such tools that they are written to work with Java and assume that a <code>class com.foo.Bar.class</code> corresponds to a file <code>com/foo/Bar.java</code>. Unwinding that assumption can be tedious.</p>
<p><a href="http://emma.sourceforge.net/" rel="nofollow noreferrer">EMMA</a> is a ClassLoader that does byte-code re-writing for code-coverage collection in Java. The coding style is a little funky, but I recommend reading source code for some ideas.</p>
<p>If your scripting language is interpreted then you will need a higher-level class loader (at a source level) that hooks into the interpreter.</p>
|
<p>Thxm, Mc! <a href="http://asm.objectweb.org" rel="nofollow noreferrer">http://asm.objectweb.org</a>/ is another one. <em>Excellent</em> documentation on byte code instrumentation, but nothing "directly" aimed at writing a coverage tool - just some hints or ideas.</p>
| 2,429
|
<p>I know that the SLS 3D printer stands for selective laser sintering,where as DMLS stands for direct metal laser sintering.</p>
<p>I want to know that,can i convert SLS 3D printer to DMLS.</p>
<p>By just changing powder(or another way?)</p>
|
<p>By just changing powder: No.<br>
Changing the powder, the laser and the chamber, maybe you can get something, but it's not recommended.<br>
DMLS machines use a sealed chamber with a flow of Argon, Nitrogen, or other gas to prevent oxidation of metal powder (and avoid fire or explosions).<br>
Laser power for metal needs to be of higher power than that used por polymer laser sintering (SLS, SLM, LS, etc).<br>
BTW. DMLS also need a metallic build plate to dissipate heat.</p>
|
<p>Totally agreed with the answer provided.To add to that answer, the use of DMLS lies on the thickness and material limitations of SLS method. So, regarding the amount of thickness, the <a href="http://www.atlanticprecision.com" rel="nofollow">original source</a> of sizing for both the methods vary drastically and hence cannot be inter-converted. </p>
| 291
|
<p>I have used cyanoacrylate glue aka superglue to bond PLA. I have created several electronics enclosures. (Definitely the most time-consuming part of the project.)</p>
<p>Now my question is which debonder/solvent can I use to separate the pieces again without destroying the PLA parts?</p>
<p>Wikipedia proposes the following:</p>
<ul>
<li>nitromethane</li>
<li>dimethyl sulfoxide,</li>
<li>methylene chloride,</li>
<li>gamma-Butyrolactone.</li>
</ul>
|
<p><strong>Acetone</strong></p>
<p>Acetone will dissolve cynoacrylate (superglue) and should weaken it enough to be able to separate the parts.<br>
A readily available cheap source of acetone is nail varnish remover (just make sure you don't buy the acetone free version!).<br>
Give the pieces a soak in nail varnish remover for 10-20 minutes and they should come apart with some prying.<br>
Acetone does not dissolve PLA, so the PLA parts should be undamaged. If you were to try this on ABS parts however, they would begin to dissolve.</p>
|
<p>Gamma butyrolactone is by far the best product to remove cyanoacrylate and also great to dissolve PLA.</p>
| 380
|
<p>I enjoy programming, usually. Tedious stuff is easy to get done as quickly and correctly as possible so I can get through it and not have to see it again.</p>
<p>But a lot of my coding is <em>fun</em> and when I get in the 'zone' I just really enjoy myself.</p>
<p>Which is where I make the mistake of spending too much time, perhaps adding features, perhaps writing it in a cool or elegant manner, or just doing neat prototypes.</p>
<ul>
<li>How do you recognize this is happening before it exceeds your time frame?</li>
<li>What do you do before starting a potentially fun piece of code, or during, to get back on track?</li>
<li>When is it ok to let yourself go "hog wild" and just enjoy it without worrying about consequences?</li>
</ul>
<p>-Adam</p>
|
<p>Keep a detailed prioritized feature list/bug list. review it often then balance the fun work with bugs/features that need to get done.</p>
|
<p>Justify any "fun" features you insert by regarding them as marketable eye-candy.</p>
<p>Unless, of course, they're not visible ;)</p>
| 8,508
|
<p>How would you describe and promote WCF as a technology to a non-technical client/manager/CEO/etc?</p>
<p>What are competing solutions or ideas that they might bring up(such as those they read about in their magazines touting new technology)?</p>
<p>What is WCF <em>not</em> good for that you've seen people try to shoehorn it into?</p>
<p>-Adam</p>
|
<p>Comparing with .asmx: WCF is the next generation of Microsoft's Web service development platform, which addresses many of the issues with older versions, specifically:</p>
<ul>
<li>better interoperation, so you can interoperate with Web services that aren't from Microsoft or that are published on the Internet</li>
<li>much more flexible, so it's easier and faster for developers to get their jobs done</li>
<li>easier to configure without changing code, reducing the cost of maintenance significantly</li>
</ul>
<p>It may be that they raise the question of how it relates to SOA, a "service-oriented architecture". WCF is the Microsoft solution for creating applications that participate in these distributed systems.</p>
|
<p>In a single sentence, I'd say that WCF is "software that lets you set up and manage communication between systems a lot more efficiently than in the past".</p>
<p>I can see them bringing up BizTalk as a competitor, but of course you could say that WCF works with it and is in fact used as base technology for it in the more recent versions.</p>
<p>I'm not sure if I can think of any inappropriate shoe-horning of WCF that I have seen, although there are plenty of legacy apps that will probably be "upgraded" to WCF that don't really need to be for any real business reason.</p>
| 7,281
|
<p>What is the correct way to get the process size on <code>Solaris, HP-UX</code> and <code>AIX</code>? Should we use <code>top</code> or <code>ps -o vsz</code> or something else?</p>
|
<p>The exact definitions of <code>vsize</code>, <code>rss</code>, <code>rprvt</code>, <code>rshrd</code>, and other obscure-looking abbreviations vary from OS to OS. The manual pages for the <code>top</code> and <code>ps</code> commands will have some sort of description, but all such descriptions are simplified greatly (or are based on long-extinct kernel implementations).<br>
"Process size" as a concept is fiendishly difficult to pin down in the general case. Answers in specific instances depend heavily on the actual memory management implementation in the OS, and are rarely as satisfying as the tidy "process size" concept that exists in the minds of most users (and most developers).</p>
<p>For example, none of those numbers (nor, likely, any combination of them) can be used to tell you exactly how many such processes can run at once in a given amount of free memory. But really, your best bet is to come at it from that end: why do you want this number, and what will you use it for? Given that information, I think you'll get more useful answers.</p>
|
<p>Yes, you are right to lock at the VSZ.</p>
<p><code>ps u</code> will give you the VSZ and RSS, which are the virtual memory size and resident set size. The RSS is how much physical memory has been allocated to the process, and the VSZ is the virtual memory size of the process. If you have several copies of a program running, a lot of the memory in the VSZ will be shared between those processes.</p>
| 2,351
|
<p>I have quite a few developers asking me if certain SQL jobs ran, and I would like to give them access to check it on their own without giving them <code>sysadmin</code> rights. I know that in <code>SQL 2005</code>, you can grant them the <code>SQLAgentReaderRole</code>, but I am looking for a solution in <code>SQL 2000</code>. </p>
|
<p>Pretty sure there isn't one out of the box. This thread seems to be pretty decent...halfway down they discuss creating a role and then locking that down further. Also you could just create a mini-program (sp even?) to email the results of the job as a summary, or add to each job an on completion event to email an email group.</p>
<p><a href="http://sqlforums.windowsitpro.com/web/forum/messageview.aspx?catid=60&threadid=43021&enterthread=y" rel="nofollow noreferrer">http://sqlforums.windowsitpro.com/web/forum/messageview.aspx?catid=60&threadid=43021&enterthread=y</a></p>
|
<p>Looks like there's some hope for those of us still working with 2000 -</p>
<p>"In order to accomplish this in SQL Server 2000 the DBA must add the user to TargetServersRole role in MSDB database. Prior to Service Pack 3 on SQL Server 2000 the user must be added to the sysadmin group in order to get a chance to view the jobs that are owned by sysadmin group."</p>
<p>Quoted from <a href="http://www.sql-server-performance.com/faq/sqlagent_scheduled_jobs_p1.aspx" rel="nofollow">http://www.sql-server-performance.com/faq/sqlagent_scheduled_jobs_p1.aspx</a> via <a href="http://social.msdn.microsoft.com/Forums/en/sqlsmoanddmo/thread/8a05fe47-50c7-4b95-b631-8f7d69d31dae" rel="nofollow">http://social.msdn.microsoft.com/Forums/en/sqlsmoanddmo/thread/8a05fe47-50c7-4b95-b631-8f7d69d31dae</a></p>
| 9,289
|
<p>I have two identical tables and need to copy rows from table to another. What is the best way to do that? (I need to programmatically copy just a few rows, I don't need to use the bulk copy utility).</p>
|
<p>As long as there are no identity columns you can just </p>
<pre><code>INSERT INTO TableNew
SELECT * FROM TableOld
WHERE [Conditions]
</code></pre>
|
<p>To select only few rows..This will work like charm..</p>
<pre><code>SELECT TOP 10 *
INTO db2.dbo.new_table
FROM db1.dbo.old_table;
</code></pre>
<p>Note : Just create a new table in the required db..We need not define its structure.</p>
| 8,137
|
<p>Does anybody know of a tool to test OCSP responses? Preferably, something that can be used from a Windows Command-line and/or can be included (easily) in a Java/python program </p>
|
<p>Looking a bit more, I think I've found some answers:</p>
<p>a) OpenSSL at the rescue:</p>
<pre><code>openssl ocsp -whatever
</code></pre>
<p>For more info, <a href="http://www.openssl.org/docs/apps/ocsp.html" rel="nofollow noreferrer">http://www.openssl.org/docs/apps/ocsp.html</a></p>
<p>b) <a href="http://www.openvalidation.org/" rel="nofollow noreferrer">http://www.openvalidation.org/</a> is another way of testing a cert. And via its links, I got to:</p>
<ul>
<li><a href="http://security.polito.it/tools/ocsp/" rel="nofollow noreferrer">http://security.polito.it/tools/ocsp/</a></li>
<li>Ascertia OCSP Client tool (<a href="http://www.ascertia.com/products/ocsptool/" rel="nofollow noreferrer">http://www.ascertia.com/products/ocsptool/</a>)</li>
<li>Ascertia OCSP Crusher tool (an OCSP load generator) (<a href="http://www.ascertia.com/products/ocspCrusher/" rel="nofollow noreferrer">http://www.ascertia.com/products/ocspCrusher/</a>)</li>
</ul>
<p>Thanks to all the answers!</p>
|
<p>Can you test it over HTTP as described in the specs in Appendix A? If so, then you can use any web test util. Since you mentioned Java, <a href="http://jakarta.apache.org/jmeter/" rel="nofollow noreferrer">JMeter</a> comes to mind. With JMeter, you can create your java code to do validation, etc and re-use it in your test cases.</p>
<p>Can you use something other than CMD line, such as a BASH script via <a href="http://cygwin.com" rel="nofollow noreferrer">Cygwin</a>?</p>
<p>You'd still have to script some things to validate the test, perhaps using <a href="http://www.openssl.org/docs/apps/ocsp.html" rel="nofollow noreferrer">openssl</a>?</p>
<pre>
curl http://some.ocsp.url/ > resp.der
openssl ocsp -respin resp.der -text
</pre>
<p>See page <a href="http://www.ietf.org/rfc/rfc2560.txt" rel="nofollow noreferrer">http://www.ietf.org/rfc/rfc2560.txt</a></p>
| 9,695
|
<p>This isn't a design question, really, though it may seem like it. (Well, okay, it's kind of a design question). What I'm wondering is why the C++ <code>std::fstream</code> classes don't take a <code>std::string</code> in their constructor or open methods. Everyone loves code examples so:</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
int main()
{
std::string filename = "testfile";
std::ifstream fin;
fin.open(filename.c_str()); // Works just fine.
fin.close();
//fin.open(filename); // Error: no such method.
//fin.close();
}
</code></pre>
<p>This gets me all the time when working with files. Surely the C++ library would use <code>std::string</code> wherever possible?</p>
|
<p>By taking a C string the C++03 <a href="http://en.cppreference.com/w/cpp/io/basic_fstream" rel="noreferrer"><code>std::fstream</code></a> class reduced dependency on the <code>std::string</code> class. In C++11, however, the <code>std::fstream</code> class does allow passing a <code>std::string</code> for its constructor parameter.</p>
<p>Now, you may wonder why isn't there a transparent conversion from a <code>std:string</code> to a C string, so a class that expects a C string could still take a <code>std::string</code> just like a class that expects a <code>std::string</code> can take a C string.</p>
<p>The reason is that this would cause a conversion cycle, which in turn may lead to problems. For example, suppose <code>std::string</code> would be convertible to a C string so that you could use <code>std::string</code>s with <code>fstream</code>s. Suppose also that C string are convertible to <code>std::string</code>s as is the state in the current standard. Now, consider the following:</p>
<pre><code>void f(std::string str1, std::string str2);
void f(char* cstr1, char* cstr2);
void g()
{
char* cstr = "abc";
std::string str = "def";
f(cstr, str); // ERROR: ambiguous
}
</code></pre>
<p>Because you can convert either way between a <code>std::string</code> and a C string the call to <code>f()</code> could resolve to either of the two <code>f()</code> alternatives, and is thus ambiguous. The solution is to break the conversion cycle by making one conversion direction explicit, which is what the STL chose to do with <code>c_str()</code>.</p>
|
<p>Is there any class in STL that takes a string... I dont think so (couldnt find any in my quick search). So it's probably some design decision, that no class in STL should be dependent on any other STL class (that is not directly needed for functionality).</p>
| 5,222
|
<p>What I want to achieve is this. I want to give the user the ability to upload an image file, store the image in BLOB in SQL Server, and then use this image as a logo in other pages of the site. </p>
<p>I have done this by using </p>
<pre><code> Response.Clear();
Response.ContentType = "image/pjpeg";
Response.BinaryWrite(imageConents);
Response.End();
</code></pre>
<p>but to do this, I use a User control in the place where I want to show the image. I want to do it if possible using an asp:Image control, or even a pure old html image control. Is this possible?</p>
|
<p>Add a 'Generic Handler' to your web project, name it something like Image.ashx. Implement it like this:</p>
<pre><code>public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
using(Image image = GetImage(context.Request.QueryString["ID"]))
{
context.Response.ContentType = "image/jpeg";
image.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
public bool IsReusable
{
get
{
return true;
}
}
}
</code></pre>
<p>Now just implement the GetImage method to load the image with the given ID, and you can use</p>
<pre><code><asp:Image runat="server" ImageUrl="~/Image.ashx?ID=myImageId" />
</code></pre>
<p>to display it. You might want to think about implementing some form of caching in the handler too. And remember if you want to change the image format to PNG, you need to use an intermediate MemoryStream (because PNGs require a seekable stream to be saved).</p>
|
<p>We actually just released some classes that help with exactly this kind of thing:</p>
<p><a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449" rel="nofollow noreferrer">http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449</a></p>
<p>Specifically, check out the DatabaseImage sample.</p>
| 4,191
|
<p>What would be a good place to go to understand arrows? Ideally, I am just looking for some place with a concise definition with motivation from some good examples, something similar to Wadler's exposition on monads.</p>
|
<p><a href="http://en.wikibooks.org/wiki/Haskell/Understanding_arrows" rel="nofollow noreferrer"><a href="http://en.wikibooks.org/wiki/Haskell/Understanding_arrows" rel="nofollow noreferrer">http://en.wikibooks.org/wiki/Haskell/Understanding_arrows</a></a></p>
|
<p>If you learn better from practice than theory, try using <a href="http://www.fh-wedel.de/~si/HXmlToolbox/" rel="nofollow noreferrer">HXT</a> for XML manipulation, or <a href="http://www.cs.helsinki.fi/u/ekarttun/PArrows/" rel="nofollow noreferrer">PArrows</a> for general parsing. They both have APIs centered around arrows.</p>
| 9,060
|
<p>I'm returning to c++ after being away for a bit and trying to dust off the old melon. </p>
<p>In Java Iterator is an interface to a container having methods: <code>hasNext()</code>, <code>next()</code> and <code>remove()</code>. The presence of <code>hasNext()</code> means it <strong>has the concept of a limit</strong> for the container being traversed.</p>
<pre><code>//with an Iterator
Iterator<String> iter = trees.iterator();
while (iter.hasNext())
{
System.out.println(iter.next());
}
</code></pre>
<p>In the C++ standard template library, iterators seem to represent a datatype or class the supports the <code>operator++</code> and <code>operator==</code> but has <strong>no concept of a limit</strong> built in so comparison is required before advancing to the next item. The limit has to checked by the user comparing two iterators in the normal case the second iterator is the container end.</p>
<pre><code>vector<int> vec;
vector<int>::iterator iter;
// Add some elements to vector
v.push_back(1);
v.push_back(4);
v.push_back(8);
for (iter= v.begin(); iter != v.end(); iter++)
{
cout << *i << " "; //Should output 1 4 8
}
</code></pre>
<p>The interesting part here is that in C++ a pointer is an iterator to an array. The STL took what was existing and build convention around it.</p>
<p>It there any further subtlety to this that I am missing?</p>
|
<p>Yes, there is a large conceptual difference. C++ utilizes different "classes" of iterators. Some are used for random access (unlike Java), some are used for forward access (like java). While even others are used for writing data (for use with, say, <code>transform</code>). </p>
<p>See the iterators concept in the <a href="http://en.cppreference.com/w/cpp/iterator" rel="noreferrer">C++ Documentation</a>:</p>
<ul>
<li>Input Iterator</li>
<li>Output Iterator</li>
<li>Forward Iterator</li>
<li>Bidirectional Iterator</li>
<li>Random Access Iterator</li>
</ul>
<p>These are far more interesting and powerful compared to Java/C#'s puny iterators. Hopefully these conventions will be codified using C++0x's <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Concepts" rel="noreferrer">Concepts</a>.</p>
|
<p>Iterators are only equivalent to pointers in the trivial case of iterating over the contents of an array in sequence. An iterator could be supplying objects from any number of other sources: from a database, from a file, from the network, from some other calculation, etc.</p>
| 8,026
|
<p>I'm having a similar issue to <a href="https://3dprinting.stackexchange.com/questions/1207/how-to-remove-a-pla-print-stack-to-a-buildtak-sheet">this one</a>: I have retrofitted my printer with a BuildTak sticker. I'm printing PLA at 60°C bed temperature - currently using a 0.3 mm nozzle, but I had similar issues with the 0.4mm nozzle before. </p>
<p>If I bring the nozzle close enough to the print surface to get a reasonable first layer, I need excessive force to remove the parts afterwards - so much force that I already have damaged the BuildTak in one or two places. If I lower the bed (the physical bed using the screws, not the temperature!) so that the parts come off easier, the first layer is very uneven and it takes 5-6 layers until the layers start to stack onto one another the way they are supposed to. What can I do to influence the adhesion of the printed parts to the BuildTak surface - especially to lower it in a controlled manner without changing the nozzle height?</p>
|
<p>Try printing with the heated printbed off. Heat makes the pla stick more to buildtak</p>
|
<p>These are more like backups for when the part gets stuck, but you could try spraying that part where it meets the bed with liquid computer duster. The shrinkage from cooling usually helps to release the part from the bed. You could also try heating the bed very hot to save the bed at the expense of the part.</p>
| 554
|
<p>I once had the task of determining the following performance parameters from inside a running application:</p>
<ul>
<li>Total virtual memory available</li>
<li>Virtual memory currently used</li>
<li>Virtual memory currently used by my process<hr></li>
<li>Total RAM available</li>
<li>RAM currently used</li>
<li>RAM currently used by my process<hr></li>
<li>% CPU currently used</li>
<li>% CPU currently used by my process</li>
</ul>
<p>The code had to run on Windows and Linux. Even though this seems to be a standard task, finding the necessary information in the manuals (WIN32 API, GNU docs) as well as on the Internet took me several days, because there's so much incomplete/incorrect/outdated information on this topic to be found out there.</p>
<p>In order to save others from going through the same trouble, I thought it would be a good idea to collect all the scattered information plus what I found by trial and error here in one place.</p>
|
<h2>Windows</h2>
<p>Some of the above values are easily available from the appropriate Win32 API, I just list them here for completeness. Others, however, need to be obtained from the Performance Data Helper library (PDH), which is a bit "unintuitive" and takes a lot of painful trial and error to get to work. (At least it took me quite a while, perhaps I've been only a bit stupid...)</p>
<p>Note: for clarity all error checking has been omitted from the following code. Do check the return codes...!</p>
<ul>
<li><p>Total Virtual Memory:</p>
<pre><code>#include "windows.h"
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
DWORDLONG totalVirtualMem = memInfo.ullTotalPageFile;
</code></pre>
<p>Note: The name "TotalPageFile" is a bit misleading here. In reality this parameter gives the "Virtual Memory Size", which is size of swap file plus installed RAM.</p>
</li>
<li><p>Virtual Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code> DWORDLONG virtualMemUsed = memInfo.ullTotalPageFile - memInfo.ullAvailPageFile;
</code></pre>
</li>
<li><p>Virtual Memory currently used by current process:</p>
<pre><code>#include "windows.h"
#include "psapi.h"
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
SIZE_T virtualMemUsedByMe = pmc.PrivateUsage;
</code></pre>
</li>
<li><p>Total Physical Memory (RAM):</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>DWORDLONG totalPhysMem = memInfo.ullTotalPhys;
</code></pre>
</li>
<li><p>Physical Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>DWORDLONG physMemUsed = memInfo.ullTotalPhys - memInfo.ullAvailPhys;
</code></pre>
</li>
<li><p>Physical Memory currently used by current process:</p>
<p>Same code as in "Virtual Memory currently used by current process" and then</p>
<pre><code>SIZE_T physMemUsedByMe = pmc.WorkingSetSize;
</code></pre>
</li>
<li><p>CPU currently used:</p>
<pre><code>#include "TCHAR.h"
#include "pdh.h"
static PDH_HQUERY cpuQuery;
static PDH_HCOUNTER cpuTotal;
void init(){
PdhOpenQuery(NULL, NULL, &cpuQuery);
// You can also use L"\\Processor(*)\\% Processor Time" and get individual CPU values with PdhGetFormattedCounterArray()
PdhAddEnglishCounter(cpuQuery, L"\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
PdhCollectQueryData(cpuQuery);
}
double getCurrentValue(){
PDH_FMT_COUNTERVALUE counterVal;
PdhCollectQueryData(cpuQuery);
PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, NULL, &counterVal);
return counterVal.doubleValue;
}
</code></pre>
</li>
<li><p>CPU currently used by current process:</p>
<pre><code>#include "windows.h"
static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
static int numProcessors;
static HANDLE self;
void init(){
SYSTEM_INFO sysInfo;
FILETIME ftime, fsys, fuser;
GetSystemInfo(&sysInfo);
numProcessors = sysInfo.dwNumberOfProcessors;
GetSystemTimeAsFileTime(&ftime);
memcpy(&lastCPU, &ftime, sizeof(FILETIME));
self = GetCurrentProcess();
GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
memcpy(&lastSysCPU, &fsys, sizeof(FILETIME));
memcpy(&lastUserCPU, &fuser, sizeof(FILETIME));
}
double getCurrentValue(){
FILETIME ftime, fsys, fuser;
ULARGE_INTEGER now, sys, user;
double percent;
GetSystemTimeAsFileTime(&ftime);
memcpy(&now, &ftime, sizeof(FILETIME));
GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
memcpy(&sys, &fsys, sizeof(FILETIME));
memcpy(&user, &fuser, sizeof(FILETIME));
percent = (sys.QuadPart - lastSysCPU.QuadPart) +
(user.QuadPart - lastUserCPU.QuadPart);
percent /= (now.QuadPart - lastCPU.QuadPart);
percent /= numProcessors;
lastCPU = now;
lastUserCPU = user;
lastSysCPU = sys;
return percent * 100;
}
</code></pre>
</li>
</ul>
<hr />
<h2>Linux</h2>
<p>On Linux the choice that seemed obvious at first was to use the POSIX APIs like <code>getrusage()</code> etc. I spent some time trying to get this to work, but never got meaningful values. When I finally checked the kernel sources themselves, I found out that apparently these APIs are not yet completely implemented as of Linux kernel 2.6!?</p>
<p>In the end I got all values via a combination of reading the pseudo-filesystem <code>/proc</code> and kernel calls.</p>
<ul>
<li><p>Total Virtual Memory:</p>
<pre><code>#include "sys/types.h"
#include "sys/sysinfo.h"
struct sysinfo memInfo;
sysinfo (&memInfo);
long long totalVirtualMem = memInfo.totalram;
//Add other values in next statement to avoid int overflow on right hand side...
totalVirtualMem += memInfo.totalswap;
totalVirtualMem *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Virtual Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>long long virtualMemUsed = memInfo.totalram - memInfo.freeram;
//Add other values in next statement to avoid int overflow on right hand side...
virtualMemUsed += memInfo.totalswap - memInfo.freeswap;
virtualMemUsed *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Virtual Memory currently used by current process:</p>
<pre><code>#include "stdlib.h"
#include "stdio.h"
#include "string.h"
int parseLine(char* line){
// This assumes that a digit will be found and the line ends in " Kb".
int i = strlen(line);
const char* p = line;
while (*p <'0' || *p > '9') p++;
line[i-3] = '\0';
i = atoi(p);
return i;
}
int getValue(){ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];
while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmSize:", 7) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result;
}
</code></pre>
</li>
<li><p>Total Physical Memory (RAM):</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>long long totalPhysMem = memInfo.totalram;
//Multiply in next statement to avoid int overflow on right hand side...
totalPhysMem *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Physical Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>long long physMemUsed = memInfo.totalram - memInfo.freeram;
//Multiply in next statement to avoid int overflow on right hand side...
physMemUsed *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Physical Memory currently used by current process:</p>
<p>Change getValue() in "Virtual Memory currently used by current process" as follows:</p>
<pre><code>int getValue(){ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];
while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmRSS:", 6) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result;
}
</code></pre>
</li>
</ul>
<p></p>
<ul>
<li><p>CPU currently used:</p>
<pre><code>#include "stdlib.h"
#include "stdio.h"
#include "string.h"
static unsigned long long lastTotalUser, lastTotalUserLow, lastTotalSys, lastTotalIdle;
void init(){
FILE* file = fopen("/proc/stat", "r");
fscanf(file, "cpu %llu %llu %llu %llu", &lastTotalUser, &lastTotalUserLow,
&lastTotalSys, &lastTotalIdle);
fclose(file);
}
double getCurrentValue(){
double percent;
FILE* file;
unsigned long long totalUser, totalUserLow, totalSys, totalIdle, total;
file = fopen("/proc/stat", "r");
fscanf(file, "cpu %llu %llu %llu %llu", &totalUser, &totalUserLow,
&totalSys, &totalIdle);
fclose(file);
if (totalUser < lastTotalUser || totalUserLow < lastTotalUserLow ||
totalSys < lastTotalSys || totalIdle < lastTotalIdle){
//Overflow detection. Just skip this value.
percent = -1.0;
}
else{
total = (totalUser - lastTotalUser) + (totalUserLow - lastTotalUserLow) +
(totalSys - lastTotalSys);
percent = total;
total += (totalIdle - lastTotalIdle);
percent /= total;
percent *= 100;
}
lastTotalUser = totalUser;
lastTotalUserLow = totalUserLow;
lastTotalSys = totalSys;
lastTotalIdle = totalIdle;
return percent;
}
</code></pre>
</li>
<li><p>CPU currently used by current process:</p>
<pre><code>#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "sys/times.h"
#include "sys/vtimes.h"
static clock_t lastCPU, lastSysCPU, lastUserCPU;
static int numProcessors;
void init(){
FILE* file;
struct tms timeSample;
char line[128];
lastCPU = times(&timeSample);
lastSysCPU = timeSample.tms_stime;
lastUserCPU = timeSample.tms_utime;
file = fopen("/proc/cpuinfo", "r");
numProcessors = 0;
while(fgets(line, 128, file) != NULL){
if (strncmp(line, "processor", 9) == 0) numProcessors++;
}
fclose(file);
}
double getCurrentValue(){
struct tms timeSample;
clock_t now;
double percent;
now = times(&timeSample);
if (now <= lastCPU || timeSample.tms_stime < lastSysCPU ||
timeSample.tms_utime < lastUserCPU){
//Overflow detection. Just skip this value.
percent = -1.0;
}
else{
percent = (timeSample.tms_stime - lastSysCPU) +
(timeSample.tms_utime - lastUserCPU);
percent /= (now - lastCPU);
percent /= numProcessors;
percent *= 100;
}
lastCPU = now;
lastSysCPU = timeSample.tms_stime;
lastUserCPU = timeSample.tms_utime;
return percent;
}
</code></pre>
</li>
</ul>
<hr />
<h2>TODO: Other Platforms</h2>
<p>I would assume, that some of the Linux code also works for the Unixes, except for the parts that read the /proc pseudo-filesystem. Perhaps on Unix these parts can be replaced by <code>getrusage()</code> and similar functions?</p>
|
<p>I used this following code in my C++ project and it worked fine:</p>
<pre><code>static HANDLE self;
static int numProcessors;
SYSTEM_INFO sysInfo;
double percent;
numProcessors = sysInfo.dwNumberOfProcessors;
//Getting system times information
FILETIME SysidleTime;
FILETIME SyskernelTime;
FILETIME SysuserTime;
ULARGE_INTEGER SyskernelTimeInt, SysuserTimeInt;
GetSystemTimes(&SysidleTime, &SyskernelTime, &SysuserTime);
memcpy(&SyskernelTimeInt, &SyskernelTime, sizeof(FILETIME));
memcpy(&SysuserTimeInt, &SysuserTime, sizeof(FILETIME));
__int64 denomenator = SysuserTimeInt.QuadPart + SyskernelTimeInt.QuadPart;
//Getting process times information
FILETIME ProccreationTime, ProcexitTime, ProcKernelTime, ProcUserTime;
ULARGE_INTEGER ProccreationTimeInt, ProcexitTimeInt, ProcKernelTimeInt, ProcUserTimeInt;
GetProcessTimes(self, &ProccreationTime, &ProcexitTime, &ProcKernelTime, &ProcUserTime);
memcpy(&ProcKernelTimeInt, &ProcKernelTime, sizeof(FILETIME));
memcpy(&ProcUserTimeInt, &ProcUserTime, sizeof(FILETIME));
__int64 numerator = ProcUserTimeInt.QuadPart + ProcKernelTimeInt.QuadPart;
//QuadPart represents a 64-bit signed integer (ULARGE_INTEGER)
percent = 100*(numerator/denomenator);
</code></pre>
| 8,874
|
<p>I've been tasked with <em>improving the performance of an ASP.NET 2.0 application</em>.<br> The page I'm currently focused on has many problems but one that I'm having trouble digging into is the render time of the page. Using Trace.axd the duration between Begin Render and End Render is 1.4 seconds. From MSDN I see that</p>
<blockquote>
<p>All ASP.NET Web server controls have a
Render method that writes out the
control's markup that is sent to the
browser.</p>
</blockquote>
<p>If I had the source code for all the controls on the page, I would just instrument them to trace out their render time. Unfortunately, this particular page has lots of controls, most of them third-party. Is there tool or technique to get better visibility into what is going on during the render? I would like to know if there is a particularly poorly performing control, or if there are simply too many controls on the page.</p>
|
<p>Download ANTS PROFILER, this will give you a perfect overview of the lines causing the slowdown.</p>
<p>Also when it's about rendering make sure you don't use to much string concats (like string += "value") but use StringBuilders to improve performance.</p>
|
<p>It may not help if the problem is inside one of your controls - as you expect - but if the page is poorly designed and that's causing render to be slow, <a href="http://developer.yahoo.com/yslow/" rel="nofollow noreferrer">YSlow</a> should help clean that up.</p>
| 3,632
|
<p>Is there some reasonably cross platform way to create a thumbnail image given a URL? I know there are thumbnail web services that will do this, but I want a piece of software or library that will do this locally. I guess in Linux I could always spawn a browser window using a headless X server, but what about Windows or OS X?</p>
|
<p>You can use Firefox or XULRunner with some fairly simple XUL to create thumbnails as PNG dataURLs (that you could then write to file if needed). Robert O'Callahan has some excellent information on it here:</p>
<p><a href="http://weblogs.mozillazine.org/roc/archives/2005/05/rendering_web_p.html" rel="nofollow noreferrer">http://weblogs.mozillazine.org/roc/archives/2005/05/rendering_web_p.html</a></p>
|
<p>There are a number of commercial packages that will do what you want. I'm not sure from reading your question if free is a requirement. But here are some applications I've found that are reasonably priced and which do exactly what you want. I have not used them myself, but they have free trial downloads so you can evaluate before you purchase.</p>
<ul>
<li><a href="http://www.guangmingsoft.net/htmltoimage/help.htm" rel="nofollow noreferrer">HTML to Image from Guanming Software</a> - Runs on Linux and Windows</li>
<li><a href="http://www.sysimage.com/windows/html2image/" rel="nofollow noreferrer">HTML2Image from SysImage</a> - Runs on Windows</li>
<li><a href="http://www.tooto.com/html2image/" rel="nofollow noreferrer">HTML2Image from Tooto</a> - Runs on Windows</li>
<li><a href="http://www.converthtmltoimage.com/" rel="nofollow noreferrer">Convert HTML to Image from FrameworkTeam</a> - Windows command line tool</li>
</ul>
| 9,082
|
<p>3D printing can be used to make injection molds of unimaginable complexity but which kind of 3D printing process is suitable when? </p>
<p>Suppose that a part is to be made using injection molding in large quantity for an extended period of time, what Additive Manufacturing (AM) process will be the best, such that the mold does not give way too soon? </p>
<p>Also, suppose that the part to be made is custom and only has to be made in small quantities - that is to say that the injection mold will be used limited number of items and then thrown away - which is the best AM technique then? Best in the sense of economic feasibility, lower cost, lower capital investment etc.?</p>
|
<p>Yes, this is very broad. That said...</p>
<p>For high detail you want SLA. i.e. jewelry. If you just want a prototype of a mold, you can do a standard FDM style printer (95% of printers are FDM, and that number is a guess)</p>
<p>Really, you should be asking what material you need for your mold, but you can open a second question for that.</p>
<p>Do more research on injection molding. There is a great deal of information on how molds are made, i.e. <a href="https://www.youtube.com/watch?v=seZqq1qxW30" rel="nofollow noreferrer">How It's Made Plastic injection molds</a>.</p>
<p>You will see there is a vast difference between a plastic, or silicon, mold and an injection molding machine. You are thinking that injection molding as a single mold, when it is really it is a system composing of several pieces of heavy duty machinery that can pump out hundreds of items a day automatically. However, it usually starts at 20k USD for the tooling for injection molding. Your costs could be a fraction of that or could be several times that. This is just a generality. So, if you are making 100 units you won't want to go down that route. For 10,000 units, on the other hand, it would be acceptable. </p>
|
<p>Injection molds generally require tooling and are not usually cast from 3D prints. Depending on the size of your part - costs can easily skyrocket to over $60,000. The price per part is sometimes lower than other methods. Other possible methods (depending on the part) are Thermo-Forming, Vacu-Forming, and different Casting methods - sandcasting (investment casting), flexible casting (rubber, urethane, and alginate), and hard casting (printing mold negative). Some have immediate use of 3D Printed parts...others have work flows in place to convert your files for use. You can print a mold negative, prep it, use mold release, and cast shapes from that mold... certainly the casting material would be flexible or the mold would need the proper relief- But it is certainly possible.</p>
| 450
|
<p>I’m designing a part that will need to be autoclaved—it will be under steam at 121°C for about 15 min per job and I will want it to be able to go through the autoclave repeatedly. I ran a test PLA part through the autoclave and it warped noticeably; based on their glass transition temperatures, ABS (105ºC) and PETG (80ºC) would probably also not hold up. For a consumer-grade FDM printer, what filament materials that could be used for parts that could be autoclaved?</p>
|
<p>It might seem that common 3D printer materials such as PLA and ABS should be capable of being autoclaved—unfortunately. However, although their melting temperatures are higher than autoclave temperature (typically 121ºC), their glass transition temperatures are below that limit so they can warp or undergo creep deformation.</p>
<p>Sterilization of numerous plastics is described <a href="https://www.industrialspec.com/resources/plastics-sterilization-compatibility/" rel="noreferrer">here</a>, with PLA, ABS, and PET all being described as "poor" for autoclaving. For each "good" material on that list, I looked for filament by Googling and consulting material guides from <a href="https://www.prusa3d.com/material-guides/" rel="noreferrer">Prusa</a> and <a href="https://www.matterhackers.com/3d-printer-filament-compare" rel="noreferrer">Matter Hackers</a>.</p>
<p>Polypropylene (PP) or acetal (POM, also known as Delrin) are the best choices. Filament is available for PEEK, PEI (ULTEM), FEP, PPSU, and PPS but these filaments are expensive (>$100/kg) and require high extruder temperatures (>300ºC).</p>
<p>In contrast, PP is about $50/kg and uses an extruder temperature of 254ºC; POM is similarly priced and uses an extruder temperature of 210ºC. Nylon (depending on the exact type) and HT-PLA may also be worth considering.</p>
<p>"High temperature" filaments are not worthwhile for this application. Again, they're expensive and, more significantly, do not work well with consumer-grade 3D printers. For example, the upper limit for a Prusa i3 MK3s is about 280ºC—the thermistor only is good up to that temperature. Higher temperatures would require swapping out sensors and modifying firmware and building an enclosure. <a href="https://forum.prusaprinters.org/forum/original-prusa-i3-mk2.5s-mk2.5-how-do-i-print-this-printing-help/can-i-use-pps-filament-on-my-printer/" rel="noreferrer">It's been done</a>. Printers designed for high-temperature filaments easily cost <a href="https://www.aniwaa.com/best-peek-3d-printer-pei-ultem/" rel="noreferrer">thousands of dollars</a>.</p>
<p>This question was previously asked on <a href="https://www.reddit.com/r/3Dprinting/comments/9l8gao/what_filament_would_hold_up_to_regular/" rel="noreferrer">Reddit</a> <a href="https://www.reddit.com/r/3Dprinting/comments/3caivh/question_about_autoclavable_plastic_for_3d/" rel="noreferrer">a few times</a> but this analysis is more comprehensive.</p>
|
<p>You need to order the part printed by an SLA machine in PA, preferably with 10 % mineral or glass content. The heat deflection temperature is suitably high for any autoclaving you'll do, and the material will resist most every that your lab and throw at it. I also went down this road with a part for my own lab and found no reasonable solution from a consumer level FDM printer. </p>
| 1,320
|
<p>I want to make Polyurethane molds for <strong>concrete</strong> using 3D printed PLA or ABS master object. like this video:</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/UhkrEm5XtRU?start=0"></iframe>
</div></div> (this video is not about concrete of course!)</p>
<p>I'm not sure if it will stick to PLA or ABS master or not! if it does stick, whick wax material can solve this problem... Do I need to print my masters with another filament?</p>
<p><a href="https://i.stack.imgur.com/JGMR5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JGMR5.jpg" alt="enter image description here"></a> </p>
|
<p>In my experience, polyurethane sticks to PLA like super glue, not good. But silicone and alginate doesn't stick at all.</p>
<p>What I do is print the model of the mold with PLA or ABS, no matter. Then, cast a mold of the PLA model of the mold with alginate, then you have the negative of your mold.</p>
<p>Now with this alginate mold of the mold cast your actual mold with silicone. And then you can cast your part on polyurethane in the silicone mold.</p>
|
<h2>Temperature</h2>
<p>As polyurethane cures (or hardens), it undergoes a chemical bonding reaction, linking the mono- and oligomer strings in the components into long polyurethane chains. <a href="http://www.essentialchemicalindustry.org/polymers/polyurethane.html" rel="nofollow noreferrer">The chemical reaction is exothermic</a>, it creates heat.</p>
<p>So, we have a process that heats up the polyurethane mixture as it hardens, but how much? Well, it's hard to find numbers for it, but I suspect it can easily reach 30 to 40 °C, depending on the mixture (fast curing) it could easily go higher. To combat the effects of heat softening of the PLA/ABS model inside the mold, I strongly suggest printing with extra shells and extra infill. While most items can get away with 10 %, in this case, I suggest 20-30 %. ABS would be the superior choice above PLA as it starts to deform at a higher temperature. PLA can start to deform at around 60 °C, ABS only at about 80 °C.</p>
<p>The temperature of the PU curing depends on the speed of the curing process - it is safer for the masters to choose a slower curing mix as the heat is generated over a longer time and the maximum temperature is thus lower as a result (as excess heat is lost to the room)</p>
<h2>Surface</h2>
<p>To reduce the sticking to the surface from the material creeping into the gaps of the model, it has to be as smooth as possible and best also sealed. If you choose ABS, a quick acetone vapor bath would do the trick in this case. PLA should be lacquer sealed as it doesn't like to stick to most waxes.</p>
<p>Adding a mold release agent isn't necessarily needed, but could help in removing the masters from the mold.</p>
<h2>Conclusion</h2>
<p>ABS might be the better choice in this application. It is advisable to use extra-thick walls (3+), a lot of infill (20-30 %) and a vapor smoothed surface.</p>
| 1,481
|
<p>If you're using Opera 9.5x you may notice that our client-side <a href="http://docs.jquery.com/Plugins/Validation" rel="noreferrer">JQuery.Validate</a> code is disabled here at Stack Overflow.</p>
<pre><code>function initValidation() {
if (navigator.userAgent.indexOf("Opera") != -1) return;
$("#post-text").rules("add", { required: true, minlength: 5 });
}
</code></pre>
<p>That's because it generates an exception in Opera! Of course it works in every other browser we've tried. I'm starting to seriously, seriously hate Opera.</p>
<p>This is kind of a bummer because without proper client-side validation some of our requests will fail. We haven't had time to put in complete server-side messaging when data is incomplete, so <strong>you may see the YSOD on Opera much more than other browsers</strong>, if you forget to fill out all the fields on the form.</p>
<p>Any Opera-ites want to uncomment those lines (they're on core Ask & Answer pages like this one -- just View Source and search for <code>"Opera"</code>) and give it a go?</p>
|
<p>turns out the problem was in the</p>
<pre><code>{ debug : true }
</code></pre>
<p>option for the JQuery.Validate initializer. <strong>With this removed, things work fine in Opera.</strong> Thanks to Jörn Zaefferer for helping us figure this out!</p>
<p>Oh, and the $50 will be donated to the JQuery project. :)</p>
|
<p>I can't seem to reproduce this bug. Can you give more details?</p>
<p>I have my copy of Opera masquerading as Firefox so the validation should be executing:</p>
<pre><code>>>> $.browser.opera
false
</code></pre>
<p>When I go to the edit profile page and enter a malformed date, the red text comes up and says "Please enter a valid date". That's jQuery.Validate working, right? Does it only fail on certain forms/fields?</p>
<p>This is Opera 9.51 on WinXP.</p>
<p>Edit: testing editing on Opera.</p>
<p>Edit: It also works when I comment out the "if ($.browser.opera) return;" line on a copy of the edit profile page I saved locally. I really can't reproduce this bug. What is your environment like? (Vista? Opera plugins?)</p>
| 3,014
|
<p>I have binary data in a file that I can read into a byte array and process with no problem. Now I need to send parts of the data over a network connection as elements in an XML document. My problem is that when I convert the data from an array of bytes to a String and back to an array of bytes, the data is getting corrupted. I've tested this on one machine to isolate the problem to the String conversion, so I now know that it isn't getting corrupted by the XML parser or the network transport.</p>
<p>What I've got right now is</p>
<pre><code>byte[] buffer = ...; // read from file
// a few lines that prove I can process the data successfully
String element = new String(buffer);
byte[] newBuffer = element.getBytes();
// a few lines that try to process newBuffer and fail because it is not the same data anymore
</code></pre>
<p>Does anyone know how to convert binary to String and back without data loss?</p>
<p>Answered: Thanks Sam. I feel like an idiot. I had this answered yesterday because my SAX parser was complaining. For some reason when I ran into this seemingly separate issue, it didn't occur to me that it was a new symptom of the same problem.</p>
<p>EDIT: Just for the sake of completeness, I used the <a href="http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html" rel="noreferrer">Base64</a> class from the <a href="http://commons.apache.org/" rel="noreferrer">Apache Commons</a> <a href="http://commons.apache.org/codec/" rel="noreferrer">Codec</a> package to solve this problem.</p>
|
<p>If you encode it in base64, this will turn any data into ascii safe text, but base64 encoded data is larger than the orignal data</p>
|
<p>How are you building your XML document? If you use java's built in XML classes then the string encoding should be handled for you.</p>
<p>Take a look at the javax.xml and org.xml packages. That's what we use for generating XML docs, and it handles all the string encoding and decoding quite nicely.</p>
<p>---EDIT:</p>
<p>Hmm, I think I misunderstood the problem. You're not trying to encode a regular string, but some set of arbitrary binary data? In that case the Base64 encoding suggested in an earlier comment is probably the way to go. I believe that's a fairly standard way of encoding binary data in XML.</p>
| 4,110
|
<p>I have the Xming X Window Server installed on a laptop running Windows XP to connect to some UNIX development servers. </p>
<p>It works fine when I connect directly to the company network in the office. However, it does not work when I connect to the network remotely over a VPN.</p>
<p>When I start Xming when connected remotely none of my terminal Windows are displayed.</p>
<p>I think it may have something to do with the DISPLAY environment variable not being set correctly to the IP address of the laptop when it is connected.</p>
<p>I've noticed that when I do an ipconfig whilst connected remotely that my laptop has two IP addresses, the one assigned to it from the company network and the local IP address I've set up for it on my "local network" from my modem/router.</p>
<p>Are there some configuration changes I need to make in Xming to support its use through the VPN?</p>
|
<p>Chances are it's either X authentication, the X server binding to an interface, or your DISPLAY variable. I don't use Xming myself but there are some general phenomenon to check for. One test you can do to manually verify the DISPLAY variable is correct is:</p>
<ol>
<li>Start your VPN. Run ipconfig to be sure you have the two IP addresses you mentioned (your local IP and your VPN IP).</li>
<li>Start Xming. Run 'netstat -n' to see how it's binding to the interface. You should see something that either says localIP:6000 or VPNIP:6000. It may not be 6000 but chances are it will be something like that. If there's no VPNIP:6000 it may be binding only to your localIP or even 127.0.0.1. That will probably not work over the VPN. Check if there are some Xming settings to make it bind to other or all interfaces.</li>
<li>If you see VPNIP:6000 or something similar, take note of what it says and remote shell into your UNIX host (hopefully something like ssh, if not whatever you have to get a text terminal).</li>
<li>On the UNIX terminal type 'echo $DISPLAY'. If there is nothing displayed try 'export DISPLAY=VPNIP:0.0' where VPNIP is your VPN IP address and 0.0 is the port you saw in step 3 minus 6000 with .0 at the end (i.e. 6000 = 0.0, 6010 = 10.0).</li>
<li>On the UNIX host run something like 'xclock' or 'xterm' to see if it runs. The error message should be informative. It will tell you that it either couldn't connect to the host (a connectivity problem) or authentication failed (you'll need to coordinate Xauth on your host and local machine or Xhosts on your local machine).</li>
</ol>
<p>Opening Xhosts (with + for all hosts or something similar) isn't too bad if you have a locally protected network and you're going over a VPN. Hopefully this will get you started tracking down the problem. Another option that is often useful as it works over a VPN or simple ssh connectivity is ssh tunneling or X11 forwarding over ssh. This simulates connectivity to the X server on your local box by redirecting a port on your UNIX host to the local port on your X server box. Your display will typically be something like localhost:10.0 for the local 6010 port.</p>
<p>X can be ornery to set up but it usually works great once you get the hang of it.</p>
|
<p>Haven't have the exact problem, but I think you need to look at the xhost and make sure that the vpn remote is allowed to send data to the x server. </p>
<p>This link might help:
<a href="http://www.straightrunning.com/XmingNotes/trouble.php" rel="nofollow noreferrer">http://www.straightrunning.com/XmingNotes/trouble.php</a></p>
| 2,650
|
<p>Is there any convention on how to mark an all metal hotend to distinguish it from a hotend with a PTFE tube in the heatbreak? Once assembled for a German Riprap 3D printer, they look exactly the same on the outside. I'm trying to decide on a way of marking them to indicate the difference.</p>
<p>Hotend with heatsink
<a href="https://i.stack.imgur.com/ZljCB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZljCB.jpg" alt="enter image description here" /></a></p>
<p>Exposed part of heatbreak between heater block and heatsink
<a href="https://i.stack.imgur.com/GpQtt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GpQtt.jpg" alt="enter image description here" /></a></p>
<p>Easy to see PTFE tube on nozzle side of heatbreak (all metal hotend has an all metal heatbreak with no PTFE)
<a href="https://i.stack.imgur.com/VKfVG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VKfVG.jpg" alt="enter image description here" /></a></p>
<p>Even after removing heatsink, PTFE tube is difficult to see in heatbreak (all metal hotend has an all metal heatbreak with no PTFE)
<a href="https://i.stack.imgur.com/Injic.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Injic.jpg" alt="enter image description here" /></a></p>
<p>Nozzle end of all metal heatbreak
<a href="https://i.stack.imgur.com/31MYU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/31MYU.jpg" alt="enter image description here" /></a></p>
<p>Heatsink end of all metal heatbreak
<a href="https://i.stack.imgur.com/srJZ2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/srJZ2.jpg" alt="enter image description here" /></a></p>
|
<p>Given your heatbreaks are the same material and external dimensions, it seems that the most practical way to distinguish one from the other would be to mount the all metal heatbreaks in a heat sink that's anodized to some other color than natural aluminum -- red or blue, for instance.</p>
<p>If you can't buy them that way, or already have plenty on hand, anodizing is fairly easy to do at home -- you need battery acid, a car battery (or heavy duty charger for one), and some strongly colored dye to apply after the anodize has established the oxide layer on the aluminum part. There are many online references on how to proceed and how to stay safe while handling the acid.</p>
<p>If you have machining capability, another option would be to make, say, a copper heat sink for the all metal heatbreak, while keeping the aluminum for the conventional one.</p>
|
<p>Usually, the neck of an all-metal heat break would be thinner (as it does not need to contain the PTFE tube, and making it overly thick would conduct heat unneccesarily). This may be observable when one loses track of what is where.
If one needs to see at a glance, I do not think there is a convention.</p>
| 1,971
|
<p>I have an application with one form in it, and on the Load method I need to hide the form. </p>
<p>The form will display itself when it has a need to (think along the lines of a outlook 2003 style popup), but I can' figure out how to hide the form on load without something messy.</p>
<p>Any suggestions?</p>
|
<p>I'm coming at this from C#, but should be very similar in vb.net.</p>
<p>In your main program file, in the Main method, you will have something like:</p>
<pre><code>Application.Run(new MainForm());
</code></pre>
<p>This creates a new main form and limits the lifetime of the application to the lifetime of the main form.</p>
<p>However, if you remove the parameter to Application.Run(), then the application will be started with no form shown and you will be free to show and hide forms as much as you like.</p>
<p>Rather than hiding the form in the Load method, initialize the form before calling Application.Run(). I'm assuming the form will have a NotifyIcon on it to display an icon in the task bar - this can be displayed even if the form itself is not yet visible. Calling <code>Form.Show()</code> or <code>Form.Hide()</code> from handlers of NotifyIcon events will show and hide the form respectively.</p>
|
<p>Here is a simple approach:<br>
It's in C# (I don't have VB compiler at the moment)</p>
<pre><code>public Form1()
{
InitializeComponent();
Hide(); // Also Visible = false can be used
}
private void Form1_Load(object sender, EventArgs e)
{
Thread.Sleep(10000);
Show(); // Or visible = true;
}
</code></pre>
| 9,564
|
<p>Is the standard Java 1.6 <a href="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilder.html" rel="noreferrer">javax.xml.parsers.DocumentBuilder</a> class thread safe? Is it safe to call the parse() method from several threads in parallel?</p>
<p>The JavaDoc doesn't mention the issue, but the <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/DocumentBuilder.html" rel="noreferrer">JavaDoc for the same class</a> in Java 1.4 specifically says that it <em>isn't</em> meant to be concurrent; so can I assume that in 1.6 it is?</p>
<p>The reason is that I have several million tasks running in an ExecutorService, and it seems expensive to call DocumentBuilderFactory.newDocumentBuilder() every time.</p>
|
<p>Even though DocumentBuilder.parse appears not to mutate the builder it does on the Sun JDK default implementation (based on Apache Xerces). Eccentric design decision. What can you do? I guess use a ThreadLocal:</p>
<pre><code>private static final ThreadLocal<DocumentBuilder> builderLocal =
new ThreadLocal<DocumentBuilder>() {
@Override protected DocumentBuilder initialValue() {
try {
return
DocumentBuilderFactory
.newInstance(
"xx.MyDocumentBuilderFactory",
getClass().getClassLoader()
).newDocumentBuilder();
} catch (ParserConfigurationException exc) {
throw new IllegalArgumentException(exc);
}
}
};
</code></pre>
<p>(Disclaimer: Not so much as attempted to compile the code.)</p>
|
<p>You can also check this code to make further optimization <a href="https://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java" rel="nofollow">https://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java</a></p>
| 8,081
|
<p>I have this CTC i3 printer; when I print square test prints, as it moves along the Y-axis back to zero (front). It extrudes lines but very thin or none at all.</p>
<p>But opposite direction along the Y axis is 100 % </p>
<p><img src="https://i.stack.imgur.com/BChHj.jpg" alt="enter image description here"></p>
<p><img src="https://i.stack.imgur.com/PvPDT.jpg" alt="enter image description here"></p>
|
<p>Without images of the problem it is difficult to diagnose, but, the described symptoms sounds as if the nozzle is too close to the bed. If the nozzle is too close to the bed, and the extruder not strong enough, the filament flow is very limited due to pressure caused by a very small opening between the nozzle and the bed. Skipping of the extruder may wear out (grind) the filament and stop extrusion altogether.</p>
<p>Re-level the bed with a (thicker) piece of paper or with a feeler gauge. Alternatively, increase the height of the nozzle by re-defining the height or add an extra Z raise in the slicer (see question: "<a href="https://3dprinting.stackexchange.com/questions/13330/how-can-i-add-an-offset-to-the-first-layer-to-increase-clearance/13334">How can I add an offset to the first layer to increase clearance?</a>").</p>
|
<p>Clearly you're having an extrusion problem. Extrusion problems usually come either from a clogged nozzle (as @Adam S. said) or from the extruder it self. To determine where the problem is located I would first do a flow rate test using <a href="https://www.youtube.com/watch?v=lWBkPIXTOlo&feature=emb_logo" rel="nofollow noreferrer">this</a>. When doing this test you can determine if the extruder is grinding the filament or if it's not grabbing it too much. After the calibration of the flowrate you can be certain that the printer is (by .gcode) pushing the correct amount of filament. If the problem persist I would first do an unclogging (since it's cheaper than the following option) using something like <a href="https://www.youtube.com/watch?v=XR7tUVLku14" rel="nofollow noreferrer">this</a>. </p>
<p>If both previous options do not solve the problem, I would highly recommend you to by a mk-8 like metal extruder. After a while, the plastic one that comes with the printer loses force and you'll lose steps. Personally, I had a similar problem where the first layer was printed in a droplet pattern and was solved by changing the extruder to a metal one.</p>
<p>Try these options and if the problem persist you could upload some pictures of the first layer or a video. Other possibilities I think of are that the filament is having trouble passing through the Bowden tube or maybe you'll have to reasemble the hotend.</p>
| 1,661
|
<p>I'm trying to do this (which produces an unexpected T_VARIABLE error):</p>
<pre><code>public function createShipment($startZip, $endZip, $weight =
$this->getDefaultWeight()){}
</code></pre>
<p>I don't want to put a magic number in there for weight since the object I am using has a <code>"defaultWeight"</code> parameter that all new shipments get if you don't specify a weight. I can't put the <code>defaultWeight</code> in the shipment itself, because it changes from shipment group to shipment group. Is there a better way to do it than the following?</p>
<pre><code>public function createShipment($startZip, $endZip, weight = 0){
if($weight <= 0){
$weight = $this->getDefaultWeight();
}
}
</code></pre>
|
<p>This isn't much better:</p>
<pre><code>public function createShipment($startZip, $endZip, $weight=null){
$weight = !$weight ? $this->getDefaultWeight() : $weight;
}
// or...
public function createShipment($startZip, $endZip, $weight=null){
if ( !$weight )
$weight = $this->getDefaultWeight();
}
</code></pre>
|
<p>Improving upon Kevin's answer if you are using PHP 7 you may do:</p>
<pre><code>public function createShipment($startZip, $endZip, $weight=null){
$weight = $weight ?: $this->getDefaultWeight();
}
</code></pre>
| 2,383
|
<p>This is a line drawing and I would like to print it a couple of mm high. I cannot figure out how to get this line drawing filled. I converted to SVG with Inkscape, used GIMP, took it online to TinkerCad and tried it with Onshape but all I ever get is just the line and this does not work well on my printer. What is a smart way to get this filled in and ready to go?</p>
<p>I use TinkerCad to convert to STL and that works fine. So I could also try to edit the STL in stead of the SVG file.</p>
<p>Maybe I should print the original scanned image (TIFF) and then fill it by hand with black ink and then scan it and convert it to SVG but that sounds really dumb.</p>
<p><a href="https://i.stack.imgur.com/qzDoY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qzDoY.png" alt="should be SVG"></a></p>
<p><strong>UPDATE</strong><br>
I went back to the original drawing and using the bucket tool. The result is a rather noisy image and I need it to be sharp and tight to be able to convert it to a good SVG later on.
Looks like it is more of a graphics design question now..<br>
<a href="https://graphicdesign.stackexchange.com/questions/94773/from-drawing-to-3d-print">https://graphicdesign.stackexchange.com/questions/94773/from-drawing-to-3d-print</a></p>
<p><a href="https://i.stack.imgur.com/jakBT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jakBT.png" alt="enter image description here"></a></p>
|
<p>If you don't mind adding another tool to your toolbox, you can use a plug-in for Inkscape called <a href="https://www.thingiverse.com/thing:14221" rel="nofollow noreferrer">Inkscape OpenSCAD DXF Export</a> that will convert your SVG drawing to appropriate code to import to <a href="http://www.openscad.org/" rel="nofollow noreferrer">OpenSCAD</a>. Even if you aren't keen on learning OpenSCAD, once you have the code, press F5 for a preview, F6 for a rendering and then export the STL file.</p>
<p>The link on Thingiverse gives instructions how to add the plug-in (extension) to Inkscape, which is relatively simple. I've been using the extension for applicable projects with great success. Expect minor complications for closed paths within other paths, however. You may have to create separate STL files for those paths and use Boolean subtraction to remove the "holes" as needed.</p>
<p><a href="https://i.stack.imgur.com/NpFF2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NpFF2.jpg" alt="Inkscape OpenSCAD DXF image"></a></p>
<p>The extension is slightly counter-intuitive. Be sure to manually add the .scad extension to the file as it does not perform that task automatically.</p>
<p>UPDATE: I have discovered that the above link is not the one I've been using. I'm leaving it in place as it may be useful to others to have the ability to create .DXF files from Inkscape. The correct one is called <a href="https://www.thingiverse.com/thing:25036" rel="nofollow noreferrer">Inkscape to OpenSCAD converter v6</a> and works as described above.</p>
<p>As always, read and follow all label instructions. Do not operate heavy machinery after using this product.</p>
<p><a href="https://i.stack.imgur.com/rHHru.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rHHru.jpg" alt="Inkscape to OpenSCAD"></a></p>
|
<p>Free 3D printing program <a href="https://www.nanodlp.com" rel="nofollow noreferrer">NanoDLP</a> does support extruding single image frame to 3D object in required height. You can use Windows or Linux version of the program.</p>
| 645
|
<p>Here's my first question at SO.</p>
<p>I have a internal application for my company which I've been recently ask to maintain. The applications is built in PHP and its fairly well coded (OO, DB Abstraction, Smarty) nothing WTF-ish. </p>
<p>The problem is the applications is <strong>very slow</strong>.</p>
<p>How do I go about finding out what's slowing the application down? I've optimized the code to make very few DB queries, so I know that it is the PHP code which is taking a while to execute. I need to get some tools which can help me with this and need to devise a strategy for checking my code.</p>
<p>I can do the checking/strategy work myself, but I need more PHP tools to figure out where my app is crapping up. </p>
<p>Thoughts?</p>
|
<p>I've used <a href="http://www.xdebug.org/docs/profiler" rel="noreferrer">XDebug profiling</a> recently in a similiar situation. It outputs a full profile report that can be read with many common profiling apps ( Can't give you a list though, I just used the one that came with slackware ). </p>
|
<p>We use Zend Development Environment (windows). We resolved a memory usage spike yesterday by stepping through the debugger while running Process Explorer to watch the memory/cpu/disk activity as each line was executed. </p>
<p>Process Explorer: <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx</a>. </p>
<p>ZDE includes a basic performance profiler that can show time spent in each function call during page requests.</p>
| 7,955
|
<p>What is your favorite method to handle errors in Bash?
The best example of handling errors I have found on the web was written by William Shotts, Jr at <a href="http://www.linuxcommand.org" rel="noreferrer">http://www.linuxcommand.org</a>. </p>
<p>He suggests using the following function for error handling in Bash:</p>
<pre><code>#!/bin/bash
# A slicker error handling routine
# I put a variable in my scripts named PROGNAME which
# holds the name of the program being run. You can get this
# value from the first item on the command line ($0).
# Reference: This was copied from <http://www.linuxcommand.org/wss0150.php>
PROGNAME=$(basename $0)
function error_exit
{
# ----------------------------------------------------------------
# Function for exit due to fatal program error
# Accepts 1 argument:
# string containing descriptive error message
# ----------------------------------------------------------------
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 1
}
# Example call of the error_exit function. Note the inclusion
# of the LINENO environment variable. It contains the current
# line number.
echo "Example of error with line number and message"
error_exit "$LINENO: An error has occurred."
</code></pre>
<p>Do you have a better error handling routine that you use in Bash scripts?</p>
|
<p>Use a trap!</p>
<pre><code>tempfiles=( )
cleanup() {
rm -f "${tempfiles[@]}"
}
trap cleanup 0
error() {
local parent_lineno="$1"
local message="$2"
local code="${3:-1}"
if [[ -n "$message" ]] ; then
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
else
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
fi
exit "${code}"
}
trap 'error ${LINENO}' ERR
</code></pre>
<p>...then, whenever you create a temporary file:</p>
<pre><code>temp_foo="$(mktemp -t foobar.XXXXXX)"
tempfiles+=( "$temp_foo" )
</code></pre>
<p>and <code>$temp_foo</code> will be deleted on exit, and the current line number will be printed. (<code>set -e</code> will likewise give you exit-on-error behavior, <A HREF="http://mywiki.wooledge.org/BashFAQ/105" rel="nofollow noreferrer">though it comes with serious caveats</A> and weakens code's predictability and portability).</p>
<p>You can either let the trap call <code>error</code> for you (in which case it uses the default exit code of 1 and no message) or call it yourself and provide explicit values; for instance:</p>
<pre><code>error ${LINENO} "the foobar failed" 2
</code></pre>
<p>will exit with status 2, and give an explicit message.</p>
<p>Alternatively <code>shopt -s extdebug</code> and give the first lines of the trap a little modification to trap all non-zero exit codes across the board (mind <code>set -e</code> non-error non-zero exit codes):</p>
<pre><code>error() {
local last_exit_status="$?"
local parent_lineno="$1"
local message="${2:-(no message ($last_exit_status))}"
local code="${3:-$last_exit_status}"
# ... continue as above
}
trap 'error ${LINENO}' ERR
shopt -s extdebug
</code></pre>
<p>This then is also "compatible" with <code>set -eu</code>.</p>
|
<p>Using trap is not always an option. For example, if you're writing some kind of re-usable function that needs error handling and that can be called from any script (after sourcing the file with helper functions), that function cannot assume anything about exit time of the outer script, which makes using traps very difficult. Another disadvantage of using traps is bad composability, as you risk overwriting previous trap that might be set earlier up in the caller chain.</p>
<p>There is a little trick that can be used to do proper error handling without traps. As you may already know from other answers, <code>set -e</code> doesn't work inside commands if you use <code>||</code> operator after them, even if you run them in a subshell; e.g., this wouldn't work:</p>
<pre class="lang-sh prettyprint-override"><code>#!/bin/sh
# prints:
#
# --> outer
# --> inner
# ./so_1.sh: line 16: some_failed_command: command not found
# <-- inner
# <-- outer
set -e
outer() {
echo '--> outer'
(inner) || {
exit_code=$?
echo '--> cleanup'
return $exit_code
}
echo '<-- outer'
}
inner() {
set -e
echo '--> inner'
some_failed_command
echo '<-- inner'
}
outer
</code></pre>
<p>But <code>||</code> operator is needed to prevent returning from the outer function before cleanup. The trick is to run the inner command in background, and then immediately wait for it. The <code>wait</code> builtin will return the exit code of the inner command, and now you're using <code>||</code> after <code>wait</code>, not the inner function, so <code>set -e</code> works properly inside the latter:</p>
<pre class="lang-sh prettyprint-override"><code>#!/bin/sh
# prints:
#
# --> outer
# --> inner
# ./so_2.sh: line 27: some_failed_command: command not found
# --> cleanup
set -e
outer() {
echo '--> outer'
inner &
wait $! || {
exit_code=$?
echo '--> cleanup'
return $exit_code
}
echo '<-- outer'
}
inner() {
set -e
echo '--> inner'
some_failed_command
echo '<-- inner'
}
outer
</code></pre>
<p>Here is the generic function that builds upon this idea. It should work in all POSIX-compatible shells if you remove <code>local</code> keywords, i.e. replace all <code>local x=y</code> with just <code>x=y</code>:</p>
<pre class="lang-sh prettyprint-override"><code># [CLEANUP=cleanup_cmd] run cmd [args...]
#
# `cmd` and `args...` A command to run and its arguments.
#
# `cleanup_cmd` A command that is called after cmd has exited,
# and gets passed the same arguments as cmd. Additionally, the
# following environment variables are available to that command:
#
# - `RUN_CMD` contains the `cmd` that was passed to `run`;
# - `RUN_EXIT_CODE` contains the exit code of the command.
#
# If `cleanup_cmd` is set, `run` will return the exit code of that
# command. Otherwise, it will return the exit code of `cmd`.
#
run() {
local cmd="$1"; shift
local exit_code=0
local e_was_set=1; if ! is_shell_attribute_set e; then
set -e
e_was_set=0
fi
"$cmd" "$@" &
wait $! || {
exit_code=$?
}
if [ "$e_was_set" = 0 ] && is_shell_attribute_set e; then
set +e
fi
if [ -n "$CLEANUP" ]; then
RUN_CMD="$cmd" RUN_EXIT_CODE="$exit_code" "$CLEANUP" "$@"
return $?
fi
return $exit_code
}
is_shell_attribute_set() { # attribute, like "x"
case "$-" in
*"$1"*) return 0 ;;
*) return 1 ;;
esac
}
</code></pre>
<p>Example of usage:</p>
<pre class="lang-sh prettyprint-override"><code>#!/bin/sh
set -e
# Source the file with the definition of `run` (previous code snippet).
# Alternatively, you may paste that code directly here and comment the next line.
. ./utils.sh
main() {
echo "--> main: $@"
CLEANUP=cleanup run inner "$@"
echo "<-- main"
}
inner() {
echo "--> inner: $@"
sleep 0.5; if [ "$1" = 'fail' ]; then
oh_my_god_look_at_this
fi
echo "<-- inner"
}
cleanup() {
echo "--> cleanup: $@"
echo " RUN_CMD = '$RUN_CMD'"
echo " RUN_EXIT_CODE = $RUN_EXIT_CODE"
sleep 0.3
echo '<-- cleanup'
return $RUN_EXIT_CODE
}
main "$@"
</code></pre>
<p>Running the example:</p>
<pre class="lang-sh prettyprint-override"><code>$ ./so_3 fail; echo "exit code: $?"
--> main: fail
--> inner: fail
./so_3: line 15: oh_my_god_look_at_this: command not found
--> cleanup: fail
RUN_CMD = 'inner'
RUN_EXIT_CODE = 127
<-- cleanup
exit code: 127
$ ./so_3 pass; echo "exit code: $?"
--> main: pass
--> inner: pass
<-- inner
--> cleanup: pass
RUN_CMD = 'inner'
RUN_EXIT_CODE = 0
<-- cleanup
<-- main
exit code: 0
</code></pre>
<p>The only thing that you need to be aware of when using this method is that all modifications of Shell variables done from the command you pass to <code>run</code> will not propagate to the calling function, because the command runs in a subshell.</p>
| 9,039
|
<p>Working with software day-to-day usually means you have to juggle project work, meetings, calls and other interrupts.</p>
<p>What single technique, trick, or tool do you find most useful in managing your time?</p>
<p>How do you stay focused?</p>
<p>What is your single biggest distraction from your work?</p>
|
<p>I read this rule somewhere, and I use it every day...</p>
<ul>
<li>If someone asks you to do something - if it takes less than 2 minutes, do it immediately. If it takes longer, put it on your list and come back to it.</li>
</ul>
<p>This really works for me.</p>
|
<p>Single most useful? <a href="http://www.nowdothis.com" rel="nofollow noreferrer">http://www.nowdothis.com</a> is AWESOME for focusing on what currrently needs to get done, and has raised my productivity by tons. (Bonus tip: Use Google Chrome to make it its own application and then make the app always be on top of other windows)</p>
<p>Biggest distraction? Google Reader.</p>
| 9,675
|
<p>I have printed a couple weeks perfectly fine with my Ender 3. Two weeks ago I changed the firmware but the settings were all fine and resulted in good prints.</p>
<p>Now, suddenly <em>during</em> a print the extruder motor started to under-extrude.</p>
<p>I thought "hey, could be the file" and used a test file that printed well two weeks ago: Under-extrusion, barely a line.</p>
<p>I looked at the extruder, no filament grinding, no clicking from lost steps or moving against pressure. The Bowden tube is firmly seated though.</p>
<p>I measured what is coming out: instead of 50 mm I ordered to push into the hotend got 28.7 mm. So I went and looked at the steps/mm, which is 93, exactly what it is also on the TronXY X1, which uses pretty much the same extruder setup but for a different style, same sized gear.</p>
<p>I cleaned out the nozzle nevertheless, but that didn't change the results.</p>
<p>What might be wrong and how can I fix it?!</p>
<p>Edit:</p>
<ul>
<li>Touching the filament while I was printing a freshly sliced test, I realized it DID lose steps, just the filament did slip back (almost) quietly. Pressing a finger on the filament made me able to feel the shiver in it.</li>
<li>Inspecting what was printed showed, that the nozzle had migrated against the print platform a little over the weeks.</li>
</ul>
|
<p>A close inspection of what happened when printing the first layer resulted in this:</p>
<ul>
<li>The missing steps on the new print came from the nozzle scraping too close to the print surface, which lead to no first layer</li>
<li>Readjusting the Z-axis end stop, which had moved down, resulted in no more lost steps, but the print not sticking for the first test.</li>
<li><p>Releveling the bed and making sure the bar was parallel to the bed resulted in a perfect first layer.</p></li>
<li><p>Lost steps and under-extrusion could not be replicated after 48 hours of <em>rest</em> for the printer.</p></li>
</ul>
<p>I have no idea why the print had failed due to under-extrusion <em>during</em> the print, but apparently, my immediate tests were flawed enough to not detect the first layer height resulting in getting almost no extrusion. This I mistook for massive under-extrusion, making me believe something else was at fault.</p>
|
<p>Sounds similar to something I experienced with my Y-axis. The grub screw on the toothed wheel had come a little loose, and I was experiencing a reasonably consistent degree of slip.</p>
<p>In the extruder particularly, these locking screws might not be too obvious to check.</p>
| 1,026
|
<p>I am working on a SharePoint application that supports importing multiple documents in a single operation. I also have an ItemAdded event handler that performs some basic maintenance of the item metadata. This event fires for both imported documents and manually created ones. The final piece of the puzzle is a batch operation feature that I implemented to kick off a workflow and update another metadata field.</p>
<p>I am able to cause a COMException 0x81020037 by extracting the file data of a SPListItem. This file is just an InfoPath form/XML document. I am able to modify the XML and sucessfully push it back into the SPListItem. When I fire off the custom feature immediately afterwards and modify metadata, it occassionally causes the COM error.</p>
<p>The error message basically indicates that the file was modified by another thread. It would seem that the ItemAdded event is still writing the file back to the database while the custom feature is changing metadata. I have tried putting in delays and error catching loops to try to detect that the SPListItem is safe to modify with little success.</p>
<p>Is there a way to tell if another thread has a lock on a document?</p>
|
<p>Sometimes I see the <code>ItemAdded</code> or <code>ItemUpdated</code> firing twice for a single operation.
You can try to put a breakpoint in the <code>ItemAdded()</code> method to confirm that.</p>
<p>The solution in my case was to single thread the <code>ItemAdded()</code> method:</p>
<pre><code>private static object myLock = new object();
public override void ItemAdded(SPItemEventProperties properties) {
if (System.Threading.Monitor.TryEnter(myLock, TimeSpan.FromSeconds(30))
{
//do your stuff here.
System.Threading.Monitor.Exit(myLock);
}
}
</code></pre>
|
<p>I'll have to look into that and get back to you. The problem on my end seems to be that there is code running in a different class, in a different feature, being controlled by a different thread, all of which are trying to access the same record.</p>
<p>I am trying to avoid using a fixed delay. With any threading issue, there is the pathological possibility that one thread can delay or block beyond what we expect. With deployments on different server hardware with different loads, this is a very real possibility. On the other end of the spectrum, even if I were to go with a delay, I don't want it to be very high, especially not 30 seconds. My client will be importing tens of thousands of documents, and a delay of any significant length will cause the import to take literally all day.</p>
| 4,237
|
<p>Given a select with multiple option's in jQuery. </p>
<pre><code>$select = $("<select></select>");
$select.append("<option>Jason</option>") //Key = 1
.append("<option>John</option>") //Key = 32
.append("<option>Paul</option>") //Key = 423
</code></pre>
<p>How should the key be stored and retrieved?</p>
<p>The ID may be an OK place but would not be guaranteed unique if I had multiple select's sharing values (and other scenarios).</p>
<p>Thanks</p>
<p>and in the spirit of TMTOWTDI.</p>
<pre><code>$option = $("<option></option>");
$select = $("<select></select>");
$select.addOption = function(value,text){
$(this).append($("<option/>").val(value).text(text));
};
$select.append($option.val(1).text("Jason").clone())
.append("<option value=32>John</option>")
.append($("<option/>").val(423).text("Paul"))
.addOption("321","Lenny");
</code></pre>
|
<p>Like lucas said the value attribute is what you need. Using your code it would look something like this ( I added an id attribute to the select to make it fit ):</p>
<pre><code>$select = $('<select id="mySelect"></select>');
$select.append('<option value="1">Jason</option>') //Key = 1
.append('<option value="32">John</option>') //Key = 32
.append('<option value="423">Paul</option>') //Key = 423
</code></pre>
<p>jQuery lets you get the value using the val() method. Using it on the select tag you get the current selected option's value.</p>
<pre><code>$( '#mySelect' ).val(); //Gets the value for the current selected option
$( '#mySelect > option' ).each( function( index, option ) {
option.val(); //The value for each individual option
} );
</code></pre>
<p>Just in case, the .each method loops throught every element the query matched.</p>
|
<p>If you are using HTML5, you can use a <a href="http://ejohn.org/blog/html-5-data-attributes/" rel="nofollow noreferrer">custom data attribute</a>. It would look like this:</p>
<pre><code>$select = $("<select></select>");
$select.append("<option data-key=\"1\">Jason</option>") //Key = 1
.append("<option data-key=\"32\">John</option>") //Key = 32
.append("<option data-key=\"423\">Paul</option>") //Key = 423
</code></pre>
<p>Then to get the selected key you could do:</p>
<pre><code>var key = $('select option:selected').attr('data-key');
</code></pre>
<p>Or if you are using XHTML, then you can create a custom namespace.</p>
<p>Since you say the keys can repeat, using the value attribute is probably not an option since then you wouldn't be able to tell which of the different options with the same value was selected on the form post.</p>
| 4,683
|
<p>I was looking for a good free debugger for STP (Stored Procedures) as I need to make changes to a few of them as a part of my recent project. The stored procedures are stored in independent <code>.sql</code> files and not in the code.</p>
<p>A debugger would speed things up quite a it in my case. Could anyone recommend any tools that can be used for this?
</p>
|
<blockquote>
<p>The stored procedures are stored in independent '.sql' files and not in the code.</p>
</blockquote>
<p>In order to debug a proc it has to be created in the RDBMS and then executed, how will you debug a proc stored in a file?</p>
|
<p>Yes, you are right. These stored procedures are called through code which has all the necessary libraries to connect to the database (RDBMS). </p>
<p>However, what I am looking for is to understand what the stored procedures do. At the moment I am using dbVisualizer for this. I have set up the connections to the RDBMS in the tool, so I am able to run individual queries into the database.</p>
<p>The free version of dbVisualizer, does not allow the debugging of stored procedures. Hence the reason to look for another tool which can help me do this.</p>
<p>I apologize for not including enough detail into the original question.</p>
<p>Thanks.</p>
| 3,873
|
<p>In VB.NET is there a library of template dialogs I can use? It's easy to create a custom dialog and inherit from that, but it seems like there would be some templates for that sort of thing.</p>
<p>I just need something simple like Save/Cancel, Yes/No, etc. </p>
<p>Edit: MessageBox is not quite enough, because I want to add drop-down menus, listboxes, grids, etc. If I had a dialog form where I could ask for some pre-defined buttons, each of which returned a modal result and closed the form, then I could add those controls and the buttons would already be there.</p>
|
<p>Do you need something more than what can be provided by MsgBox?</p>
<pre><code>MsgBox("Do you want to see this message?", MsgBoxStyle.OkCancel + MsgBoxStyle.Information, "Respond")
</code></pre>
|
<p>Are you unable to use the <a href="http://msdn.microsoft.com/en-us/library/aa335422(VS.71).aspx" rel="nofollow noreferrer">MessageBox class</a>?</p>
| 8,839
|
<p>I have a <code>String</code> representation of a date that I need to create a <code>Date</code> or <code>Calendar</code> object from. I've looked through <code>Date</code> and <code>Calendar</code> APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?</p>
|
<p>In brief:</p>
<pre><code>DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
try {
Date date = formatter.parse("01/29/02");
} catch (ParseException e) {
e.printStackTrace();
}
</code></pre>
<p>See <a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer"><code>SimpleDateFormat</code> javadoc</a> for more.</p>
<p>And to turn it into a <code>Calendar</code>, do:</p>
<pre><code>Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
</code></pre>
|
<p>Try this:</p>
<pre><code>DateFormat.parse(String)
</code></pre>
| 6,538
|
<p>I was wondering if I could access the iPhones Core Location framework over a website?</p>
<p>My goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other. I can have them manually enter lng/lat but its not the easiest thing to find. If the iPhone could display or upload this automatically it would be great.</p>
<p>I don't own a Mac yet (waiting for the new Mac Book Pro) but would like something a little more automatic right now. Once I have the mac I could download the SDK and build a better version later. For now a webapp version would be great if possible. Thanks.</p>
|
<p>Why not simply use W3C <a href="https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/GettingGeographicalLocations/GettingGeographicalLocations.html" rel="nofollow noreferrer">GeoLocation</a> API available in mobile Safari? This will work on ipod touch as well (suburb precision).</p>
<p>It's literally 10 lines of code and the javascript will work without change on Firefox 3.5. Far easier than scrape some third party website.</p>
|
<p>We built a really thin iphone client app that simply calls a predefined .js file on our site. Works like a charm. </p>
<p>See arisgames.org for the project.</p>
| 4,678
|
<p>What code analysis tools do you use on your Java projects?</p>
<p>I am interested in all kinds</p>
<ul>
<li>static code analysis tools (FindBugs, PMD, and any others)</li>
<li>code coverage tools (Cobertura, Emma, and any others)</li>
<li>any other instrumentation-based tools </li>
<li>anything else, if I'm missing something</li>
</ul>
<p>If applicable, also state what build tools you use and how well these tools integrate with both your IDEs and build tools. </p>
<p>If a tool is only available a specific way (as an IDE plugin, or, say, a build tool plugin) that information is also worth noting.</p>
|
<p>For static analysis tools I often use CPD, <a href="http://pmd.sourceforge.net" rel="noreferrer">PMD</a>, <a href="http://findbugs.sourceforge.net" rel="noreferrer">FindBugs</a>, and <a href="http://checkstyle.sourceforge.net" rel="noreferrer">Checkstyle</a>.</p>
<p><p>CPD is the PMD "Copy/Paste Detector" tool. I was using PMD for a little while before I noticed the <a href="http://pmd.sourceforge.net/cpd.html" rel="noreferrer">"Finding Duplicated Code" link</a> on the <a href="http://pmd.sourceforge.net" rel="noreferrer">PMD web page</a>.</p>
<p><p>I'd like to point out that these tools can sometimes be extended beyond their "out-of-the-box" set of rules. And not just because they're open source so that you can rewrite them. Some of these tools come with applications or "hooks" that allow them to be extended. For example, PMD comes with the <a href="http://pmd.sourceforge.net/howtowritearule.html" rel="noreferrer">"designer" tool</a> that allows you to create new rules. Also, Checkstyle has the <a href="http://checkstyle.sourceforge.net/config_misc.html#DescendantToken" rel="noreferrer">DescendantToken</a> check that has properties that allow for substantial customization.</p>
<p><p>I integrate these tools with <a href="http://virtualteamtls.svn.sourceforge.net/viewvc/virtualteamtls/trunk/scm/common.xml?view=markup" rel="noreferrer">an Ant-based build</a>. You can follow the link to see my commented configuration.</p>
<p><p>In addition to the simple integration into the build, I find it helpful to configure the tools to be somewhat "integrated" in a couple of other ways. Namely, report generation and warning suppression uniformity. I'd like to add these aspects to this discussion (which should probably have the "static-analysis" tag also): how are folks configuring these tools to create a "unified" solution? (I've asked this question separately <a href="https://stackoverflow.com/questions/79918/configuring-static-analysis-tools-for-uniformity">here</a>)</p>
<p><p>First, for warning reports, I transform the output so that each warning has the simple format:</p>
<pre><code>/absolute-path/filename:line-number:column-number: warning(tool-name): message</code></pre>
<p><p>This is often called the "Emacs format," but even if you aren't using Emacs, it's a reasonable format for homogenizing reports. For example:</p>
<pre><code>/project/src/com/example/Foo.java:425:9: warning(Checkstyle):Missing a Javadoc comment.</code></pre>
<p><p>My warning format transformations are done by my Ant script with Ant <a href="http://ant.apache.org/manual/Types/filterchain.html" rel="noreferrer">filterchains</a>.</p>
<p><p>The second "integration" that I do is for warning suppression. By default, each tool supports comments or an annotation (or both) that you can place in your code to silence a warning that you want to ignore. But these various warning suppression requests do not have a consistent look which seems somewhat silly. When you're suppressing a warning, you're suppressing a warning, so why not always write "<code>SuppressWarning</code>?"</p>
<p><p>For example, PMD's default configuration suppresses warning generation on lines of code with the string "<code>NOPMD</code>" in a comment. Also, PMD supports Java's <code>@SuppressWarnings</code> annotation. I configure PMD to use comments containing "<code>SuppressWarning(PMD.</code>" instead of <code>NOPMD</code> so that PMD suppressions look alike. I fill in the particular rule that is violated when using the comment style suppression:</p>
<pre><code>// SuppressWarnings(PMD.PreserveStackTrace) justification: (false positive) exceptions are chained</code></pre>
<p><p>Only the "<code>SuppressWarnings(PMD.</code>" part is significant for a comment, but it is consistent with PMD's support for the <code>@SuppressWarning</code> annotation which does recognize individual rule violations by name:</p>
<pre><code>@SuppressWarnings("PMD.CompareObjectsWithEquals") // justification: identity comparision intended</code></pre>
<p><p>Similarly, Checkstyle suppresses warning generation between pairs of comments (no annotation support is provided). By default, comments to turn Checkstyle off and on contain the strings <code>CHECKSTYLE:OFF</code> and <code>CHECKSTYLE:ON</code>, respectively. Changing this configuration (with Checkstyle's "SuppressionCommentFilter") to use the strings "<code>BEGIN SuppressWarnings(CheckStyle.</code>" and "<code>END SuppressWarnings(CheckStyle.</code>" makes the controls look more like PMD:</p>
<pre>
<code>// BEGIN SuppressWarnings(Checkstyle.HiddenField) justification: "Effective Java," 2nd ed., Bloch, Item 2</code>
<code>// END SuppressWarnings(Checkstyle.HiddenField)</code>
</pre>
<p><p>With Checkstyle comments, the particular check violation (<code>HiddenField</code>) <em>is</em> significant because each check has its own "<code>BEGIN/END</code>" comment pair.</p>
<p><p>FindBugs also supports warning generation suppression with a <code>@SuppressWarnings</code> annotation, so no further configuration is required to achieve some level of uniformity with other tools. Unfortunately, Findbugs has to support a custom <code>@SuppressWarnings</code> annotation because the built-in Java <code>@SuppressWarnings</code> annotation has a <code>SOURCE</code> retention policy which is not strong enough to retain the annotation in the class file where FindBugs needs it. I fully qualify FindBugs warnings suppressions to avoid clashing with Java's <code>@SuppressWarnings</code> annotation:</p>
<pre><code>@edu.umd.cs.findbugs.annotations.SuppressWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")</code></pre>
<p><p>These techniques makes things look reasonably consistent across tools. Note that having each warning suppression contain the string "<code>SuppressWarnings</code>" makes it easy to run a simple search to find all instances for all tools over an entire code base.</p>
|
<p>I am looking for many answers to learn about new tools and consolidate this knowledge in a one question/thread, so I doubt there will be 1 true answer to this question.</p>
<p>My answer to my own question is that we use:</p>
<ul>
<li>Findbugs to look for common errors bad/coding - run from maven, and also integrates easily into Eclipse</li>
<li>Cobertura for our coverage reports - run from maven</li>
</ul>
<p>Hudson also has a task-scanner plugin that will display a count of your TODO and FIXMEs, as well as show where they are in the source files.</p>
<p>All are integrated with Maven 1.x in our case and tied into Hudson, which runs our builds on check-in as well as extra things nightly and weekly. Hudson trend graphs our JUnit tests, coverage, findbugs, as well as open tasks. There is also a Hudson plugin that reports and graphs our compile warnings. We also have several performance tests with their own graphs of performance and memory use over time using the Hudson plots plugin as well.</p>
| 2,610
|
<p>If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong?</p>
<p>(The specific scenario I'm facing is no-char boxes within a <select> when it should be showing Japanese chars.)</p>
|
<p>Firstly, "ugly no-char boxes" might not be an encoding problem, they might just be a sign you don't have a font installed that can display the glyphs in the page.</p>
<p>Most character encoding problems happen when strings are being passed from one system to another. For webapps, this is usually between the browser and the application, between the application and the filesystem and between the application and the database.</p>
<p>So you need to check where the mis-encoded data is coming from, what character encoding it has at the source, and what encoding it is being received as. The best way is to send through characters you know the system is having problems with, and examine them at each level of the app. What do they look like inside the app? In the database? When you get them back from the database? When they're displayed in the browser?</p>
<p>Sorry to be so general, but the question doesn't give much more to work with.</p>
|
<p>Redirect the data to disk and use a <a href="https://www.hhdsoftware.com/free-hex-editor" rel="nofollow noreferrer">Hex Editor</a>. Most text editors / viewers do their own conversions behind the scenes, so it is difficult to be sure you are seeing the data in it's true form.</p>
| 4,915
|
<p>Another discussion (we've been having a lot of them these days!) in our work is whether data binding is a bad idea or not.</p>
<p>Personally, I think it is a Bad Thing™.</p>
<p>My reasons are thrice:</p>
<ol>
<li><p>It circumvents my well architectured MVP framework - with databinding, the view communicates bi-directionally with a model. Ewww.</p></li>
<li><p>It promotes hooking up view controls to datafields at design time. In my experience, this leads to vital code (binding column A to Field X) being obscure and hidden away in some designer file. IMO this code should be explicit and in-your-face, so that it is easy to modify and see what is going on, without having to use a clunky designer interface.</p></li>
<li><p>Relating to Point #1 this direct binding makes it harder to isolate each component (view, model, controller/presenter) and unit-test. </p></li>
</ol>
<p>The pros are that it is easy to set up, and you can take advantage of some nice features (validation etc) which come with the plumbing already done for you. </p>
<p>But for me, databinding becomes much more of a hindrance when dealing with a large data-centric application.</p>
<p>Any thoughts?</p>
|
<p>As we say in the UK, <em>"It's Horses for courses"</em></p>
<p>First off all, I agree with you! But...</p>
<p>For enterprise level applications, then spending the extra time on the system architecture, modelling and standards will give you a robust and sustainable system.</p>
<p>But it will take longer to develop (or at least longer to get to an initial release) and this may not be appropriate for every system or every part of the system.</p>
<p>Sometimes you just need to "get it done and done quick". For internal applications, back office systems and maintenance applications that are rarely used or very dynamic (the spec's change often) then there is little justification in building the Rolls Royce solution for this. It's better to get the developer spending time on the CRITICAL part of the system.</p>
<p>What you have to avoid / prevent is using these "one click framework" solutions on the MISSION CRITICAL area's of the system where the big transaction rate area's and where data quality and integrity is critical. Spend quality time shaving the milliseconds off on the most heavily used area's on the system!!</p>
|
<p>@Timbo:</p>
<p>Yes and no.... but from a TDD perspective I'd like to cordon-off each controller so that I can test it in isolation. Also, say we want to run each edit via an EditCommand (so that we support Undo, for example) - for me, this rules out databinding.</p>
<p>@Guy:</p>
<p>Yes, this is exactly my POV. For me, databinding is great for very simple apps, but we don't do any of those! </p>
| 3,996
|
<p>A client of mine has asked me to integrate a 3rd party API into their Rails app. The only problem is that the API uses SOAP. Ruby has basically dropped SOAP in favor of REST. They provide a Java adapter that apparently works with the Java-Ruby bridge, but we'd like to keep it all in Ruby, if possible. I looked into soap4r, but it seems to have a slightly bad reputation.</p>
<p>So what's the best way to integrate SOAP calls into a Rails app?</p>
|
<p>I built <a href="http://savonrb.com" rel="noreferrer">Savon</a> to make interacting with SOAP webservices via Ruby as easy as possible.<br>
I'd recommend you check it out.</p>
|
<p>I was having the same issue, switched to Savon and then just tested it on an open WSDL (I used <a href="http://www.webservicex.net/geoipservice.asmx?WSDL" rel="nofollow">http://www.webservicex.net/geoipservice.asmx?WSDL</a>) and so far so good!</p>
<p><a href="https://github.com/savonrb/savon" rel="nofollow">https://github.com/savonrb/savon</a></p>
| 6,150
|
<pre><code>#if SYMBOL
//code
#endif
</code></pre>
<p>what values does C# predefine for use?</p>
|
<p>To add to what Nick said, the MSDN documentation does not list any pre-defined names. It would seem that all need to come from <code>#define</code> and <code>/define</code>.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx" rel="nofollow noreferrer">#if on MSDN</a></p>
|
<p>Well, that depends on the compiler you are using, and the command line options. Mono defines different names than Microsoft's compiler by default, and depending on what system you are you get different defines, etc.</p>
<p>If you provide a more specific system for which you are compiling, we might be able to come up with the list for that particular system (for example: x64 Vista system, using Visual Studio 2008).</p>
| 4,164
|
<p>Let's say I have a drive such as <strong>C:\</strong>, and I want to find out if it's shared and what it's share name (e.g. <strong>C$</strong>) is.</p>
<p>To find out if it's shared, I can use <a href="https://learn.microsoft.com/en-us/windows/desktop/api/Lmshare/nf-lmshare-netsharecheck" rel="nofollow noreferrer">NetShareCheck</a>.</p>
<p>How do I then map the drive to its share name? I thought that <a href="https://learn.microsoft.com/en-us/windows/desktop/api/Lmshare/nf-lmshare-netsharegetinfo" rel="nofollow noreferrer">NetShareGetInfo</a> would do it, but it looks like that takes the share name, not the local drive name, as an input.</p>
|
<p>If all else fails, you could always use <a href="https://learn.microsoft.com/en-us/windows/win32/api/lmshare/nf-lmshare-netshareenum" rel="nofollow noreferrer">NetShareEnum</a> and call <a href="https://learn.microsoft.com/windows/desktop/api/lmshare/nf-lmshare-netsharegetinfo" rel="nofollow noreferrer">NetShareGetInfo</a> on each.</p>
|
<p>Use;</p>
<pre><code>SHGetFileInfo with SHGFI_ATTRIBUTES
</code></pre>
<p>upon return check the dwAttributes flag for SFGAO_SHARE.</p>
<p>I'm not sure how to find the actual path tho.</p>
| 3,365
|
<p>I have an Anet A8 and have a problem with my first layer. I printed nice prints but starting today the first layer is tearing in the middle:</p>
<p><a href="https://i.stack.imgur.com/4BiUc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4BiUc.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/L94tI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L94tI.jpg" alt="enter image description here"></a></p>
<p>Any idea how to fix this?</p>
|
<p>The great pics really help with the answerability of this question. From how catastrophic the failure is, and how it's clearly independent of any specialty needs for the particular print such as tiny bed-adhesion contacts, sharp overhangs, bridges, etc. this is definitely not a problem with temperature. Different people recommend different temperatures for PLA, but I find that 210°C works well for me, and if you go much lower you'll hit problems getting the needed extrusion rate for anything but slow print speeds.</p>
<p>I've seen nearly this exact phenomenon before, so I knew it was probably a matter of the bed being too high, blocking extrusion of the first layer and forcing what little material can escape out to the sides of the nozzle, then tearing into it when the next adjacent line is laid out.</p>
<p>If I didn't know that, though, I'd still start looking for a source of the problem that's related to extrusion rate. Something was clearly wrong with getting the right amount of material in the right space, which indicates to me that there's either too much material (overextrusion/wrong filament diameter selected) or too little space (bed to high).</p>
|
<p>I found the solution to be the exact opposite. My bed was too low (as in too far from the hotend). All the above mentioned aside, I did also drop the flow rate on the brim and initial layer by roughly 2-3 %. Now it prints perfectly again. (your mileage may vary)</p>
| 1,447
|
<p>Windows has its 3D Builder software which upon importing an image, converts it to a heightmap of the image, aka turning it to a 3D model that can be saved as an stl.</p>
<p>Does Linux have software with similar properties that takes a black and white image and turning it into a 3D heightmap model?</p>
|
<p>The OpenSCAD <code>surface</code> function will do this. You can feed it a greyscale image or a textfile containing a matrix. Documentation and examples can be found at <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface" rel="nofollow noreferrer">https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface</a></p>
<p>OpenSCAD is a cross platform free open source cad package.</p>
|
<p>FreeCAD can import JPG (and IIRC TIFF and PNG as well) image files and produce a lithophane type height-map based on the brightness of each pixel. I'd be rather surprised if other 3D CAD software aimed at the 3D printing user base couldn't do the same. Most of the common free-to-use 3D CAD packages have Linux versions; FreeCAD certainly does (I use it on Kubuntu 20.04, and it should work on any recent version of any flavor of Debian-based Linux, if your hardware meets it requirements).</p>
| 1,954
|
<p>I have seen lots of printers that print chocolate using a syringe with molten chocolate. But, even cooler, would it be possible to print chocolate using some kind of feed system for <strong>continuous</strong> chocolate printing, so large objects and for a prolonged time, not only lasting the content of one syringe with molten chocolate ?</p>
<p>Things to consider are IMO: </p>
<ul>
<li>How to keep the chocolate long enough in a molten, viscous state
enough to print ?</li>
<li>Chocolate needs a tempering temperature, which
means it needs to be around 32-37 degrees celsius, else it doesn't
shine but gets a dull look (or turns white after a while). </li>
<li>Chocolate
is food, so you need foodsave equipment in the whole chain that is in
contact with the chocolate.</li>
</ul>
<p>Maybe a peristaltic pump that keeps pumping the molten chocolate to the extruder, which might be a valve that can be open/closed from G-code ?</p>
|
<p>Update: I found a nice article about chocolate printing: <a href="https://all3dp.com/2/chocolate-3d-printer-all-you-need-to-know/" rel="nofollow noreferrer">https://all3dp.com/2/chocolate-3d-printer-all-you-need-to-know/</a></p>
<hr>
<p>You are searching for chocolate extruder. I did not find one, which would fulfill all your requirements. You have to adapt each solution.</p>
<h2>Zmorph3d Liquid paste extruder</h2>
<ul>
<li><a href="https://zmorph3d.com/cake-and-chocolate-extruder/" rel="nofollow noreferrer">https://zmorph3d.com/cake-and-chocolate-extruder/</a></li>
</ul>
<p>According video on the page you insert chocolate in liquid form. That could be solved with heated chocolate container. </p>
<h2>Syringe based extruders</h2>
<ul>
<li><a href="http://www.open-electronics.org/3drag-is-now-printing-with-chocolate/" rel="nofollow noreferrer">http://www.open-electronics.org/3drag-is-now-printing-with-chocolate/</a></li>
<li><a href="http://richrap.blogspot.de/2012/04/universal-paste-extruder-ceramic-food.html" rel="nofollow noreferrer">http://richrap.blogspot.de/2012/04/universal-paste-extruder-ceramic-food.html</a></li>
<li><a href="http://www.instructables.com/id/Chocolate-Extruder-for-Ultimaker/" rel="nofollow noreferrer">http://www.instructables.com/id/Chocolate-Extruder-for-Ultimaker/</a></li>
</ul>
<p>You can use a <a href="http://esyringe.com/2l-jumbo-syringe.aspx" rel="nofollow noreferrer">2 liters syringe</a>. And if this is not enough then you can refill during print.</p>
<h2>Convert pellet extruder</h2>
<p>Printing from chocolate pellets is simpler then printing from plastic pellets. Therefore if you use foodsave parts to build such a extruder then this is useable for you. </p>
<ul>
<li><a href="https://www.youmagine.com/designs/universal-pellet-extruder-reprap-3d-printing" rel="nofollow noreferrer">https://www.youmagine.com/designs/universal-pellet-extruder-reprap-3d-printing</a></li>
</ul>
<h2>Cooling</h2>
<ul>
<li><a href="http://www.open-electronics.org/the-3drag-choco-chocolate-3d-printer-cooling-system-explained/" rel="nofollow noreferrer">3DRAG CHOCO (Chocolate 3d printer) Cooling system explained</a></li>
</ul>
<h2>Shop</h2>
<p>by Open-Electronics</p>
<ul>
<li><a href="https://store.open-electronics.org/index.php?_route_=3DCHOCO" rel="nofollow noreferrer">Extrude for chocolate</a></li>
<li><a href="http://www.open-electronics.org/syringe-heater-for-3drag-chocolate-printer/" rel="nofollow noreferrer">Syringe Heater for 3Drag chocolate printer</a></li>
</ul>
|
<p>I would look into what Hershey did for this chocolate printer in junction with 3ds. Behold state of the art Chocolate 3d printing.. The
<a href="http://richport3d.com/2015/02/17/3d-systems-unveils-the-cocojettm/" rel="nofollow noreferrer">CocoJett</a></p>
<p>That said there is little said about their tank system.</p>
<p>Far as the actual question it self. There is nothing to facilitate a large pool of continuous chocolate. It would be easy enough to build something that stirred the chocolate and a pump that feeds it in. At that point we are talking about a fair amount of new engineering. One could figure out how to map the E extrusion to a pump that would refill what was spent.</p>
<p>This section is just a bit of speculation..
I wonder. It seems to me that the way to go for XL coco printing would be powder. Bind it with an edible adhesive (hot sugar water maybe?). Have the printer refrigerated. Or just have a simple system that can change out the syringes of coco. Last you could just pause it while you change syringes. </p>
| 174
|
<p>I'm using markdown to edit this question right now. In some <a href="http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page#Wiki_markup" rel="noreferrer">wikis</a> I used wiki markup. Are they the same thing? Are they related? Please explain. If I want to implement one or the other in a web project (like stackoverflow) what do I need to use?</p>
|
<ul>
<li><a href="http://en.wikipedia.org/wiki/Markup_language" rel="noreferrer">Markup</a> is a generic term for a language that describes a document's formatting</li>
<li><a href="http://en.wikipedia.org/wiki/Markdown" rel="noreferrer">Markdown</a> is a specific markup library: <a href="http://daringfireball.net/projects/markdown/" rel="noreferrer">http://daringfireball.net/projects/markdown/</a><br />
These days the term is more commonly used to refer to markup languages that mimic the style of the library. See: <a href="https://en.wikipedia.org/wiki/Markdown" rel="noreferrer">https://en.wikipedia.org/wiki/Markdown</a></li>
</ul>
|
<p>Markup is a general term for content formatting - such as HTML - but markdown is a library that generates HTML markup. Take a look at <a href="http://daringfireball.net/projects/markdown/" rel="noreferrer">Markdown</a>.</p>
| 4,382
|
<p>Following this <a href="https://3dprinting.stackexchange.com/questions/2617/decent-cnc-control-software-for-osx">issue</a> I would like to propose to allow general CNC related questions here as well. 3D Printers are CNC machines, they only add instead of subtract. 3D printers use G-Code, just like CNC milling machines.</p>
<p>3D Printing alone makes for a very narrow community if it excludes subtractive manufacturing questions. For example, there is no python.stackexchange.com or javascript.stackexchange.com, all of that goes into one network: stackoverflow.com. That's just the same level of division.</p>
<p>Navel-gazing has never done anyone good :)</p>
|
<p>There are tens of SE sites that deal with programming in some way, shape or form. SO is obviously the most general one of these, but there are many more specialized ones (CodeReview,TeX,Programmers,Drupal/Wordpress/Joomla/Server Fault/Ubuntu/...). If this site had been "Makers StackExchange" or "Digital Fabrication" then your question might have been appropriate (this site being a more general one), but "3D printing" should be seen as a more specialized one (but if you think there is a need for a specific Makers SE or a CNC SE, then you could consider going to Area51).</p>
<p>This site is called "3D printing" and CNC milling is definitely not 3D printing. I think it does very much make sense to limit 3D printing to "additive fabrication". This is not a particularly narrow scope, since there are many types of 3D printer, and not all of them use G-code. Powder printers (binder jetting) and DLP printers are driven with raster images, for instance.</p>
<p>If the scope were extended to cover your question (which is about 2D milling, not even 3D milling, while we're at it) then I wonder if that meant that questions like "How many flutes do I need on my 8mm ball-nose left-hand bit when cutting unobtainium with my feedrate at the speed of sound?" would also be in scope. When I hear "3D printing SE" I would definitely not expect <em>that</em>.</p>
<p>I would add that your question might have been closed on a hypothetical "CNC SE" as well for a variety of reasons:</p>
<ul>
<li><p>Opinion based/list question</p></li>
<li><p>Very little own effort</p></li>
<li><p>Too broad (need to be more specific)</p></li>
</ul>
|
<p>As has been discussed previously <a href="https://3dprinting.meta.stackexchange.com/questions/147/hobbyist-machine-questions-on-topic">here</a>, the relevance of CNC questions on this site depend on the questions closeness to 3D printing. So, for instance, if the software you are asking about is the same as a 3D printer would use, I would agree that it can be asked here. However, if the software is dedicated to CNC machines and unusable for 3D printers, it does not belong here at the time being.</p>
<p>If the software you are looking for indeed works for both 3D printers and CNC machines, then perhaps you could specify this in your question to make it more relevant to this site?</p>
| 34
|
<p>What are the advantages and disadvantages of turning <strong><code>NOCOUNT</code></strong> off in SQL server queries?
</p>
|
<p>From SQL BOL: </p>
<blockquote>
<p>SET NOCOUNT ON prevents the sending of
DONE_IN_PROC messages to the client
for each statement in a stored
procedure. For stored procedures that
contain several statements that do not
return much actual data, <strong>setting SET
NOCOUNT to ON can provide a
significant performance boost</strong>, because
network traffic is greatly reduced.</p>
</blockquote>
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms189837.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms189837.aspx</a> for more details.<br>
Also, this article on SQLServerCentral is great on this subject:<br>
<a href="http://www.sqlservercentral.com/articles/Performance+Tuning/2751/" rel="noreferrer">Performance Effects of NOCOUNT</a></p>
|
<p>I personally like to turn <strong>NOCOUNT</strong> on for queries that get run in an manual fashion and use a lot of <code>Print</code> statements to output debugging messages. In this way, your output would look less like:</p>
<pre>
Updating usernames
(287 rows updated)
Done
Updating passwords
(287 rows updated)
Done
Doing the next thing
(1127 rows updated)
Done
</pre>
<p>And more like</p>
<pre>
Updating usernames
Done
Updating passwords
Done
Doing the next thing
Done
</pre>
<p>Depending on the sensitivity of what you're updating, sometimes it is helpful to include the counts; however, for complex scripts with a lot of output I usually like to leave them out.</p>
| 4,611
|
<p>Before reading anything else, please take time to read the <a href="https://stackoverflow.com/questions/1615/how-can-i-modify-xfdl-files-update-1">original thread</a>.</p>
<p>Overview: a .xfdl file is a gzipped .xml file which has then been encoded in base64. I wish to de-encode the .xfdl into xml which I can then modify and then re-encode back into a .xfdl file.</p>
<blockquote>
<p>xfdl > xml.gz > xml > xml.gz > xfdl</p>
</blockquote>
<p>I have been able to take a .xfdl file and de-encode it from base64 using uudeview:</p>
<pre><code>uudeview -i yourform.xfdl
</code></pre>
<p>Then decommpressed it using gunzip</p>
<pre><code>gunzip -S "" < UNKNOWN.001 > yourform-unpacked.xml
</code></pre>
<p>The xml produced is 100% readable and looks wonderful. Without modifying the xml then, i should be able to re-compress it using gzip:</p>
<pre><code>gzip yourform-unpacked.xml
</code></pre>
<p>Then re-encoded in base-64:</p>
<pre><code>base64 -e yourform-unpacked.xml.gz yourform_reencoded.xfdl
</code></pre>
<p>If my thinking is correct, the original file and the re-encoded file should be equal. If I put yourform.xfdl and yourform_reencoded.xfdl into beyond compare, however, they do not match up. Also, the original file can be viewed in an http://www.grants.gov/help/download_software.jsp#pureedge">.xfdl viewer. The viewer says that the re-encoded xfdl is unreadable. </p>
<p>I have also tried uuenview to re-encode in base64, it also produces the same results. Any help would be appreciated.</p>
|
<p>As far as I know you cannot find the compression level of an already compressed file. When you are compressing the file you can specify the compression level with -# where the # is from 1 to 9 (1 being the fastest compression and 9 being the most compressed file). In practice you should never compare a compressed file with one that has been extracted and recompressed, slight variations can easily crop up. In your case I would compare the base64 encoded versions instead of the gzip'd versions.</p>
|
<p>Different implementations of the gzip algorithm will always produce slightly different but still correct files, also the compression level of the original file may be different then what you are running it at.</p>
| 2,850
|
<p>Is it realistic to try and learn and code a Flex 3 application without purchasing FlexBuilder? Since the SDK and BlazeDS are open source, it seems technically possible to develop without Flex Builder, but how realistic is it.</p>
<p>I would like to test out Flex but don't want to get into a situation where I am dependent on the purchase of FlexBuilder (at least not until I am confident and competent enough with the technology to recommend purchase to my employer).</p>
<p>I am experimenting right now, so I'm taking a long time and the trial license on my Windows machine has expired. Also Linux is my primary development platform and there is only an alpha available for Linux.</p>
<p>Most of the documentation I've found seem to use Flex Builder.</p>
<p>Maybe I should use Laszlo...</p>
|
<p>I've been using Flex since version 2 and Flex3/BlazeDS since it came out of beta. I also have some experience with Lazzlo and the difference is day and night (Flex rocks!). I have not regretted once using Flex. Regarding FlexBuilder, it is worth every penny. While it is completely possible and reasonable to write Flex application without FlexBuilder, the productivity gains of using it will more than recoup the investment. Try the evaluation for 30 days and compare it to some of the other options suggested about (I'm going to try FlashDevelop). </p>
<p>Some things you get with FlexBuilder include:</p>
<ul>
<li>Code completion</li>
<li>Visual editor</li>
<li>Debugger (it is fantastic!!)</li>
<li>Profiler (also very good)</li>
</ul>
<p>Regarding Linux, the alpha version of FlexBuilder does not have a visual editor. Other than that, I understand it is reasonably feature complete, still free, and many of the Adobe employees I've talked with that use Linux are happy with it.</p>
|
<p>Absolutely. I've been a Flex developer since Flex 2 and until recently I've used my regular editor, TextMate, for coding and Ant for building. TextMate has some good extensions for ActionScript and Flex coding, but I think you could get that for any decent editor.</p>
<p>What's been missing from my setup is a usable debugger, the command line version is a pain to work with. Because of that I've been starting to use FlexBuilder on the side, using it in parallel with my regular setup.</p>
<p>Having a profiler doesn't hurt too.</p>
| 6,185
|
<p>Visually both of the following snippets produce the same UI. So why are there 2 controls..<br>
<strong>Snippet1</strong> </p>
<pre><code><TextBlock>Name:</TextBlock>
<TextBox Name="nameTextBox" />
</code></pre>
<p><strong>Snippet2</strong></p>
<pre><code><Label>Name:</Label>
<TextBox Name="nameTextBox" />
</code></pre>
<p>(<em>Well I am gonna answer this myself... thought this is a useful tidbit I learnt today from <a href="https://rads.stackoverflow.com/amzn/click/com/0596510373" rel="noreferrer" rel="nofollow noreferrer">Programming WPF</a></em>) </p>
|
<p>The WPF Textblock inherits from <strong>FrameworkElement</strong> instead of deriving from <strong>System.Windows.Control</strong> like the Label Control. This means that the Textblock is much more lightweight. The downside of using a textblock is no support for Access/Accerelator Keys and there is no link to other controls as target.</p>
<p><strong><em>When you want to display text by itself use the TextBlock</em></strong>. The benefit is a light, performant way to display text.</p>
<p><strong><em>When you want to associate text with another control like a TextBox use the Label control</em></strong>. The benefits are access keys and references to target control.</p>
|
<p>Label can be used as an alternative to TextBlock for situations where minimal text support is required such as the label for a control. Using Label can be advantageous because it requires even less resources (lighter weight) then a TextBlock. </p>
| 8,355
|
<p>I am wondering if this piece of G-code is valid:</p>
<pre><code>G0 (Some comment (Its G0 command)) Y10 Z-5
</code></pre>
<p>I have tested this on my Chinese CNC machine and it strips out the comment and works flawlessly.</p>
<p>The machine processes this as <code>G0Y10Z-5</code> which seems like the correct approach to me.</p>
<p>I have however never seen such comment in real CNC practise.
It would be nice if anyone is able to test it out on their CNC/3D Printer.</p>
<p>Many G-code simulators on the internet fail to process such a line in their parser so it makes me confused. I haven't found anything about it on RepRap Wiki or even Google.</p>
|
<p>This is not universally valid G-code, and how it is handled depends on the implementation. You can use this style of comment on <em>some</em> machines, but not all.</p>
<p>The way parsing used to be implemented in Marlin (a very common 3D printer firmware), it would work fine unless the comment string included a X, Y, Z, E or F character. The parser simply looks for the first occurrence of X/Y/Z/E/F and then tries to parse the bit of text appearing after that character into a number. If the string cannot be parsed as a number, it defaults to 0 instead. For example,</p>
<pre><code> G0 (Some comment containing the character Y) Y10 Z-5
</code></pre>
<p>would be interpreted as <code>G0 Y0 Z-5</code> and not as <code>G0 Y10 Z-5</code>, because ") " (the string appearing after the first occurrence of "Y") does not parse to any valid number. Your example happens to work fine because the comment string doesn't contain any special characters.</p>
<p>Marlin does support end-of-line comments, which should start with a semicolon and continue until the end of the line.</p>
<p>This is how it used to work in older Marlin versions. Newer Marlin versions have a more advanced parser, but it still would not play well with these parentheses-style comments. It is best to avoid them, as compatibility is not guaranteed.</p>
|
<p>It looks like comments inside parentheses are not allowed in numerous parsers (ie. Marlin). This seems to be true for most of the 3D printers. Classical CNC milling machines use parentheses without problems.</p>
<p>It should work on Prusa printers as stated in their <a href="https://reprap.org/wiki/G-code#Comments" rel="nofollow noreferrer">Wiki</a>. Unfortunately there are no words about nesting of the comments.</p>
<p>I have however found a comment on cnczone.com forums regarding the nesting of comments within parentheses.</p>
<blockquote>
<p>Printable characters and white space inside parentheses is a comment. A left parenthesis always starts a comment. The comment ends at the first right parenthesis found thereafter.</p>
<p>Once a left parenthesis is placed on a line, a matching right parenthesis must appear before the end of the line.</p>
<p>Comments may not be nested; it is an error if a left parenthesis is found after the start of a comment and before the end of the comment.</p>
<p>Here is an example of a line containing a comment: <code>G80 M5 (stop motion)</code></p>
</blockquote>
<p>Source: <a href="https://www.cnczone.com/forums/g-code-programing/103434-coments-g-code.html#post763510" rel="nofollow noreferrer">cnczone.com</a></p>
| 964
|
<p>I have been trying to implement Win32's <code>MessageBox</code> using GTK. The app uses SDL/OpenGL, so this isn't a GTK app.</p>
<p>I handle the initialization (<code>gtk_init</code>) sort of stuff inside the <code>MessageBox</code> function as follows:</p>
<pre><code>int MessageBox(HWND hwnd, const char* text, const char* caption, UINT type)
{
GtkWidget *window = NULL;
GtkWidget *dialog = NULL;
gtk_init(&gtkArgc, &gtkArgv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
// gcallback calls gtk_main_quit()
gtk_init_add((GtkFunction)gcallback, NULL);
if (type & MB_YESNO) {
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, text);
} else {
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, text);
}
gtk_window_set_title(GTK_WINDOW(dialog), caption);
gint result = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_main();
gtk_widget_destroy(dialog);
if (type & MB_YESNO) {
switch (result) {
default:
case GTK_RESPONSE_DELETE_EVENT:
case GTK_RESPONSE_NO:
return IDNO;
break;
case GTK_RESPONSE_YES:
return IDYES;
break;
}
}
return IDOK;
}
</code></pre>
<p>Now, I am by no means an experienced GTK programmer, and I realize that I'm probably doing something horribly wrong.</p>
<p>However, my problem is that the last dialog popped up with this function staying around until the process exits. Any ideas?</p>
|
<p>Hmm, ok. I'd suggest code like this, then:</p>
<pre class="lang-c prettyprint-override"><code>typedef struct {
int type;
int result;
} DialogData;
static gboolean
display_dialog(gpointer user_data)
{
DialogData *dialog_data = user_data;
GtkWidget *dialog;
if (dialog_data->type & MB_YESNO)
dialog = gtk_message_dialog_new(...);
else
dialog = gtk_message_dialog_new(...);
// Set title, etc.
dialog_data->result = gtk_dialog_run(...);
gtk_main_quit(); // Quits the main loop run in MessageBox()
return FALSE;
}
int MessageBox(...)
{
DialogData dialog_data;
dialog_data.type = type;
gtk_idle_add(display_dialog, &dialog_data);
gtk_main();
// Do stuff based on dialog_data.result
}
</code></pre>
<p>The struct is required because you need to pass around a couple pieces of data. The <code>gtk_idle_add()</code> call adds a method to be run when the main loop is running and idle, and the <code>FALSE</code> return value from the <code>display_dialog()</code> call means that it's only run once. After we get the result from the dialog, we quit the main loop. That'll cause the <code>gtk_main()</code> in your main <code>MessageBox()</code> method to return, and you'll be able to access the result from there.</p>
|
<p>A few things:</p>
<p>You are creating (and not using) an unnecessary toplevel window, named <code>window</code>. You can just delete these lines:</p>
<pre><code>window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
</code></pre>
<p>Also, the flow doesn't seem quite right. <code>gtk_main()</code> starts the GTK main loop, which blocks until something exits it. <code>gtk_dialog_run()</code> also starts a main loop, but it exits as soon as one of the buttons is clicked.</p>
<p>I think it might be enough for you to remove the <code>gtk_init_add()</code> and <code>gtk_main()</code> calls, and simply deal with the return value. Also the <code>gtk_widget_destroy()</code> call is unnecessary, as the dialog window is automatically destroyed when gtk_dialog_run() returns.</p>
| 2,276
|
<p>I'm stuck trying to create a dynamic linq extension method that returns a string in JSON format - I'm using System.Linq.Dynamic and Newtonsoft.Json and I can't get the Linq.Dynamic to parse the "cell=new object[]" part. Perhaps too complex? Any ideas? : </p>
<p><strong>My Main method:</strong></p>
<pre><code>static void Main(string[] args)
{
NorthwindDataContext db = new NorthwindDataContext();
var query = db.Customers;
string json = JSonify<Customer>
.GetJsonTable(
query,
2,
10,
"CustomerID"
,
new string[]
{
"CustomerID",
"CompanyName",
"City",
"Country",
"Orders.Count"
});
Console.WriteLine(json);
}
</code></pre>
<p><strong>JSonify class</strong></p>
<pre><code>public static class JSonify<T>
{
public static string GetJsonTable(
this IQueryable<T> query,
int pageNumber,
int pageSize,
string IDColumnName,
string[] columnNames)
{
string selectItems =
String.Format(@"
new
{
{{0}} as ID,
cell = new object[]{{{1}}}
}",
IDColumnName,
String.Join(",", columnNames));
var items = new
{
page = pageNumber,
total = query.Count(),
rows =
query
.Select(selectItems)
.Skip(pageNumber * pageSize)
.Take(pageSize)
};
return JavaScriptConvert.SerializeObject(items);
// Should produce this result:
// {
// "page":2,
// "total":91,
// "rows":
// [
// {"ID":"FAMIA","cell":["FAMIA","Familia Arquibaldo","Sao Paulo","Brazil",7]},
// {"ID":"FISSA","cell":["FISSA","FISSA Fabrica Inter. Salchichas S.A.","Madrid","Spain",0]},
// {"ID":"FOLIG","cell":["FOLIG","Folies gourmandes","Lille","France",5]},
// {"ID":"FOLKO","cell":["FOLKO","Folk och fä HB","Bräcke","Sweden",19]},
// {"ID":"FRANK","cell":["FRANK","Frankenversand","München","Germany",15]},
// {"ID":"FRANR","cell":["FRANR","France restauration","Nantes","France",3]},
// {"ID":"FRANS","cell":["FRANS","Franchi S.p.A.","Torino","Italy",6]},
// {"ID":"FURIB","cell":["FURIB","Furia Bacalhau e Frutos do Mar","Lisboa","Portugal",8]},
// {"ID":"GALED","cell":["GALED","Galería del gastrónomo","Barcelona","Spain",5]},
// {"ID":"GODOS","cell":["GODOS","Godos Cocina Típica","Sevilla","Spain",10]}
// ]
// }
}
}
</code></pre>
|
<p>This is really ugly and there may be some issues with the string replacement, but it produces the expected results:</p>
<pre><code>public static class JSonify
{
public static string GetJsonTable<T>(
this IQueryable<T> query, int pageNumber, int pageSize, string IDColumnName, string[] columnNames)
{
string select = string.Format("new ({0} as ID, \"CELLSTART\" as CELLSTART, {1}, \"CELLEND\" as CELLEND)", IDColumnName, string.Join(",", columnNames));
var items = new
{
page = pageNumber,
total = query.Count(),
rows = query.Select(select).Skip((pageNumber - 1) * pageSize).Take(pageSize)
};
string json = JavaScriptConvert.SerializeObject(items);
json = json.Replace("\"CELLSTART\":\"CELLSTART\",", "\"cell\":[");
json = json.Replace(",\"CELLEND\":\"CELLEND\"", "]");
foreach (string column in columnNames)
{
json = json.Replace("\"" + column + "\":", "");
}
return json;
}
}
</code></pre>
|
<pre><code>static void Main(string[] args)
{
NorthwindDataContext db = new NorthwindDataContext();
var query = db.Customers;
string json = query.GetJsonTable<Customer>(2, 10, "CustomerID", new string[] {"CustomerID", "CompanyName", "City", "Country", "Orders.Count" });
}
public static class JSonify
{
public static string GetJsonTable<T>(
this IQueryable<T> query, int pageNumber, int pageSize, string IDColumnName, string[] columnNames)
{
string select = string.Format("new ({0} as ID, new ({1}) as cell)", IDColumnName, string.Join(",", columnNames));
var items = new
{
page = pageNumber,
total = query.Count(),
rows = query.Select(select).Skip((pageNumber - 1) * pageSize).Take(pageSize)
};
return JavaScriptConvert.SerializeObject(items);
}
}
</code></pre>
| 7,297
|
<p>Apply / find / create a stainless steel coating to apply to a PETG or PLA part to make it react to a magnet.</p>
<p>My goal is to make a small tubular and conical shapes that can be painted with a stainless steel coating and will react with a magnet.</p>
<p>I know I can buy iron filled PLA but these rust which I want to avoid. <strong>I'm trying to get the magnetic properties of stainless steel (no rusting / reacts to magnets)</strong></p>
<p>I have found videos on how to coat with copper / silver / carbon but I'm looking for stainless steel no rust / magnetic properties.
<div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/Nx-GwKOH5qc?start=0"></iframe>
</div></div></p>
<hr />
<p><em>I'm looking for a "low-cost" solution just for testing.</em></p>
|
<h1>The surface won't work</h1>
<p>The only true-metallic surface treatments I know to be actual metal in large enough amounts to conduct electricity would be leafmetal, akin to leaf gold, and electroplating. However, you can't use the procedures for stainless steels, and even then, the thickness is in the tenth of a µm area and lower. Not only would that be far too thin to adhere a magnet to, it also would be super easy to damage with rubbing.</p>
<h1>Filling?</h1>
<p>PLA itself does not block magnetism - I have printed a PLA holder for a magnetic GPS device, into which I inserted a simple 0.5 mm steel plate for a magnetic surface with 0.5 mm of PLA acting as the container and seal against water.</p>
<p>If the prints can be done with one end open and no infill or have a dedicated area that a cheap piece of steel can be inserted into, this method can be used too. The only requirement is that there is a cavity on the inside that at some point is accessible. This also can be during the print.</p>
<p>This cavity could either take a piece of shaped steel sheet or be filled with a different magnetic filler, for example, simple iron powder. The powder could be bound in a non-oxidizing polymer, for example, epoxy resin. This method has been used to <a href="https://www.windstuffnow.com/main/poured_stator.htm" rel="nofollow noreferrer">create cast stators for electro motors</a>. It's <a href="https://www.fieldlines.com/index.php/topic,136931.msg902507.html?PHPSESSID=f201710e153b4520d5b59ec4d1475370#msg902507" rel="nofollow noreferrer">not the most efficient</a>, but might work in your application - if your walls are thin enough.</p>
<p>With the correct mixture, such a material can be used to coat or fill the inside with enough magnetic material to give the magnets something to stick to and not rust away - the shell and the resin together would shield the iron from any air that could rust it. Indeed, a quite stuffed Resin-Iron-mix and a strong magnet have been <a href="https://www.sightunseen.com/2012/04/at-the-2012-milan-furniture-fair/" rel="nofollow noreferrer">used in 2012 to create furniture by the name of "Gravity Stools"</a> or other art pieces like in <a href="https://youtu.be/pxUUTIUOkW0" rel="nofollow noreferrer">this video</a></p>
|
<p>No rust but has magnetic properties? You could try varnishing the iron filled PLA.</p>
| 1,854
|
<p>Searching for some sample code for converting a point in WGS84 coordinate system to a map position in Google Maps (pixel position), also supporting zoom levels. </p>
<p>If the codes is well commented, then it can also be in some other language.</p>
<p>You can also point me to a open source Java project :)</p>
<p>Some resources found:</p>
<p><a href="http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Layer" rel="nofollow noreferrer">OpenLayer</a> implementation. </p>
<p><a href="http://josm.openstreetmap.de/browser/trunk/src/org/openstreetmap/josm/data/projection" rel="nofollow noreferrer">JOSM</a> project</p>
<p>Excellent <a href="https://github.com/OSUCartography/JMapProjLib" rel="nofollow noreferrer">Java Map Projection Library </a> from JH LABS. This is a pure java PROJ.4 port. Does projection from WGS84 to meters. From there it's quite straightforward to convert meters to tile pixels.</p>
|
<p><a href="http://web.archive.org/web/20110809084551/http://mapki.com/wiki/Tile_utility_code_in_Java" rel="nofollow noreferrer">Tile utility code in Java</a> on mapki.com (great resource for google map developers)</p>
|
<p>Someone took the javascript code from Google Maps and ported it to python: <a href="http://code.google.com/p/gheat/source/browse/trunk/__/lib/python/gmerc.py" rel="nofollow noreferrer">gmerc.py</a></p>
<p>I've used this and it works great.</p>
| 2,922
|
<p>What are the strategies for versioning of a web application/ website? </p>
<p>I notice that here in the Beta there is an svn revision number in the footer and that's ideal for an application that uses svn over one repository. But what if you use externals or a different source control application that versions separate files? </p>
<p>It seems easy for a Desktop app, but I can't seem to find a suitable way of versioning for an asp.net web application. </p>
<p><strong>NB</strong> I'm not sure that I have been totally clear with my question.</p>
<ol>
<li>What I want to know is how to build and auto increment a version number for an asp.net application.</li>
<li>I'm not interested in how to link it with svn.</li>
</ol>
|
<p>For my big apps I just use a incrementing version number id (1.0, 1.1, ...) that i store in a comment of the main file (usually index.php).<Br />
For just websites I usually just have a revision number (1,2,3,...).</p>
|
<p>I maintain a system of web applications with various components that live in separate SVN repos. To be able to version track the system as a whole, I have another SVN repo which contains all other repos as external references. It also contains install / setup script(s) to deploy the whole thing. With that setup, the SVN revision number of the "metarepository" could possibly be used for versioning the complete system.</p>
<p>In another case, I include the SVN revision via <a href="http://svnbook.red-bean.com/en/1.2/svn.advanced.props.html#svn.advanced.props.special.keywords" rel="nofollow noreferrer" title="SVN keywords">SVN keywords</a> in a class file that serves no other purpose (to avoid the risk of keyword substitution breaking my code). The class in that file contains a string variable that is manipulated by SVN and parsed by a class method.</p>
<p>An inconvenience with both approaches is that the revision number is not automatically updated by changes in the externals (approach 1) or the rest of the code (approach 2).</p>
| 4,958
|
<p>Are there conventions for function names when using the Perl Test::More or Test::Simple modules?</p>
<p>I'm specifically asking about the names of functions that are used to set up a test environment before the test and to tear down the environment after successful completion of the test(s).</p>
<p>cheers,</p>
<p>Rob</p>
|
<p>I dont think there are any such conventions out there.</p>
<p>The only way you can do it is perhaps use BEGIN/END blocks, if the resources are to be used over the whole file.</p>
<p>The general approach I take is to put related tests in one code block and then initialize the variables/resource etc there. You can perhaps keep an easy count of how many tests you have for each function.</p>
<p>Something like ...</p>
<pre><code>BEGIN {
# If you want to set some global db setting/file setting/INC changes etc
}
# Tests functionality 1...
{
# have fun ....
}
# Tests functionality 2...
{
# have more fun ....
}
END {
# Clean up the BEGIN changes
}
</code></pre>
<p>On other note, you may want to read this for testing in perl ... <a href="http://perlandmac.blogspot.com/2007/08/using-perl-testsimple-and-testmore.html" rel="nofollow noreferrer">http://perlandmac.blogspot.com/2007/08/using-perl-testsimple-and-testmore.html</a></p>
|
<p>First convention I'd suggest is ditching Test::More for Test::Most</p>
| 6,737
|
<p>I am at a school with several Makerbot Replicator+ – a total of 9 of them.</p>
<p>So, they seem to print fine and I can hook up to two of them to one laptop (they are some Lenovo models from a few years back) using Makerbot Print. Well and good.</p>
<p>But I wanted to hook them up to my MacBook Pro (2020, OS X Catalina) with the USB cables, and the MacBook doesn't seem to "read" the printers, it's like they aren't even there. Makerbot Print (latest version) doesn't seem to "see" that they are hooked up. I checked the system prefs to see if the Makerbots showed up as connected USB devices and they don't seem to be there either.</p>
<p>Now, I am connecting via the USB cables and then through an adapter that connects the USB-A to USB-C. If I should just use a USB-B to USB-C cable (I ordered one to test it) then fine, I'll do that. I just wanted to check that there wasn't some other problem or if anyone else had this issue.</p>
<p>Next up: USB hubs. Makerbot says they don't recommend it, but sometimes I have to print out lots of stuff at once for student projects and I can't tie up multiple laptops for hours-long prints. I have done the technique of leaving stuff all night but that's hit or miss – if something goes wrong I am not there to stop the print (at least once something got unstuck from the build plate and I ended up with an extruder with the end encased in hard plastic like a stalactite. Unless I basically blowtorch it off... )</p>
<p>So, the question(s) is/are:</p>
<p>Any recommendations for USB hubs? (I would do wireless but that I am less sure of, and it seems easier, faster, and more reliable to link up through USB. The wireless connection always drops).</p>
<p>Any recommendations for the MacBook issue? Is it just a matter of finding the right cable? (it's certainly possible my $10 USB-A to USB-C adapter plugs aren't well designed, and I should just go for direct cabling)</p>
<p>Any recommendations for a good USB hub to link a Mac (or anything else) to Makerbots?</p>
<p>Thanks for your time and help. I do hope I am not duplicating a post but I don't see anything in my searches that addresses the specific issues I have; though it's possible I didn't use the right search terms.</p>
|
<p><em><strong>It would seem that the printer control board doesn't use a CH340 (see bottom of this answer) and therefore this answer should be ignored.</strong></em></p>
<hr />
<h3>CH340 and OS X incompatibility</h3>
<p>The reason your Mac might not see the printers <em>could</em> be down to the USB interface <em><strong>on the printer controller board</strong></em>.</p>
<p>If it is implemented by a CH340 (which is probably is, in order to reduce manufacturing costs) then, historically, MacBooks have a problem with the drivers for this device and its derivatives. That is to say, the OS has a problem - more specifically the device drivers used by the OS X kernel - as opposed to the hardware. There are a number of posts dealing with this problem, it is common on Arduino clones too, see <a href="https://arduino.stackexchange.com/search?q=mac+ch340">here</a>.</p>
<p>The third party drivers for the CH340(G) written for OS X are often poorly written and/or have shoddy documentation - although this opinion may be hotly debated, and I have no wish to expand upon.</p>
<p>If the USB interface, on the printer controller board, is implemented with an FTDI or a ATmega 16U2 then it will work fine. Unfortunately the solution is probably not to use the Mac and stick with the Lenovos (i.e. PC clone).</p>
<p>See the extensive answers to <a href="https://3dprinting.stackexchange.com/q/6221/4762">Can't connect Cura to my Anet A8 on OSX 10.11.6</a></p>
<hr />
<p>As an aside, I gave up trying to buy/use cheap Arduino clones with a CH340(G), on a Mac long along, as it just wasn't worth the effort in trying to get the Mac to see it. I now ensure that either:</p>
<ul>
<li>I purchase a slightly more expensive Arduino which uses a 16U2 (the more pricey FTDI chip is more rarely used on boards these days, but can still be found). Obviously, you don't have that sort of luxury when selecting a 3D printer.</li>
<li>I will use a PC instead, if the board has a CH340(G), or similar.</li>
</ul>
<h3>One possible solution</h3>
<p>However, having said all of that, this issue <strong>may</strong> have been resolved in newer versions of OS X (post Mountain Lion, or thereabouts). This <em>might</em> provide a solution, <a href="https://arduino.stackexchange.com/q/57126/6936">Connect to ch340 on MacOS Mojave</a></p>
<blockquote>
<p>remove all old drivers:</p>
<pre><code>sudo rm -rf /Library/Extensions/usbserial.kext
sudo rm -rf /System/Library/Extensions/usb.kext
</code></pre>
<p>Now reboot the computer.</p>
<p>And then (very important, because it took me 10 cables to find the
right one) use a <strong>fully connected</strong> cable ;-)</p>
<p>Now I have these ports:</p>
<pre><code>/dev/cu.wchusbserial1410
/dev/cu.usbserial-1410
</code></pre>
</blockquote>
<p><strong>Important note</strong>: Clearly, deleting kernel drivers (also known as <em>kernel extensions</em>, <code>.kext</code>) shouldn't be taken lightly. If you feel uncomfortable doing it, or don't know how to revert the process, by using a saved backup of the drivers, then <em><strong>please don't attempt this</strong></em>.</p>
<p>For completeness:</p>
<ul>
<li><p>To back up the <code>kext</code> (<em><strong>before</strong></em> deleting it as shown above):</p>
<pre><code>sudo cp /Library/Extensions/usbserial.kext /Library/Extensions/usbserial.kext.bak
sudo cp /System/Library/Extensions/usb.kext /System/Library/Extensions/usb.kext.bak
</code></pre>
</li>
<li><p>To restore the <code>kext</code> (<em><strong>after</strong></em> having deleted the kernel extension and then finding that it made no difference whatsoever):</p>
<pre><code>sudo mv /Library/Extensions/usbserial.kext.bak /Library/Extensions/usbserial.kext
sudo mv /System/Library/Extensions/usb.kext.bak /System/Library/Extensions/usb.kext
</code></pre>
</li>
</ul>
<hr />
<p>Alternatively, instead of <em>deleting</em> the kernel drivers, you could just <em>rename</em> them to hide them, by adding <code>.bak</code> to the filename, like so</p>
<pre><code>sudo mv /Library/Extensions/usbserial.kext /Library/Extensions/usbserial.kext.bak
sudo mv /System/Library/Extensions/usb.kext /System/Library/Extensions/usb.kext.bak
</code></pre>
<p>Then reboot. Check the printer connects or not. If not, then just <em>restore</em> them using the same commands shown above - so you just end up removing the additional <code>.bak</code> from the filename.</p>
<hr />
<p>With respect to the quoted answer, I'm not entirely sure what is meant by a <strong>fully connected</strong> cable... There <em>is</em> a well-known issue that some USB <em><strong>charging</strong></em> cables - that look like normal USB cables - have only the power lines connected, and omit the data lines (again for cheapness), and it can be difficult to tell the two apart (usually by thickness, the thicker cables have more lines connected). Obviously, if the data lines are missing then the cable will not transfer data.</p>
<p><em>However</em>, this usually applies only to cables with mini, or micro USB connectors, and usually doesn't apply to standard peripheral cables such as a USB-A to USB-B cable:</p>
<p><a href="https://i.stack.imgur.com/11mVl.png" rel="nofollow noreferrer" title="USB connectors"><img src="https://i.stack.imgur.com/11mVl.png" alt="USB connectors" title="USB connectors" /></a></p>
<p>So, this issue should only arise for micro/mini USB connectors... it will depend upon your connector type.</p>
<hr />
<p>We can't recommend particular makes or models of USB hubs as that is a shopping question, which is <a href="https://3dprinting.stackexchange.com/help/on-topic">off-topic</a>.</p>
<hr />
<h3>Analysis on the printer board</h3>
<p>Makerbot appear to use the Mightyboard for the Replicator. INterestingly from the following two photos it would appear that a CH340(G) is <em><strong>not</strong></em> used, and the IC is in fact a 16U2.</p>
<p>Here is a photo of the board (image from <a href="https://www.fargo3dprinting.com/products/makerbot-replicator-2-2x-rev-h-mightyboard-oem/" rel="nofollow noreferrer">MakerBot Replicator 2/2X Rev H Mightyboard – Official, OEM Board w/ 4 BotSteps</a>):</p>
<p><a href="https://i.stack.imgur.com/AcMoE.jpg" rel="nofollow noreferrer" title="Photo of Mightboard"><img src="https://i.stack.imgur.com/AcMoE.jpg" alt="Photo of Mightboard" title="Photo of Mightboard" /></a></p>
<p>The IC closest to the USB-B port would appear to be a 16U2:</p>
<ul>
<li>Its form is square like a 16U2 and not elongated like a CH340G</li>
<li>It would appear to have an Atmel logo printed upon it.</li>
</ul>
<p>This image (from <a href="https://www.teknistore.com/en/3d-printer-module-board/19403-mightyboard-motherboard-3d-printer-dashboard.html?mobile_theme_ok" rel="nofollow noreferrer">MightyBoard Motherboard 3D Printer Dashboard</a>), also suggests the a 16U2 is used:</p>
<p><a href="https://i.stack.imgur.com/DoO9c.jpg" rel="nofollow noreferrer" title="Annotated photo of MightBoard"><img src="https://i.stack.imgur.com/DoO9c.jpg" alt="Annotated photo of MightBoard" title="Annotated photo of MightBoard" /></a></p>
<p>All of which means that, if your printer(s) have this board, then your Mac <em>should</em> indeed connect to the printer.</p>
|
<blockquote>
<p>what do you mean by SD card approach? The Makerbots take flash drives, but my attempts to print off of one were unsuccessful (it seems to be rather hard to make the right kind of file, it won't work with STLs and I gave up figuring out how to make them .makerbot files)</p>
</blockquote>
<p>This sounds like you need a better basic understanding of the printing process.</p>
<p>An STL file describes a shape you want to print, but it does not have all the information needed to actually print the object. In order to actually print the file, you need to know things like what material you will use (which will determine temperatures), what the capabilities of the machine are (how fast you can go), how much vertical detail is important to retain (layer thickness vs print time trade-off), and how strong the piece needs to be (trade-off between infill + wall thickness vs print time + material costs). You also need to specify things like how to orient the shape for best print results and what to do when there are steep overhangs or bridges.</p>
<p>To get this information, you must <strong>slice</strong> the STL (or OBJ or 3DS) file.</p>
<p>There are a number of different software packages available to do slicing, many of them freely available: Cura and slic3r come to mind. Makerbot also has their own slicer. I know you can download and install Cura on a Mac.</p>
<p>The output of the slicer is usually a <strong>.gcode</strong> file, and I would expect your Makerbots to be able to handle gcode files that were produced with the appropriate options. In fact, I strongly suspect the ".makerbot" file mentioned in your comment is actually a gcode file in disguise.</p>
<p>Why does this matter?</p>
<p>Print jobs can take hours and even days, and they tend to completely take over the computer while printing. No one wants to leave their laptop sitting next to a printer overnight, not able to do anything else. Newer printers will also have features like automatic resume from power loss, filament out detection, are more, that a are less likely to function properly when printing from a computer.</p>
<p>There's just too much that can go wrong while printing via computer, such that <em>you're pretty much always better off going with the SD card or USB option.</em><sup>*</sup></p>
<p>In other words, printing directly from your main computer is <strong>waaaaay</strong> down the list. It's not the first, second, or even third of fourth option as the best way to do this.</p>
<hr />
<p><sub>* A <em>dedicated</em> print station can work well, when setup properly, and people often use OctoPrint installed on a Raspberri Pi in this way. However, this also implies a high-end laptop is complete overkill for the task.</sub></p>
| 2,049
|
<p>I'm trying to model the threads of a "Poland Spring" 500 ml bottle so I can 3D print an adapter for it. But I can't find information about it. I emailed them but they said they didn't have the information.</p>
<p>How can I find this information out?</p>
<p>The bottle seems to use non standard threads. It uses 3 threads 120 degrees apart that does not go all the way around. Any information on how to get this information?</p>
<p><a href="https://i.stack.imgur.com/nEnwV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nEnwV.png" alt="bottle" /></a></p>
|
<p>You can use a program known as <a href="http://www.openscad.org/" rel="nofollow noreferrer">OpenSCAD</a> with the <a href="https://dkprojects.net/openscad-threads/" rel="nofollow noreferrer">threads library</a> to assist your objective.</p>
<p>The important aspects of a thread are the major diameter (outside diameter at the thread surface), the length of the bolt/nut and for your project, the start count. The noted library has a parameter called n-starts, which covers your triple start requirement.</p>
<p>It may require some trial and error processing, but you have a good foundation with OpenSCAD library.</p>
<p>Even if the bottle is manufactured with Imperial reference (unlikely), you'd probably have an easier time with metric threads. I just checked a Dasani water bottle, which measured at 27.27 mm major diameter, 10 mm length, thread pitch 2 mm. The thread pitch in metric is the distance between peaks (or valleys) from one to the next. This particular bottle has an interrupted thread, but that should not be a factor for creating an adapter.</p>
<p>This Dasani bottle does not have a multi-start thread. It's not a complete thread, but it is single start. Considering that a water bottle top has minimal length, you may also have an interrupted rather than a multi-start thread.</p>
<p>The code for the measured thread in OpenSCAD is relatively simple.</p>
<blockquote>
<p>use <threads.scad>;<br />
thread_dia = 27.27;<br />
thread_pitch = 2;<br />
thread_length = 10;<br />
metric_thread(thread_dia, thread_pitch, thread_length, n_starts = 3);</p>
</blockquote>
<p>The above code would generate a 3-start thread in the form of a bolt. Using a difference() code would provide for the inverse required for your proposed adapter.</p>
<p><a href="https://i.stack.imgur.com/bvliP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bvliP.png" alt="single start 27 mm threads" /></a></p>
<p><a href="https://i.stack.imgur.com/i4vsS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i4vsS.png" alt="triple start threads" /></a></p>
<p>top image is single start, bottom is triple start.</p>
<p>Top view comparison:</p>
<p><a href="https://i.stack.imgur.com/0oGnP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0oGnP.png" alt="comparison top view" /></a></p>
|
<p>It's really unlikely that a bottle is using nonstandard threads; the engineering and tooling cost for doing so would not make sense. Most plastic drink bottles use PCO 1881 or PCO 1810 threads. If not, it should be one of a number of other less widely used standards.</p>
<p>The industry term for drink bottle thread is "neck finish". Searching on that, or on one of the standard names like PCO 1881, will find you a lot of information. You can then try to find a match for your threads. Note that the breaks 120 degrees apart do not affect the thread design, and may or may not be part of the neck finish standard, so you can ignore them.</p>
<p>There are existing OpenSCAD libraries for some of these, including</p>
<ul>
<li><a href="https://github.com/adrianschlatter/threadlib#list-of-supported-threads" rel="nofollow noreferrer">threadlib</a></li>
<li><a href="https://github.com/MisterHW/IoP-satellite" rel="nofollow noreferrer">IoP-satellite</a></li>
</ul>
<p>And some related articles on Hackaday about their development and use:</p>
<ul>
<li><a href="https://hackaday.com/2020/07/12/learn-the-secrets-of-matching-bottle-cap-threads-to-one-another/" rel="nofollow noreferrer">Learn The Secrets Of Matching Bottle Cap Threads To One Another</a></li>
<li><a href="https://hackaday.io/page/5252-generating-nice-threads-in-openscad" rel="nofollow noreferrer">Generating Nice Threads in OpenSCAD</a></li>
</ul>
| 1,721
|
<p>Just downloaded the CodeRush trial version and I can't easily find the one feature that I really wanted. I would like to be able to start typing a class name and to jump to its definition, sort of like the quick navigator but I want it to search in closed files within my solution as well as open ones. I know R# has that ability, I assume CodeRush does too.</p>
|
<p>1) <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Q</kbd> (this will bring up the Quick Nav)</p>
<p>2) Start typing the name of the Type, Variable, etc. </p>
<p>3) Hit Enter to select when the target shows in the top of the list</p>
<p>If the scope is not already set to "Solution" (you can tell via the drop-down on the right of the Quick Nav), you can hit <kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>S</kbd> to set and it will save the state.</p>
|
<p>A quick remark to the excellent answer by Troy, if the version you downloaded is the newer one, 3.2, the Quick Nav has been remapped to <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Q</kbd>.</p>
| 7,878
|
<p>The subject says it all - normally easy and cross platform way is to poll, intelligently. But every OS has some means to notify without polling. Is it possible in a reasonably cross platform way? (I only really care about Windows and Linux, but I use mac, so I thought posix may help?)</p>
|
<p>Linux users can use <a href="http://en.wikipedia.org/wiki/Inotify" rel="noreferrer">inotify</a></p>
<blockquote>
<p>inotify is a Linux kernel subsystem
that provides file system event
notification.</p>
</blockquote>
<p>Some goodies for Windows fellows:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/bb158663.aspx" rel="noreferrer">File Change Notification</a> on MSDN</li>
<li>"<a href="http://www.relisoft.com/win32/watcher.html" rel="noreferrer">When Folders Change</a>" article</li>
<li><a href="http://techsupt.winbatch.com/TS/T000001048F39.html" rel="noreferrer">File System Notification on Change</a></li>
</ul>
|
<p>I believe OS X now has appropriate hooks/callbacks because they were needed for Spotlight indexing. </p>
<p>On linux you'll have the additional trouble that there are multiple file systems commonly used. If you need the functionality for only a limited amount of files/directories, I'd try about actively looking for modifications at regular intervals.</p>
| 8,641
|
<p>Some web applications, like Google Docs, store data generated by the users. Data that can only be read by its owner. Or maybe not?</p>
<p>As far as I know, this data is stored as is in a remote database. So, if anybody with enough privileges in the remote system (a sysadmin, for instance) can lurk my data, my privacy could get compromised.</p>
<p>What could be the best solution to store this data encrypted in a remote database and that only the data's owner could decrypt it? How to make this process transparent to the user? (You can't use the user's password as the key to encrypt his data, because you shouldn't know his password).</p>
|
<p>If encryption/decryption is performed on the server, there is no way you can make sure that the cleartext is not dumped somewhere in some log file or the like.</p>
<p>You need to do the encryption/decryption inside the browser using JavaScript/Java/ActiveX or whatever. As a user, you need to trust the client-side of the web service not to send back the info unencrypted to the server.</p>
<p>Carl</p>
|
<p>No, you can't use passwords, but you could use password hashes. However, Google Docs are all about sharing, so such a method would require storing a copy of the document for each user.</p>
| 6,094
|
<p>I am sketching the architecture for a set of programs that share various interrelated objects stored in a database. I want one of the programs to act as a service which provides a higher level interface for operations on these objects, and the other programs to access the objects through that service.</p>
<p>I am currently aiming for Python and the Django framework as the technologies to implement that service with. I'm pretty sure I figure how to daemonize the Python program in Linux. However, it is an optional spec item that the system should support Windows. I have little experience with Windows programming and no experience at all with Windows services.</p>
<p><strong>Is it possible to run a Python programs as a Windows service (i. e. run it automatically without user login)?</strong> I won't necessarily have to implement this part, but I need a rough idea how it would be done in order to decide whether to design along these lines.</p>
<p><i>Edit: Thanks for all the answers so far, they are quite comprehensive. I would like to know one more thing: <b>How is Windows aware of my service? Can I manage it with the native Windows utilities?</b> <strong>What is the equivalent of putting a start/stop script in /etc/init.d?</i></strong></p>
|
<p>Yes you can. I do it using the pythoncom libraries that come included with <a href="http://www.activestate.com/Products/activepython/index.mhtml" rel="noreferrer">ActivePython</a> or can be installed with <a href="https://sourceforge.net/projects/pywin32/" rel="noreferrer">pywin32</a> (Python for Windows extensions).</p>
<p>This is a basic skeleton for a simple service:</p>
<pre><code>import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "TestService"
_svc_display_name_ = "Test Service"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None,0,0,None)
socket.setdefaulttimeout(60)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
self.main()
def main(self):
pass
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(AppServerSvc)
</code></pre>
<p>Your code would go in the <code>main()</code> method—usually with some kind of infinite loop that might be interrupted by checking a flag, which you set in the <code>SvcStop</code> method</p>
|
<p><a href="https://www.chrisumbel.com/article/windows_services_in_python" rel="nofollow noreferrer">https://www.chrisumbel.com/article/windows_services_in_python</a></p>
<ol>
<li><p>Follow up the PySvc.py</p></li>
<li><p>changing the dll folder </p></li>
</ol>
<p>I know this is old but I was stuck on this forever. For me, this specific problem was solved by copying this file - pywintypes36.dll</p>
<p>From -> Python36\Lib\site-packages\pywin32_system32</p>
<p>To -> Python36\Lib\site-packages\win32</p>
<pre><code>setx /M PATH "%PATH%;C:\Users\user\AppData\Local\Programs\Python\Python38-32;C:\Users\user\AppData\Local\Programs\Python\Python38-32\Scripts;C:\Users\user\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pywin32_system32;C:\Users\user\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\win32
</code></pre>
<ol start="3">
<li>changing the path to python folder by</li>
</ol>
<p><code>cd C:\Users\user\AppData\Local\Programs\Python\Python38-32</code></p>
<ol start="4">
<li><code>NET START PySvc</code></li>
<li><code>NET STOP PySvc</code></li>
</ol>
| 5,233
|
<p><a href="https://stackoverflow.com/questions/32230/tracking-down-where-disk-space-has-gone-on-linux">In this question</a> someone asked for ways to display disk usage in Linux. I'd like to take this one step further down the cli-path... how about a shell script that takes the output from something like a reasonable answer to the previous question and generates a graph/chart from it (output in a png file or something)? This may be a bit too much code to ask for in a regular question, but my guess is that someone already has a oneliner laying around somewhere...</p>
|
<p>I would recommend <a href="http://munin.projects.linpro.no/" rel="nofollow noreferrer">munin</a>. It is designed for exactly this sort of thing - graphing CPU usage, memory usage, disc-usage and such. sort of like MRTG (but MRTG is primarily aimed at graphing router's traffic, graphing anything but bandwidth with it is very hackish)</p>
<p>Writing Munin plugins is very easy (it was one of the projects goals). They can be written in almost anything (shell script, perl/python/ruby/etc, C, anything that can be execute and produce an output). The plugin output format is basically <code>disc1usage.value 1234</code>. And debugging the plugins is very easy (compared to MRTG)</p>
<p>I've set it up on my laptop to monitor disc-usage, bandwidth usage (by pulling data from my ISP's control panel, it graphs my two download "bins", uploads and newsgroup usage), load average and number of processes. Once I got it installed (currently slightly difficult on OS X, but it's trivial on Linux/FreeBSD), I had written a plugin in a few minutes, and it worked, first time!</p>
<p>I would describe how it's setup, but the munin site will do that far better than I could!</p>
<p>There's an example installation <a href="http://munin.ping.uio.no/" rel="nofollow noreferrer">here</a></p>
<p>Some alternatives are nagios and cacti. You could also write something similar using rrdtool. Munin, MRTG and Cacti are basically all far-nicer-to-use systems based around this graphing tool.</p>
<p>If you want something really, really simple, you could do..</p>
<pre><code>import os
import time
while True:
disc_usage = os.system("df -h / | awk '{print $3}'")
log = open("mylog.txt")
log.write(disc_usage + "\n")
log.close()
time.sleep(60*5)
</code></pre>
<p>Then..</p>
<pre><code>f = open("mylog.txt")
lines = f.readlines()
# Convert each line to a float number
lines = [float(cur_line) for cur_line in lines]
# Get the biggest and smallest
biggest = max(lines)
smallest = min(lines)
for cur_line in lines:
base = (cur_line - smallest) + 1 # make lowest value 1
normalised = base / (biggest - smallest) # normalise value between 0 and 1
line_length = int(round(normalised * 28)) # make a graph between 0 and 28 characters wide
print "#" * line_length
</code></pre>
<p>That'll make a simple ascii graph of the disc usage. I <em>really really</em> don't recommend you use something like this. Why? The log file will get bigger, and bigger, and bigger. The graph will get progressively slower to graph. RRDTool uses a rolling-database system to store it's data, so the file will never get bigger than about 50-100KB, and it's consistently quick to graph as the file is a fixed length.</p>
<p>In short. If you want something to easily graph almost anything, use <a href="http://munin.projects.linpro.no/" rel="nofollow noreferrer">munin</a>. If you want something smaller and self-contained, write something with RRDTool.</p>
|
<p>I guess there are a couple of options:</p>
<ol>
<li><p>For a pure CLI solution, use something like gnuplot. See <a href="http://t16web.lanl.gov/Kawano/gnuplot/intro/working-e.html" rel="nofollow noreferrer">here</a> for example usage. I haven't used gnuplot since my student days :-)</p></li>
<li><p>Not really a pure CLI solution, but download something like <a href="http://www.jfree.org/jfreechart/" rel="nofollow noreferrer">JFreeChart</a> and write a simple Java app that reads stdin and creates your chart.</p></li>
</ol>
<p>Hope this helps.</p>
| 6,202
|
<p>I've been utlising a "web browser control" in desktop based applications (in my case Windows Forms .NET) for a number of years. I mostly use it to create a familiar flow-based user interface that also allows a seamless transition to the internet where required.</p>
<p>I'm really tired of the IE browser control because of the poor quality html it generates on output. Also, I guess that it is really just IE7 behind the scenes and so has many of that browser "issues". Despite this, it is quite a powerful control and provides rich interaction with your desktop app.</p>
<p>So, what other alternatives to the IE browser control are there? I looked at a Mosaic equivalent a year ago but was disappointed with the number of unimplemented features, maybe this has improved recently?</p>
|
<p>hmm..Interestingly </p>
<ol>
<li><a href="http://www.iol.ie/~locka/mozilla/control.htm" rel="nofollow noreferrer">Mozilla</a> seems to provide ActiveX control</li>
<li><a href="http://kmeleon.sourceforge.net/" rel="nofollow noreferrer">K-Melon</a> is another Gecko based browser control</li>
</ol>
|
<p>Popular layout engines:</p>
<ol>
<li>Mozilla Gecko</li>
<li>KHTML</li>
<li>WebKit (based on KHTML)</li>
</ol>
<p>Though I'm not sure how easy it is to embed those in a .Net app.</p>
| 8,631
|
<p>What is the easiest way to compare strings in Python, ignoring case?</p>
<p>Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads).</p>
<p>I guess I'm looking for an equivalent to C's stricmp().</p>
<p>[Some more context requested, so I'll demonstrate with a trivial example:]</p>
<p>Suppose you want to sort a looong list of strings. You simply do theList.sort().
This is O(n * log(n)) string comparisons and no memory management (since all
strings and list elements are some sort of smart pointers). You are happy.</p>
<p>Now, you want to do the same, but ignore the case (let's simplify and say
all strings are ascii, so locale issues can be ignored).
You can do theList.sort(key=lambda s: s.lower()), but then you cause two new
allocations per comparison, plus burden the garbage-collector with the duplicated
(lowered) strings.
Each such memory-management noise is orders-of-magnitude slower than simple string comparison.</p>
<p>Now, with an in-place stricmp()-like function, you do: theList.sort(cmp=stricmp)
and it is as fast and as memory-friendly as theList.sort(). You are happy again.</p>
<p>The problem is any Python-based case-insensitive comparison involves implicit string
duplications, so I was expecting to find a C-based comparisons (maybe in module string).</p>
<p>Could not find anything like that, hence the question here.
(Hope this clarifies the question).</p>
|
<p>Here is a benchmark showing that using <a href="http://docs.python.org/2/library/string.html?highlight=lower#string.lower" rel="nofollow noreferrer"><code>str.lower</code></a> is faster than the accepted answer's proposed method (<code>libc.strcasecmp</code>):</p>
<pre><code>#!/usr/bin/env python2.7
import random
import timeit
from ctypes import *
libc = CDLL('libc.dylib') # change to 'libc.so.6' on linux
with open('/usr/share/dict/words', 'r') as wordlist:
words = wordlist.read().splitlines()
random.shuffle(words)
print '%i words in list' % len(words)
setup = 'from __main__ import words, libc; gc.enable()'
stmts = [
('simple sort', 'sorted(words)'),
('sort with key=str.lower', 'sorted(words, key=str.lower)'),
('sort with cmp=libc.strcasecmp', 'sorted(words, cmp=libc.strcasecmp)'),
]
for (comment, stmt) in stmts:
t = timeit.Timer(stmt=stmt, setup=setup)
print '%s: %.2f msec/pass' % (comment, (1000*t.timeit(10)/10))
</code></pre>
<p>typical times on my machine:</p>
<pre><code>235886 words in list
simple sort: 483.59 msec/pass
sort with key=str.lower: 1064.70 msec/pass
sort with cmp=libc.strcasecmp: 5487.86 msec/pass
</code></pre>
<p>So, the version with <code>str.lower</code> is not only the fastest by far, but also the most portable and pythonic of all the proposed solutions here.
I have not profiled memory usage, but the original poster has still not given a compelling reason to worry about it. Also, who says that a call into the libc module doesn't duplicate any strings?</p>
<p>NB: The <code>lower()</code> string method also has the advantage of being locale-dependent. Something you will probably not be getting right when writing your own "optimised" solution. Even so, due to bugs and missing features in Python, this kind of comparison may give you wrong results in a unicode context.</p>
|
<p>You could subclass <code>str</code> and create your own case-insenstive string class but IMHO that would be extremely unwise and create far more trouble than it's worth.</p>
| 8,805
|
<p>This has been driving me crazy for a few days. Why doesn't the following work?</p>
<blockquote>
<pre><code> Dim arr(3, 3) As Integer
For y As Integer = 0 To arr.GetLength(0) - 1
For x As Integer = 0 To arr.GetLength(y) - 1
arr(y, x) = y + x
Next
Next
</code></pre>
</blockquote>
<p>Also, what if the array looked like this instead?</p>
<pre><code>{ {1, 2, 3},
{4, 5, 6, 7, 8, 9, 9, 9},
{5, 4, 3, 2}
}
</code></pre>
|
<p>Ok, so what you really need is a "jagged array". This will allow you to have an "array that contains other arrays of varying lengths".</p>
<pre><code> Dim arr As Integer()() = {New Integer() {1, 2, 3}, New Integer() {4, 5, 6, 7, 8, 9, 9, 9}, New Integer() {5, 4, 3, 2}}
For x = 0 To arr.GetUpperBound(0)
Console.WriteLine("Row " & x & " has " & arr(x).GetUpperBound(0) & " columns")
For y = 0 To arr(x).GetUpperBound(0)
Console.WriteLine("(" & x & "," & y & ") = " & arr(x)(y))
Next
Next
</code></pre>
<p>Output: </p>
<pre><code>Row 0 has 2 columns
(0,0) = 1
(0,1) = 2
(0,2) = 3
Row 1 has 7 columns
(1,0) = 4
(1,1) = 5
(1,2) = 6
(1,3) = 7
(1,4) = 8
(1,5) = 9
(1,6) = 9
(1,7) = 9
Row 2 has 3 columns
(2,0) = 5
(2,1) = 4
(2,2) = 3
(2,3) = 2
</code></pre>
|
<p>Your declaration: <code>DIM arr(3,3) As Integer</code> allready specifies that there are 3 elements in any given row (or 4, I'm not so sure about VB)</p>
<p>You could try:</p>
<pre><code>Dim arr(3) as Integer()
</code></pre>
<p>You should then be able to do:</p>
<pre><code>arr(n).Length
</code></pre>
<p>To find the length of row n.</p>
<p>I'm a bit rusty on VB6 and never learned VB.NET, but this should give you a 'jagged' array. Check out the msdn documentation on multidimensioned arrays.</p>
| 7,324
|
<p>Do you actively manage <a href="http://forums.construx.com/blogs/stevemcc/archive/2007/11/01/technical-debt-2.aspx" rel="noreferrer">technical debt</a> debt on your software development projects and if so, how do you do it?</p>
|
<p>One aspect of managing technical debt is in convincing non-technical managers that you need time allocated for refactoring and bug fixing.</p>
<p><a href="https://blog.asmartbear.com/software-quality-mortgage.html" rel="nofollow noreferrer">Here's an article with specific suggestions</a> on how to do that.</p>
|
<p>It depends a lot on the product. When I worked in a field where our code had to be outside-audited it was a planned part of our sprint. PM just asked development what area needed refactoring and it was put in the plan. That's not to say you wouldn't fix the code in the area you were working on, but you wouldn't devote a day to rewriting a mangled chunk of code that worked. Now I'm working in scrum and developers just do it as they work. My impression is that about the same amount of time goes into refactoring work, either way.</p>
| 7,918
|
<p>I was just listening to some older .Net Rocks! episodes, and I <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=D91887EA-5128-4BB1-B861-1DC1F9564941&displaylang=en" rel="nofollow noreferrer">found #329 on DSLs</a> to be interesting. My problem is that I can't find any good online resources for people trying to learn this technology. I get the basics of the creating new designers, but the MS docs on the T4 engine used by the DSL tools and then how to integrate the templates with the DSL models are lacking.</p>
<p>Does anyone know of some good introductory resources for the MS DSL tools?</p>
|
<p>The architects of the DSL Tools team wrote a book, <a href="https://rads.stackoverflow.com/amzn/click/com/0321398203" rel="nofollow noreferrer" rel="nofollow noreferrer">Domain-Specific Development with Visual Studio DSL Tools.</a> The book's <a href="http://www.domainspecificdevelopment.com/" rel="nofollow noreferrer">website</a> has some other links and resources.</p>
|
<p>A fantastic option for DSLs is <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">Boo</a>. I've been using it for things like setting up my IoC container, defining routes, validation rules. <a href="http://www.ayende.com/Blog/" rel="nofollow noreferrer">Ayende Rahien</a> is writing an fantastic book on the subject for Manning called <a href="http://www.manning.com/rahien/" rel="nofollow noreferrer">Building Domain Specific Languages in Boo</a></p>
| 2,646
|
<p>Having worked with Classic ASP for about 2 years now by creating a few 100 simple web forms I can't see a good reason for switching to .net; however, I'm not that versed in .net so I'm sure I could be missing a few things.</p>
<p>Some points that I often hear around work can be found here: <a href="http://www.packtpub.com/article/Classic-ASP" rel="noreferrer"><a href="http://www.packtpub.com/article/Classic-ASP" rel="noreferrer">http://www.packtpub.com/article/Classic-ASP</a></a> (not that I share all of these thoughts, but it's a good jumping off point)</p>
<p>I'm very interested to hear what others have to say on this matter.</p>
|
<p>You're missing more than a few things! ASP.NET is orders of magnitudes more productive, robust, and maintainable than old-school ASP ever thought about being. Server side controls, third-party controls, master pages, forms authentication, forms validation, an OO model than encourages appropriate application partitioning, easy deployment, built-in debugging and tracing, state management.</p>
<p>You even have the choice of WebForms or MVC. It's not an understatement to say that you are simply out of your mind if you don't thoroughly investigate what you're missing. </p>
|
<h2><a href="http://weblogs.asp.net/dwahlin/archive/2009/04/06/5-reasons-you-should-take-a-closer-look-at-asp-net-mvc.aspx" rel="nofollow noreferrer">5 Reasons You Should Take a Closer Look at ASP.NET MVC</a></h2>
| 6,700
|
<p>I'm starting to develop a browser-based game (and by this I mean text-based, no Flash or similar stuff on it) and I'm struggling to decide on which development framework to use.</p>
<p>As far as requirements are concerned, the most important thing that I can think of right now is the ability to translate it to several languages. A good object-relational mapping and a way to generate forms from logical objects would also be very good, as I've noticed that I always spend lots of time solving the problems that come up when I change any of those things.</p>
<p>The programming language is kind of unimportant. I have some experience in PHP and C#, but I don't mind, and I would even like to use this as an excuse, learning some new thing like Python or Ruby. What I do want is something with a good and thriving community and lots of samples and tutorials online to help me.</p>
|
<blockquote>
<p>I would reccomend sticking to what you know - PHP is more than capable.</p>
</blockquote>
<p>That's true of course, but:</p>
<blockquote>
<p>I don't mind, and I would even like to use this as an excuse, learning some new thing like Python or Ruby.</p>
</blockquote>
<p>Then writing a browser game is an excellent opportunity to do this. Learning something new is never wrong and learning an alternative to PHP can never hurt (<a href="http://www.codinghorror.com/blog/archives/001119.html" rel="nofollow noreferrer">eh, Jeff?</a>). While neither Ruby on Rails nor Django are especially useful for writing games, they're still great. We had to write a small browser game in a matter of weeks for a project once and Rails worked charms. On the other hand, all successful browser games have enormous work loads and if you want to scale well you either have to get good hardware and load balancing or you need a non-interpreted framework (sorry, guys!).</p>
|
<p>I would reccomend sticking to what you know - PHP is more than capable.</p>
<p>I used to play a game called <a href="http://www.hyperiums.com/" rel="nofollow noreferrer">Hyperiums</a> - a text based browser game like yours - which is created using Java (it's web-based quivalent is JSP?) and servlets. It works fairly well (it has had downtime issues but those were more related to it's running on a pretty crap server).</p>
<p>As for which framework to use - why not create your own? Spend a good amount of time pre-coding deciding how you're going to handle various things - such as langauge support: you could use a phrase system or seperate langauge-specific templates. Third party frameworks are probably better tested than one you make but they're not created for a specific purpose, they're created for a wide range of purposes.</p>
| 4,563
|
<p>I have created a namespace extension that is rooted under Desktop. The main purpose of the extension is to provide a virtual list of ZIP files that represent a list of configurable directories. When the user clicks one of the those items the contents of the related directory are zipped in place and the resulting ZIP file is stored in a cache folder.</p>
<p>All this works well aside a minor issue. If we go to Windows Explorer, open the extension and double click an item the opened file is the one from the cache. [CORRECT]</p>
<p>If on the other hand we open it by an Open Dialog the opened file is one from a Temporary Internet files directory. [INCORRECT]</p>
<p>What do I have to change for the Open Dialog (when used for example trough notepad.exe) to open the file from the cache folder and not from Temporary Internet files. I have tried to send allways the qualified file name in IShellFolder::GetDisplayNameOf but without any luck.</p>
|
<p>What would be wrong with doing something like the following:</p>
<p>Defining a 'Maintainer' interface with the addListener(Listener, Enum) method.</p>
<p>Create a DefaultMaintainer class (as above) which implements Maintainer.</p>
<p>Then, in each Listener class, 'inject' the Maintainer interface (constructor injection might be a good choice). The listener can then register itself with the Maintainer.</p>
<p>other than that, I'm not 100% clear on exactly what your difficulty is with Spring at the moment! :)</p>
|
<blockquote>
<p>You said "... you can't have java.lang.Enum as"
annotation param ..."</p>
</blockquote>
<p>I think you are wrong on that. I have recently used on a project something like this :</p>
<pre><code>public @interface MyAnnotation {
MyEnum value();
}
</code></pre>
| 9,697
|
<p>Continuing the "Hidden features of ..." meme, let's share the lesser-known but useful features of Ruby programming language.</p>
<p>Try to limit this discussion with core Ruby, without any Ruby on Rails stuff.</p>
<p>See also:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden features of C#</a></li>
<li><a href="https://stackoverflow.com/questions/15496/hidden-features-of-java">Hidden features of Java</a></li>
<li><a href="https://stackoverflow.com/questions/61088/hidden-features-of-javascript">Hidden features of JavaScript</a></li>
<li><a href="https://stackoverflow.com/questions/709679/hidden-features-of-ruby-on-rails">Hidden features of Ruby on Rails</a></li>
<li><a href="https://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a></li>
</ul>
<p>(Please, just <em>one</em> hidden feature per answer.)</p>
<p>Thank you</p>
|
<p>Peter Cooper has a <a href="http://www.rubyinside.com/21-ruby-tricks-902.html" rel="nofollow noreferrer">good list</a> of Ruby tricks. Perhaps my favorite of his is allowing both single items and collections to be enumerated. (That is, treat a non-collection object as a collection containing just that object.) It looks like this:</p>
<pre><code>[*items].each do |item|
# ...
end
</code></pre>
|
<pre><code>@user #=> nil (but I did't know)
@user.name rescue "Unknown"
</code></pre>
| 8,945
|
<p>How do I fix a broken debugger, one that just won't start, in <a href="http://www.eclipseme.org/" rel="nofollow noreferrer">EclipseME</a> (now Mobile Tools Java)?</p>
<p>(This question has an answer which will be transferred from another question soon)</p>
|
<p>The most annoying issue with EclipseME for me was the "broken" debugger, which just wouldn't start. This is covered in docs, but it took me about an hour to find this tip when I first installed EclipseME, and another hour when I returned to JavaME development a year later, so I decided to share this piece of knowledge here, too.</p>
<p>If the debugger won't start,</p>
<ol>
<li>open "Java > Debug" section in Eclipse "Preferences" menu, and uncheck "Suspend execution on uncaught exceptions" and "Suspend execution on compilation errors" and</li>
<li>increase the "Debugger timeout" near the bottom of the dialog to at least 15000 ms (so the docs say; in fact, a binary search on this value could find optimal delay for your case).</li>
</ol>
<p>After that, Eclipse should be able to connect to KVM and run a midlet with a debugger attached.</p>
|
<p>most debuggers are just plug-ins that also have a command-line interface; try running the debugger from the command-line and see if it works. If it does, then check the plug-in configuration; you may have to re-install the plug-in.</p>
<p>caveat: I have not used EclipseME, but had similar problems with the Gnu C debugger in Eclipse for Ubuntu.</p>
| 9,311
|
<p>I am very new to 3D printing. I am looking to purchase the Ender 3 V2 but before I do I would appreciate some advice on what I should purchase as the upgrades/addons for it. I'm not sure as to what I would need for the V2 since most websites are for the original Ender 3 so I don't know if the V2 already has that upgrade/addons or not when compared to the original. I would rather get all the upgrades/addons and the Ender 3 V2 at the same to save on shipping and all. </p>
<p>Pretty much the only upgrade/addons I have constantly seen is the auto bed level. </p>
<p>So if anyone can help out a first time 3D printer noob then that would be great!</p>
|
<p>IMHO, it's probably better to get the printer as-is first. This way you can get familiar with the printer and 3D printing in general before you get overwhelmed with all the extra introduced variables from your upgrades.</p>
<p>The new model already has loads of features that were considered upgrades on the older model and you can already get very nice results.</p>
<p>Upgrading your printer is a part of the 3D printing hobby, and you'll probably never be done with it :)</p>
|
<p>I have an Ender 3 v2 and I haven't upgraded anything except updating the firmware. The first thing I suggest is updating the firmware and changing the hotend to an all-metal one. This will allow you to print in higher temperatures and adding a BLTouch for automatic bed leveling will make your life a bit easier.</p>
| 1,736
|
<p>I'm looking for a tool to generate a JavaScript stub from a WSDL.</p>
<p>Although I usually prefer to use REST services with JSON or XML, there are some tools I am currently integrating that works only using SOAP.</p>
<p>I already created a first version of the client in JavaScript but I'm parsing the SOAP envelope by hand and I doubt that my code can survive a service upgrade for example, seeing how complex the SOAP envelope specification is.</p>
<p>So is there any tool to automatically generate fully SOAP compliant stubs for JavaScript from the WSDL so I can be more confident on the future of my client code.</p>
<p>More: The web service I try to use is RPC encoded, not document literal.</p>
|
<p>I had to do this myself in the past and I found this <a href="http://www.codeproject.com/KB/ajax/JavaScriptSOAPClient.aspx" rel="noreferrer">CodeProject article</a>. I changed it up some, but it gave me a good foundation to implement everything I needed. One of the main features it already has is generating the SOAP client based off the WSDL. It also has built in caching of the WSDL for multiple calls.</p>
<p>This article also has a custom implementation of XmlHttpRequest for Ajax calls. This is the part that I didn't use. During that time, I think I was using <a href="http://www.prototypejs.org/" rel="noreferrer">Prototype</a> javascript library and modified the code in this article to use it's Ajax functions instead. I just felt more comfortable using Prototype for the ajax calls, because it was widely used and had been tested on all the browsers.</p>
|
<p>It would probably be an overkill, but NetBeans has this feature.</p>
| 6,273
|
<p>I'm having trouble figuring out how to get the testing framework set up and usable in <strong>Visual Studio 2008</strong> for <code>C++</code> presumably with the built-in unit testing suite.</p>
<p>Any links or tutorials would be appreciated.</p>
|
<p><a href="http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle" rel="nofollow noreferrer">This page</a> may help, it reviews quite a few C++ unit test frameworks:</p>
<ul>
<li>CppUnit </li>
<li>Boost.Test</li>
<li>CppUnitLite </li>
<li>NanoCppUnit</li>
<li>Unit++</li>
<li>CxxTest</li>
</ul>
<p>Check out <strong><em><a href="http://www.objectmentor.com/resources/downloads.html" rel="nofollow noreferrer">CPPUnitLite</a></em></strong> or <strong><em><a href="http://gamesfromwithin.com/?p=48" rel="nofollow noreferrer">CPPUnitLite2</a></em></strong>. </p>
<p><em>CPPUnitLite</em> was created by Michael Feathers, who originally ported Java's JUnit to C++ as CPPUnit (CPPUnit tries mimic the development model of JUnit - but C++ lacks Java's features [e.g. reflection] to make it easy to use). </p>
<p>CPPUnitLite attempts to make a true C++-style testing framework, not a Java one ported to C++. (I'm paraphrasing from Feather's <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="nofollow noreferrer" rel="nofollow noreferrer">Working Effectively with Legacy Code</a> book). <em>CPPUnitLite2</em> seems to be another rewrite, with more features and bug fixes.</p>
<p>I also just stumbled across <strong><em><a href="http://sourceforge.net/projects/unittest-cpp/" rel="nofollow noreferrer">UnitTest++</a></em></strong> which includes stuff from CPPUnitLite2 and some other framework.</p>
<p>Microsoft has released <strong><em><a href="http://winunit.codeplex.com/" rel="nofollow noreferrer">WinUnit</a></em></strong>. </p>
<p>Also checkout <strong><em><a href="https://github.com/philsquared/Catch" rel="nofollow noreferrer">Catch</a></em></strong> or <strong><em><a href="https://github.com/onqtam/doctest" rel="nofollow noreferrer">Doctest</a></em></strong></p>
|
<p>I've used <a href="http://cppunit.sourceforge.net/cppunit-wiki" rel="nofollow noreferrer">CppUnit</a> with VS2005 and Eclipse. The wiki is very thorough (especially if you are familiar with JUnit).</p>
| 2,532
|
<p>We are trying out Visual Studio 2008 and Expression Blend on a new project. The goal is to clearly define the role of the developer and designer as separate, but reap the benefit of the developer being able to directly consume the XAML produced by the designer.</p>
<p>For the most part this has worked great, and I really like the possibilities. One difficulty we have come across though is designing against DataBindings. In many cases, the GUI does not populate rows, or other data structures unless the application is run, and a database call is made. Consequently the designer does not have access to the visual layout of the GUI.</p>
<p>What I would like to do, is somehow create some simple stubbed or mocked data that the designer can use to work on the design. The big goal is to have that stubbed data show up in Expression Blend, but then be applied to the real collection at runtime.</p>
<p>Has anyone found a solid method of doing this?</p>
|
<p>I would suggest reading <a href="http://www.galasoft.ch/mydotnet/articles/article-2007091401.html" rel="nofollow noreferrer">this blog</a>. The final method seems to work well, your test data shows up in Blend very nicely. Just keep in mind that you have to compile the DLL before it will display the data.</p>
|
<p>I would look into creating XML data islands which emulate the structure of the objects you will eventually bind the UI to. This way your designer can bind the root element of the page (or user control, etc.) to the top level of your fake XML data island and all the relative paths will stay the same when you swap that data island out for the real DataContext binding. </p>
<p>there will be some degree of refactoring to attach to the real object when you are ready, but that is why your developers should at least know enough XAML to know how to modify the bindings properly.</p>
<p>it looks like the commenter above me has a link to an example of this.</p>
| 9,200
|
<pre><code>$output = preg_replace("|(/D)(/s+)(/d+)(;)|", "//1,//3;", $output);
</code></pre>
<p>I'm trying to replace all alphabetical character followed by one or more whitespace characters (tabs and/or spaces) followed by one or more numerical characters followed by a semicolon with the alphabetical character followed by a comma followed by the numerical digits and then the semicolon.</p>
<p>I'll provide an example:</p>
<p>Start:</p>
<pre><code>hello world 1007;
</code></pre>
<p>End:</p>
<pre><code>hello world,1007;
</code></pre>
|
<p>The two <code>|</code> at the start and end probably are incorrect - and should both be forward-slashes.</p>
<p>All other forward slashes should be backward slashes (and need escaping).</p>
<p>And since PHP 4.04 <code>$n</code> is the preferred way of referring to a capture group.</p>
<pre><code>$output = preg_replace("/(\\D)\\s+(\\d+;)/", "$1,$2", $output);
</code></pre>
<p>If you use single quotes you don't need to escape your backslashes:</p>
<pre><code>$output = preg_replace('/(\D)\s+(\d+;)/', '$1,$2', $output);
</code></pre>
|
<p>You want backslashes in the regular expression, not forward slashes. The starting and ending pipes <strong>are</strong> needed (or another delimiter for the regex)</p>
<pre><code>$x = "hello world 1007;";
echo preg_replace('|(\D)(\s+)(\d+)(;)|','$1,$3',$x);
echo preg_replace('/(\D)(\s+)(\d+)(;)/','$1,$3',$x);
echo preg_replace('{(\D)(\s+)(\d+)(;)}','$1,$3',$x);
</code></pre>
| 7,754
|
<p>Is there an integrated kickback protection in stepper motor drivers or should I make my own?
I am afraid the steppers might fry the driver or the arduino when i turn off the power for them.
I do that by turning off the power supply.
I haven't had an issue yet but it still bothers me.</p>
|
<p>Kinda, sort of, but not really. I'll look at the A4988 (<a href="https://www.pololu.com/file/0J450/a4988_DMOS_microstepping_driver_with_translator.pdf" rel="nofollow noreferrer">datasheet</a>).</p>
<p>The motor pins are connected by diodes to ground and Vbb (the motor suppply voltage). Essentially, they act as a bridge rectifier making any back EMF or inductive spikes appear (rectified) on Vbb. If you were to suddenly power down the driver this could cause a rather large spike on Vbb.</p>
<p>According to the datasheet, there is a 40 V Zener on Vbb which will clamp the voltage to that level. (Another popular stepper driver, the DRV8825, does not appear to have this Zener - always check your datasheet!)</p>
<p>So, yes, there is inductive kickback protection. However, it only clamps the voltage to 40 V. Depending on the rest of your circuit, this could be quite damaging.</p>
<p>The datasheet recommends that a 100 μF capacitor be placed on Vbb. If you are driving a typical stepper motor with 2 A and 4 mH coil inductance, the energy stored in the coil is 8 mJ. This energy is only enough to take the capacitor up from 12 V to ~17.5 V, so if you have a large enough capacitor on your stepper driver (as you should!) then you're protected against inductive kickback.</p>
<p>Note that if you move the motors by hand then you can still build up a higher voltage on Vbb. I've heard anecdotes of people who damaged their printers like that.</p>
|
<p>"Inductive kickback" from motor coils is caused by the inductance of the coils and the wiring. It is not some strange effect. Inductance is charged with current, just as capacitance is changed with voltage. Most bipolar motor drivers use an H-bridge on the output. By driving the H-bridge correctly, the driver can continue to provide a path for the motor current when it is no longer applying voltage, such as by connecting both wires of a motor to ground.</p>
<p>Although some may find it counter-intuitive, connecting the Vmot side of the motor to Gmot, while the other side remains at Gmot, keeps current flowing in the coil more smoothly and with lower losses. The voltage across the motor coil is near zero, so there is little voltage trying to change the motor current. If the coil is undriven and subject to the clamping diodes, the voltage across the motor will me much higher, and the current will stop faster. </p>
<p>The higher ripple current in the motor increases the coil heating, may increase audible noise, and decreases the efficiency of the drive.</p>
| 829
|
<p>I have a set of Berkeley DB files on my Linux file system that I'd like to examine.</p>
<p>What useful tools exist for getting a quick overview of the contents? I can write Perl scripts that use BDB modules for examining them, but I'm looking for some CLI utility to be able to take a look inside without having to start writing scripts.</p>
|
<p>Check out the <strong>db-utils</strong> package. If you use apt, you can install it with the following: <code>apt-get install db-util</code> (or <code>apt-get install db4.8-util</code> or whatever version you have or prefer.)</p>
<p>Additional links:</p>
<ul>
<li><a href="http://rpmfind.net/linux/rpm2html/search.php?query=db-utils" rel="nofollow noreferrer">http://rpmfind.net/linux/rpm2html/search.php?query=db-utils</a></li>
<li><a href="http://packages.ubuntu.com/search?keywords=db4.4-util" rel="nofollow noreferrer">https://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=db-util&searchon=names</a></li>
<li><a href="http://www.linux.gr/cgi-bin/man/man2html?db4.4_dump+1" rel="nofollow noreferrer">Man page of db4.4_dump</a></li>
</ul>
|
<p>Under Amazon Linux you can install it with:</p>
<p><strong>yum install db43-utils</strong></p>
| 5,841
|
<p>I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perhaps a my.cnf setting for the replicating slave ignore-replicating-errors or some of the sort ;) )</p>
<p>This is what happens, every now and then, when the slave tries to replicate an item that does not exist, the slave just dies. a quick check at <strong>SHOW SLAVE STATUS \G;</strong> gives</p>
<pre><code> Slave-IO-Running: Yes
Slave-SQL-Running: No
Replicate-Do-DB:
Last-Errno: 1062
Last-Error: Error 'Duplicate entry '15218' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO db.table ( FIELDS ) VALUES ( VALUES )'
</code></pre>
<p>which I promptly fix (once I realize that the slave has been stopped) by doing the following:</p>
<pre><code>STOP SLAVE;
RESET SLAVE;
START SLAVE;
</code></pre>
<p>... lately this has been getting kind of tiresome, and before I spit out some sort of PHP which does this for me, i was wondering if there's some my.cnf entry which will not kill the slave on the first error.</p>
<p>Cheers,</p>
<p>/mp</p>
|
<p>Yes, with --slave-skip-errors=xxx in my.cnf, where xxx is 'all' or a comma sep list of error codes.</p>
|
<p>i think you are doing replication with out sync the database first sync the database and try for replication and servers are generating same unique ids and try to set auto incerment offset</p>
| 5,054
|
<p>In a C# .NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using <code>System.Windows.Forms.FolderBrowserDialog</code> but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of typing a UNC path).</p>
<p>I'd like something more like the <code>System.Windows.Forms.OpenFileDialog</code>, but for folders instead of files. </p>
<p>What can I use instead? A WinForms or WPF solution is fine, but I'd prefer not to PInvoke into the Windows API if I can avoid it.</p>
|
<p>Don't create it yourself! It's been done. You can use <a href="http://dotnetzip.codeplex.com/SourceControl/changeset/view/29832#432677" rel="nofollow noreferrer">FolderBrowserDialogEx</a> -
a re-usable derivative of the built-in FolderBrowserDialog. This one allows you to type in a path, even a UNC path. You can also browse for computers or printers with it. Works just like the built-in FBD, but ... better. </p>
<p>Full Source code. Free. MS-Public license.</p>
<p><img src="https://i.stack.imgur.com/V1caf.png" alt="FolderBrowserDialogEx"></p>
<p>Code to use it: </p>
<pre><code>var dlg1 = new Ionic.Utils.FolderBrowserDialogEx();
dlg1.Description = "Select a folder to extract to:";
dlg1.ShowNewFolderButton = true;
dlg1.ShowEditBox = true;
//dlg1.NewStyle = false;
dlg1.SelectedPath = txtExtractDirectory.Text;
dlg1.ShowFullPathInEditBox = true;
dlg1.RootFolder = System.Environment.SpecialFolder.MyComputer;
// Show the FolderBrowserDialog.
DialogResult result = dlg1.ShowDialog();
if (result == DialogResult.OK)
{
txtExtractDirectory.Text = dlg1.SelectedPath;
}
</code></pre>
|
<p>So far, based on the lack of responses to <a href="https://stackoverflow.com/questions/31059/how-do-you-configure-an-openfiledialog-to-select-folders">my identical question</a>, I'd assume the answer is to roll your own dialog from scratch.</p>
<p>I've seen things here and there about subclassing the common dialogs from VB6 and I think this might be part of the solution, but I've never seen anything about modifying what the dialog thinks it's selecting. It'd be possible through .NET via PInvoke and some other tricks, but I have yet to see code that does it.</p>
<p>I <em>know</em> it's possible and it's not Vista-specific because Visual Studio has done it since VS 2003.</p>
<p>Here's hoping someone answers either yours or mine!</p>
| 6,801
|
<p>Most restrictions and tricks with windows forms are common to most programmers. But since .NET 3.0 there is also WPF available, the Windows Presentation Foundation. It is said that you can make "sexy applications" more easy with it and with .NET 3.5 SP1 it got a good speed boost on execution.</p>
<p>But on the other side a lot of things are working different with WPF. I will not say it is more difficult but you have to learn "everything" from scratch.</p>
<p>My question: Is it worth to spend this extra time when you have to create a new GUI and there is no time pressure for the project?</p>
|
<p>WPF enables you to do some amazing things, and I LOVE it... but I always feel obligated to qualify my recommendations, whenever developers ask me whether I think they should be moving to the new technology.</p>
<p>Are your developers willing (preferrably, EAGER) to spend the time it takes to learn to use WPF effectively? I never would have thought to say this about MFC, or Windows Forms, or even unmanaged DirectX, but you probably do NOT want a team trying to "pick up" WPF over the course of a normal dev. cycle for a shipping product!</p>
<p>Do at least one or two of your developers have some design sensibilities, and do individuals with final design authority have a decent understanding of development issues, so you can leverage WPF capabilities to create something which is actually BETTER, instead of just more "colorful", featuring gratuitous animation?</p>
<p>Does some percentage of your target customer base run on integrated graphics chip sets that might not support the features you were planning -- or are they still running Windows 2000, which would eliminate them as customers altogether? Some people would also ask whether your customers actually CARE about enhanced visuals but, having lived through internal company "Our business customers don't care about colors and pictures" debates in the early '90s, I know that well-designed solutions from your competitors will MAKE them care, and the real question is whether the conditions are right, to enable you to offer something that will make them care NOW.</p>
<p>Does the project involve grounds-up development, at least for the presentation layer, to avoid the additional complexity of trying to hook into incompatible legacy scaffolding (Interop with Win Forms is NOT seamless)?</p>
<p>Can your manager accept (or be distracted from noticing) a significant DROP in developer productivity for four to six months?</p>
<p>This last issue is due to what I like to think of as the "FizzBin" nature of WPF, with ten different ways to implement any task, and no apparent reason to prefer one approach to another, and little guidance available to help you make a choice. Not only will the shortcomings of whatever choice you make become clear only much later in the project, but you are virtually guaranteed to have every developer on your project adopting a different approach, resulting in a major maintenance headache. Most frustrating of all are the inconsistencies that constantly trip you up, as you try to learn the framework.</p>
<p>You can find more in-depth WPF-related information in an entry on my blog:</p>
<p><a href="http://missedmemo.com/blog/2008/09/13/WPFTheFizzBinAPI.aspx" rel="nofollow noreferrer">http://missedmemo.com/blog/2008/09/13/WPFTheFizzBinAPI.aspx</a></p>
|
<p>For conversion projects (from <a href="http://en.wikipedia.org/wiki/Visual_Basic#Timeline" rel="nofollow noreferrer">Visual Basic 6.0</a>), it's hard to get a team to switch to WPF. Besides the learning curve, people are already used to the old interface. Windows Forms, although being phased out, will be around for a long time still. </p>
| 8,233
|
<p>I was given an .xml file that I needed to read into my code as a DataSet (as background, the file was created by creating a <code>DataSet</code> in C# and calling <code>dataSet.WriteXml(file, XmlWriteMode.IgnoreSchema)</code>, but this was done by someone else). </p>
<p>The .xml file was shaped like this:</p>
<pre><code> <?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Foo>
<Bar>abcd</Bar>
<Foo>efg</Foo>
</Foo>
<Foo>
<Bar>hijk</Bar>
<Foo>lmn</Foo>
</Foo>
</NewDataSet>
</code></pre>
<p>Using C# and .NET 2.0, I read the file in using the code below:</p>
<pre><code> DataSet ds = new DataSet();
ds.ReadXml(file);
</code></pre>
<p>Using a breakpoint, after this <code>line ds.Tables[0]</code> looked like this (using dashes in place of underscores that I couldn't get to format properly):</p>
<pre><code>Bar Foo-Id Foo-Id-0
abcd 0 null
null 1 0
hijk 2 null
null 3 2
</code></pre>
<p>I have found a workaround (I know there are many) and have been able to successfully read in the .xml, but what I would like to understand why <code>ds.ReadXml(file)</code> performed in this manner, so I will be able to avoid the issue in the future. Thanks.</p>
|
<p>This appears to be correct for your <em>nested</em> Foo tags:</p>
<pre><code><NewDataSet>
<Foo> <!-- Foo-Id: 0 -->
<Bar>abcd</Bar>
<Foo>efg</Foo> <!-- Foo-Id: 1, Parent-Id: 0 -->
</Foo>
<Foo> <!-- Foo-Id: 2 -->
<Bar>hijk</Bar>
<Foo>lmn</Foo> <!-- Foo-Id: 3, Parent-Id: 2 -->
</Foo>
</NewDataSet>
</code></pre>
<p>So this correctly becomes 4 records in your result, with a parent-child key of "Foo-Id-0"</p>
<p>Try:</p>
<pre><code><NewDataSet>
<Rec> <!-- Rec-Id: 0 -->
<Bar>abcd</Bar>
<Foo>efg</Foo>
</Rec>
<Rec> <!-- Rec-Id: 1 -->
<Bar>hijk</Bar>
<Foo>lmn</Foo>
</Rec>
</NewDataSet>
</code></pre>
<p>Which should result in:</p>
<pre><code>Bar Foo Rec-Id
abcd efg 0
hijk lmn 1
</code></pre>
|
<p>These are my observations rather than a full answer:</p>
<p>My guess (without trying to re-produce it myself) is that a couple of things may be happening as the DataSet tries to 'flatten' a hierarchical structure to a relational data structure.</p>
<p>1) thinking about the data from a relational database perspective; there is no obvious primary key field for identifying each of the Foo elements in the collection so the DataSet has automatically used the ordinal position in the file as an auto-generated field called Foo-Id.</p>
<p>2) There are actually two elements called 'Foo' so that probably explains the generation of a strange name for the column 'Foo-Id-0' (it has auto-generated a unique name for the column - I guess you could think of this as a fault-tolerant behaviour in the DataSet).</p>
| 7,493
|
<p>I finished a 3D object for 4 wheels, but something seems wrong with the final scene to me:</p>
<p>The nearer wheels (#1 and #2) appear smaller than the far one (#3 and #4), and the distance between wheel #3 an #4 seems longer than between (1) and (2), like you can see in this picture:</p>
<p><a href="https://i.stack.imgur.com/8YdzP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8YdzP.png" alt="4 wheels"></a></p>
<p>I want to achieve the scene like this:</p>
<p><a href="https://i.stack.imgur.com/RkHkU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RkHkU.png" alt="Example of a wanted render"></a></p>
<p>How to do that in FreeCAD?</p>
|
<p>CAD programs uses parallel view not perspective view.
So the length of 2 objects with the same length are displayed as 2 objects with the same length on the screen.
This is better for constructing stuff. </p>
|
<p>CAD programs uses parallel view not perspective view.
So the length of 2 objects with the same length are displayed as 2 objects with the same length on the screen.
This is better for constructing stuff. </p>
| 1,044
|
<p>I'm trying to send messages to Objective-C objects in gdb.</p>
<pre><code>(gdb) p $esi
$2 = (void *) 0x1268160
(gdb) po $esi
<NSArray: 0x1359c0>
(gdb) po [$esi count]
Target does not respond to this message selector.
</code></pre>
<p>I can't send any message to it. Am I missing something? Do I really need the symbols, or something else?</p>
|
<p>If you must override gdb and send a message to an object when it will not let you, you can use performSelector:</p>
<pre><code>(gdb) print (int)[receivedData count]
Target does not respond to this message selector.
(gdb) print (int)[receivedData performSelector:@selector(count) ]
2008-09-15 00:46:35.854 Executable[1008:20b] *** -[NSConcreteMutableData count]:
unrecognized selector sent to instance 0x105f2e0
</code></pre>
<p>If you need to pass an argument use withObject:</p>
<pre><code>(gdb) print (int)[receivedData performSelector:@selector(count) withObject:myObject ]
</code></pre>
|
<p>@[John Calsbeek]</p>
<p>Then it complains about missing symbols.</p>
<pre><code>(gdb) p (NSUInteger)[(NSObject*)$esi retainCount]
No symbol table is loaded. Use the "file" command.
(gdb) p [(NSArray *)$esi count]
No symbol "NSArray" in current context.
</code></pre>
<p>I tried to load the symbols for Foundation:</p>
<pre><code>(gdb) add-symbol-file /System/Library/Frameworks/Foundation.framework/Foundation
add symbol table from file "/System/Library/Frameworks/Foundation.framework/Foundation"? (y or n) y
Reading symbols from /System/Library/Frameworks/Foundation.framework/Foundation...done.
</code></pre>
<p>but still no luck:</p>
<pre><code>(gdb) p [(NSArray *)$esi count]
No symbol "NSArray" in current context.
</code></pre>
<p>Anyway, I don't think casting is the solution to this problem, you shouldn't have to know what kind of object it is, to be able to send messages to it.
The weird thing is that I found an NSCFArray I have no problems sending messages to:</p>
<pre><code>(gdb) p $eax
$11 = 367589056
(gdb) po $eax
<NSCFArray 0x15e8f6c0>(
file://localhost/Users/ask/Documents/composing-fractals.pdf
)
(gdb) p (int)[$eax retainCount]
$12 = 1
</code></pre>
<p>so I guess there was a problem with the object I was investigating... or something.</p>
<p>Thanks for your help!</p>
| 8,041
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.