instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I am looking to buy an Ender-3 Pro, but the place I'm looking to buy from has this picture:</p>
<p><a href="https://i.stack.imgur.com/RY2ds.jpg" rel="nofollow noreferrer" title="Confusing 3D printer publicity photo"><img src="https://i.stack.imgur.com/RY2ds.jpg" alt="Confusing 3D printer publicity photo" title="Confusing 3D printer publicity photo" /></a></p>
<p>My question is, what is meant by "Junior" in the name?</p>
<p>I'm just wondering if this means it's an alternative kind of version for kids or something, or if it's just the name of that type of 3D Printer (e.g. in the way you might have a Junior Hacksaw or something)? I.e. is this the normal Ender V3 Pro?</p>
|
<p>There is no such thing as a <em>Junior</em><sup>1</sup>, you can see the official Creality range of FDM printers on the <a href="https://www.creality.com/product/fdm-3d-printer" rel="nofollow noreferrer">FDM 3D PRINTER</a> page, on their web site.</p>
<p>Upon a cursory comparison of the photo it is one of these:</p>
<ul>
<li>Ender-3 Max 3D Printer</li>
<li>Ender-3 Pro 3D Printer</li>
<li>Ender-3 3D Printer</li>
</ul>
<p>However, the first one can be discounted as the spool holder is missing. So this leaves the last two.</p>
<p>Finally, the biggest clue is in the photo itself, as the name is written in the last line: <a href="https://www.creality.com/goods-detail/ender-3-pro-3d-printer" rel="nofollow noreferrer"><em><strong>Ender-3 Pro</strong></em></a>.</p>
<p>Nevertheless, given the seller's random "junior" labelling, it is not entirely guaranteed that the printer is, in fact, a Pro.</p>
<p>Unless they are super cheap or a renowned seller, then it is probably best to avoid purchasing anything from them. Or contact the seller to see if they would clarify their misleading advert.</p>
<hr />
<p><sup>1</sup> The term <em>junior</em> could be an indication of the base level entry of the printer, or a reference to its build size, which, while not small and is pretty standard, it is not as large as some of the more pricey Creality models.</p>
|
<p>That is an Ender 3, with the vertical PSU, the older interface, and many tweaks like the drawer and filament loading knob isn't present.</p>
<p>Consider the Ender 3 V2 instead, which is an iteration on the same basic design and is newer.</p>
<p>Personally I found it cheaper to buy the V2 direct from Creality's website than to buy the older model from a local or other online seller, and it had free freight from China, and arrived in about 3 weeks.</p>
| 2,065
|
<p>My first printer is Delta style Kossel clone and I have bad luck with Print In Place (PIP) models, especially with hinges. I suspect that my printer just can't achieve low enough tolerances to make the hinges work. </p>
<p>Are there any tricks I can employ to get better prints for PIP models?</p>
|
<p>Delta printers are considered to be able to be accurate printers cause of the limited weight in the head (using Bowden extruder setup). The positioning can be very accurate (limited weight, limited overshooting) and because of the limited amount of weight, the print speed can be increased.</p>
<p>An <a href="http://www.scielo.br/pdf/mr/v20s2/1516-1439-mr-1980-5373-MR-2016-1039.pdf" rel="nofollow noreferrer">interesting paper</a> has been written on a comparative study between a Cartesian and a Delta machine. The paper concludes that the Delta style printer produces "a better surface finish". However, I'm a bit skeptical as the images of the Cartesian printed part they have printed are of far less quality I can produce with 2 of my printers. Fact is that Delta machines have no Z-wobble (also called <a href="http://www.soliwiki.com/Banding" rel="nofollow noreferrer">banding</a>) that is a common problem with Prusa i3 style printers for instance.</p>
|
<p>It is possible that your printer is over-extruding, and this will certainly give less satisfactory results when you try to print models which have internal clearances. </p>
<p>It is also possible that you have some calibration issues which affect orthogonality, x/y/z dimensions or flatness in each axis.</p>
<p>In terms of general improvements, slower and maybe cooler might help - but before jumping in with difficult models, how are your 'standard' print test parts coming out?</p>
| 952
|
<p>I've having trouble directly accessing the <strong>Win32_OperatingSystem</strong> management class that is exposed via WMI.</p>
<p>It is a singleton class, and I'm pretty certain "Win32_OperatingSystem=@" is the correct path syntax to get the instance of a singleton.</p>
<p>The call to InvokeMethod produces the exception listed at the bottom of the question, as does accessing the ClassPath property (commented line).</p>
<p>What am I doing wrong?</p>
<p>[I'm aware that I can use ManagementObjectSearcher/ObjectQuery to return a collection of Win32_OperatingSystem (which would contain only one), but since I know it is a singleton, I want to access it directly.]</p>
<hr>
<pre><code>ManagementScope cimv2 = InitScope(string.Format(@"\\{0}\root\cimv2", this.Name));
ManagementObject os = new ManagementObject(
cimv2,
new ManagementPath("Win32_OperatingSystem=@"),
new ObjectGetOptions());
//ManagementPath p = os.ClassPath;
os.InvokeMethod("Reboot", null);
</code></pre>
<hr>
<p>System.Management.ManagementException was caught
Message="Invalid object path "
Source="System.Management"
StackTrace:
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObject.Initialize(Boolean getObject)
at System.Management.ManagementBaseObject.get_wbemObject()
at System.Management.ManagementObject.get_ClassPath()
at System.Management.ManagementObject.GetMethodParameters(String methodName, ManagementBaseObject& inParameters, IWbemClassObjectFreeThreaded& inParametersClass, IWbemClassObjectFreeThreaded& outParametersClass)
at System.Management.ManagementObject.InvokeMethod(String methodName, Object[] args)</p>
<hr>
<p>Thanks for the replies.</p>
<p><strong>Nick</strong> - I don't know how to go about doing that :)</p>
<p><strong>Uros</strong> - I was under the impression that it was a singleton class because of <a href="http://msdn.microsoft.com/en-us/library/aa394239.aspx" rel="nofollow noreferrer">this</a> MSDN page. Also, opening the class in the WBEMTest utility shows <a href="http://img247.imageshack.us/img247/5686/64933271au3.png" rel="nofollow noreferrer">this</a>.</p>
<hr>
<p>The instances dialog shows: "1 objects" and "max. batch: 1" in those fields and lists "Win32_OperatingSystem=@"</p>
<p>The ManagementScope is verified as working, so I don't know what's up. I'm a WMI novice, but this seems like one of the simplest use cases!</p>
|
<p>Win32_OperatingSystem is not a singleton class - if you check its qualifiers, you'll see that there is no Singleton qualifier defined for it, so you'll have to use ManagementObjectSearcher.Get() or ManagementClass.GetInstances() even though there is only one instance of the class. Win32_OperatingSystem key property is Name, so there is an option to get the instance directly, using </p>
<pre><code>ManagementObject OS = new ManagementObject(@"Win32_OperatingSystem.Name='OSname'")
</code></pre>
<p>but in my experience, OSName is always something like:</p>
<p>"Microsoft Windows XP Professional|C:\WINDOWS|\Device\Harddisk0\Partition1"</p>
<p>so using ManagementObjectSearcher is probably the easiest solution.</p>
|
<p>I'm not 100% sure of the answer, but have you tried using reflector to look at what ManagementObjectSearcher does? It may give you some clue as to what you are doing wrong.</p>
| 8,008
|
<p>I know Microsoft has made efforts in the direction of semantic and cross-browser compliant XHTML and CSS, but it still seems like a PitA to pull off elegant markup. I've downloaded and tweaked the CSS Friendly Adapters and all that. But I still find myself frustrated with bloated and unattractive code.</p>
<p>Is elegant, semantic CSS with ASP.Net still a pipe dream? Or is it finally possible, I just need more practice?</p>
|
<p>The easiest way to generate elegant HTML and CSS is to use MVC framework, where you have much more control over HTML generation than with Web Forms.</p>
|
<p>As long as you use the Visual Studio designer, it's probably a pipe dream. I write all of my ASP.NET code (all markup, and CSS) by hand, simply to avoid the designer. Later versions of Visual Studio have gotten much better at not mangling your .aspx/.ascx files, but they're still far from perfect.</p>
| 5,323
|
<p>Obviously, that's 64-bit windows.</p>
<p>Also, what's the maximum amount of memory a single 64-bit process can use?
I was kind of counting on using it all...
(Yes, I know what I'm doing, please don't tell me that if I need that much RAM i must be doing something wrong)</p>
<p>Also, is this the same for a .Net 2.0 process? Or is there a lower limit for .Net?</p>
|
<p>What version of windows? it differs from XP to vista and from home to business versions of vista, and I would guess again for server.</p>
<p>see <a href="http://msdn.microsoft.com/en-us/library/aa366778.aspx" rel="nofollow noreferrer">here for more info on maximum ram for diffrent windows versions</a></p>
<p>for Windows Server 2008 Datacenter MS quote 2 TB of physical memory.</p>
|
<p>Something we found out recently: with MySQL running on Win32, you can only use up to 2GB per process. On Win64, the memory is not managed as well and a single MySQL instance will run your memory into the ground. Ours used up all 16GB we have. So regarding how much memory 1 64-bit process can use: the answer is however much the OS allows.</p>
| 5,370
|
<p>I'm trying to create an SSIS package that takes data from an XML data source and for each row inserts another row with some preset values. Any ideas? I'm thinking I could use a DataReader source to generate the preset values by doing the following:</p>
<pre><code>SELECT 'foo' as 'attribute1', 'bar' as 'attribute2'
</code></pre>
<p>The question is, how would I insert one row of this type for every row in the XML data source?</p>
|
<p>I've never tried it, but it looks like you might be able to use a <a href="http://msdn.microsoft.com/en-us/library/ms141069(SQL.90).aspx" rel="nofollow noreferrer">Derived Column transformation</a> to do it: set the expression for attribute1 to <code>"foo"</code> and the expression for attribute2 to <code>"bar"</code>.</p>
<p>You'd then transform the original data source, then only use the derived columns in your destination. If you still need the original source, you can Multicast it to create a duplicate.</p>
<p>At least I think this will work, based on the documentation. YMMV.</p>
|
<p>I would probably switch to using a Script Task and place your logic in there. You may still be able leverage the File Reading and other objects in SSIS to save some code.</p>
| 7,407
|
<p>In Linux, what is the difference between <code>/dev/ttyS0</code> and <code>/dev/ttys0</code>?</p>
<p>I know that the first is a serial port, but what about the second, with the small <code>s</code>?</p>
|
<p><a href="http://www.linuxselfhelp.com/HOWTO/Text-Terminal-HOWTO-6.html" rel="nofollow noreferrer">see this</a></p>
<blockquote>
<p>For a pseudo terminal pair such as
ptyp3 and ttyp3, the pty... is the
master or controlling terminal and the
tty... is the slave. There are only 16
ttyp's: ttyp0-ttypf (f is a
hexadecimal digit). <strong>To get more
pairs, the 3 letters q, r, s may be
used instead of p</strong>. For example the
pair ttys8, ptys8 is a pseudo terminal
pair. The master and slave are really
the same "port" but the slave is used
by the application program and the
master is used by a network program
(or the like) which supplies (and
gets) data to/from the slave port.</p>
</blockquote>
|
<p>And this: <a href="http://lists.opensuse.org/archive/opensuse/2003-12/msg02404.html" rel="nofollow noreferrer">http://lists.opensuse.org/archive/opensuse/2003-12/msg02404.html</a></p>
| 4,210
|
<p>I'm looking at using OpenID for my authentication scheme and wanted to know what the best .NET library is to use for MVC specific applications?</p>
<p>thx</p>
|
<p><a href="http://code.google.com/p/dotnetopenid/" rel="nofollow noreferrer">.Net OpenID project</a> is the best library to use right now that I know of. I think SO used it also. The source includes a sample ASP.NET MVC project using the library.</p>
<p>Scott Hanselman did a <a href="http://www.hanselman.com/blog/TheWeeklySourceCode25OpenIDEdition.aspx" rel="nofollow noreferrer">post</a> on how to use the .Net OpenID project inside of ASP.NET MVC.</p>
|
<p>We have been using .Net Open Id project and are pretty happy with it so far. Andrew Arnott does a great work of answering the queries and suggesting workarounds if you are struck. Give it a try and you will love it :)</p>
| 7,154
|
<p>In the code below I am using a recursive CTE(Common Table Expression) in SQL Server 2005 to try and find the top level parent of a basic hierarchical structure. The rule of this hierarchy is that every CustID has a ParentID and if the CustID has no parent then the ParentID = CustID and it is the highest level.</p>
<pre><code>DECLARE @LookupID int
--Our test value
SET @LookupID = 1
WITH cteLevelOne (ParentID, CustID) AS
(
SELECT a.ParentID, a.CustID
FROM tblCustomer AS a
WHERE a.CustID = @LookupID
UNION ALL
SELECT a.ParentID, a.CustID
FROM tblCustomer AS a
INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID
WHERE c.CustID <> a.CustomerID
)
</code></pre>
<p>So if tblCustomer looks like this: </p>
<pre><code>ParentID CustID
5 5
1 8
5 4
4 1
</code></pre>
<p>The result I get from the code above is: </p>
<pre><code>ParentID CustID
4 1
5 4
5 5
</code></pre>
<p>What I want is just the last row of that result: </p>
<pre><code>ParentID CustID
5 5
</code></pre>
<p>How do I just return the last record generated in the CTE (which would be highest level CustID)?</p>
<p>Also note that there are multiple unrelated CustID hierarchies in this table so I can't just do a SELECT * FROM tblCustomer WHERE ParentID = CustID. I can't order by ParentID or CustID because the ID number is not related to where it is in the hierarchy.</p>
|
<p>If you just want want the highest recursion depth couldn't you do something like this?Then, when you actually query the CTE just look for the row with max(Depth)? Like so:</p>
<pre><code>DECLARE @LookupID int
--Our test value
SET @LookupID = 1;
WITH cteLevelOne (ParentID, CustID, Depth) AS
(
SELECT a.ParentID, a.CustID, 1
FROM tblCustomer AS a
WHERE a.CustID = @LookupID
UNION ALL
SELECT a.ParentID, a.CustID, c.Depth + 1
FROM tblCustomer AS a
INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID
WHERE c.CustID <> a.CustID
)
select * from CTELevelone where Depth = (select max(Depth) from CTELevelone)
</code></pre>
<p>or, adapting what trevor suggests, this could be used with the same CTE: </p>
<pre><code>select top 1 * from CTELevelone order by Depth desc
</code></pre>
<p>I don't think CustomerID was necessarily what you wanted to order by in the case you described, but I wasn't perfectly clear on the question either.</p>
|
<p>First the cte will not be finished if any of the parent child are same. As it is a recursive CTE it has to be terminated. Having Parent and cust id same , the loop will not end.</p>
<p>Msg 530, Level 16, State 1, Line 15
The statement terminated. The maximum recursion 100 has been exhausted before statement completion.</p>
| 5,577
|
<p>I am working on a cocoa software and in order to keep the GUI responsive during a massive data import (Core Data) I need to run the import outside the main thread.</p>
<p>Is it safe to access those objects even if I created them in the main thread without using locks <strong>if</strong> I don't explicitly access those objects while the thread is running.</p>
|
<p>With Core Data, you should have a separate managed object context to use for your import thread, connected to the same coordinator and persistent store. You cannot simply throw objects created in a context used by the main thread into another thread and expect them to work. Furthermore, you cannot do your own locking for this; you must at minimum lock the managed object context the objects are in, as appropriate. But if those objects are bound to by your views a controls, there are no "hooks" that you can add that locking of the context to.</p>
<p>There's no free lunch.</p>
<p>Ben Trumbull explains some of the reasons why you need to use a separate context, and why "just reading" isn't as simple or as safe as you might think, in <a href="http://lists.apple.com/archives/webobjects-dev/2004/Dec/msg00255.html" rel="nofollow noreferrer" title="Re: locking problem">this great post from late 2004 on the webobjects-dev list</a>. (The whole thread is great.) He's discussing the Enterprise Objects Framework and WebObjects, but his advice is fully applicable to Core Data as well. Just replace "EC" with "NSManagedObjectContext" and "EOF" with "Core Data" in the meat of his message.</p>
<p>The solution to the problem of sharing data between threads in Core Data, like the Enterprise Objects Framework before it, is "don't." If you've thought about it further and you really, honestly do have to share data between threads, then the solution is to keep independent object graphs in thread-isolated contexts, and use the information in the save notification from one context to tell the other context what to re-fetch. <a href="http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/Reference/Reference.html#//apple_ref/occ/instm/NSManagedObjectContext/refreshObject:mergeChanges:" rel="nofollow noreferrer" title="-[NSManagedObjectContext refreshObject:mergeChanges:]"><code>-[NSManagedObjectContext refreshObject:mergeChanges:]</code></a> is specifically designed to support this use.</p>
|
<p>The whole point of using locks is to ensure that two threads don't try to access the same resource. If you can guarantee that through some other mechanism, go for it.</p>
| 9,274
|
<p>I have always thought that the .equals() method in java should be overridden to be made specific to the class you have created. In other words to look for equivalence of two different instances rather than two references to the same instance. However I have encountered other programmers who seem to think that the default object behavior should be left alone and a new method created for testing equivalence of two objects of the same class. </p>
<p>What are the argument for and against overriding the equals method?</p>
|
<p>Overriding the equals method is necessary if you want to test equivalence in standard library classes (for example, ensuring a java.util.Set contains unique elements or using objects as keys in java.util.Map objects).</p>
<p>Note, if you override equals, ensure you honour the API contract as described in the documentation. For example, ensure you also override <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html" rel="noreferrer">Object.hashCode</a>:</p>
<blockquote>
<p>If two objects are equal according to
the equals(Object) method, then
calling the hashCode method on each of
the two objects must produce the same
integer result.</p>
</blockquote>
<p>EDIT: I didn't post this as a complete answer on the subject, so I'll echo Fredrik Kalseth's statement that overriding equals works best for <a href="http://en.wikipedia.org/wiki/Immutable_object" rel="noreferrer">immutable objects</a>. To quote the API for <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html" rel="noreferrer">Map</a>:</p>
<blockquote>
<p>Note: great care must be exercised if
mutable objects are used as map keys.
The behavior of a map is not specified
if the value of an object is changed
in a manner that affects equals
comparisons while the object is a key
in the map.</p>
</blockquote>
|
<p>The Equals method is intended to compare references. So it should not be overriden to change its behaviour.</p>
<p>You should create a new method to test for equivalence in different instances if you need to (or use the CompareTo method in some .NET classes)</p>
| 3,728
|
<p>I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form.</p>
<p>in vb.net: <code>Parent.FindControl(TargetControlName)</code></p>
<p>I would like to pass a method to the control in the ASPX markup. </p>
<p>for example: <code><c:MyCustomerControl runat=server InitializeStuffCallback="InitializeStuff"></code></p>
<p>So, I tried using reflection to access the given method name from the Parent.</p>
<p>Something like (in VB)</p>
<pre class="lang-vb prettyprint-override"><code>Dim pageType As Type = Page.GetType
Dim CallbackMethodInfo As MethodInfo = pageType.GetMethod( "MethodName" )
'Also tried
sender.Parent.GetType.GetMethod("MethodName")
sender.Parent.Parent.GetType.GetMethod("MethodName")
</code></pre>
<p>The method isn't found, because it just isn't apart of the Page. Where should I be looking? I'm fairly sure this is possible because I've seen other controls do similar.</p>
<hr>
<p>I forgot to mention, my work-around is to give the control events and attaching to them in the Code-behind.</p>
|
<p>If you want to be able to pass a method in the ASPX markup, you need to use the <code>Browsable</code> attribute in your code on the event.</p>
<p>VB.NET</p>
<pre class="lang-vb prettyprint-override"><code><Browsable(True)> Public Event InitializeStuffCallback
</code></pre>
<p>C#</p>
<pre><code>[Browsable(true)]
public event EventHandler InitializeStuffCallback;
</code></pre>
<p>Reference:
<a href="http://msdn.microsoft.com/en-us/library/tk67c2t8.aspx" rel="nofollow noreferrer">Design-Time Attributes for Components</a> and <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.aspx" rel="nofollow noreferrer">BrowsableAttribute Class</a></p>
<p>All the events, properties, or whatever need to be in the code-behind of the control with the browsable attribute to make it so you can change it in the tag code.</p>
|
<p>Your workaround is actually the better answer. If you have code that you must run at a certain part of your control's lifecycle, you <strong>should</strong> expose events to let the container extend the lifecycle with custom functionality.</p>
| 5,315
|
<p>I bought a buddha statue and I would like to scan it using photogrammetry and publish the result. </p>
<p><strong>Am I allowed to do that?</strong></p>
<p>Is this the same like scanning a book and publishing it? Sketchfab on the other hand is full of 3d models of commercial products.</p>
|
<p>If the design was made from an artist and is not public domain, than you should not upload that scan without the (written) permission of the creator of the design. Espacially a scan of a decorative object will likely be protected, so costumers buy the original instead of printing itself or buy a printed version. If you would design a deco object and sell copies of it, you also don't want that others just scan it and print it.</p>
|
<p>First thing to do is get a lawyer skilled in copyright law as applicable where you live. It's going to depend in no small part on whether your scanned model is considered a copy or a transformative work of art. </p>
<p>Personally, I see scanning an object as similar to photographing it (or sketching it). Lots of art objects, or for that matter personal items such as a photo of a living person, are protected by copyright; others aren't. If I made the laws, which I sadly don't :-) , I would consider a scanned, printed object to be in the same boat as a sketch -- has to be demonstrably transformative and all that. </p>
| 1,000
|
<p>I need to find/create an application that will create employee web usage reports from HTTP proxy logs. Does anyone know of a good product that will do this?</p>
<p><em>@Joe Liversedge - Good point. I don't have to worry about this, however, as I am the only person in my company with the know-how to pull off an SSH tunnel.</em></p>
|
<p>Here's a scenario: What's to stop two employees, let's call them 'Eric' and 'Tim', from running their own little SSH tunnel back home to prevent 'the Man', in this case <em>you</em>, from narc'ing out their use of the Internet. Now you have a useless report.</p>
<p>If you're serious about getting real data, you'll want something close to the pipes.</p>
<p>But agreed, <a href="http://www.splunk.com/" rel="nofollow noreferrer">Splunk</a> would work pretty well, as would an over-long and unmaintainable Perl script or a series of <code>awk</code>s, <code>sort</code>s, <code>uniq -c</code>'s, etc. </p>
|
<p>or Sensage... which has a more formalized model {more like a normal relational database} of data - at the expense of requiring a little more thought and setup cost to start consuming logs. </p>
<p>I don't think that they offer a free low-volume version like splunk do though.</p>
| 6,884
|
<p>If I have .Net Form with a component/object such as a textbox that I need to access from a parent or other form I obviously need to "upgrade" the modifier to this component to an Internal or Public level variable.</p>
<p>Now, if I were providing a public variable of an int or string type etc. in my form class I wouldn't think twice about using Getters and (maybe) Setters around this, even if they didn't do anything other than provide direct access to the variable.</p>
<p>However, the VS designer doesn't seem to implement such Getters/Setters for those public objects that are components on a form (and therefore does not comply with good programming practice).</p>
<p>So, the question is; In order to do the "right thing" should I wrap such VS designer components or objects in a Getter and/or Setter?</p>
|
<p>"<em>However, the VS designer doesn't seem to implement such Getters/Setters for those public objects that are components on a form (and therefore does not comply with good programming practice).</em>"</p>
<p>If you mean the controls you're dragging and dropping onto the form, these are marked as private instance members and are added to the form's Controls collection. Why would they be otherwise? A form could have forty or fifty controls, it'd be somewhat unnecessary and unwieldy to provide a getter/setter for every control on the form. The designer leaves it up to you to provide delegated access to specific controls via public getter/setters.</p>
<p>The designer does the right thing here.</p>
|
<p>I always do that, and if you ARE following an MVP design creating getter/setters for your view components would be a design requirement.</p>
<p>I do not understand what you mean by "does not comply with good programming practice". Microsoft violates <em>a lot</em> of good programming practices to make it easier to create stuff on Visual Studio (for the sake of rapid app development) and I do not see the lack of getters/setters for controls as evidence of violating any such best practices.</p>
| 2,785
|
<p>I'm trying to use <strong>NIS</strong> for authentication on a st of machines. I had to change one of the user ID numbers for a user account on the NIS server (I changed the userid for <code>username</code> from 500 to 509 to avoid a conflict with a local user account with id 500 on the clients). The problem is that it has not updated properly on the client. </p>
<p>In particular, if I do <code>ypcat passwd | grep username</code>, I get the up-to-date info:</p>
<pre><code>username:*hidden*:509:509:User Name:/home/username:/bin/bash
</code></pre>
<p>But if I do, <code>ypmatch username passwd</code>, it says:</p>
<pre><code>username:*hidden*:500:500:User Name:/home/username:/bin/bash
</code></pre>
<p>This means that when the user logs onto one of the clients, it has the wrong userid, which causes all sorts of problems. I've done <code>"cd /var/yp; make"</code> on the server, and <code>"service ypbind restart"</code> on the client, but that hasn't fixed the problem. Does anybody know what would be causing this and how I can somehow force a refresh on the client? (I'm running Fedora 8 on both client and server).</p>
|
<p>John O pointed me in the right direction. </p>
<p>He is right. If you set "files: 0" in /etc/ypserv.conf, you can get ypserv to not cache files. If you have to restart ypserv after each make, this is the problem.</p>
<p>The real solution is to look in /var/log/messages for this error: </p>
<pre><code>ypserv[]: refused connect from 127.0.0.1 to procedure ypproc_clear (,;0)
</code></pre>
<p>makedbm -c means: send YPPROC_CLEAR to the local ypserv. The error message in the log means that CLEAR message is getting denied. You need to add 127.0.0.1 to /var/yp/securenets. </p>
|
<p>hmm, you're not supposed to have to restart the ypserver to have updates take effect; the <em>make</em> in /var/yp ought to do the trick. you might want to check the Makefile in /var/yp to be sure it's triggering on the right conditions (namely, passwd.by* should check the timestamp on /etc/passwd in some fashion, versus its current table. the process used to go through a passwd.time rule on the NIS server i ran, back in the dark ages). killing and restarting your nis server can have funky effects on (particularly non-linux) clients, so be careful doing it willy-nilly.</p>
| 5,268
|
<p>What is the best approach to make sure you only need to authenticate once when using an API built on WCF?</p>
<p>My current bindings and behaviors are listed below</p>
<pre><code> <bindings>
<wsHttpBinding>
<binding name="wsHttp">
<security mode="TransportWithMessageCredential">
<transport/>
<message clientCredentialType="UserName" negotiateServiceCredential="false" establishSecurityContext="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NorthwindBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceAuthorization principalPermissionMode="UseAspNetRoles"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</code></pre>
<p>Next is what I am using in my client app to authenticate (currently I must do this everytime I want to make a call into WCF)</p>
<pre><code>Dim client As ProductServiceClient = New ProductServiceClient("wsHttpProductService")
client.ClientCredentials.UserName.UserName = "foo"
client.ClientCredentials.UserName.Password = "bar"
Dim ProductList As List(Of Product) = client.GetProducts()
</code></pre>
<p>What I would like to do is auth w/ the API once using these credentials, then get some type of token for the period of time my client application is using the web service project. I thought establishsecuritycontext=true did this for me?</p>
|
<p>If you're on an intranet, Windows authentication can be handled for "free" by configuration alone. </p>
<p>If this isn't appropriate, token services work just fine, but for some situations they may be just too much.</p>
<p>The application I'm working on needed bare-bones authentication. Our server and client run inside a (very secure) intranet, so we didn't care too much for the requirement to use an X.509 certificate to encrypt the communication, which is required if you're using username authentication.</p>
<p>So we added a <a href="http://www.winterdom.com/weblog/2006/10/02/CustomWCFBehaviorsThroughAppConfig.aspx" rel="nofollow noreferrer">custom behavior</a> to the client that adds the username and (encrypted) password to the message headers, and another custom behavior on the server that verifies them.</p>
<p>All very simple, required no changes to the client side service access layer or the service contract implementation. And as it's all done by configuration, if and when we need to move to something a little stronger it'll be easy to migrate.</p>
|
<p>While I hate to give an answer I'm not 100% certain of, the lack of responses so far makes me think a potentially correct answer might be okay in this case.</p>
<p>As far as I'm aware there isn't the kind of session token mechanism you're looking for out-of-the-box with WCF which means you're going to have to do some heavy lifting to get things working in the way you want. I should make it clear there is a session mechanism in WCF but it's focused on guaranteeing message orders and is not the ideal tool for creating an authentication session.</p>
<p>I just finished working on a project where we implemented our own session mechanism to handle all manner of legacy SOAP stacks, but I believe the recommended way to implement authenticated sessions is to use a Secure Token Service (STS) like <a href="http://weblogs.asp.net/cibrax/archive/2006/09/08/SAML-_2D00_-STS-implementation-for-WCF.aspx" rel="nofollow noreferrer">Pablo Cibraro's</a>.</p>
<p>If you want more details please shout, but I suspect Pablo's blog will have more than enough info for you to steam ahead.</p>
| 5,066
|
<p>I have a huge ear that uses log4j and there is a single config file that is used to set it up. In this config file there is no mention of certain log files but, additional files apart from those specified in the config file get generated in the logs folder. I've searched for other combinations of (logger|log4j|log).(properties|xml) and haven't found anything promising in all of the jar files included in the ear. How do I track down which is the offending thread/class that is creating these extra files?</p>
|
<p>Try placing a breakpoint in the File class' constructors and the mkdir and createNewFile methods. Generally, code will use the File class to create its files or directories. You should have the Java source code for these classes included with your JVM.</p>
|
<p>Formally SysInternal's, now Microsoft's 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>"Find" menu item -> "Find Handle or DLL..."</p>
| 9,088
|
<p>This query works great:</p>
<pre><code>var pageObject = (from op in db.ObjectPermissions
join pg in db.Pages on op.ObjectPermissionName equals page.PageName
where pg.PageID == page.PageID
select op)
.SingleOrDefault();
</code></pre>
<p>I get a new type with my 'op' fields. Now I want to retrieve my 'pg' fields as well, but</p>
<pre><code>select op, pg).SingleOrDefault();
</code></pre>
<p>doesn't work.</p>
<p>How can I select everything from both tables so that they appear in my new pageObject type?</p>
|
<p>You can use anonymous types for this, i.e.:</p>
<pre><code>var pageObject = (from op in db.ObjectPermissions
join pg in db.Pages on op.ObjectPermissionName equals page.PageName
where pg.PageID == page.PageID
select new { pg, op }).SingleOrDefault();
</code></pre>
<p>This will make pageObject into an IEnumerable of an anonymous type so AFAIK you won't be able to pass it around to other methods, however if you're simply obtaining data to play with in the method you're currently in it's perfectly fine. You can also name properties in your anonymous type, i.e.:-</p>
<pre><code>var pageObject = (from op in db.ObjectPermissions
join pg in db.Pages on op.ObjectPermissionName equals page.PageName
where pg.PageID == page.PageID
select new
{
PermissionName = pg,
ObjectPermission = op
}).SingleOrDefault();
</code></pre>
<p>This will enable you to say:-</p>
<pre><code>if (pageObject.PermissionName.FooBar == "golden goose") Application.Exit();
</code></pre>
<p>For example :-)</p>
|
<p>change </p>
<pre><code>select op)
</code></pre>
<p>to</p>
<pre><code>select new { op, pg })
</code></pre>
| 5,237
|
<p>Context:
I'm in charge of running a service written in .NET. Proprietary application. It uses a SQL Server database. It ran as a user member of the Administrators group in the local machine. It worked alright before I added the machine to a domain.</p>
<p>So, I added the machine to a domain (Win 2003) and changed the user to a member of the Power Users group and now, the</p>
<p>Problem:
Some of the SQL sentences it tries to execute are "magically" in spanish localization (where , separates floating point numbers instead of .), leading to errors. </p>
<blockquote>
<p>There are fewer columns in the INSERT
statement than values specified in the
VALUES clause. The number of values in
the VALUES clause must match the
number of columns specified in the
INSERT statement. at
System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection)</p>
</blockquote>
<p>Operating System and Regional Settings in the machine are in English. I asked the provider of the application and he said:</p>
<blockquote>
<p>Looks like you have a combination of
code running under Spanish locale, and
SQL server under English locale. So
the SQL expects '15.28' and not
'15,28'</p>
</blockquote>
<p>Which looks wrong to me in various levels (how can SQL Server distinguish between commas to separate arguments and commas belonging to a floating point number?).</p>
<p>So, the code seems to be grabbing the spanish locale from somewhere, I don't know if it's the user it runs as, or someplace else (global policy, maybe?). But the question is</p>
<p>What are the places where localization is defined on a machine/user/domain basis?</p>
<p>I don't know all the places I must search for the culprit, so please help me to find it!</p>
|
<p>There are two types of localisation in .NET, both the settings for the cultures can be found in these variables (fire up a .NET command line app on the machine to see what it says):</p>
<p>System.Thread.CurrentThread.CurrentCulture
&
System.Thread.CurrentThread.CurrentUICulture</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.threading.thread_members.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.threading.thread_members.aspx</a></p>
<p>They relate to the settings in the control panel (in the regional settings part).
Create a .NET command line app, then just call ToString() on the above properties, that should tell you which property to look at.</p>
<p><strong>Edit:</strong></p>
<p>It turns out the setting for the locales per user are held here:</p>
<pre><code>HKEY_CURRENT_USER\Control Panel\International
</code></pre>
<p>It might be worth inspecting the registry of the user with the spanish locale, and comparing it to one who is set to US or whichever locale you require.</p>
|
<p>Great, I created the console app and indeed, the app is not crazy, CurrentCulture is in spanish, but for THAT User in THAT machine only. If I run the console app as another user it returns english for all cultures.</p>
<p>Should I open a new question asking where are user-wise locale settings?</p>
| 8,347
|
<p>Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation?</p>
|
<p>If you <em>do</em> find you need to write unique code for an environment, use pythons </p>
<pre><code>import mymodule_jython as mymodule
import mymodule_cpython as mymodule
</code></pre>
<p>have this stuff in a simple module (''module_importer''?) and write your code like this:</p>
<pre><code>from module_importer import mymodule
</code></pre>
<p>This way, all you need to do is alter <code>module_importer.py</code> per platform.</p>
|
<p>I'm pretty sure you already know this but unfortunately Jython <a href="http://www.jython.org/Project/userfaq.html#is-jython-the-same-language-as-python" rel="nofollow noreferrer">can't load c extension modules.</a></p>
| 7,705
|
<p>I am wondering how people that use standalone 3D printers (printers that have the ability to print autonomously from SD Card) feed in filament, prime the printhead and/or change filaments without a laptop ?</p>
<p>Do the printers have a menu to arrange all these tasks ?
I often only see the options to preheat the head to a certain temperature, but not to load/unload filament, extrude a small amount etc.</p>
<p>I understand this differs from printer to printer, but still am wondering about this.</p>
|
<p>My printer (IdeaWerk 150) is very basic and doesn't have any options for this from the screen.</p>
<p>I wrote a really simple GCODE file that brings the nozzle up to temperature, then runs the extruder for a few seconds, then waits, then extrudes for a bit again. I think it does this 3 or 4 times then stops. I can put the file (when converted to .x3g!) onto an SD card and run it whenever I need it.</p>
<p>I have a similar file that allows me to level the bed without a computer by just moving the nozzle around to a few key points on the bed and pausing for a few seconds.</p>
<p>I used a GCODE file generated by my slicer in verbose mode to get started, along with a <a href="http://softsolder.com/2013/03/14/g-code-and-m-code-grand-master-list/">list of codes</a></p>
<p>I don't have these files to hand at the moment, but this is my <code>start.gcode</code>:</p>
<pre><code>(**** beginning of start.txt ****)
(This file is for a WeisTek IdeaWerk 150)
(**** begin initilization commands ****)
G21 (Metric FTW)
G90 (Absolute Positioning)
M18 (This disables the stepper motors.)
G92 X0 Y0 Z0 A0 B0 (Declare the current position to be 0,0,0,0,0)
(**** end initilization commands ****)
(**** begin homing ****)
G161 Y X F2500
G92 X0 Y0 Z0 A0 B0
G1 X5.0 Y5.0 Z-5.0 F450
G162 Z F450
G161 Y X F2500 (Home X axis maximum, go until reaching the end stop.)
G92 Z142.4 ( ** Set Bed Height ** )
G92 X-75 Y-75 (set zero for X and Y)
(**** end homing ****)
M108 R8.0 (Extruder speed = max)
M6 T0 (wait for toolhead parts, nozzle, HBP, etc., to reach temperature)
G1 Z10 F500 (Bring bed up)
M101 (Turn on Extruder)
G04 P8000 (Wait for 8 seconds for flow)
(**** end of start.txt ****)
</code></pre>
<p>If I feed <em>just</em> this file into my printer, it will heat up the nozzle, bring the bed up to about 10cm below printing height and once the nozzle is at temperature, it turns on the extruder for 8 seconds.</p>
<p>Your printer will likely be different to mine - there are a few different flavours of GCODE and you will likely have different XYZ positions, so take a look at some GCODE generated by your own slicer and identify the different parts. The principle is the same.</p>
|
<p>There are options for tablets. They are running software <strong><a href="http://www.3ders.org/articles/20130408-control-3d-printer-with-pengpod-touch-screen-linux-tablet.html" rel="nofollow noreferrer">(for example)</a></strong> on some device that has internal storage, wifi, USB connection etc.
You can buy a new tablet, or reuse your old one just to be a controller. </p>
<p>Another great example is <strong><a href="https://www.matterhackers.com/store/printer-accessories/mattercontrol-touch" rel="nofollow noreferrer">this app</a></strong>.</p>
<p>Apps have menus that can arrange everything for you, now it depends on what app do you use and what filament you use. It's very simple thing.</p>
<p><a href="https://i.stack.imgur.com/oI8Sz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oI8Sz.png" alt="enter image description here"></a></p>
| 180
|
<p>XML, granted, is very useful, but can be quite verbose. What alternatives are there and are they specialised for any particular purpose? Library support to interrogate the contents easily is a big plus point.</p>
|
<p>There seems to be a lot of multi-platform support for <a href="http://www.json.org/" rel="noreferrer">JSON</a>.</p>
|
<p>If you're asking in the perspective of a DSL, <a href="http://www.gnu.org/software/guile/guile.html" rel="nofollow noreferrer">Guile Scheme</a> could help, as already suggested with the S-expressions.</p>
<p>Personally I also use JSON for AJAX transactions.</p>
| 6,592
|
<p>I just saw a <a href="https://stackoverflow.com/questions/5516/what-happened-to-all-of-the-java-developers-how-can-i-get-started-in-net#5522">comment of suggesting J#</a>, and it made me wonder... is there a real, beneficial use of J# over Java? So, my feeling is that the only reason you would even consider using J# is that management has decreed that the company should jump on the Java bandwagon... and the .NET bandwagon. If you use J#, you are effectively losing the biggest benefit of picking Java... rich cross platform support. Sure there is Mono, but it's not as richly supported or as full featured right? I remember hearing Forms are not fully (perhaps at all) supported.</p>
<p>I'm not trying to bash .NET here, I'm just saying, if you are going to go the Microsoft route, why not just use C#? If you are going to go the Java route, why would J# enter the picture?</p>
<p>I'm hoping to find some real world cases here, so please especially respond if you've ACTUALLY used J# in a REAL project, and why.</p>
|
<p>J# is no longer included in VS2008. Unless you already have J# code, you should probably stay away.</p>
<p>From <a href="http://msdn.microsoft.com/en-us/vjsharp/default.aspx" rel="noreferrer">j# product page:</a></p>
<blockquote>
<p>Since customers have told us that the
existing J# feature set largely meets
their needs and usage of J# is
declining, Microsoft is retiring the
Visual J# product and Java Language
Conversion Assistant tool to better
allocate resources for other customer
requirements. The J# language and JLCA
tool will not be available in future
versions of Visual Studio. To preserve
existing customer investments in J#,
Microsoft will continue to support the
J# and JLCA technology that shipped
with Visual Studio 2005 through to
2015 as per our product life-cycle
strategy. For more information, see
Expanded Microsoft Support Lifecycle
Policy for Business & Development
Products.</p>
</blockquote>
|
<p>Strongly agree that syntactically C# beats Java hands down, so there is really no reason to lament the demise of j#. Now trying to get c# compiling to Java bytecode might be an interesting move as Sun's hotspot jvm is great software.</p>
<p>Or, for a bit of fun with what might well become the next generation of Java, how about <a href="http://www.scala-lang.org/node/168" rel="nofollow noreferrer">Scala on the CLR</a>...</p>
| 2,743
|
<p>I woud like to create a cross-platform drawing program. The one requirement for writing my app is that I have pixel level precision over the canvas. For instance, I want to write my own line drawing algorithm rather than rely on someone elses. I do not want any form of anti-aliasing (again, pixel level control is required.) I would like the users interactions on the screen to be quick and responsive (pending my ability to write fast algorithms.)</p>
<p>Ideally, I would like to write this in Python, or perhaps Java as a second choice. The ability to easily make the final app cross-platform is a must. I will submit to different API's on different OS'es if necessary as long as I can write an abstraction layer around them. Any ideas?</p>
<p>addendum: I need the ability to draw <em>on-screen</em>. Drawing out to a file I've got figured out.</p>
|
<p>I just this week put together some slides and demo code for doing 2d graphics using OpenGL from python using the library pyglet. Here's a representative post: <a href="https://www.tartley.com/posts/pyglet-week-2-better-vertex-throughput/" rel="nofollow noreferrer">Pyglet week 2, better vertex throughput</a> (or <a href="https://www.tartley.com/posts/flying-high-hobbyist-opengl-from-python/" rel="nofollow noreferrer">3D stuff using the same basic ideas</a>)</p>
<p>It is very fast (relatively speaking, for python) I have managed to get around 1,000 independently positioned and oriented objects moving around the screen, each with about 50 vertices.</p>
<p>It is very portable, all the code I have written in this environment works on windows and Linux and mac (and even obscure environments like Pypy) without me ever having to think about it.</p>
<p>Some of these posts are very old, with broken links between them. You should be able to find all the relevant posts <a href="https://www.tartley.com/categories/graphics/" rel="nofollow noreferrer">using the 'graphics' tag</a>.</p>
|
<p>QT's Canvas an QPainter are very good for this job if you'd like to use C++. and it is cross platform.</p>
<p>There is a python binding for QT but I've never used it.</p>
<p>As for Java, using SWT, pixel level manipulation of a canvas is somewhat difficult and slow so I would not recommend it. On the other hand Swing's Canvas is pretty good and responsive. I've never used the AWT option but you probably don't want to go there.</p>
| 9,256
|
<p>I converted my company's calendar to XSL and changed all the tables to divs. It worked pretty well, but I had a lot of 8 day week bugs to work out initially owing to precarious cross-browser spacing issues. But I was reading another post regarding when to use tables v. divs and the consensus seemed to be that you should only use divs for true divisions between parts of the webpage, and only use tables for tabular data. </p>
<p>I'm not sure I could even have used tables with XSL but I wanted to follow up that discussion of Divs and Tables with a discussion of the ideal way to make a web calendars and maybe a union of the two. </p>
|
<p>A calendar is the perfect reason to use a table! Calendars inherently present tabular data and HTML tables are good at presenting tabular data. And HTML table markup provides nearly all the CSS hooks you need to associate CSS selectors with various parts of the table to dress it up. </p>
<p>I'm all for using DIVs for layout--but stick with tables for tabular data. </p>
<p>Here is a cool article on how to dress up tables with CSS:
<a href="http://www.smashingmagazine.com/2008/08/13/top-10-css-table-designs" rel="noreferrer">http://www.smashingmagazine.com/2008/08/13/top-10-css-table-designs</a></p>
|
<p>Tables are for displaying tabular data. So I would say <code><table></code> is ideal.</p>
| 6,357
|
<p>What is the Reuse/Release Equivalence Principle and why is it important?</p>
|
<p>The Reuse/Release Equivalence Principle (REP) says:</p>
<blockquote>
<p>The unit of reuse is the unit of release. Effective reuse requires tracking of releases from a change control system. The package is the effective unit of reuse and release.</p>
</blockquote>
<p><b>The unit of reuse is the unit of release</b></p>
<p>Code should not be reused by copying it from one class and pasting it into another. If the original author fixes any bugs in the code, or adds any features, you will not automatically get the benefit. You will have to find out what's changed, then alter your copy. Your code and the original code will gradually diverge.</p>
<p>Instead, code should be reused by including a released library in your code. The original author retains responsibility for maintaining it; you should not even need to see the source code.</p>
<p><b>Effective reuse requires tracking of releases from a change control system</b></p>
<p>The author of a library needs to identify releases with numbers or names of some sort. This allows users of the library to identify different versions. This requires the use of some kind of release tracking system.</p>
<p><b>The package is the effective unit of reuse and release</b></p>
<p>It might be possible to use a class as the unit of reuse and release, however there are so many classes in a typical application, it would be burdensome for the release tracking system to keep track of them all. A larger-scale entity is required, and the package fits this need well.</p>
<p>See also Robert Martin's article on <a href="https://web.archive.org/web/20030614000424/http://objectmentor.com/resources/articles/granularity.pdf" rel="nofollow noreferrer">Granularity</a>.</p>
|
<p>From Clean Architecture, by Robert Martin.</p>
<blockquote>
<p>The Reuse/Release Equivalence Principle (REP) is a principle that seems
obvious, at least in hindsight. People who want to reuse software components
cannot, and will not, do so unless those components are tracked through a
release process and are given release numbers.</p>
<p>This is not simply because, without release numbers, there would be no way to
ensure that all the reused components are compatible with each other. Rather, it
also reflects the fact that software developers need to know when new releases
are coming, and which changes those new releases will bring.</p>
<p>It is not uncommon for developers to be alerted about a new release and decide,
based on the changes made in that release, to continue to use the old release
instead. Therefore the release process must produce the appropriate notifications
and release documentation so that users can make informed decisions about
when and whether to integrate the new release.</p>
</blockquote>
| 8,869
|
<p>I hear that heated beds can help with removing finished prints, but not all printers have them! </p>
<ul>
<li>Is this a nice to have or must have feature? </li>
<li>Are there any downsides to heated beds?</li>
</ul>
|
<p>I'll try to give it a shot as the other answer (perfectly sound answer b.t.w.) does explain <strong>"how"</strong> we use heated beds, but not <strong>"why"</strong> they are actually needed for good prints.</p>
<p>Plastics or polymers are mostly <strong>amorphous</strong> (no macro crystalline structure) and usually relatively hard and brittle at low temperatures (this is referred to as "glassy"). By increasing the temperature of the plastics the state of the material changes as it becomes soft and more ductile (called the viscous or rubbery state). The temperature at which this transition takes place is called the "<strong>glass transition temperature</strong>". It is this temperature where you would heat your bed too (or close to this temperature). Below the glass temperature, the expansion is reduced/low because the polymer chains cannot move easily due to the closer packing and stronger inter-molecular forces; increasing the temperature increases the expansion lowering inter-molecular forces. The difference in stress between the bed and your print is therefore reduced (as of the expansion of the heated polymer).</p>
<p>This explains why we use heated bed to get the prints to stick to the bed. To answer your question why it helps in removing prints is that when the temperature is lowered, the polymer gets back into its "glassy" state, shrinks a bit and automatically loosens the print from the bed. </p>
<p>Indeed for printing PLA you can print without a heated bed, but for materials with a higher glass transition temperature and higher printing temperature it's almost a must to have. Downsides of heated beds are that they require a lot of power and when improperly installed lead to burned wires and connectors. It's usually wise to strain relief the wires from the bed and use proper gauge silicone leads and connectors.</p>
|
<p>There is no simple answer. I will only cover the three main filaments: PLA, ABS, and PETG.</p>
<ul>
<li><p><strong>ABS</strong>: </p>
<ul>
<li>ABS likes to warp, and dislikes breezes and temperature changes. so a heat bed is required, as is some way to keep breezes off and heat in (I use a plastic tarp over my printer). </li>
<li>Although there <em>are</em> print surfaces that will claim to stop the warp. but a print surface can not change the nature of the filament. </li>
<li>A heated bed is pretty much required for ABS</li>
</ul></li>
<li><p><strong>PLA</strong>: </p>
<ul>
<li>PLA is currently the most popular filament, it has low warping tendencies and it likes breezes, and prints really easy. </li>
<li>PLA does not need a heated bed, but if the part is big it may peel off the print surface. </li>
<li>A heated bed is optional but will help with any warping you may encounter.</li>
</ul></li>
<li><p><strong>PETG</strong>: </p>
<ul>
<li>PETG is described as combining the printability of PLA and the strength of ABS. </li>
<li>PETG is quite stringy and has a higher slightly chance of warping then PLA. </li>
<li>A heated bed is recommended, and will help keep it from warping.</li>
</ul></li>
</ul>
<p>Now, for print removal, a heated bed can help as well:</p>
<ul>
<li>Most PLA prints, especially <em>smaller</em> ones will remove just fine without a heated bed, </li>
<li><em>Medium</em> prints having a removal tool will get those off </li>
<li>A heated bed is really helpful for removing <em>large</em> prints or prints that won't release using other methods.</li>
</ul>
| 870
|
<p>Not very technical, but... I have to implement a bad words filter in a new site we are developing. So I need a "good" bad words list to feed my db with... any hint / direction? Looking around with google I <a href="http://urbanoalvarez.es/blog/2008/04/04/bad-words-list/" rel="noreferrer">found this</a> one, and it's a start, but nothing more.</p>
<p>Yes, I know that this kind of filters are easily escaped... but the client will is the client will !!! :-) </p>
<p>The site will have to filter out both english and italian words, but for italian I can ask my colleagues to help me with a community-built list of "parolacce" :-) - an email will do. </p>
<p>Thanks for any help.</p>
|
<p>Beware of <a href="http://thedailywtf.com/Articles/The-Clbuttic-Mistake-.aspx" rel="noreferrer">clbuttic mistakes</a>.</p>
<blockquote>
<p>"Apple made the clbuttic mistake of forcing out their visionary - I mean, look at what NeXT has been up to!"</p>
<p>Hmm. "clbuttic".</p>
<p>Google "clbuttic" - thousands of hits!</p>
<p>There's someone who call his car 'clbuttic'.</p>
<p>There are "Clbuttic Steam Engine" message boards.</p>
<p>Webster's dictionary - no help.</p>
<p>Hmm. What can this be?</p>
<p>HINT: People who make buttumptions about their regex scripts, will be
embarbutted when they repeat this mbuttive mistake.</p>
</blockquote>
|
<p>In researching this topic I determined that what was needed was more than just a list that does arbitrary replacements. I have built a web service that allows you to identify the level of 'cleanliness' you desire. It also makes an effort to identify false positives - i.e. where a word may be bad in one context but not in others.
Take a look at <a href="http://filterlanguage.com" rel="nofollow noreferrer">http://filterlanguage.com</a></p>
| 4,412
|
<p>I'm a beginner. I've a Printrbot Play with a heated bed add-on. I'm using it exclusively with PLA.</p>
<p>It worked great initially, but then I took the nozzle out and put it back in, and the Z calibration was lost (and I didn't know the calibration was a thing). As a result, I started having issues with the piece warping up and not sticking to the bed in the corners and around the edge, when the piece was large and flat.</p>
<p>I've installed the heated bed. I used Kapton tape. All these made it perhaps a little better.</p>
<p>Finally I started tweaking the Z axis calibration (the fine adjustment for the initial distance between nozzle and bed) and that made it perfect. No warping anymore.</p>
<p>But now I have the opposite problem. When printing pieces with large flat surfaces that are siting flush with the bed, it's next to impossible to tear it off at the end.</p>
<p>I went back to using plain blue tape instead of Kapton, but it's still sticking too well to the bottom of the piece. I tried to pry it off by pushing a knife under the piece, but that has put a few scratches on the bed. Obviously I don't want to continue doing that.</p>
<p>What can I do? How to prevent warping, while also making sure the piece does not stick too hard to whatever is underneath?</p>
<hr>
<p><strong>EDIT:</strong> The accepted answer was very good and I don't want to mess with it by adding my own "answer". So here it is:</p>
<p>I ended up adding a glass plate on top of the bed, with a heat conductive layer between bed and plate (it's a funny looking, rubbery, chewing-gum-y material that conducts heat). Now I just apply glue stick on the glass and print. Works great. Large pieces come off on their own sometimes if I let them cool down to 30 C or lower.</p>
<p>I had some issues with the Z calibration sensor due to the plate, eventually got solved, but that would take too long to explain here.</p>
|
<p><strong>Options to check</strong> (in order of probability of occurenece and success):</p>
<ol>
<li>Z-calibration</li>
</ol>
<p>Maybe you should perform calibration again. It's possible that nozzle is now too close which causes the filament is spread on the heatbed, which causes that the bottom surface is "too flat". It means all separate filament tracks are spilled and they create "glass flat" surface. You did mention that the model sticks too much even to kapton. It suggests z-calibration.</p>
<ol start="2">
<li>Temperature calibration</li>
</ol>
<p>Check if the temperature is not too high. Reducing it a bit can reduce sticking. If filament is too soft then material sticks usually better (causes the same as in #1)</p>
<ol start="3">
<li>Heatbed cleaning</li>
</ol>
<p>If your HB is scatched (even not visible scratches) then it's possible that previous printouts left little grains in such scratches. Cleaning HB could then help. Are you using glass? if yes - change glass side to check this option. Eventually replace glass with new one.</p>
<ol start="4">
<li>Heatbed surface</li>
</ol>
<p>If your heatbed is scratched then filament can penetrate such scratches and increase sticking.</p>
<ol start="5">
<li>Filament</li>
</ol>
<p>Did you change filament vendor? If not then maybe your filament had changed during a time/humidity/sun/cigarete smoke. This is very doubtful option but who knows.</p>
<p><strong>What methods you can use to detach model</strong> </p>
<ol>
<li>Paper knife</li>
</ol>
<p>I also have the same problem when I use paper glue stick. Some vendors produce such sticky glue that I affraid to break a glass (which I use of course). When this happens I use a paper knife. Glass is scratchproof enough. <strong>Be careful - if your model suddenly detaches releasing knife... just be careful</strong>. Unmount HB or unmount glass first of course.</p>
<ol start="2">
<li>Hammer</li>
</ol>
<p>I know people use hammer to detach sticked model. I would suggest this method only for big and relatively simple elements. Especially for solids (fully filled with the material, without any grid/honeycomb inner structure). One short hit in the same surface as the HB. Be careful of course and unmount HB or unmount glass first.</p>
<ol start="3">
<li>Fridge</li>
</ol>
<p>As HB material and filament have most likely different thermal shrinkage factor it might help. And guess what - unmount HB/glass first ;)</p>
|
<p>When I started, I got a lot of failed prints due to loss of adhesion. It still happens but much rarer. Dialling in settings improved that, but downside is that parts stay stuck to my glass bed really well even when completely cooled off.</p>
<p>I now use a 30mm paint scraper to peel the brim up as far around the model as possible. I only use a 5mm brim width now, and that seems workable.</p>
<p>I then use the same paint scraper as a chisel right at the end of a part, and push it into the bed so the blade is flexed. Then I tap the handle end with a rubber mallet. This generally either pops the part off completely, or at least lets the blade slip underneath where I can push it further by hand.</p>
<p>I'd prefer perfect adhesion, but would rather have over-adhesion than under-adhesion.</p>
| 373
|
<p>This line in YUI's <a href="http://developer.yahoo.com/yui/reset/" rel="nofollow noreferrer">Reset CSS</a> is causing trouble for me:</p>
<pre class="lang-css prettyprint-override"><code>address,caption,cite,code,dfn,em,strong,th,var {
font-style: normal;
font-weight: normal;
}
</code></pre>
<p>It makes my <code>em</code> not italic and my <code>strong</code> not bold. Which is okay. I know how to override that in my own stylesheet.</p>
<pre class="lang-css prettyprint-override"><code>strong, b
{
font-weight: bold;
}
em, i
{
font-style: italic;
}
</code></pre>
<p>The problem comes in when I have text that's both <code>em</code> and <code>strong</code>. </p>
<pre><code><strong>This is bold, <em>and this is italic, but not bold</em></strong>
</code></pre>
<p>My rule for <code>strong</code> makes it bold, but YUI's rule for <code>em</code> makes it normal again. How do I fix that? </p>
|
<p>If your strong declaration comes after YUI's yours should override it. You can force it like this:</p>
<pre><code>strong, b, strong *, b * { font-weight: bold; }
em, i, em *, i * { font-style: italic; }
</code></pre>
<p>If you still support IE7 you'll need to add <code>!important</code>.</p>
<pre><code>strong, b, strong *, b * { font-weight: bold !important; }
em, i, em *, i * { font-style: italic !important; }
</code></pre>
<p>This works - see for yourself:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>/*YUI styles*/
address,caption,cite,code,dfn,em,strong,th,var {
font-style: normal;
font-weight: normal;
}
/*End YUI styles =*/
strong, b, strong *, b * {
font-weight: bold;
}
em, i, em *, i * {
font-style: italic;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <strong>Bold</strong> - <em>Italic</em> - <strong>Bold and <em>Italic</em></strong></code></pre>
</div>
</div>
</p>
|
<p>I thought I had an ideal solution:</p>
<pre><code>strong, b
{
font-weight: bold;
font-style: inherit;
}
em, i
{
font-style: italic;
font-weight: inherit;
}
</code></pre>
<p>Unfortunately, Internet Explorer doesn't support "inherit." :-(</p>
| 4,046
|
<p>At my day job we have load balanced web servers which talk to load balanced app servers via web services (and lately WCF). At any given time, we have 4-6 different teams that have the ability to add new web sites or services or consume existing services. We probably have about 20-30 different web applications and corresponding services.</p>
<p>Unfortunately, given that we have no centralized control over this due to competing priorities, org structures, project timelines, financial buckets, etc., it is quite a mess. We have a variety of services that are reused, but a bunch that are specific to a front-end.</p>
<p>Ideally we would have better control over this situation, and we are trying to get control over it, but that is taking a while. One thing we would like to do is find out more about what all of the inter-relationships between web sites and the app servers.</p>
<p>I have used Reflector to find dependencies among assemblies, but would like to be able to see the traffic patterns between services. </p>
<p>What are the options for trying to map out web service relationships? For the most part, we are mainly talking about internal services (web to app, app to app, batch to app, etc.). Off the top of my head, I can think of two ways to approach it:</p>
<ul>
<li>Analyze assemblies for any web references. The drawback here is that not everything is a web reference and I'm not sure how WCF connections are listed. However, this would at least be a start for finding 80% of the connections. Does anyone know of any tools that can do that analysis? Like I said, I've used Reflector for assembly references but can't find anything for web references.</li>
<li>Possibly tap into IIS and passively monitor the traffic coming in and out and somehow figure out what is being called and where from. We are looking at enterprise tools that could help but it would be a while before they are implemented (and cost a lot). But is there anything out there that could help out quickly and cheaply? One tool in particular (AmberPoint) can tap into IIS on the servers and monitor inbound and outbound traffic, adds a little special sauce and begin to build a map of the traffic. Very nice, but costs a bundle. </li>
</ul>
<p>I know, I know, how the heck did you get into this mess in the first place? Beats me, just trying to help us get control of it and get out of it.</p>
<p>Thanks,
Matt</p>
|
<p>The easiest way is to look through the logs, but if that doesn't include the referrer than you may also want to monitor what is going out from your web to the app server. You can use tools like Wireshark or Microsoft Network Monitor to see this traffic.</p>
<p>The other "solution" and I use this loosely is to bind a specific web server to app server and then run through a bundle and see what it is hitting on the app server. You could probably do this in a test environment to lesson the effects on the users of the site.</p>
|
<p>You need a service registry (UDDI??)... If you had a means to catalog these services and their consumers, it would make this job of dependency discovery a lot easier. That is not an easy solution, though. It takes time and documentation to get a catalog in place.</p>
<p>I think the quickest solution would be to query your IIS logs and find source URLs which originate from your own servers. You would at least be able to track down which servers your consumers are coming from.</p>
<p>Also, if you already have some kind of authentication mechanism in place, you could trace who is using a particular service based on login.</p>
<p>You are right about AmberPoint. There are other tools that catalog the service traffic and provide reports showing what is happening to your services. Systinet, SOA Software and Actional also has a products similar to Amberpoint but Amberpoint has a free-ware version, I believe.</p>
| 6,641
|
<p>Is anyone aware of a language feature or technique in C++ to prevent a child class from over riding a particular method in the parent class?</p>
<pre><code>class Base {
public:
bool someGuaranteedResult() { return true; }
};
class Child : public Base {
public:
bool someGuaranteedResult() { return false; /* Haha I broke things! */ }
};
</code></pre>
<p>Even though it's not virtual, this is still allowed (at least in the Metrowerks compiler I'm using), all you get is a compile time warning about hiding non-virtual inherited function X.</p>
|
<p>A couple of ideas:</p>
<ol>
<li>Make your function private.</li>
<li>Do not make your function virtual. This doesn't actually prevent the function from being shadowed by another definition though.</li>
</ol>
<p>Other than that, I'm not aware of a language feature that will lock away your function in such a way which prevents it from being overloaded and still able to be invoked through a pointer/reference to the child class.</p>
<p>Good luck!</p>
|
<p>C++ methods are private and un-overridable by default.</p>
<ul>
<li>You cannot override a private method</li>
<li>You cannot override a non-<code>virtual</code> method</li>
</ul>
<p>Are you perhaps referring to overloading?</p>
| 3,812
|
<p>I'd like some advice regarding defects on my print :
<a href="https://i.stack.imgur.com/5x4u2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5x4u2.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/3CgUe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3CgUe.jpg" alt="enter image description here"></a></p>
<p>Here some details :</p>
<ul>
<li>Printer CR-10 S, nozzle 0.4</li>
<li>Material PLA</li>
<li>Bed 60, Hotend 215, 50 mm/s speed</li>
<li>SLiced with cura 4.1, 5 walls (i can provide more detail of the profile if needed)</li>
<li>Layer height 0.1</li>
<li>modeled on fusion 360</li>
<li>The surface where the defect sits is actually tilted 45 degres</li>
</ul>
<p>Thanks !</p>
|
<p>If you break up a large piece into multiple smaller pieces and properly glue them together, you basically add stiffeners (as a result of printing walls). This could lead to a more stiff model; this might have been confused by calling large prints more brittle opposed to constructed models.</p>
<p>If printing is conducted at similar conditions on large printers, there shouldn't be a reason why the model becomes more brittle unless the conditions aren't the same. But that would be true for printing at small printers too, e.g. if one print was printed in a draft.</p>
|
<p>I'd recommend getting the object to fit together by design, rather than glue - though I tend (if the item is never to be disassembled) use Zap-a-gap - that stuff sticks like crazy though you must not squeeze the parts together but let it naturally sit.</p>
| 1,354
|
<p>How would you find the fractional part of a floating point number in PHP?</p>
<p>For example, if I have the value <code>1.25</code>, I want to return <code>0.25</code>.</p>
|
<pre><code>$x = $x - floor($x)
</code></pre>
|
<p>To stop the confusion on this page actually this is the best answer, which is fast and works for both positive and negative values of $x:</p>
<pre><code>$frac=($x<0) ? $x-ceil($x) : $x-floor($x);
</code></pre>
<p>I ran speed tests of 10 million computations on PHP 7.2.15 and even though both solutions give the same results, fmod is slower than floor/ceil. </p>
<p><code>$frac=($x<0) ? $x-ceil($x) : $x-floor($x);</code>
-> 490-510 ms (depending on the sign of $x) </p>
<p><code>$frac=fmod($x, 1);</code>
-> 590 - 1000 ms (depending on the value of $x) </p>
<p>Whereas the actual empty loop itself takes 80 ms (which is included in above timings). </p>
<p>Test script:</p>
<pre><code>$x=sqrt(2)-0.41421356237;
$time_start = microtime(true);
for ($i=0;$i<=9999999;$i++) {
//$frac=fmod($x, 1); // version a
$frac=($x<0) ? $x-ceil($x) : $x-floor($x); // version b
}
$time_end = microtime(true);
$time = $time_end - $time_start;
</code></pre>
| 7,360
|
<p>I'm trying to set up a Creality Sprite Extruder on my Ender 3 Pro without using the kit (installing the extruder alone).</p>
<p>I can see <a href="https://store.creality.com/products/sprite-extruder-pro-kit-300%E2%84%83-printing?official-website-top=&spm=..product_0f7e137a-4505-43ca-958f-022f372863a0.products_display_1.1" rel="nofollow noreferrer">here</a> that the extruder operates at 1.4VDC and 0.8A.</p>
<p>I'm using TMC2208 and Klipper. How can I set my extruder's driver up so that the provided voltage is 1.4V? Is it the same as setting the VRef to 1.4V?
Can it be done in the Klipper config (I have UART set up) or does it need to be done on the trimpot?</p>
<p>Thanks</p>
|
<p>Since I have been unable to find a way to fix the E3D V6 clone hotend I have instead replaced it with a Creality Mk 8 that I had on-hand, which has so far worked flawlessly.</p>
<p>I am assuming that the improved performance is related to the use of a shorter nozzle and/or the Bowden tube butting directly against the nozzle instead of interfacing with an all-metal heat-break. Those seem to be the biggest differences between the two designs.</p>
|
<p>I had issues with my all metal hot-end where I got heat creep. I ended up doing e-steps, PID tune, and ensuring my speed wasn't too slow either. Is your printer in an enclosure? I found that mine being in an enclosure caused the hotend to not cool sufficiently, so I had to lower the hot bed temp by 10 degrees and that seems to have resolved my issue for heat creep. I also have the Hero Me fan housing which improves airflow.</p>
| 2,171
|
<p>What is a good challenge to improve your skills in object oriented programming?</p>
<p>The idea behind this poll is to provide an idea of which exercises are useful for learning OOP.</p>
<p>The challenge should be as language agnostic as possible, requiring either little or no use of specific libraries, or only the most common of libraries. Try to include only one challenge per answer, so that a vote will correspond to the merits of that challenge alone. Would also be nice if a level of skill required was indicated, and also the rationale behind why it is a useful exercise.</p>
<p>Solutions to the challenges could then be posted as answers to a "How to..." question and linked to from here.</p>
<p>For example:</p>
<ul>
<li>Challenge - implement a last-in-first-out stack</li>
<li>Skill level - beginner</li>
<li>Rationale - gives experience of how to reference objects</li>
</ul>
|
<p><a href="https://www.itmaybeahack.com/homepage/books" rel="nofollow noreferrer">Building Skills in Object-Oriented Design</a> is a free book that might be of use.</p>
<p>The description is as follows:</p>
<p>"The intent of this book is to help the beginning designer by giving them a sequence of interesting and moderately complex exercises in OO design. This book can also help managers develop a level of comfort with the process of OO software development. The applications we will build are a step above trivial, and will require some careful thought and design. Further, because the applications are largely recreational in nature, they are interesting and engaging. This book allows the reader to explore the processes and artifacts of OO design before project deadlines make good design seem impossible."</p>
|
<p>A given task has very little to do with being "OOP", it's more in how you grade it.</p>
<p>I would look at the Refactoring book, chapter 3, and make sure none of the bad code smells exist in the solution. Or, more importantly, go over ones that do apply.</p>
<p>Most importantly, watch for the existence of setters and getters (indicating that you are operating on values from a class and not asking the class to operate on it's own values)--or using "extends" without applying the Liskov Substitution Principle, stuff like that.</p>
| 8,492
|
<p>I'm trying to add support for stackoverflow feeds in my rss reader but <strong>SelectNodes</strong> and <strong>SelectSingleNode</strong> have no effect. This is probably something to do with ATOM and xml namespaces that I just don't understand yet.</p>
<p>I have gotten it to work by removing all attributes from the <strong>feed</strong> tag, but that's a hack and I would like to do it properly. So, how do you use <strong>SelectNodes</strong> with atom feeds?</p>
<p>Here's a snippet of the feed.</p>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:thr="http://purl.org/syndication/thread/1.0">
<title type="html">StackOverflow.com - Questions tagged: c</title>
<link rel="self" href="http://stackoverflow.com/feeds/tag/c" type="application/atom+xml" />
<subtitle>Check out the latest from StackOverflow.com</subtitle>
<updated>2008-08-24T12:25:30Z</updated>
<id>http://stackoverflow.com/feeds/tag/c</id>
<creativeCommons:license>http://www.creativecommons.org/licenses/by-nc/2.5/rdf</creativeCommons:license>
<entry>
<id>http://stackoverflow.com/questions/22901/what-is-the-best-way-to-communicate-with-a-sql-server</id>
<title type="html">What is the best way to communicate with a SQL server?</title>
<category scheme="http://stackoverflow.com/feeds/tag/c/tags" term="c" /><category scheme="http://stackoverflow.com/feeds/tag/c/tags" term="c++" /><category scheme="http://stackoverflow.com/feeds/tag/c/tags" term="sql" /><category scheme="http://stackoverflow.com/feeds/tag/c/tags" term="mysql" /><category scheme="http://stackoverflow.com/feeds/tag/c/tags" term="database" />
<author><name>Ed</name></author>
<link rel="alternate" href="http://stackoverflow.com/questions/22901/what-is-the-best-way-to-communicate-with-a-sql-server" />
<published>2008-08-22T05:09:04Z</published>
<updated>2008-08-23T04:52:39Z</updated>
<summary type="html">&lt;p&gt;I am going to be using c/c++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one?&lt;/p&gt;</summary>
<link rel="replies" type="application/atom+xml" href="http://stackoverflow.com/feeds/question/22901/answers" thr:count="2"/>
<thr:total>2</thr:total>
</entry>
</feed>
</code></pre>
<p><br/></p>
<h2>The Solution</h2>
<pre><code>XmlDocument doc = new XmlDocument();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
doc.Load(feed);
// successful
XmlNodeList itemList = doc.DocumentElement.SelectNodes("atom:entry", nsmgr);
</code></pre>
|
<p>Don't confuse the namespace names in the XML file with the namespace names for your namespace manager. They're both shortcuts, and they don't necessarily have to match.</p>
<p>So you can register "<a href="http://www.w3.org/2005/Atom" rel="noreferrer">http://www.w3.org/2005/Atom</a>" as "atom", and then do a SelectNodes for "atom:entry".</p>
|
<p>I just want to use..</p>
<pre><code>XmlNodeList itemList = xmlDoc.DocumentElement.SelectNodes("entry");
</code></pre>
<p>but, what namespace do the <strong>entry</strong> tags fall under? I would assume xmlns="http://www.w3.org/2005/Atom", but it has no title so how would I add that namespace?</p>
<pre><code>XmlDocument document = new XmlDocument();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
nsmgr.AddNamespace("", "http://www.w3.org/2005/Atom");
document.Load(feed);
</code></pre>
<p>Something like that?</p>
| 4,440
|
<p>I've created a learning application using <a href="http://jimneath.org/2008/09/09/bort-base-rails-application/" rel="noreferrer">Bort</a>, which is a base app that includes Restful Authentication and RSpec. I've got it up and running and added a new object that requires users to be logged in before they can do anything(<code>before_filter :login_required</code> in the controller). [edit: I should also mention that the user <code>has_many</code> of the new class and only the user should be able to see it.]</p>
<p>I've created the new model/controller using Rspec's generators which have created a number of default tests. They all pass if there is no <code>before_filter</code> but several fail, as should be expected, once the <code>before_filter</code> is in place.</p>
<p>How do I get the generated tests to run as if there is/is not a logged in user? Do I need a whole batch of matching not logged in - redirect tests? I assume it is some sort of mocking or fixture technique but I am new to RSpec and a bit adrift. Good RSpec tutorial links would also be appreciated.</p>
|
<p>I have a very similar setup, and below is the code I'm currently using to test this stuff. In each of the <code>describe</code>s I put in:</p>
<pre><code>it_should_behave_like "login-required object"
def attempt_access; do_post; end
</code></pre>
<p>If all you need is a login, or</p>
<pre><code>it_should_behave_like "ownership-required object"
def login_as_object_owner; login_as @product.user; end
def attempt_access; do_put; end
def successful_ownership_access
response.should redirect_to(product_url(@product))
end
</code></pre>
<p>If you need ownership. Obviously, the helper methods change (very little) with each turn, but this does most of the work for you. This is in my spec_helper.rb</p>
<pre><code>shared_examples_for "login-required object" do
it "should not be able to access this without logging in" do
attempt_access
response.should_not be_success
respond_to do |format|
format.html { redirect_to(login_url) }
format.xml { response.status_code.should == 401 }
end
end
end
shared_examples_for "ownership-required object" do
it_should_behave_like "login-required object"
it "should not be able to access this without owning it" do
attempt_access
response.should_not be_success
respond_to do |format|
format.html { response.should be_redirect }
format.xml { response.status_code.should == 401 }
end
end
it "should be able to access this if you own it" do
login_as_object_owner
attempt_access
if respond_to?(:successful_ownership_access)
successful_ownership_access
else
response.should be_success
end
end
end
</code></pre>
|
<p>To mock a user being logged in, I hack into the controller to set <code>@current_user</code> manually:</p>
<pre><code>module AuthHelper
protected
def login_as(model, id_or_attributes = {})
attributes = id_or_attributes.is_a?(Fixnum) ? {:id => id} : id_or_attributes
@current_user = stub_model(model, attributes)
target = controller rescue template
target.instance_variable_set '@current_user', @current_user
if block_given?
yield
target.instance_variable_set '@current_user', nil
end
return @current_user
end
def login_as_user(id_or_attributes = {}, &block)
login_as(User, id_or_attributes, &block)
end
end
</code></pre>
| 9,045
|
<p>I need to create a linked server to a DB2 database on a mainframe. Has anyone done this successfully on a 64-bit version of SQL Server 2005? If so, which provider and settings were used?</p>
<p>It's important that the linked server work whether we are using a Windows authenticated account to login to SQL Server or a SQL Server login. It's also important that both the 4-part name and <code>OPENQUERY</code> query methods are functional. We have one set up on a SQL Server 2000 machine that works well, but it uses a provider that's not available for 64-bit SS 2005.</p>
|
<p>We had this same issue with a production system late last year (sept 2007) and the official word from our Microsoft contact was that they had a 64 bit oledb driver to connect to ASI/DB2 <strong>but</strong> it was in <strong>BETA</strong> at the time.</p>
<p>Not sure when it will be out of beta but that was the news as of last year.</p>
<p>We decided to move the production server onto a 32 bit machine since we were not comfortable using beta drivers on production systems.</p>
<p>I know this doesn't <em>answer</em> your question but it hopefully gives you some insight</p>
|
<p>What provider are you using for Sql 2000? I'm pretty sure MS has an x64 OLEDB driver for DB2 (part of Host Integration Server, but available as a separate download). IBM has x64 for .NET and ODBC, and possible OLEDB as well (though it's a PITA to find).</p>
<p>Once you get the linked server setup, I'm pretty sure all of your other requirements would be automatic....</p>
| 3,208
|
<p>Is there an easy way to read an entire Access file (.mdb) into a DataSet in .NET (specifically C# or VB)?</p>
<p>Or at least to get a list of tables from an access file so that I can loop through it and add them one at a time into a DataSet?</p>
|
<p>Thanks for the suggestions. I was able to use those samples to put together this code, which seems to achieve what I'm looking for.</p>
<pre><code>Using cn = New OleDbConnection(connectionstring)
cn.Open()
Dim ds As DataSet = new DataSet()
Dim Schema As DataTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
For i As Integer = 0 To Schema.Rows.Count - 1
Dim dt As DataTable = New DataTable(Schema.Rows(i)!TABLE_NAME.ToString())
Using adapter = New OleDbDataAdapter("SELECT * FROM " + Schema.Rows(i)!TABLE_NAME.ToString(), cn)
adapter.Fill(dt)
End Using
ds.Tables.Add(dt)
Next i
End Using
</code></pre>
|
<p>There is a discussion on this point in <a href="http://forum.lessthandot.com/viewtopic.php?f=95&t=1262" rel="nofollow noreferrer">Less Than Dot</a>. Here is one example of code from the discussion.</p>
<pre><code> public DataTable GetColumns(string tableName)
{
string[] restrictions = new string[4];
restrictions[2] = tableName;
_connDb.Open();
DataTable mDT = _connDb.GetSchema("Columns", restrictions);
_connDb.Close();
return mDT;
}
</code></pre>
| 6,859
|
<p>What is the Java equivalent of PHP's <code>$_POST</code>? After searching the web for an hour, I'm still nowhere closer.</p>
|
<p>Your <code>HttpServletRequest</code> object has a <code>getParameter(String paramName)</code> method that can be used to get parameter values. <a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)" rel="noreferrer">http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)</a></p>
|
<p>For getting all post parameters there is Map which contains request param name as key and param value as key.</p>
<pre><code>Map params = servReq.getParameterMap();
</code></pre>
<p>And to get parameters with known name normal</p>
<pre><code>String userId=servReq.getParameter("user_id");
</code></pre>
| 2,718
|
<p>What profilers have you used when working with .net programs, and which would you particularly recommend?</p>
|
<p>I have used <a href="http://www.jetbrains.com/profiler/" rel="noreferrer">JetBrains dotTrace</a> and <a href="http://www.red-gate.com/products/ants_performance_profiler/" rel="noreferrer">Redgate ANTS</a> extensively. They are fairly similar in features and price. They both offer useful performance profiling and quite basic memory profiling.</p>
<p>dotTrace integrates with Resharper, which is really convenient, as you can profile the performance of a unit test with one click from the IDE. However, dotTrace often seems to give spurious results (e.g. saying that a method took several years to run)</p>
<p>I prefer the way that ANTS presents the profiling results. It shows you the source code and to the left of each line tells you how long it took to run. dotTrace just has a tree view.</p>
<p><a href="http://www.eqatec.com/Profiler/" rel="noreferrer">EQATEC profiler</a> is quite basic and requires you to compile special instrumented versions of your assemblies which can then be run in the EQATEC profiler. It is, however, free.</p>
<p>Overall I prefer ANTS for performance profiling, although if you use Resharper then the integration of dotTrace is a killer feature and means it beats ANTS in usability.</p>
<p>The free Microsoft CLR Profiler (<a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13382" rel="noreferrer">.Net framework 2.0</a> / <a href="http://www.microsoft.com/download/en/details.aspx?id=16273" rel="noreferrer">.Net Framework 4.0</a>) is all you need for .NET memory profiling.</p>
<p><strong>2011 Update:</strong></p>
<p>The <a href="http://memprofiler.com/" rel="noreferrer">Scitech memory profiler</a> has quite a basic UI but lots of useful information, including some information on unmanaged memory which dotTrace and ANTS lack - you might find it useful if you are doing COM interop, but I have yet to find any profiler that makes COM memory issues easy to diagnose - you usually have to break out <code>windbg.exe</code>.</p>
<p>The ANTS profiler has come on in leaps and bounds in the last few years, and its memory profiler has some truly useful features which now pushed it ahead of dotTrace as a package in my estimation. I'm lucky enough to have licenses for both, but if you are going to buy one .Net profiler for both performance and memory, make it ANTS.</p>
|
<p>I've found plenty of problems in a big C# app using <a href="https://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024">this</a>.</p>
<p>Usually the problem occurs during startup or shutdown as plugins are being loaded, and big data structures are being created, destroyed, serialized, or deserialized. Often they are created and initialized more than once, and change handlers get added multiple times, further compounding the problem.</p>
<p>In cases like this, the program can be so sluggish that only 2 samples are sufficient to pinpoint the guilty method / function / property call sites.</p>
| 2,596
|
<p>I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does.</p>
<p>I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?</p>
<p>(I really want the Cursor Position on that line, not 'column', per se)</p>
|
<pre><code>int line = textbox.GetLineFromCharIndex(textbox.SelectionStart);
int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line);
</code></pre>
|
<p>Off the top of my head, I think you want the SelectionStart property.</p>
| 9,198
|
<p>I've been working with <a href="http://msdn.microsoft.com/en-us/library/aa479030.aspx" rel="noreferrer">providers</a> a fair bit lately, and I came across an interesting situation where I wanted to have an abstract class that had an abstract static method. I read a few posts on the topic, and it sort of made sense, but is there a nice clear explanation?</p>
|
<p>Static methods are not <em>instantiated</em> as such, they're just available without an object reference.</p>
<p>A call to a static method is done through the class name, not through an object reference, and the Intermediate Language (IL) code to call it will call the abstract method through the name of the class that defined it, not necessarily the name of the class you used.</p>
<p>Let me show an example.</p>
<p>With the following code:</p>
<pre><code>public class A
{
public static void Test()
{
}
}
public class B : A
{
}
</code></pre>
<p>If you call B.Test, like this:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
B.Test();
}
}
</code></pre>
<p>Then the actual code inside the Main method is as follows:</p>
<pre><code>.entrypoint
.maxstack 8
L0000: nop
L0001: call void ConsoleApplication1.A::Test()
L0006: nop
L0007: ret
</code></pre>
<p>As you can see, the call is made to A.Test, because it was the A class that defined it, and not to B.Test, even though you can write the code that way.</p>
<p>If you had <em>class types</em>, like in Delphi, where you can make a variable referring to a type and not an object, you would have more use for virtual and thus abstract static methods (and also constructors), but they aren't available and thus static calls are non-virtual in .NET.</p>
<p>I realize that the IL designers could allow the code to be compiled to call B.Test, and resolve the call at runtime, but it still wouldn't be virtual, as you would still have to write some kind of class name there.</p>
<p>Virtual methods, and thus abstract ones, are only useful when you're using a variable which, at runtime, can contain many different types of objects, and you thus want to call the right method for the current object you have in the variable. With static methods you need to go through a class name anyway, so the exact method to call is known at compile time because it can't and won't change.</p>
<p>Thus, virtual/abstract static methods are not available in .NET.</p>
|
<p>The abstract methods are implicitly virtual. Abstract methods require an instance, but static methods do not have an instance. So, you can have a static method in an abstract class, it just cannot be static abstract (or abstract static).</p>
| 2,547
|
<p>In my web application there is a process that queries data from all over the web, filters it, and saves it to the database. As you can imagine this process takes some time. My current solution is to increase the page timeout and give an AJAX progress bar to the user while it loads. This is a problem for two reasons - 1) it still takes to long and the user must wait 2) it sometimes still times out.</p>
<p>I've dabbled in threading the process and have read I should async post it to a web service ("Fire and forget").</p>
<p>Some references I've read:<br>
- <a href="http://msdn.microsoft.com/en-us/library/ms978607.aspx#diforwc-ap02_plag_howtomultithread" rel="nofollow noreferrer">MSDN</a><br>
- <a href="http://aspalliance.com/329" rel="nofollow noreferrer">Fire and Forget</a></p>
<p>So my question is - what is the best method?</p>
<p>UPDATE: After the user inputs their data I would like to redirect them to the results page that incrementally updates as the process is running in the background.</p>
|
<p>To avoid excessive architecture astronomy, I often <a href="http://encosia.com/2007/10/03/easy-incremental-status-updates-for-long-requests/" rel="nofollow noreferrer">use a hidden iframe to call the long running process and stream back progress information</a>. Coupled with something like <a href="http://www.bram.us/demo/projects/jsprogressbarhandler/" rel="nofollow noreferrer">jsProgressBarHandler</a>, you can pretty easily create great out-of-band progress indication for longer tasks where a generic progress animation doesn't cut it.</p>
<p>In your specific situation, you may want to use one LongRunningProcess.aspx call per task, to avoid those page timeouts. </p>
<p>For example, call LongRunningProcess.aspx?taskID=1 to kick it off and then at the end of that task, emit a </p>
<pre><code>document.location = "LongRunningProcess.aspx?taskID=2".
</code></pre>
<p>Ad nauseum.</p>
|
<ol>
<li>How are you querying the remote data?</li>
<li>How often does it change?</li>
<li>Are the results something that could be cached for a period of time?</li>
<li>How long a period of time are we actually talking about here?</li>
</ol>
<p>The 'best method' is likely to depend in some way on the answers to these questions...</p>
| 9,869
|
<p>How can i format currency related data in a manner that is culture aware in JavaScript?</p>
|
<p>Dojo has a <a href="http://api.dojotoolkit.org/jsdoc/dojo/HEAD/dojo.currency.format" rel="nofollow noreferrer">currency formatter</a> that's locale aware. </p>
<p>If you don't want to include Dojo in your project just for this function, then perhaps you can localize the currency in your back-end?</p>
|
<p>there is a Number.localeFormat function but I'm not sure it's what your after</p>
<p><a href="http://msdn.microsoft.com/en-gb/library/bb310813.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-gb/library/bb310813.aspx</a></p>
| 7,468
|
<p>I came across <a href="http://www.ddj.com/cpp/184403758" rel="noreferrer">this article</a> written by Andrei Alexandrescu and Petru Marginean many years ago, which presents and discusses a utility class called ScopeGuard for writing exception-safe code. I'd like to know if coding with these objects truly leads to better code or if it obfuscates error handling, in that perhaps the guard's callback would be better presented in a catch block? Does anyone have any experience using these in actual production code?</p>
|
<p>It definitely improves your code. Your tentatively formulated claim, that it's obscure and that code would merit from a <code>catch</code> block is simply not true in C++ because RAII is an established idiom. Resource handling in C++ <em>is</em> done by resource acquisition and garbage collection is done by implicit destructor calls.</p>
<p>On the other hand, explicit <code>catch</code> blocks would bloat the code and introduce subtle errors because the code flow gets much more complex and resource handling has to be done explicitly.</p>
<p>RAII (including <code>ScopeGuard</code>s) isn't an obscure technique in C++ but firmly established best-practice.</p>
|
<p>My experience shows that usage of <code>scoped_guard</code> is far inferior to any of the short reusable RAII classes that you can write by hand.</p>
<p>Before trying the <code>scoped_guard</code>, I had written RAII classes to</p>
<ul>
<li>set GLcolor or GLwidth back to the original, once I've drawn a shape</li>
<li>make sure a file has <code>fclose</code>d once I had <code>fopen</code>ed it.</li>
<li>reset a mouse pointer to its initial state, after I've changed it to gears/hourgrlass during a execution of a slow function</li>
<li>reset the <code>sorting</code> state of a QListView's back to its previous state, once I've temporarily finished with altering its <code>QListViewItems</code> -- I did not want the list to reorder itself everytime I changed the text of a single item...</li>
</ul>
<h1>using simple RAII class</h1>
<p>Here's how my code looked like with my hand-crafted RAII classes:</p>
<pre class="lang-cpp prettyprint-override"><code>class scoped_width {
int m_old_width;
public:
scoped_width(int w) {
m_old_width = getGLwidth();
setGLwidth(w);
}
~scoped_width() {
setGLwidth(m_old_width);
}
};
void DrawTriangle(Tria *t)
{
// GLwidth=1 here
auto guard = scoped_width(2); // sets GLwidth=2
draw_line(t->a, t->b);
draw_line(t->b, t->c);
draw_line(t->c, t->a);
setGLwidth(5);
draw_point(t->a);
draw_point(t->b);
draw_point(t->c);
} // scoped_width sets GLwidth back to 1 here
</code></pre>
<p>Very simple implementation for <code>scoped_width</code>, and quite reusable.
Very simple and readable from the consumer side, also.</p>
<h1>using <code>scoped_guard</code> (C++14)</h1>
<p>Now, with the <code>scoped_guard</code>, I have to capture the existing value in the introducer (<code>[]</code>) in order to pass it to the guard's callback:</p>
<pre class="lang-cpp prettyprint-override"><code>void DrawTriangle(Tria *t)
{
// GLwidth=1 here
auto guard = sg::make_scoped_guard([w=getGLwidth()](){ setGLwidth(w); }); // capture current GLwidth in order to set it back
setGLwidth(2); // sets GLwidth=2
draw_line(t->a, t->b);
draw_line(t->b, t->c);
draw_line(t->c, t->a);
setGLwidth(5);
draw_point(t->a);
draw_point(t->b);
draw_point(t->c);
} // scoped_guard sets GLwidth back to 1 here
</code></pre>
<p>The above doesn't even work on C++11.
Not to mention that trying to introduce the state to the lambda this way hurts my eyes.</p>
<h1>using <code>scoped_guard</code> (C++11)</h1>
<p>In C++11 you have to do this:</p>
<pre class="lang-cpp prettyprint-override"><code>void DrawTriangle(Tria *t)
{
// GLwidth=1 here
int previous_width = getGLwidth(); // explicitly capture current width
auto guard = sg::make_scoped_guard([=](){ setGLwidth(previous_width); }); // pass it to lambda in order to set it back
setGLwidth(2); // sets GLwidth=2
draw_line(t->a, t->b);
draw_line(t->b, t->c);
draw_line(t->c, t->a);
setGLwidth(5);
draw_point(t->a);
draw_point(t->b);
draw_point(t->c);
} // scoped_guard sets GLwidth back to 1 here
</code></pre>
<p>As you can see,</p>
<ul>
<li><p>the <code>scoped_guard</code> snoppet requires</p>
<ul>
<li>3 lines to keep previous value (state) and set it to a new one, and</li>
<li>2 stack variables (<code>previous_width</code> and <code>guard</code>, again) to hold the previous state</li>
</ul>
</li>
<li><p>the hand-crafted <code>RAII class</code> requires</p>
<ul>
<li>1 readable line to set new state and keep the previous one, and</li>
<li>1 stack variable (<code>guard</code>) to hold the previous state.</li>
</ul>
</li>
</ul>
<h1>Conclusion</h1>
<p>I think that examples such as</p>
<pre><code>void some_function() {
sg::scoped_guard([](){ cout << "this is printed last"; }
cout << "this is printed first";
}
</code></pre>
<p>are no proof of the usefullness of <code>scoped_guard</code>.</p>
<p>I hope that somebody can show me why I don't get the expected gain from <code>scoped_guard</code>.</p>
<p>I am convinced that RAII can be exploited better by writing short hand-crafted classes, than using the more generic but hard to use <code>scoped_guard</code></p>
| 7,112
|
<p>I'm developing an MFC application and I've recently been searching for a good method to remove the icon from a Windows title bar, but retain the close button. The two obvious candidate solutions are turning off the system menu style or using the tool window style, but I would prefer not to disable the system menu or use the shrunken tool window title bar. Many MFC applications have this functionality, so I wonder: am I missing some standard way of doing this?</p>
|
<p>You can use <code>WM_NCRBUTTONDOWN</code> to detect if the user has right-clicked on your caption and then bring up the system menu.</p>
|
<p>what about getting rid of the system menu and then putting it back in another place yourseld (say next to the close button etc.)?</p>
| 3,132
|
<p>I have the situation where i use GIS software which stores the information about GIS objects into separate database table for each type/class of GIS object (road, river, building, sea, ...) and keeps the metadata table in which it stores info about the class name and its DB table.</p>
<p>Those GIS objects of different classes share some parameters, i.e. Description and ID. I'd like to represent all of these different GIS classes with one common C# class (let's call it GisObject), which is enough for what i need to do from the non-GIS part of the application which lists GIS objects of the given GIS class.</p>
<p>The problem for me is how to map those objects using NHibernate to explain to the NHibernate when creating a C# GisObject to receive and <strong>use the table name as a parameter</strong> which will be read from the meta table (it can be in two steps, i can manually fetch the table name in first step and then pass it down to the NHibernate when pulling GisObject data).</p>
<p>Has anybody dealt with this kind of situation, and can it be done at all?</p>
|
<p>@Brian Chiasson</p>
<p>Unfortunately, it's not an option to create all classes of GIS data because classes are created dynamically in the application. Every GIS data of the same type should be a class, but my user has the possibility to get new set of data and put it in the database. I can't know in front which classes my user will have in the application. Therefore, the in-front per-class mapping model doesn't work because tomorrow there will be another new database table, and a need to create new class with new mapping.</p>
<p>@all
There might be a possibility to write my own custom query in the XML config file of my GisObject class, then in the data access class fetching that query using the </p>
<pre><code>string qs = getSession().getNamedQuery(queryName);
</code></pre>
<p>and use the string replace to inject database name (by replacing some placeholder string) which i will pass as a parameter. </p>
<pre><code>qs = qs.replace(":tablename:", tableName);
</code></pre>
<p>How do you feel about that solution? I know it might be a security risk in an uncontrolled environment where the table name would be fetched as the user input, but in this case, i have a meta table containing right and valid table names for the GIS data classes which i will read before calling the query for fetching data for the specific class of GIS objects.</p>
|
<p>one way you could do it is to declare an interface say IGisObject that has the common properties declared on the interface. Then implement a concrete class which maps to each table. That way they'll still be all of type IGisObject.</p>
| 7,483
|
<p>There are hundreds of shopping cart solutions available for every platform, and all hosting plans come with several already installed. As a developer I understand that most of these are fairly similar from a user perspective. </p>
<p>But which ones are built with the developer in mind? For example, which ones have a decent API so that my custom code doesn't get mingled with the core code or which ones have a well thought through template system so that I can easily customize it for each new client? </p>
|
<p>osCommerce is one of those products that was badly designed from the beginning, and becomes basically unmaintainable as time moves forward. Addons are patches, and custom code modifies core. (Unless things have drastically changed since I last looked at it - judging by the version numbers, they have not). </p>
<p>While probably at a bit higher level than you seem to be asking, Drupal is a very attractive platform. It is a CMS at its base, and using <a href="http://drupal.org/project/ecommerce" rel="noreferrer">ecommerce</a> or <a href="http://www.ubercart.org/" rel="noreferrer">Ubercart</a> you can turn it into a store. With modules like <a href="http://drupal.org/project/cck" rel="noreferrer">CCK</a> and <a href="http://drupal.org/project/views" rel="noreferrer">Views</a> you can build very sophisticated ecommerce sites (specialized product types, attributes) with very little coding, plus you get all the CMS tools (editing, access control, etc) for free. If you write your own modules, you can hook into almost anything in Drupal without touching the core code, and you get a ton of flexibility. </p>
<p>Though a lot of developers may not consider it simply because they're stuck in this view that they should write something from scratch, Drupal is a really great development platform for this sort of thing. There is definitely a learning curve to it, especially when you need to write modules for it, but the time it takes to learn and implement a site is still probably less than writing a very customized ecommerce site from scratch.</p>
|
<p><a href="http://www.oscommerce.com/solutions/oscommerce" rel="nofollow noreferrer">osCommerce</a> seems to be pretty popular, and advertises ease of integration as one of it's main features.</p>
| 9,508
|
<p>I'm not sure how this question will be recieved here but lets give it a shot...</p>
<p>It's time for me to get a new dev PC. What's the best choice these days?</p>
<p>I typically have 2-3 Visual Studios open along with mail and all that stuff. Ideally I would imagine 2+ GB of RAM would be nice as my current XP box is dying. =)</p>
<p>I hopped on the Dell site (my days of building PC's are behind me. I just need something that gets the job done.) and started browsing around only to be confused from all the processor choices. What does a typical dev box need these days? Duo? Quad?</p>
<p>Is it worth going to 64 bit Vista as well?</p>
<p>It's been a while since I got a new machine so I'm just looking for some guidance.</p>
<p>Thanks</p>
|
<p>I just built a quad core - 8 GB of RAM and run Server 2008 with Hyper-V on it. I have VMs for my build server, dev platform, and deployment options (XP, Vista, Server 2003/2008) with snapshots at the various service pack levels. What's nice is you can spin up a VM whenever you need it, and re-allocate the resources when you don't.. So if I want to have 4 or 5 GB of ram and four processors available for my dev platform, no problem.. when I need to test some installs, I can save my status and spin up my test machines.. (and it only ran about $800 US).</p>
|
<p>People are probably going to yell at me...but I've found that Vista 64 is mostly worth it. The main reason for me though is that I'm always maxing out my memory and having a 64bit OS allows me to go past the <4GB limit of 32bit.</p>
<p>But even if you don't get 64bit, just buy 2 2GB RAM cards anyways....you will be able to use most of it (my system shows 3.5GB on 32bit) and then you've got it for if you upgrade later and (if your system has 4 slots) you'll have room to expand to 8GB later on....</p>
| 3,635
|
<p>How do you stop the designer from auto generating code that sets the value for public properties on a user control?</p>
|
<p>Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden.</p>
<pre><code>[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Name
{
get;
set;
}
</code></pre>
|
<p>A slight change to Erik's answer I am using VS 2013.</p>
<pre><code>[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new string Name {
get;
set;
}
</code></pre>
| 4,943
|
<p>I have a basic cs-major understanding of multi-threading but have never had to do anything beyond simple timers in an application. Does anyone know of a good resource that will give me a tour how to work with multi-threaded applications, explaining the basics and maybe posing some of the more difficult stuff?</p>
|
<p>This is a great free resource by Joseph Albahari. <a href="http://www.albahari.com/threading/" rel="noreferrer">Threading in C#</a></p>
|
<p>One of the best resources I know on the subject is the "threading in C#" book:
<a href="http://www.albahari.com/threading/" rel="nofollow noreferrer">http://www.albahari.com/threading/</a></p>
<p>I has a great overview of all a .net developer need to understand in order to program multi threaded applications.</p>
| 7,243
|
<p>I am starting a new job on Monday. The company has a home grown enterprise case management application written in <code>ASP.NET/VB.NET</code>. They are attempting to implement an Agile development process. They have gone so far as to get two people Scrum Master certified and hire an Agile coach. They are currently focused on 6-9 months of refactoring.</p>
<p>My question is what are some good approaches/tooling given this environment for becoming familiar with the code base and being productive as soon as I hit the ground? Any suggestion?</p>
|
<p>Great question!</p>
<p>I would say the first thing to do is get the daily scrums going. Your part in the scrum will be learning the code. It will provide you a way to ask questions and get a feel for who can help you learn the code.</p>
<p>Once you have that guy (or guys) picked out start pair programming with them. Let them drive but ask questions. You will be surprised how much you can pick up that way. Given their bend on Agile, that should be an easy sell. :)</p>
<p>Once you have that established, be sure to swap partners every so often so you get a feel for the enitre code base. Just sticking woth one guy who is doing one part won't give you a big picture but jumping between people will get you a better big picture view of the code.</p>
<p>Just my 2 cents. :) Good luck and have fun!!</p>
|
<p>Congratulations on the new job!</p>
<p>Relax and keep your cool. Read something on <a href="http://www.refactoring.com/sources.html" rel="nofollow noreferrer">here</a>.</p>
<p>I guess, the process itself will make sure you are productive as long as you apply common sense :)</p>
| 8,084
|
<p>What slicers have support for belt printers like the CR-30? Or what slicers can have an add-on, plugin, or extension added to them to support it (from a user level, not a dev level).</p>
<p>I found more total slicers than I expected, since I was only expecting 3 (Cura, PrusaSlicer, Simplify3d). Surely that means I'm missing out on more, if there are already so many different slicers.</p>
<ul>
<li>Creality Slicer - Comes from the OEM of the printer</li>
<li>Blackbelt Cura - Everyone who mentions it says don't use it because it's old</li>
<li>Raise3d Ideamaker - Seems to be based on Flashforge's slicer, has some interesting features too. Not as configurable as Slic3r or PrusaSlicer though.</li>
</ul>
|
<p>It seems <strong>Creality</strong> provides a modified version of <strong>Cura 4.8.2</strong> for the <strong>CR30</strong>: <a href="https://www.creality.com/pages/download-cr-30-3d-printer" rel="nofollow noreferrer">Creality Download</a> ; <strong>BlackBelt</strong> does the same, another modified version of Cura 3.6.2: <a href="https://blackbelt-3d.com/download-area/" rel="nofollow noreferrer">Blackbelt Download</a>.</p>
<p>The current version of <strong>Cura</strong> (5.x) does not limit the area in size, but it seems very difficult to use it like that for belt printers (eg printing the same object many times), so you have to use a dedicated slicer.</p>
<p>Some possible tricks: printing the same object many times could require a simple edit/processing of the gcode, plz ask for this because it's another question.</p>
|
<p>I think most slicers don't distinguish printers based on if they have belts or delta configuration, etc. The slicer generates gcode, and the firmware on the printer translates the gcode into actuator motions specific to that printer to perform the gcode.</p>
<p>The difference slicers generally care about is if it is a FFF printer that extrudes a bead or a resin printer that solidifies liquid. Many other 3d printing methods exist, but those to are the most common ones supported by most of the open slicers.</p>
| 2,184
|
<p>I have a DotNetNuke site where my main logo is a PNG file using transparency. I tried GIF but the quality wasn't good enough.</p>
<p>Anyways it worked great on IE7 but I just saw my site in IE6 and noticed that the transparency isn't working with my logo.</p>
<p>Does anyone know of a quick way to fix this in a DotNetNuke portal?</p>
|
<p>I don't know that it's a DotNetNuke issue as much as it is IE6. Anyways, here's a site that shows you how to work around IE6's png issues. Hope it helps.</p>
<p><a href="http://24ways.org/2007/supersleight-transparent-png-in-ie6" rel="nofollow noreferrer">http://24ways.org/2007/supersleight-transparent-png-in-ie6</a></p>
|
<p>Googling "pngfix" should find a lot of different techniques for enabling alpha transparency in IE6.</p>
<p>One common one is a <a href="http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html" rel="nofollow noreferrer">HTC behaviour file</a>.</p>
| 6,878
|
<p>I'm using the <code>System.Windows.Forms.WebBrowser</code>, to make a view a-la Visual Studio Start Page. However, it seems the control is catching and handling all exceptions by silently sinking them! No need to tell this is a very unfortunate behaviour.</p>
<pre><code>void webBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
// WebBrowser.Navigating event handler
throw new Exception("OMG!");
}
</code></pre>
<p>The code above will cancel navigation and swallow the exception.</p>
<pre><code>void webBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
// WebBrowser.Navigating event handler
try
{
e.Cancel = true;
if (actions.ContainsKey(e.Url.ToString()))
{
actions[e.Url.ToString()].Invoke(e.Url, webBrowser.Document);
}
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString());
}
}
</code></pre>
<p>So, what I do (above) is catch all exceptions and pop a box, this is better than silently failing but still clearly far from ideal. I'd like it to redirect the exception through the normal application failure path so that it ultimately becomes unhandled, or handled by the application from the root.</p>
<p>Is there any way to tell the <code>WebBrowser</code> control to stop sinking the exceptions and just forward them the natural and expected way? Or is there some hacky way to throw an exception through native boundaries?</p>
|
<p>I haven't seen the browser eat exceptions, unless you mean script errors. Script errors can be enabled via the <code>browser.ScriptErrorsSuppressed</code> property.</p>
<p>If you're talking about real exceptions, not just script errors, can you show us some code that reproduces the problem? We've used the browser extensively and haven't seen what you're describing.</p>
<p><em>edit</em> the code sample wasn't there when I asked for a code sample</p>
|
<p>11 years late to the party here, but the following solution works for me.</p>
<p>In <code>webBrowserNavigating</code>, replace <code>MessageBox.Show(exception.ToString());</code> with <code>Dispatcher.BeginInvoke(() => { throw exception; });</code>.</p>
<p>As soon as the <code>webBrowserNavigating</code> method completes and control returns to the windows event loop, the exception is thrown and handled by the normal mechanism.</p>
| 3,867
|
<p>Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.</p>
|
<p>I would create a new QT project in eclipse, then switch perspectives to subclipse and simply do a SVN checkout into the new eclipse project. You should be good to go.</p>
|
<p>Checkout the project. It will ask you some options like if you want to start with a blank project, or want to use the tree to make a new project. Choose the latter and you should be ok :). It seems to work for me with Ganymed and subversive(not sure about subclipse and i don't remember.) :)</p>
| 9,736
|
<p>I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator.</p>
<p>I don't want to just lock the database and let the users quit gracefully.</p>
<p>How would I script this?</p>
|
<p>This answer is heavily influenced by a conversation here: <a href="http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3" rel="noreferrer">http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3</a></p>
<pre><code>ALTER SYSTEM ENABLE RESTRICTED SESSION;
begin
for x in (
select Sid, Serial#, machine, program
from v$session
where
machine <> 'MyDatabaseServerName'
) loop
execute immediate 'Alter System Kill Session '''|| x.Sid
|| ',' || x.Serial# || ''' IMMEDIATE';
end loop;
end;
</code></pre>
<p>I skip killing sessions originating on the database server to avoid killing off Oracle's connections to itself.</p>
|
<p>If Oracle is running in Unix /Linux then we can grep for all client connections and kill it </p>
<p>grep all oracle client process:</p>
<p>ps -ef | grep LOCAL=NO | grep -v grep | awk '{print $2}' | wc -l</p>
<p>Kill all oracle client process :</p>
<p>kill -9 <code>ps -ef | grep LOCAL=NO | grep -v grep | awk '{print $2}'</code></p>
| 7,908
|
<p>I am trying to write a unit test for an action method which calls the <code>Controller.RedirectToReferrer()</code> method, but am getting a "No referrer available" message.</p>
<p>How can I isolate and mock this method?</p>
|
<p>Have you thought about creating a <a href="http://xunitpatterns.com/Test%20Double.html" rel="nofollow noreferrer">test double</a>?</p>
|
<p>In <em>my</em> version of the trunk I'm working against, r5299, I had to do this to mock out RedirectToReferrer. I think it's been changed in recent commits, I'm not sure.</p>
<pre><code>[TestFixture]
public class LoginControllerTests : GenericBaseControllerTest<LoginController>
{
private string referrer = "http://www.example.org";
protected override IMockRequest BuildRequest()
{
var request = new StubRequest(Cookies);
request.UrlReferrer = referrer;
return request;
}
protected override IMockResponse BuildResponse(UrlInfo info)
{
var response = new StubResponse(info,
new DefaultUrlBuilder(),
new StubServerUtility(),
new RouteMatch(),
referrer);
return response;
}
</code></pre>
<p>etc. etc.</p>
<p>It's oddly the <em>Response</em> that you need to molest to get the <code>RedirectToReferrer</code> to work. I had to crawl around in the monorail sources to figure it out.</p>
| 8,737
|
<p>I'm building an application against some legacy, third party libraries, and having problems with the linking stage. I'm trying to compile with Visual Studio 9. My compile command is:</p>
<pre><code>cl -DNT40 -DPOMDLL -DCRTAPI1=_cdecl
-DCRTAPI2=cdecl -D_WIN32 -DWIN32 -DWIN32_LEAN_AND_MEAN -DWNT -DBYPASS_FLEX -D_INTEL=1 -DIPLIB=none -I. -I"D:\src\include" -I"C:\Program Files\Microsoft Visual Studio
9.0\VC\include" -c -nologo -EHsc -W1 -Ox -Oy- -MD mymain.c
</code></pre>
<p>The code compiles cleanly. The link command is:</p>
<pre><code>link -debug -nologo -machine:IX86
-verbose:lib -subsystem:console mymain.obj wsock32.lib advapi32.lib
msvcrt.lib oldnames.lib kernel32.lib
winmm.lib [snip large list of
dependencies] D:\src\lib\app_main.obj
-out:mymain.exe
</code></pre>
<p>The errors that I'm getting are:</p>
<pre><code>app_main.obj : error LNK2019:
unresolved external symbol
"_\_declspec(dllimport) public: void
__thiscall std::locale::facet::_Register(void)"
(__imp_?_Register@facet@locale@std@@QAEXXZ)
referenced in function "class
std::ctype<char> const & __cdecl
std::use_facet<class std::ctype<char>
(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z)
app_main.obj : error LNK2019:
unresolved external symbol
"__declspec(dllimport) public: static
unsigned int __cdecl
std::ctype<char>::_Getcat(class
std::locale::facet const * *)"
(__imp_?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z)
referenced in function "class
std::ctype<char> const & __cdecl
std::use_facet<class std::ctype<char>
(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z)
app_main.obj : error LNK2019:
unresolved external symbol
"__declspec(dllimport) public: static
unsigned int __cdecl
std::ctype<unsigned
short>::_Getcat(class
std::locale::facet const * *)"
(__imp_?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z)
referenced in function "class
std::ctype<unsigned short> const &
__cdecl std::use_facet<class std::ctype<unsigned short> >(class
std::locale const &)"
(??$use_facet@V?$ctype@G@std@@@std@@YAABV?$ctype@G@0@ABVlocale@0@@Z)
mymain.exe : fatal error LNK1120: 3
unresolved externals
</code></pre>
<p>Notice that these errors are coming from the legacy code, not my code - app_main.obj is part of the legacy code, while mymain.c is my source. I've done some searching around, and what that I've read says that this type of error is caused by a mismatch with the -MD switch between my code and the library that I'm linking to. Since I'm dealing with legacy code, a solution has to come from my environment. It's been a long time since I've done C++ work, and even longer since I've used Visual Studio, so I'm hoping that this is just some ignorance on my part. Any ideas on how to get these resolved?</p>
|
<p>These are standard library references. Make sure that all libraries (including the standard library) are using the <em>same</em> linkage. E.g. you can't link statically while linking the standard lib dynamically. The same goes for the threading model used. Take special care that you and the 3rd party library use the same linkage options.</p>
<p>This can be a real pain in the *ss.</p>
|
<p>After trying to get this stuff to compile under VS 2008, I tried earlier versions of VS - 2005 worked with warnings, and 2003 just worked. I double checked the linkages and couldn't find any problems, so either I just couldn't find it, or that wasn't the problem. </p>
<p>So to reiterate, downgrading to VS 2003 fixed it.</p>
| 4,321
|
<p><a href="https://3dprinting.stackexchange.com/a/4642/233">This post</a> has been up for 4-5 days now. I flagged it originally when it was first posted and that flag aged away, I have now flagged it again and it's still here. We have one <a href="https://3dprinting.stackexchange.com/users/1263/szymon-b%C4%99czkowski">user</a> that shares part of the posters name but I am unsure if they are connected in any way or if that name references the linked user. </p>
<p>Do we need more moderators to handle this? What is the process for having these removed? </p>
|
<p>The post has now been deleted and the user destroyed due to spam, so thank you for bringing this up.</p>
<p>It either must have come up after I cleaned out the inbox or I must have overlooked it.</p>
<p>Yes, we do need another moderator. I would have loved to be at a point by now that we could have had elections as part of a fully public SE site, but we've still got a few hurdles to overcome as a community.</p>
<p>I'll double check what the options are for bringing on new moderators at this stage and post back to Meta.</p>
|
<p>Seeing as I'm 20 days late to this question, you probably understand that I'm not very active at the moment myself. (At least, I'm inactive for longer periods of time.) With Ryan gone for almost a year now, that often leaves @tbm0115 as the only moderator on this site.</p>
<p>In other words, we could do with another moderator or a change of moderators (Ryan and perhaps me also).</p>
<p>On the plus side, we are getting more and more users, which makes the community handle a lot of cases by itself.</p>
| 45
|
<p>Let's say I've made a 3D scan of my face and managed to get that into FreeCAD. How might I then create an object (it's a mask, okay?) that conforms to the shape of my face, with a given thickness, such that I can export and 3D-print that part only?</p>
<p>So if I printed it, it would fit over my face, but still look like my face from the outside, too. It would be, say, 3mm thickness througout.</p>
<p>To be clear, I'm not looking to make a 3D model of my head (the world does not need such a thing), or 3D model of a mold that I can use to replicate my head. I just want to make parts that conform to the shape of other, complex, parts.</p>
|
<p>Instead of using FreeCAD, I would import the mesh data into a vertex-based 3D modeling software, such as blender.</p>
<p>After stitching the model in any areas where you still have gaps, you remove any vertex belonging to areas you do not want to use for the mask. This leaves you with pretty much a skin-tight base for your mask. Select all the remaining surfaces and scale <code>S</code> them in all directions in regards to the origin so you create a little airgap 5% extra (<code>1.05</code>) should create enough space to sit somewhat comfortably, but you might prefer a little more. As a stand-in for the face, I use this approximation of a forehead...</p>
<p><a href="https://i.stack.imgur.com/7ZUJ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ZUJ6.png" alt="enter image description here" /></a></p>
<p>Next, we thicken that surface using the modifier menu: Select the <a href="https://docs.blender.org/manual/en/latest/modeling/modifiers/generate/solidify.html" rel="nofollow noreferrer">Solidify modifier</a> and set a <code>thickness</code> that looks good to you and that might be printable. Then make sure it pushes <em>away</em> from where your face is. Also make sure the Offset is at <code>1</code> or <code>-1</code> to ensure that it does not stick out from the face-scan surface to the back!
<a href="https://i.stack.imgur.com/s5sBk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s5sBk.png" alt="enter image description here" /></a></p>
<p>Now you got a perfect base to model on the outside of using the sculpt features while retaining the inner surface! Do yourself a favor though: print at least part of this model as a test fit and adjust the mask as needed.</p>
|
<p>It depends on the software you're using, but here is an example with TinkerCad.</p>
<p>Step 1: Import your 3D model (imagine that the ball is a head):<br />
<a href="https://i.stack.imgur.com/vZwKP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vZwKP.jpg" alt="enter image description here" /></a></p>
<p>Step 2: Change its type from "Solid" to "Hole"
<a href="https://i.stack.imgur.com/hyI2S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hyI2S.png" alt="enter image description here" /></a></p>
<p>Step 3: Create a "Solid" box around your imported model.</p>
<p>Here is the inverted Solid/Hole version:
<a href="https://i.stack.imgur.com/kNleK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kNleK.jpg" alt="enter image description here" /></a></p>
<p>Here is the Solid version with the Hole model inside your Solid box:
<a href="https://i.stack.imgur.com/DpOW2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DpOW2.png" alt="enter image description here" /></a></p>
<p>Step 4: Select both models and group them:
<a href="https://i.stack.imgur.com/rxE4J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rxE4J.png" alt="enter image description here" /></a></p>
<p>Step 5: Add a box covering half of your mold (ideally splitting it in half):<br />
<a href="https://i.stack.imgur.com/xumc5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xumc5.jpg" alt="enter image description here" /></a></p>
<p>Step 6: Duplicate the mold and the box
<a href="https://i.stack.imgur.com/FBwsG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FBwsG.png" alt="enter image description here" /></a></p>
<p>Step 7: Group the left mold with its surrounding box:
<a href="https://i.stack.imgur.com/21pUL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/21pUL.png" alt="enter image description here" /></a></p>
<p>Step 8: Invert the box of the left mold by taking its left corner and dragging it over to the right side of the mold:
<a href="https://i.stack.imgur.com/piyeO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/piyeO.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/JQITx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JQITx.png" alt="enter image description here" /></a></p>
<p>Step 9: Group the right box and the mold.</p>
<p>Step 10: You now have two molds for each half of your model:
<a href="https://i.stack.imgur.com/2JdUs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2JdUs.jpg" alt="enter image description here" /></a></p>
<p>Based on your comment, I'm adding a couple more steps:</p>
<p>Step 11: Take your cast, duplicate it, enlarge the duplicate, make it a hole and fit it over your cast (like so):<br />
<a href="https://i.stack.imgur.com/XIO7P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XIO7P.jpg" alt="enter image description here" /></a></p>
<p>Step 12: Group the left cast with the larger "Hole" copy:
<a href="https://i.stack.imgur.com/IFBvK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IFBvK.jpg" alt="enter image description here" /></a></p>
<p>And if you're going to 3D print it and fit it over the old model, then you might want to enlarge the cast by a few mm.</p>
<p>It's now up to you to figure out how to clamp the molds, inject them, and then separate them.</p>
<p>A few things to keep in mind:</p>
<ol>
<li>You might want to play with the placement of the model inside the mold a little better so it's not at the bottom of the mold but more towards the middle.</li>
<li>You could also get a bit more creative with the joining of the two molds by adding channels or some kind of way that they can fit into each other with greater precision. Here is an example: <a href="https://i.etsystatic.com/6549005/r/il/271593/1763722747/il_794xN.1763722747_q1q2.jpg" rel="nofollow noreferrer"><img src="https://i.etsystatic.com/6549005/r/il/271593/1763722747/il_794xN.1763722747_q1q2.jpg" alt="mold" /></a>.</li>
<li>If the parts are more complex, then the cast will be more challenging and might require to be split into more parts.</li>
</ol>
<p>Good luck! :)</p>
| 1,920
|
<p>Everyone is aware of Dijkstra's <a href="http://portal.acm.org/citation.cfm?doid=362947" rel="noreferrer">Letters to the editor: go to statement considered harmful</a> (also <a href="http://www.cs.utexas.edu/%7EEWD/transcriptions/EWD02xx/EWD215.html" rel="noreferrer">here</a> .html transcript and <a href="http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF" rel="noreferrer">here</a> .pdf) and there has been a formidable push since that time to eschew the goto statement whenever possible. While it's possible to use goto to produce unmaintainable, sprawling code, it nevertheless remains in <a href="http://msdn.microsoft.com/en-us/library/13940fs2(VS.71).aspx" rel="noreferrer">modern programming languages</a>. Even the advanced <a href="http://en.wikipedia.org/wiki/Goto#Continuations" rel="noreferrer">continuation</a> control structure in Scheme can be described as a sophisticated goto.</p>
<p>What circumstances warrant the use of goto? When is it best to avoid?</p>
<p>As a follow-up question: C provides a pair of functions, setjmp() and longjmp(), that provide the ability to goto not just within the current stack frame but within any of the calling frames. Should these be considered as dangerous as goto? More dangerous?</p>
<hr />
<p>Dijkstra himself regretted that title, for which he was not responsible. At the end of <a href="http://www.cs.utexas.edu/%7EEWD/transcriptions/EWD13xx/EWD1308.html" rel="noreferrer">EWD1308</a> (also <a href="http://www.cs.utexas.edu/%7EEWD/ewd13xx/EWD1308.PDF" rel="noreferrer">here</a> .pdf) he wrote:</p>
<blockquote>
<p>Finally a short story for the record.
In 1968, the Communications of the ACM
published a text of mine under the
title "<em>The goto statement considered
harmful</em>", which in later years would
be most frequently referenced,
regrettably, however, often by authors
who had seen no more of it than its
title, which became a cornerstone of
my fame by becoming a template: we
would see all sorts of articles under
the title "X considered harmful" for
almost any X, including one titled
"Dijkstra considered harmful". But
what had happened? I had submitted a
paper under the title "<em><strong>A case against
the goto statement</strong></em>", which, in order
to speed up its publication, the
editor had changed into a "letter to
the Editor", and in the process he had
given it a new title of his own
invention! The editor was Niklaus
Wirth.</p>
</blockquote>
<p>A well thought out classic paper about this topic, to be matched to that of Dijkstra, is <a href="http://www.clifford.at/cfun/cliffdev/p261-knuth.pdf" rel="noreferrer">Structured Programming with go to Statements</a>, by Donald E. Knuth. Reading both helps to reestablish context and a non-dogmatic understanding of the subject. In this paper, Dijkstra's opinion on this case is reported and is even more strong:</p>
<blockquote>
<p><em>Donald E. Knuth:</em> I believe that by presenting such a
view I am not in fact disagreeing
sharply with Dijkstra's ideas, since
he recently wrote the following:
"Please don't fall into the trap of
believing that I am terribly
dogmatical about [the go to
statement]. <strong>I have the uncomfortable
feeling that others are making a
religion out of it, as if the
conceptual problems of programming
could be solved by a single trick, by
a simple form of coding discipline!</strong>"</p>
</blockquote>
|
<p>The following statements are generalizations; while it is always possible to plead exception, it usually (in my experience and humble opinion) isn't worth the risks.</p>
<ol>
<li>Unconstrained use of memory addresses (either GOTO or raw pointers) provides too many opportunities to make easily avoidable mistakes.</li>
<li>The more ways there are to arrive at a particular "location" in the code, the less confident one can be about what the state of the system is at that point. (See below.)</li>
<li>Structured programming IMHO is less about "avoiding GOTOs" and more about making the structure of the code match the structure of the data. For example, a repeating data structure (e.g. array, sequential file, etc.) is naturally processed by a repeated unit of code. Having built-in structures (e.g. while, for, until, for-each, etc.) allows the programmer to avoid the tedium of repeating the same cliched code patterns.</li>
<li>Even if GOTO is low-level implementation detail (not always the case!) it's below the level that the programmer should be thinking. How many programmers balance their personal checkbooks in raw binary? How many programmers worry about which sector on the disk contains a particular record, instead of just providing a key to a database engine (and how many ways could things go wrong if we really wrote all of our programs in terms of physical disk sectors)?</li>
</ol>
<p>Footnotes to the above:</p>
<p>Regarding point 2, consider the following code:</p>
<pre class="lang-c prettyprint-override"><code> a = b + 1
/* do something with a */
</code></pre>
<p>At the "do something" point in the code, we can state with high confidence that <code>a</code> is greater than <code>b</code>. (Yes, I'm ignoring the possibility of untrapped integer overflow. Let's not bog down a simple example.)</p>
<p>On the other hand, if the code had read this way:</p>
<pre class="lang-c prettyprint-override"><code> ...
goto 10
...
a = b + 1
10: /* do something with a */
...
goto 10
...
</code></pre>
<p>The multiplicity of ways to get to label 10 means that we have to work much harder to be confident about the relationships between <code>a</code> and <code>b</code> at that point. (In fact, in the general case it's undecideable!)</p>
<p>Regarding point 4, the whole notion of "going someplace" in the code is just a metaphor. Nothing is really "going" anywhere inside the CPU except electrons and photons (for the waste heat). Sometimes we give up a metaphor for another, more useful, one. I recall encountering (a few decades ago!) a language where</p>
<pre class="lang-c prettyprint-override"><code> if (some condition) {
action-1
} else {
action-2
}
</code></pre>
<p>was implemented on a virtual machine by compiling action-1 and action-2 as out-of-line parameterless routines, then using a single two-argument VM opcode which used the boolean value of the condition to invoke one or the other. The concept was simply "choose what to invoke now" rather than "go here or go there". Again, just a change of metaphor.</p>
|
<p>The basic idea is that goto gives you too much freedom to do something you didn't intend to. It can cause errors in places that don't appear to be related to the goto statement, so it makes code maintenance more difficult. If you think you need a goto statement, you're wrong :) and you should instead rethink your code construction. This is why modern programming languages have put alot of effort into giving you readable, maintainable flow control constructs, and exception handling mechanisms.</p>
<p>I'm also going to disagree with lassevk. Since goto is abused more than correctly used, I believe it has no place in a well designed language. Even for goto's "ideal" uses, the other ways of doing it which require more code should be preferred.</p>
<p>So in summary, yes it is still considered harmful.</p>
| 6,877
|
<p>We have a fairly new Ultimaker 3 Extended.</p>
<p>When printing ABS with the AA0.8 nozzle and the recommended settings (up-to-date CURA) we receive a very poor wall quality that exposes some kind of pores. I've attached an image of those pores.</p>
<p>I assume those pores are dragged by the nozzle when it moves inwards to print the infill.</p>
<p>I already tried to increase the wall thickness or increase the layer height to 0.3 mm. Are there other settings I might be able to tweak to eliminate those pores? </p>
<p><a href="https://i.stack.imgur.com/Rk9Lp.jpg" rel="nofollow noreferrer" title="Outer wall with pores"><img src="https://i.stack.imgur.com/Rk9Lp.jpg" alt="Outer wall with pores" title="Outer wall with pores"></a></p>
|
<p>According to <a href="https://youtu.be/QnnPsoL5cHE?t=18" rel="nofollow noreferrer">Anycubic</a> this printer uses the E3D V5 type hotend as can be seen from the linked video of the AnyCubic Mega:</p>
<p><a href="https://i.stack.imgur.com/WSL8p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WSL8p.png" alt="E3D v5 of Anycubic Mega exploded view"></a>
<a href="https://i.stack.imgur.com/cuLc1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cuLc1.png" alt="E3D v5 of Anycubic Mega assembled view"></a></p>
<p>The brass nozzle you see is fully compatible with the E3D v6 nozzle and can be found on those typical auction and Chinese websites by looking for "E3D nozzle". They are also available from <a href="https://e3d-online.com" rel="nofollow noreferrer">E3D directly</a>, the designer/creator of the E3D hotend family, and other specialized manufacturers like the <a href="http://olssonruby.com/" rel="nofollow noreferrer">Olsson Ruby</a>. These nozzles have a short nozzle (snout) and are screwed into the heater block with M6 threads.<sup>1)</sup></p>
<p><a href="https://i.stack.imgur.com/32U1im.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32U1im.jpg" alt="E3D v5/v6 nozzle"></a></p>
<p>The smaller the diameter, the smaller the filament traces and the higher the print detail resolution. Note that a smaller diameter causes thinner walls for the same amount of (vertical) walls and may require additional perimeters to get similar strength and rigidity. The maximum layer thickness also decreases, as prints with a layer height above 75 % of the nozzle diameter have very poor quality. As an example, a 0.25 mm nozzle should not print layers thicker than <span class="math-container">$0.75 \times 0.25\text{ mm} = 0.19\text{ mm}$</span>. </p>
<p>As such printing with smaller nozzle diameters increases print time. Also note that a smaller diameter requires more force to push the filament through and <em>could</em> use some extra temperature to make the filament more fluid or reduction of the print speed.</p>
<p>Just buy some spare nozzles of different nozzle diameter and experiment what works best for you.</p>
<p><sup>1)</sup> - <em>The other popular style of M6 threaded nozzles has a long body and long taper (often referred to as MK8 nozzle; they come in two different shapes). While these might work, they extend from the heater block considerably further and might need readjustment of the heater block (<a href="https://3dprinting.stackexchange.com/a/9913/8884">as explained here</a>): <br>
<a href="https://i.stack.imgur.com/pl9G1s.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pl9G1s.jpg" alt="MK8 nozzle variant 1"></a><a href="https://i.stack.imgur.com/k3r8Vs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k3r8Vs.png" alt="MK8 nozzle variant 2"></a></em></p>
|
<p>We select nozzles depending on what project we want to,do and it must match with the hot end as well.</p>
| 1,275
|
<p>Haven't fired up reflector to look at the difference but would one expect to see the exact same compiled code when comparing <code>Func<T, bool></code> vs. <code>Predicate<T></code> </p>
<p>I would imagine there is no difference as both take a generic parameter and return bool?</p>
|
<p>They share the same signature, but they're still different types.</p>
|
<p>Even without generics, you can have different delegate types that are identical in signatures and return types. For example:</p>
<pre><code>namespace N
{
// Represents a method that takes in a string and checks to see
// if this string has some predicate (i.e. meets some criteria)
// or not.
internal delegate bool StringPredicate(string stringToTest);
// Represents a method that takes in a string representing a
// yes/no or true/false value and returns the boolean value which
// corresponds to this string
internal delegate bool BooleanParser(string stringToConvert);
}
</code></pre>
<p>In the above example, the two non-generic types have the same signature and return type. (And actually also the same as <code>Predicate<string></code> and <code>Func<string, bool></code>). But as I tried to indicate, the "meaning" of the two are different.</p>
<p>This is somewhat like if I make two classes, <code>class Car { string Color; decimal Price; }</code> and <code>class Person { string FullName; decimal BodyMassIndex; }</code>, then just because both of them hold a <code>string</code> and a <code>decimal</code>, that doesn't mean they're the "same" type.</p>
| 5,269
|
<p>I am trying to print with clay.</p>
<p>These are my Slic3r speed settings,</p>
<p><a href="https://i.stack.imgur.com/FE115.png" rel="nofollow noreferrer" title="Slic3r speed settings"><img src="https://i.stack.imgur.com/FE115.png" alt="Slic3r speed settings" title="Slic3r speed settings"></a></p>
<p>Other information;</p>
<ul>
<li>Nozzle: 1.4 mm</li>
<li>First layer height: 0.9 mm</li>
<li>layer height: 1 mm</li>
<li>Filament dia: 1.8 mm</li>
<li>perimeter: 3</li>
</ul>
<p>When I print, the first layer is printed faster than remaining layers and in the remaining layers, the two inner perimeters are printed much slower than the outer perimeter.</p>
<ul>
<li>Video: <a href="https://drive.google.com/open?id=1UE2MFhjTXpVEirsNK3KlALi4Fb5Ca8rX" rel="nofollow noreferrer">print video</a></li>
<li>G-code: <a href="https://drive.google.com/open?id=1GMyNPaX8YiB3-P2UNHGC3gTZC3M3oilm" rel="nofollow noreferrer">gcode</a></li>
</ul>
<p>Isn't this strange since I give the same print speed for all?</p>
|
<p>No, you did not set all the settings to the same speed, there are 2 different print speeds defined:</p>
<ul>
<li>Infill Solid: <strong>60</strong> mm/s</li>
<li>First Layer Speed: <strong>30%</strong></li>
</ul>
<p>This means, that some walls will be printed 10 mm/s faster than the others, and that <em>first layer</em> should be printed at 30% of 50 mm/s, so at 15 mm/s - try to define it as a speed. Make sure to save and apply the settings and only <em>then</em> slice your model, as you might have sliced the model with the previous settings.</p>
|
<p>Make sure that on the Print Settings tab, under Advanced, you have set the Extrusion widths for your custom nozzle settings.</p>
| 1,117
|
<p>Printer: FDM printer (FDM == Fusion Deposition Modelling).</p>
<p>Raw Material: Thermoplastics.</p>
<p>How do I do multicolor printing? What changes should I make to the printing process/to the raw material used?</p>
<p>(Answer in the context of printing a basic 3X3 Rubix cube)</p>
<hr>
<p>Bonus: What are the best practises while doing multi-colour printing? (<-- This is opinion based and/or broad, so pl add an answer to this point as an extra to your answers if you can. It would greatly help people getting started/practising with multi-colour printing) </p>
|
<p>There are a few different approaches I've seen which you could look into.</p>
<p>The easiest and most common is multiple extruders, each with a different color of thermoplastic. Tools like Pronterface and Slic3r have built-in support for multiple extruders. With multiple extruders you can get one color per extruder; there's no clear way to mix colors and get a color between the input materials' colors.</p>
<p>Another, more complicated approach is to use a single extruder with three inputs, like <a href="http://www.aliexpress.com/item/Diamond-hotend-Prusa-i3-Extruder-Full-kit-E3D-V6-Brass-Multi-Color-Nozzle-3-IN-1/32516521911.html">this one</a>, where thermoplastic from the three inputs can be mixed in varying amounts to get color gradients between the input colors. With red, yellow, and blue filament, you could get a rainbow of colors...albeit without any control over value (white to black) or saturation (bright vs dull color).</p>
|
<p>If you are trying to print something like a Rubic's Cube in the correct colors without using paint or stickers, there are only a couple of options.</p>
<p>Assuming that you are using a printer with only a single extruder and no fancy gadgets, you will need to print each color cube you will need to print in a lot of pieces and then put them together. You can't use tricks like changing the filament manually at a certain level for most of the cubes because most of the cubes are corner cubes with 3 colors.</p>
<p>Assuming that you have some sort of multi-material system, then you just use STL files that are made with the proper colors. And I'm talking any sort of multi-material system, including multiple extruders, the fancy extruder described by @Martin Carney, or the MMS from prusia3d.com which has 4 inputs to a single extruder with the disadvantage of no mixing and having to automatically waste filament when changing colors.</p>
<p>There is another system used by the <a href="https://techcrunch.com/2017/08/31/xyzprinting-announces-a-3000-full-color-3d-printer/" rel="nofollow noreferrer">da Vinchi Full Color 3d Printer</a> which sprays ink onto the filament as its printing.</p>
<p>Since the standard STL file doesn't have color definitions, the normal thing to do is to break up the original file into several STL files each with their own color. This requires Meshmixer or a 3d modeling program.</p>
<p>I've done a lot of research on this, but haven't had a chance to try yet because my Original Prusia 3d and its Multi-Material kit haven't arrived yet. :(</p>
| 124
|
<p>I have a <code>byte[]</code> array, the contents of which represent a TIFF file (as in, if I write out these bytes directly to a file using the <code>BinaryWriter</code> object, it forms a perfectly valid TIFF file) and I'm trying to turn it into a System.Drawing.Image object so that I can use it for later manipulation (feeding into a multipage TIFF object)</p>
<p>The problem I'm having is that the commonly accepted code for this task:</p>
<pre><code> public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms, true);
return returnImage;
}
</code></pre>
<p>doesn't work for me. The second line of the above method where it calls the <code>Image.FromStream</code> method dies at runtime, saying</p>
<pre><code>Parameter Not Valid
</code></pre>
<p>I believe that the method is choking on the fact that this is a TIFF file but I cannot figure out how to make the <code>FromStream</code> method accept this fact.</p>
<p>How do I turn a byte array of a TIFF image into an Image object?</p>
<p>Also, like I said the end goal of this is to have a byte array representing a multipage TIFF file, which contains the TIFF files for which I have byte array objects of right now. If there's a much better way to go about doing this, I'm all for it.</p>
|
<p><strong>Edit:</strong> The assumption below is not correct, I had a chance to fire up my IDE later and tested with and without Write and both populated the MemoryStream correctly.</p>
<p>I think you need to write to your MemeoryStream first.</p>
<p>As if my memory (no pun intended) serves me correctly this:</p>
<pre><code>MemoryStream ms = new MemoryStream(byteArrayIn);
</code></pre>
<p>Creates a memory stream of that size.</p>
<p>You then need to write your byte array contents to the memory stream:</p>
<pre><code>ms.Write(byteArrayIn, 0, byteArrayIn.Length);
</code></pre>
<p>See if that fixes it.</p>
|
<p>All these were clues that helped me figure out my problem which was the same problem as the question asks. So i want to post my solution which i arrived at because of these helpful clues. Thanks for all the clues posted so far!</p>
<p>As Time Saunders posted in his answer, that Write method to actually write the bytes to the memory stream is essential. That was my first mistake.</p>
<p>Then my data was bad TIFF data too, but in my case, i had an extra character 13 at the beginning of my image data. Once i removed that, it all worked fine for me.</p>
<p>When i read about some basic TIFF file format specs, i found that TIFF files must begin with II or MM (two bytes with values of either 73 or 77). II means little-endian byte order ('Intel byte ordering') is used. MM means big-ending ('Motorola byte ordering') is used. The next two bytes are a two byte integer value ( = Int16 in .NET) of 42, binary 101010.</p>
<p>Thus a correct TIFF stream of bytes begins with the decimal byte values of: 73, 73, 42, 0 or 77, 77, 0, 42. I encourage anyone with the same problem that we experienced to inspect your TIFF data byte stream and make sure your data is valid TIFF data!</p>
<p>Thanks Schnapple and Tim Saunders!!</p>
| 5,276
|
<p>I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not?</p>
<p>Is there anything more to be added to the code that goes into a real world application?</p>
<p>What all steps are to be taken to make the application more robust and secure?</p>
<p>Here is a sample source code I got from the web:</p>
<pre><code>function getChats() {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
return;
}
var url="getchat.php?latest="+latest;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function GetXmlHttpObject() {
var xmlHttp=null;
try {
xmlHttp=new XMLHttpRequest();
} catch (e) {
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</code></pre>
|
<p>The code you posted is missing one important ingredient: the function stateChanged.</p>
<p>If you don't quite understand the code you posted yourself, then what happens is when the call to getchats.php is complete, a function "stateChanged" is called and that function will be responsible for handling the response. Since the script you're calling and the function itself is prefixed with "gets" then I'm pretty sure the response is something you're going to be interested in. </p>
<p>That aside, there are a number of ways to improve on the code you posted. I'd guess it works by declaring a single "xmlHttp" object and then making that available to every function (because if it doesn't, the stateChanged function has no way of getting the response). This is fine until you run an AJAX request before the last one (or last few) haven't replied yet, which in that case the object reference is overwritten to the latest request each time.</p>
<p>Also, any AJAX code worth its salt provides functionality for sucess and failure (server errors, page not found, etc.) cases so that the appriopiate message can be delivered to the user.</p>
<p>If you just want to use AJAX functionality on your website then I'd point you in the direction of <a href="http://www.jquery.com" rel="nofollow noreferrer">jQuery</a> or a <a href="http://www.prototypejs.org" rel="nofollow noreferrer">similar</a> <a href="http://www.mootools.net" rel="nofollow noreferrer">framework</a>.</p>
<p>BUT if you actually want to understand the technology and what is happening behind the scenes, I'd continue doing what you're doing and asking specific questions as you try to build a small lightweight AJAX class on your own. This is how I done it, and although I use the jQuery framework today.. I'm still glad I know how it works behind the scenes.</p>
|
<p>I would use a framework like <a href="http://www.domassistant.com/" rel="nofollow noreferrer">DOMAssistant</a> which has already done the hard work for you and will be more robust as well as adding extra useful features.</p>
<p>Apart from that, you code looks like it would do the job.</p>
| 6,510
|
<p>On a recent Java project, we needed a free Java based real-time data plotting utility. After much searching, we found this tool called the <a href="http://www.epic.noaa.gov/java/sgt/" rel="noreferrer">Scientific Graphics Toolkit or SGT</a> from NOAA. It seemed pretty robust, but we found out that it wasn't terribly configurable. Or at least not configurable enough to meet our needs. We ended up digging very deeply into the Java code and reverse engineering the code and changing it all around to make the plot tool look and act the way we wanted it to look and act. Of course, this killed any chance for future upgrades from NOAA. </p>
<p>So what free or cheap Java based data plotting tools or libraries do you use?</p>
<p><em>Followup: Thanks for the <a href="http://www.jfree.org/jfreechart/" rel="noreferrer">JFreeChart</a> suggestions. I checked out their website and it looks like a very nice data charting and plotting utility. I should have made it clear in my original question that I was looking specifically to plot real-time data. I corrected my question above to make that point clear. It appears that <a href="http://www.jfree.org/jfreechart/faq.html#FAQ5" rel="noreferrer">JFreeChart support for live data is marginal at best, though</a>. Any other suggestions out there?</em></p>
|
<p>I've had success using <a href="http://www.jfree.org/jfreechart/" rel="noreferrer">JFreeChart</a> on multiple projects. It is <em>very</em> configurable. JFreeChart is open source, but they charge for the <a href="http://www.jfree.org/jfreechart/devguide.html" rel="noreferrer">developer guide</a>. If you're doing something simple, the sample code is probably good enough. Otherwise, $50 for the developer guide is a pretty good bargain.</p>
<p>With respect to "real-time" data, I've also used JFreeChart for these sorts of applications. Unfortunately, I had to create some custom data models with appropriate synchronization mechanisms to avoid race conditions. However, it wasn't terribly difficult and JFreeChart would still be my first choice. However, as the FAQ suggests, JFreeChart might not give you the best performance if that is a big concern.</p>
|
<p>You might want to check out JMathPlot</p>
| 2,832
|
<p>To analyze lots of text logs I did some hackery that looks like this:</p>
<ol>
<li>Locally import logs into Access </li>
<li>Reprocess Cube link to previous mdb in Analisis Service 2000 (yes it is 2k)</li>
<li>Use Excel to visualize Cube (it is not big - up to milions raw entries)</li>
</ol>
<p>My hackery is a succes and more people are demanding an access to my Tool. As you see I see more automating and easier deployment.</p>
<p>Do you now some tools/libraries that would give me the same but with easier deployment?
Kind of <strong>embedded OLAP</strong> service?</p>
<p><strong>Edit:</strong> I heard of Mondrian but we don't do much with Java. Have you seen something similiar done for .Net/Win32 ? Comercial is also OK.</p>
|
<p>You could also try the other free open source OLAP server, PALO from Jedox (www.palo.net)</p>
|
<p>I dont think that Mondrian is better than SSAS but I do know that its free and you independently distribute it. It uses XMLA and its cube definition XML file is almost the same as SSAS.</p>
| 2,653
|
<p>Simply, are there any Java Developer specific Linux distros?</p>
|
<p>A real Sun geek would chime in here about the virtues of using Solaris as a Java development platform, but I am much more ambivalent. Developing with Java is about the same on any linux distro; you are going to wind up having to install the JDK and tools of your choosing (Eclipse, Sun Studio, Tomcat, etc) so you may as well choose a distro on other criteria... perhaps how comfortable you are with it, how easy package management is, and if the look & feel suit your development habits are all big factors.</p>
<p>So, to answer your question more directly, a Java developer would do well with any major linux distro that they are comfortable with using in general. If you want some Java goodness out of the box, Fedora 9 and Ubuntu 8.04 have OpenJDK (and NetBeans) according to <a href="http://www.vnunet.com/vnunet/news/2215568/open-source-java-added-linux" rel="noreferrer">a recent announcement</a>.</p>
|
<p>While not <em>really</em> a distribution, there is a virtual machine available for <a href="http://virtualappliances.net/products/tomcat.php" rel="nofollow noreferrer">Tomcat</a>. It could be adapted pretty easily for other Java based deployments (available for several virtualization technologies). </p>
<p>There are also several Java App Server VMs available from <a href="http://www.vmware.com/appliances/" rel="nofollow noreferrer">VMWare</a> (VMWare only, of course). </p>
| 7,057
|
<p>I have a multiple selection SELECT field which I don't want the end user to be able to change the value of. </p>
<p>For UI reasons, I would like to be able to do this without using the disabled="true" attribute. I've tried using onmousedown, onfocus, onclick and setting each to blur or return false but with no success.</p>
<p>Can this be done or am I trying to do the impossible?</p>
|
<p>I know you mentioned that you don't want to, but I actually think that using the <code>disabled</code> attribute is a better solution:</p>
<pre><code><select multiple="multiple">
<option value="volvo" selected="true" disabled="disabled">Volvo</option>
<option value="saab" disabled="disabled">Saab</option>
<option value="opel" disabled="disabled">Opel</option>
<option value="audi" disabled="disabled">Audi</option>
</select>
</code></pre>
<p>If necessary, you can always give the <code>select</code> a <code>class</code> and style it with CSS. This solution will work in all browsers regardless of scripting capabilities.</p>
|
<p>@Jack & @17 of 26, good point but the end user will be expecting the select box to be disabled so that confusion shouldn't be an issue. </p>
<p>I should have been clearer about why I couldn't just disable the control. </p>
<p>The application that will be using this will need to disable the selection of the options and there is a requirement that the "locked" control still maintain the look and feel of normal form controls.</p>
| 6,551
|
<p>I'd like to have a <code>TabNavigator</code> component that has a close button for some of the tabs. How do I do that? <br>
It seems that the <code>TabNavigator</code> component does not allow (or I could not find) extensibility of this form.
Help. Thanks</p>
|
<p>You should take a look at the SuperTabNavigator component from the <a href="http://code.google.com/p/flexlib/" rel="nofollow noreferrer">FlexLib</a> project:</p>
<ul>
<li><a href="http://flexlib.googlecode.com/svn/trunk/examples/SuperTabNavigator_Sample.swf" rel="nofollow noreferrer">SuperTabNavigator example</a></li>
<li><a href="http://flexlib.googlecode.com/svn/trunk/docs/flexlib/containers/SuperTabNavigator.html" rel="nofollow noreferrer">SuperTabNavigator documentation</a></li>
<li><a href="http://code.google.com/p/flexlib/wiki/ComponentList" rel="nofollow noreferrer">FlexLib Component list</a></li>
</ul>
<p>If you don't want all of the tabs to have close buttons (I understand from the question that you don't) it looks like you could use the <a href="http://flexlib.googlecode.com/svn/trunk/docs/flexlib/containers/SuperTabNavigator.html#setClosePolicyForTab()" rel="nofollow noreferrer">setClosePolicyForTab()</a> method for specifying which tabs you want to have them.</p>
|
<p>Spark Based Component</p>
<p><a href="http://blog.flexwiz.net/spark-tabs-with-close-button/" rel="nofollow"> <strong>flexwiz</strong> spark-tabs-with-close-button</a></p>
| 9,305
|
<p>Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this?</p>
<p>I'm looking for a checklist or timeline of action items, such as</p>
<ul>
<li>8:30 shut down apps</li>
<li>8:45 modify schema</li>
<li>9:15 install new apps</li>
<li>9:30 restart db</li>
</ul>
<p>etc, showing how to minimize risk and downtime. Issues such as</p>
<ul>
<li>backing out of the upgrade if things go awry</li>
<li>minimizing impact to existing apps</li>
<li>"hot" updates while the database is running</li>
<li>promoting from dev to test to production servers</li>
</ul>
<p>are especially of interest.</p>
|
<p>I have a lot of experience with this. My application is highly iterative, and schema changes happen frequently. I do a production release roughly every 2 to 3 weeks, with 50-100 items cleared from my FogBugz list for each one. Every release we've done over the last few years has required schema changes to support new features.</p>
<p>The key to this is to practice the changes several times in a test environment before actually making them on the live servers.</p>
<p>I keep a deployment checklist file that is copied from a template and then heavily edited for each release with anything that is out of the ordinary.</p>
<p>I have two scripts that I run on the database, one for schema changes, one for programmability (procedures, views, etc). The changes script is coded by hand, and the one with the procs is scripted via Powershell. The change script is run when everything is turned off (you have to pick a time that annoys the least amount of users for this), and it is run command by command, manually, just in case anything goes weird. The most common problem I have run into is adding a unique constraint that fails due to duplicate rows.</p>
<p>When preparing for an integration testing cycle, I go through my checklist on a test server, as if that server was production. Then, in addition to that, I go get an actual copy of the production database (this is a good time to swap out your offsite backups), and I run the scripts on a restored local version (which is also good because it proves my latest backup is sound). I'm killing a lot of birds with one stone here.</p>
<p>So that's 4 databases total:</p>
<ol>
<li>Dev: all changes must be made in the change script, never with studio.</li>
<li>Test: Integration testing happens here</li>
<li>Copy of production: Last minute deployment practice</li>
<li>Production</li>
</ol>
<p>You really, really need to get it right when you do it on production. Backing out schema changes is hard.</p>
<p>As far as hotfixes, I will only ever hotfix procedures, never schema, unless it's a very isolated change and crucial for the business.</p>
|
<p>This is a topic that I was just talking about at work. Mainly the problem is that unless database migrations is handled for you nicely by your framework, eg rails and their migration scripts, then it is left up to you. </p>
<p>The current way that we do it has apparent flaws, and I am open to other suggestions. </p>
<ol>
<li>Have a schema dump with static data that is required to be there kept up to date and in version control. </li>
<li>Every time you do a schema changing action, ALTER, CREATE, etc. dump it to a file and throw it in version control. </li>
<li>Make sure you update the original sql db dump. </li>
<li>When doing pushes to live make sure you or your script applies the sql files to the db. </li>
<li>Clean up old sql files that are in version control as they become old.</li>
</ol>
<p>This is by no means optimal and is really not intended as a "backup" db. It's simply to make pushes to live easy, and to keep developers on the same page. There is probably something cool you could setup with capistrano as far as automating the application of the sql files to the db. </p>
<p>Db specific version control would be pretty awesome. There is probably something that does that and if there isn't there probably should be. </p>
| 5,123
|
<p>I want to print a model of an animal cell.</p>
<p>What I have so far: I managed to use different colors to print out the different parts of the cell.<br>
My question is: what is the best way to connect plastic 3d printed parts?<br>
Glue? Melted plastic? I need it to have a strong connection and not very visible when used well, and preferable dries fast.</p>
|
<p>For ABS print, I recommend <a href="https://en.wikipedia.org/wiki/Acetone" rel="nofollow">acetone</a>. It is not a glue, but it will dissolve the plastic a bit and if you apply it to both connecting parts and push them together, they will stay connected after the acetone dries. However, it does not dry very fast and you have to be careful not to destroy the object.</p>
<p>For PLA I usually use regular super glue (<a href="https://en.wikipedia.org/wiki/Cyanoacrylate" rel="nofollow">Cyanoacrylate</a>).</p>
|
<p>After doing the processes that hroncok described, the edges of the print can be finished with a 3D printing pen. The pen extrudes filament as a regular print head does, but is hand held. The filament can be extruded on the previous gap between the two prints. It will melt between the two sides and can be finished to create a smooth connection point.</p>
| 100
|
<p>What is the configuration setting for modifying the default homepage in a Grails application to no longer be appName/index.gsp? Of course you can set that page to be a redirect but there must be a better way.</p>
|
<p>Add this in UrlMappings.groovy </p>
<pre>
"/" {
controller = "yourController"
action = "yourAction"
}
</pre>
<p>By configuring the URLMappings this way, the home-page of the app will be yourWebApp/yourController/yourAction.</p>
<p>(cut/pasted from <a href="http://blog.intelligrape.com/?p=18" rel="noreferrer">IntelliGrape Blog</a>)</p>
|
<p>All the answers are correct!
But let's imagine a scenario: </p>
<p>I mapped path "/" with the controller: "Home" and action: "index", so when i access "/app-name/" the controller Home gets executed, but if i type the path "/app-name/home/index", it will still be executed! so there are 2 paths for one resources. it would work until some one finds out "home/index" path.</p>
<p>another thing is if I have a form without any action attribute specified, so by default it will be POST to the same controller and action! so if the form is mapped to "/" path and no action attribute is specified then it will be submitted to the same controller, but this time the path will be "home/index" in your address-bar, not "/", because it's being submitted to the controller/action not to the URI.</p>
<p>To solve this problem what you have to do, is to remove or comment out these lines.</p>
<pre><code>// "/$controller/$action?/$id?(.$format)?"{
// constraints {
// // apply constraints here
// }
// }
</code></pre>
<p>So now when you access "/", will work. but "home/index" will not. But there's a one flaw, now you have to map all the paths to the controllers manually by explicitly writing into URLMapping file. I guess this would help! </p>
| 4,751
|
<p>You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are irrelevant, you can remove them or avoid them if you like.</p>
<p>To be clear, I'm interested in the algorithm. Feel free to post code in any language and paradigm that you like.</p>
|
<p>Edit as of 2018: You should probably stop reading this. (But I can't delete it as it is accepted.)</p>
<p>If you write out the sums like this:</p>
<pre><code>1 4 5 6 8 9
---------------
2 5 6 7 9 10
8 9 10 12 13
10 11 13 14
12 14 15
16 17
18
</code></pre>
<p>You'll notice that since M[i,j] <= M[i,j+1] and M[i,j] <= M[i+1,j], then you only need to examine the top left "corners" and choose the lowest one.</p>
<p>e.g.</p>
<ul>
<li>only 1 top left corner, pick 2</li>
<li>only 1, pick 5</li>
<li>6 or 8, pick 6</li>
<li>7 or 8, pick 7</li>
<li>9 or 8, pick 8</li>
<li>9 or 9, pick both :)</li>
<li>10 or 10 or 10, pick all</li>
<li>12 or 11, pick 11</li>
<li>12 or 12, pick both</li>
<li>13 or 13, pick both</li>
<li>14 or 14, pick both</li>
<li>15 or 16, pick 15</li>
<li>only 1, pick 16</li>
<li>only 1, pick 17</li>
<li>only 1, pick 18</li>
</ul>
<p>Of course, when you have <em>lots</em> of top left corners then this solution devolves.</p>
<p>I'm pretty sure this problem is Ω(n²), because you have to calculate the sums for each M[i,j] -- unless someone has a better algorithm for the summation :)</p>
|
<p>If you are looking for a truly language agnostic solution then you will be sorely disappointed in my opinion because you'll be stuck with a for loop and some conditionals. However if you opened it up to functional languages or functional language features (I'm looking at you LINQ) then my colleagues here can fill this page with elegant examples in Ruby, Lisp, Erlang, and others.</p>
| 2,324
|
<p>My printer is calibrated for a certain clearance from the heated bed, which is chosen based on PLA.</p>
<p>I would like to try to increase it for the first layer for PETG, so that adhesion is reduced. The printer has M5 screws with 4000 steps/mm, so the resolution clearly allows that. </p>
<p>I don't want to modify the printer, I would like a G-Code or another option that I can apply in Prusa slicer in association with the specific filament when desired. I don't want to change the flow rate of the first layer, only the "zero" distance.</p>
<p>How can I do that?</p>
|
<p>Maybe you would be better off with TPU or some other type of flexible material...</p>
<p>I have been able to print PLA and have it flex quite a bit, but that was an ~0.2mm single layer print, I guess maybe up to 0.3-0.4mm should still be a little bit flexible, but not much. Also since you want it to wipe things, maybe you should look if TPU even has all the properties required for that as Carl mentioned in the comments.</p>
|
<p>You can not 3D print that because there is no nozzle or method for producing filaments of the required size. A few microns at least. You might be able to spin molten pla like cotton candy and it might absorb; but I doubt it.</p>
<p><a href="https://phys.org/news/2010-05-cotton-candy-machine-tiny-nanofibers.html" rel="nofollow noreferrer">https://phys.org/news/2010-05-cotton-candy-machine-tiny-nanofibers.html</a> </p>
<p><a href="https://i.stack.imgur.com/VFHQd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VFHQd.jpg" alt="Rotary Jet-Spinning"></a></p>
| 1,627
|
<p>How would you design a database to support the following tagging features:</p>
<ul>
<li>items can have a large number of tags</li>
<li>searches for all items that are tagged with a given set of tags must be quick (the items must have ALL tags, so it's an AND-search, not an OR-search)</li>
<li>creating/writing items may be slower to enable quick lookup/reading</li>
</ul>
<p>Ideally, the lookup of all items that are tagged with (at least) a set of n given tags should be done using a single SQL statement. Since the number of tags to search for as well as the number of tags on any item are unknown and may be high, using JOINs is impractical.</p>
<p>Any ideas?</p>
<hr>
<p>Thanks for all the answers so far.</p>
<p>If I'm not mistaken, however, the given answers show how to do an OR-search on tags. (Select all items that have one or more of n tags). I am looking for an efficient AND-search. (Select all items that have ALL n tags - and possibly more.)</p>
|
<p>About ANDing: It sounds like you are looking for the "relational division" operation. <a href="http://www.dbazine.com/ofinterest/oi-articles/celko1" rel="noreferrer">This article</a> covers relational division in concise and yet comprehendible way.</p>
<p>About performance: A bitmap-based approach intuitively sounds like it will suit the situation well. However, I'm not convinced it's a good idea to implement bitmap indexing "manually", like digiguru suggests: It sounds like a complicated situation whenever new tags are added(?) But some DBMSes (including Oracle) offer bitmap indexes which may somehow be of use, because a built-in indexing system does away with the potential complexity of index maintenance; additionally, a DBMS offering bitmap indexes should be able to consider them in a proper when when performing the query plan.</p>
|
<p>You won't be able to avoid joins and still be somewhat normalized.</p>
<p>My approach is to have a Tag Table.</p>
<pre><code> TagId (PK)| TagName (Indexed)
</code></pre>
<p>Then, you have a TagXREFID column in your items table.</p>
<p>This TagXREFID column is a FK to a 3rd table, I'll call it TagXREF:</p>
<pre><code> TagXrefID | ItemID | TagId
</code></pre>
<p>So, to get all tags for an item would be something like:</p>
<pre><code>SELECT Tags.TagId,Tags.TagName
FROM Tags,TagXref
WHERE TagXref.TagId = Tags.TagId
AND TagXref.ItemID = @ItemID
</code></pre>
<p>And to get all items for a tag, I'd use something like this:</p>
<pre><code>SELECT * FROM Items, TagXref
WHERE TagXref.TagId IN
( SELECT Tags.TagId FROM Tags
WHERE Tags.TagName = @TagName; )
AND Items.ItemId = TagXref.ItemId;
</code></pre>
<p>To AND a bunch of tags together, You would to modify the above statement slightly to add AND Tags.TagName = @TagName1 AND Tags.TagName = @TagName2 etc...and dynamically build the query.</p>
| 7,092
|
<p>In C++ we acquiring a resource in a constructor and release it in a destructor.</p>
<p>So when an exception rises in a middle of a function there will be no resource leak or locked mutexes or whatever.</p>
<p>AFAIK java classes don't have destructors. So how does one do the resource management in Java.</p>
<p>For example:</p>
<pre><code>public int foo() {
Resource f = new Resource();
DoSomething(f);
f.Release();
}
</code></pre>
<p>How can one release resource if DoSomething throws an exception? We can't put try\catch blocks all over the code, can we?</p>
|
<p>Yes you can and should put try/catch/finally block around your code. In C# there is a shorthand "using" statement, but in Java you are stuck with:</p>
<pre><code>public int foo() {
Resource f = new Resource();
try {
DoSomething(f);
}
finally {
f.Release();
}
}
</code></pre>
|
<p>Sorry to disappoint you but in Java we <strong>do</strong> use try\catch\finally blocks a lot. And with "a lot", I mean <strong>A LOT</strong>. I do sometimes wish that Java has the C# using block. Most of the time you won't need to free up resources as Java's garbage collector will take care of that.</p>
<p>However exceptions do have their uses in making error handling a lot cleaner. You can write your own exceptions and catch them for whatever you are doing. No more returning arbitrary error codes to the user!</p>
| 8,292
|
<p>I've created a map system for a game that runs on the principle of drawing the picture of the map from tiles. There are many reasons for this which I won't go into here but if you really want to know then I'm sure you can find out how to contact me ;)</p>
<p>I have <a href="http://woarl.com/board/rob.php?mode=map&x=-1&y=9&w=2&h=2" rel="noreferrer">made the latest version live</a> so you can see exactly where the problem lies and the source. The issue is the line between the top 2 tiles and the bottom 2 tiles, I can't figure out why it's gone like this and any help would be appreciated.</p>
<p>In the source is a marker called "stackoverflow", if you search for "stackoverflow" when viewing source then it should take you to the table in question.</p>
<p>I have also uploaded an <a href="http://woarl.com/badMap.png" rel="noreferrer">image of the issue</a>.</p>
|
<p>I think you need to use <code>display: block</code> on your images. When images are <code>inline</code> there's a little extra space for the line spacing.</p>
|
<p>I haven't looked up the whole thing, but the problem lies somewhere in the style sheets.</p>
<p>If you copy out only the table part of it, it is displaying the map correctly.</p>
<p>If you remove the final <code></span></code> tag from this part, it is also working (however the page gets mixed):</p>
<pre><code><div class="inner"><span class="corners-top"><span></span></span>
<div class="content" style="font-size: 1.1em;">
<!-- Stackoverflow findy thingy -->
<table border="0" cellspacing="0" cellpadding="0">
</code></pre>
<p>So either try from the beginning with the css or try to remove one-by-one them, to see, which is causing the problem.</p>
| 4,202
|
<p>I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help? </p>
|
<p>Generally, the way you implement it is simply to add the required function to your view's controller, and set its delegate. For example, if you want code to run when the view loads, you just delegate your view to the controller, and implement the awakeFromNib function.</p>
<p>So, to detect a key press in a text view, make sure your controller is the text view's delegate, and then implement this:</p>
<pre><code>- (void)keyUp:(NSEvent *)theEvent
</code></pre>
<p>Note that this is an inherited NSResponder method, not a NSTextView method.</p>
|
<p>I've done some hard digging, and I did find an answer to my own question. I'll get at it below, but thanks to the two fellas who replied. I think that Stack Overflow is a fantastic site already--I hope more Mac developers find their way in once the beta is over--this could be a great resource for other developers looking to transition to the platform.</p>
<p>So, I did, as suggested by Danny, find my answer in delegation. What I didn't understand from Danny's post was that there are a set of delegate-enabled methods in the delegating object, and that the delegate must implement said events. And so for a TextView, I was able to find the method textDidChange, which accomplished what I wanted in an even better way than simply capturing key presses would have done. So if I implement this in my controller:</p>
<pre><code>- (void)textDidChange:(NSNotification *)aNotification;
</code></pre>
<p>I can respond to the text being edited. There are, of course, other methods available, and I'm excited to play with them, because I know I'll learn a whole lot as I do. Thanks again, guys.</p>
| 3,244
|
<p>Perhaps the biggest risk in pushing new functionality to live lies with the database modifications required by the new code. In Rails, I believe they have 'migrations', in which you can programmatically make changes to your development host, and then make the same changes live along with the code that uses the revised schema. And roll both backs if needs be, in a synchronized fashion.</p>
<p>Has anyone come across a similar toolset for PHP/MySQL? Would love to hear about it, or any programmatic or process solutions to help make this less risky...</p>
|
<p>I've never come across a tool that would do the job. Instead I've used individual files, numbered so that I know which order to run them: essentially, a manual version of Rails migrations, but without the rollback.</p>
<p>Here's the sort of thing I'm talking about:</p>
<pre><code>000-clean.sql # wipe out everything in the DB
001-schema.sql # create the initial DB objects
002-fk.sql # apply referential integrity (simple if kept separate)
003-reference-pop.sql # populate reference data
004-release-pop.sql # populate release data
005-add-new-table.sql # modification
006-rename-table.sql # another modification...
</code></pre>
<p>I've never actually run into any problems doing this, but it's not very elegant. It's up to you to track which scripts need to run for a given update (a smarter numbering scheme could help). It also works fine with source control.</p>
<p>Dealing with surrogate key values (from autonumber columns) can be a pain, since the production database will likely have different values than the development DB. So, I try never to reference a literal surrogate key value in any of my modification scripts if at all possible.</p>
|
<p>I've always preferred to keep my development site pointing to the same DB as the live site. This may sound risky at first but in reality it solves many problems. If you have two sites on the same server pointing to the same DB, you get a real time and accurate view of what your users will see when it goes live. </p>
<p>You will only ever have 1 database and so long as you make it a policy to never delete a column from a table, you know your new code will match up with the database you are using.</p>
<p>There is also significantly less havoc when migrating. You only need to move over the PHP scripts and they are already tested using the same DB.</p>
<p>I also tend to create a symlink to any folder that is a target for user uploads. This means there is no confusion on which user files have been updated.</p>
<p>Another side affect is the option of porting over a small group of 'beta-testers' to use the site in everyday use. This can lead to a lot of feedback that you can implement <em>before</em> the public launch.</p>
<p>This may not work in all cases but I've started moving all my updates to this model. It's caused much smoother development and launches.</p>
| 5,548
|
<p>I am still at calibration stage and need some info from the PCB. I connected the USB and ran Repetier. The PCB wants to talk at a higher baud rate than my serial port says it can do. I tried setting the serial port to its highest setting 125k and reduced the PCB baud in Repetier setting to 125k. No joy. PC port reverts to 9600 every time I check it. Thoughts?</p>
<p>PC running Windows 7 Home Premium 32bit.</p>
|
<p>Sorted. Repetier Server was hijacking my com port. Uninstalled it and Repetier host worked fine. As I have no desire to monitor or control prints remotely I have no use for the server software.</p>
<p>Hope that helps others.</p>
|
<p>My A8 just started doing this. </p>
<p>I shut down repetier server, and voila, all is good! Since I will go do OctoPi eventually, I just uninstalled RS.</p>
| 787
|
<p>In <a href="http://www.codinghorror.com/blog/archives/001152.html" rel="nofollow noreferrer">Maybe Normalizing Isn't Normal</a> Jeff Atwood says, "You're automatically measuring all the queries that flow through your software, right?" I'm not but I'd like to. </p>
<p>Some features of the application in question:</p>
<ul>
<li>ASP.NET</li>
<li>a data access layer which depends on the <a href="http://msdn.microsoft.com/en-us/library/cc309504.aspx" rel="nofollow noreferrer">MS Enterprise Library Data Access Application Block</a></li>
<li>MS SQL Server</li>
</ul>
|
<p>In addition to Brad's mention of SQL Profiler, if you want to do this in code, then <strong>all your database calls need to funnelled through a common library</strong>. You insert the timing code there, and voila, you know how long every query in your system takes.</p>
<p>A single point of entry to the database is a fairly standard feature of any ORM or database layer -- or at least it has been in any project I've worked on so far!</p>
|
<p>The <a href="http://www.codeplex.com/dropthings" rel="nofollow noreferrer">Dropthings</a> project on CodePlex has a class for timing blocks of code.
The class is named TimedLog. It implements IDisposable. You wrap the block of code you wish to time in a using statement.</p>
| 3,180
|
<p>What are some good resources to learn best practices for Javascript? I'm mainly concerned about when something should be an object vs. when it should just be tracked in the DOM. Also I would like to better learn how to organize my code so it's easy to unit test.</p>
|
<p>Seconding <a href="http://oreilly.com/catalog/9780596517748/" rel="noreferrer">Javascript: The Good Parts</a> and Resig's book <a href="http://jsninja.com/" rel="noreferrer">Secrets of the Javascript Ninja</a>.</p>
<p>Here are some tips for Javascript:</p>
<ul>
<li>Don't pollute the global namespace (put all functions into objects/closures)
<ul>
<li>Take a look at <a href="http://developer.yahoo.com/yui/" rel="noreferrer">YUI</a>, it's a huge codebase with only 2 global objects: YAHOO and YAHOO_config</li>
</ul></li>
<li>Use the Module pattern for singletons (<a href="http://yuiblog.com/blog/2007/06/12/module-pattern/" rel="noreferrer">http://yuiblog.com/blog/2007/06/12/module-pattern/</a>)</li>
<li>Make your JS as reusable as possible (jQuery plugins, YUI modules, basic JS objects.) Don't write tons of global functions.</li>
<li>Don't forget to var your variables</li>
<li>Use JSlint : <a href="http://www.jslint.com/" rel="noreferrer">http://www.jslint.com/</a></li>
<li>If you need to save state, it's probably best to use objects instead of the DOM.</li>
</ul>
|
<p>You can pick up a lot from <a href="https://rads.stackoverflow.com/amzn/click/com/1590597273" rel="nofollow noreferrer" rel="nofollow noreferrer">Pro JavaScript Techniques</a>, and I'm looking forward to Resig's forthcoming <a href="http://jsninja.com/" rel="nofollow noreferrer">Secrets of the JavaScript Ninja</a>.</p>
| 6,080
|
<p>I have a list of objects I wish to sort based on a field <code>attr</code> of type string. I tried using <code>-</code></p>
<pre><code>list.sort(function (a, b) {
return a.attr - b.attr
})
</code></pre>
<p>but found that <code>-</code> doesn't appear to work with strings in JavaScript. How can I sort a list of objects based on an attribute with type string?</p>
|
<p>Use <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare" rel="noreferrer"><code>String.prototype.localeCompare</code></a> a per your example:</p>
<pre><code>list.sort(function (a, b) {
return ('' + a.attr).localeCompare(b.attr);
})
</code></pre>
<p>We force a.attr to be a string to avoid exceptions. <code>localeCompare</code> has been supported <a href="https://learn.microsoft.com/en-us/scripting/javascript/reference/localecompare-method-string-javascript" rel="noreferrer">since Internet Explorer 6</a> and Firefox 1. You may also see the following code used that doesn't respect a locale:</p>
<pre><code>if (item1.attr < item2.attr)
return -1;
if ( item1.attr > item2.attr)
return 1;
return 0;
</code></pre>
|
<pre><code><!doctype html>
<html>
<body>
<p id = "myString">zyxtspqnmdba</p>
<p id = "orderedString"></p>
<script>
var myString = document.getElementById("myString").innerHTML;
orderString(myString);
function orderString(str) {
var i = 0;
var myArray = str.split("");
while (i < str.length){
var j = i + 1;
while (j < str.length) {
if (myArray[j] < myArray[i]){
var temp = myArray[i];
myArray[i] = myArray[j];
myArray[j] = temp;
}
j++;
}
i++;
}
var newString = myArray.join("");
document.getElementById("orderedString").innerHTML = newString;
}
</script>
</body>
</html>
</code></pre>
| 7,412
|
<p>I'm working with a SQL Server 2000 database that likely has a few dozen tables that are no longer accessed. I'd like to clear out the data that we no longer need to be maintaining, but I'm not sure how to identify which tables to remove.</p>
<p>The database is shared by several different applications, so I can't be 100% confident that reviewing these will give me a complete list of the objects that are used.</p>
<p>What I'd like to do, if it's possible, is to get a list of tables that haven't been accessed at all for some period of time. No reads, no writes. How should I approach this?</p>
|
<p>MSSQL2000 won't give you that kind of information. But a way you can identify what tables ARE used (and then deduce which ones are not) is to use the SQL Profiler, to save all the queries that go to a certain database. Configure the profiler to record the results to a new table, and then check the queries saved there to find all the tables (and views, sps, etc) that are used by your applications. </p>
<p>Another way I think you might check if there's any "writes" is to add a new timestamp column to every table, and a trigger that updates that column every time there's an update or an insert. But keep in mind that if your apps do queries of the type </p>
<pre><code>select * from ...
</code></pre>
<p>then they will receive a new column and that might cause you some problems. </p>
|
<p>If you have lastupdate columns you can check for the writes, there is really no easy way to check for reads. You could run profiler, save the trace to a table and check in there</p>
<p>What I usually do is rename the table by prefixing it with an underscrore, when people start to scream I just rename it back</p>
| 5,552
|
<p>Most text editors have a navigation pane that lets you see all the files you currently have open. Or a pane that lets you browse a file directory.</p>
<p>How do I do this in Emacs?</p>
|
<p>Try <kbd>Ctrl-x</kbd> followed by <kbd>Ctrl-b</kbd> (in Emacs terminology <kbd>C-x C-b</kbd>) to list buffers.</p>
|
<p>Also, if you want to get rid of the list of open buffers, type <kbd>C-x 1</kbd>.</p>
| 9,041
|
<p>Is there a way of reducing the amount and strength of Model support when slicing in Cura?</p>
<p>Cleaning a model with large amounts of support can consume large amounts of time.</p>
|
<p>There's a lot that can be done to improve the removability of supports, and much of this is not widely known/published.</p>
<p>One big wrong default in Cura that contributes to problems with support is <em>Limit Support Retractions</em>, which defaults to on. This causes heavy stringing between components of the support structure that should be separate, and poor layer adhesion between layers of the support <em>and between layers of whatever is printed right after the support</em> (!!), making support more brittle and difficult to remove in clean chunks. This setting should be turned off.</p>
<p>I find <em>Enable Support Brim</em> is also useful. Its nominal purpose is to make supports adhere to the bed better, but it also gives them more of a solid bottom so that the structure is rigid and admits snapping off as a chunk.</p>
<p>A nonzero <em>Support Wall Line Count</em> (it's zero by default for zigzag and most support patterns, but one by default for support tree and others) can make chunks of support easier to remove by making them more rigid.</p>
<p><em>Connect Support Lines</em> (also called <code>zig_zaggify_infill</code>) helps with rigidity too, and with reducing time wasted on retractions once you turn off <em>Limit Support Retractions</em>.</p>
<p>Aside from these less-well-known tunables, the obvious ones are <em>Support Z Distance</em> and <em>Support X/Y Distance</em>, especially Z. You can increase this slightly from the default to make supports easier to remove, but it will hurt the quality of the surface just above the support (making it less flat, more stringy like a bridge). And the biggest one of all is <em>Support Angle</em>. Generally increase it as high as you can go, after doing some test prints to determine the maximum overhang angle you can print without support. This will save material and make it easier to remove what supports remain.</p>
<p>Finally, aside from support options, you want to make sure you don't have underlying print problems causing oozing, bulging, or other dimensional-accuracy/extrusion-accuracy issues. This is because any material that is printed or expands into the wrong place will, if it's adjacent to support material, bond to the support material and make it hard to remove.</p>
|
<p>You could reduce the <code>Support Density</code>:</p>
<blockquote>
<p>A higher value results in better overhangs, but the supports are harder to remove.</p>
</blockquote>
<p>Furthermore read <a href="https://3dprinting.stackexchange.com/a/7991/">this answer</a> on question: "<a href="https://3dprinting.stackexchange.com/questions/7989/difficult-to-remove-support-material/">Difficult to remove support material</a>".</p>
| 1,722
|
<p>We are trying to lighten our page load as much as possible. Since ViewState can sometimes swell up to 100k of the page, I'd love to completely eliminate it.</p>
<p>I'd love to hear some techniques other people have used to move ViewState to a custom provider.</p>
<p>That said, a few caveats:</p>
<ul>
<li>We serve on average 2 Million unique visitors per hour.</li>
<li>Because of this, Database reads have been a serious issue in performance, so I don't want to store ViewState in the database.</li>
<li>We also are behind a load balancer, so any solution has to work with the user bouncing from machine to machine per postback.</li>
</ul>
<p>Ideas?</p>
|
<p>How do you handle Session State? There is a built-in "store the viewstate in the session state" provider. If you are storing the session state in some fast, out of proc system, that might be the best option for the viewstate.</p>
<p>edit: to do this add the following code to the your Page classes / global page base class</p>
<pre><code> protected override PageStatePersister PageStatePersister {
get { return new SessionPageStatePersister(this); }
}
</code></pre>
<p>Also... this is by no means a perfect (or even good) solution to a large viewstate. As always, minimize the size of the viewstate as much as possible. However, the SessionPageStatePersister is relatively intelligent and avoids storing an unbounded number of viewstates per session as well as avoids storing only a single viewstate per session.</p>
|
<p>Due to the typical organizational bloat, requesting new hardware takes eons, and requesting hardware that would involve a complete rewire of our current setup would probably get some severe resistance from the engineering department.</p>
<p>I really need to come up with a software solution, because that's the only world I have some control over.</p>
<p>Yay for Enterprise :(</p>
| 7,042
|
<p>I find myself doing some relatively advanced stuff with memcached in PHP. It's becoming a mental struggle to think about and resolve race conditions and concurrency issues caused by the lock-free nature of the cache.</p>
<p>PHP seems pretty poor in tools when it comes to concurrency (threads, anyone?), so I wonder if there are any solutions out there to test/debug this properly. </p>
<p>I don't want to wait until two users request two scripts that will run as parallel processes at the same time and cause a concurrency issue that will leave me scratching my head, or that I might not ever notice until it snowballs into a clusterfsck.</p>
<p>Any magic PHP concurrency wand I should know of?</p>
|
<p>PHP is not a language designed for multi-threading, and I don't think it ever will be.</p>
<p>If you need mutex functionality, PHP has a <a href="http://us.php.net/sem" rel="nofollow noreferrer">Semaphore</a> functions you can compile in. </p>
<p>Memcache has no mutex capability, but it can be emulated using the <a href="http://us.php.net/manual/en/function.memcache-add.php" rel="nofollow noreferrer">Memcache::add()</a> method.</p>
<p>If you are using a MySQL database, and are trying to prevent some kind of race condition corruption, you can use the <a href="http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html" rel="nofollow noreferrer">lock tables</a> statement, or use <a href="https://web.archive.org/web/20081219053301/http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-transactions.html" rel="nofollow noreferrer">transactions</a>.</p>
|
<p>Not specifically for this issue but: <a href="http://www.firephp.org/" rel="nofollow noreferrer">FirePHP</a>?</p>
| 9,253
|
<p>I've been noticing in some of my linear advance test towers that the (very minor/fine) ripple pattern in walls varies with the K factor, which made me think that it isn't coming from any vibration in the print head motion, but rather from quantization of the extruder into discrete steps (i.e. wall gets slightly thicker right after a step, thins out afterwards until the next step, repeats).</p>
<p>By my math, with 1.75 mm filament and 93 steps per mm on my printer (Ender 3), each step is 0.02585 mm³ of material. At 0.4 mm line width and 0.2 mm layer height, there's 0.08 mm³ of material per linear mm, so that should give roughly 3 extruder steps per linear mm. That seems comparable to the ripple rate I see, although not exact; I suppose it varies somewhat because of linear advance and perhaps other reasons.</p>
<p>Anyway, to get to the question, am I missing something or is this the limiting factor in print resolution on my printer? It seems like isolated small details (smaller than 1/3 mm) won't be extrudable at all except as ooze, or over-extruded if they happen to cross a step threshold, and like things would be far worse if I tried to use a smaller nozzle and thinner layers. It seems that, ideally, you'd want the E-axis steps per mm to be sufficiently high that quantization is a non-issue (i.e. +-1 step is small relative error) for extrusions corresponding to a single X- or Y-axis microstep.</p>
|
<p>Your calculations about the theoretical extruder resolution are spot on. I did a similar calculation to evaluate which extruder to use with different hot ends, I paste the results. The dark cells are the input cells, the rest is calculated. You can see that for some lines I entered directly the mm/microstep value, since I wanted not a theoretical but practical result for my printer (3 mm filament) or for known extruders (BMG).</p>
<p><a href="https://i.stack.imgur.com/3mQeA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3mQeA.png" alt="enter image description here" /></a></p>
<p>Concerning the question, the resolution of the extruder matters, but it's a bit complicated to estimate exactly how much.</p>
<p>In general, this are the factors I can think about.</p>
<p>A poor resolution may not impact straight lines much, since the rotation of the extruder is continuous and the extruder is unlikely to snap exactly to the desired microstep position as soon as you ask for it: it's likely a bit behind all the time, that's how torque is obtained (more or less).</p>
<p>The issue may become smaller with drivers which interpolate microsteps up to 256x.</p>
<p>However, whenever there is a change of flow rate, poor resolution implies that you cannot control the exact location/moment where/when the flow changes. This matters mostly at the end and at the beginning or retractions/re-retractions. Maybe you get more ooze?</p>
<p>However, the extruder resolution is not, in practice, as good as you calculated. In fact, as we know, microsteps reduce the incremental torque to very low values. The extruder is a motor which requires quite a lot of torque, since pushing the filament is quite hard, and it is unlikely that you can achieve all the time the 16x microstep accuracy you assumed. For example, due to friction in Bowden, hot end, ... the filament (= the motor shaft) may at a certain point stay "back" more than average. This would cause an increase of effective torque, pushing the filament a bit faster, which would it bring to in sync or so with the desired position, but at that point it would slow down, and so on. Depending on the average speed, this oscillation may be dampened (and then no rippling is visible) or may oscillate constantly, and you see ripples also along straight lines.</p>
<p>This is why I placed the usteps column in my calculations: it is meant to calculate a more realistic resolution assuming that no accurate microstepping is achieved. I assumed higher achievable microsteps the lower the load on the motor is (this means gears, or thinner filament).</p>
<p>Having a high resolution to begin with clearly helps to reduce this issue. You can try to increase the current to the max your drivers and motor and cooling allow, and see if the ripples change. I think it will be reduced.</p>
<p>You may also try to build the <a href="https://www.thingiverse.com/thing:4223085" rel="noreferrer">Orbiter extruder</a> (linked also in the table) and see how it goes.</p>
|
<h2>Short answer</h2>
<p><em>Usually</em> no.</p>
<h2>Long answer</h2>
<p>There are several big factors that limit how small things you can print. The bigger ones are pretty much:</p>
<ul>
<li>Positional accuracy and settings (limited by steps/mm in X, Y, Z)</li>
<li>Nozzle diameter</li>
</ul>
<p>Now, why don't you need to care about steps/mm on the extruder that muchin the grand scale compared to the positional accuracy? Well, we have 1.8° per step, from which, with the diameter of the gear, 11mm, we get 0,1778 mm of filament extrusion or 0.428 mm³ of extruded plastic per full 1.8° step - which clearly is unsuitable to printing at all. But with the 16 micro-steps the shorter movements are possible and a single micro-step extrusion is in the area you calculated - I got to 0,0267 mm³, possibly the result of different rounding between us. With an assumed effective gear diameter of 11mm (usually the effective gear diameter is a little smaller, thus the 93 steps) we come to about 89.9 steps per mm of filament, which corresponds to about 2.4 mm³ of extruded plastic, or about 30 mm of line (with your given parameters), bringing us to about 3 microsteps per millimeter of line on the tray. So far, your math checks out. But that usually shouldn't be too much a limiting factor. We know from your given settings, that the <em>Configuration.h</em> will look like this, putting the microsteps into the steps/mm:</p>
<pre><code>/**
* Default Axis Steps Per Unit (steps/mm)
* Override with M92
* X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]]
*/
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 93 }
</code></pre>
<p>As you don't have a micro-stepping driver, this part in <em>Configuration_adv.h</em> is non-functional:</p>
<pre><code>// Microstep setting (Only functional when stepper driver microstep pins are connected to MCU.
#define MICROSTEP_MODES {16,16,16,16,16} // [1,2,4,8,16]
</code></pre>
<p>With the proposed 0.4 mm/0.2 mm line, we are still somewhat on the good side, allowing us about 1/3rd of a millimeter as the shortest line printable as a single step extrusion. That's a consistent with printing a simple, circular dot being printable with these settings - 0.4 > 1/3.</p>
<p>But once you get to smaller nozzle diameters, the limitation gets more noticeable: at a 0.2 mm nozzle and 0.22 mm line at 0.1 mm height, that's a 0.022 mm² crosssection, so the 1-step extrusion is equivalent to a full millimeter of line! That's much more bothersome in theory.</p>
<p>However, I haven't been able to witness the inability of showing that limit of lacking extrusion yet on my TronXY-X1 with a 0.2 mm nozzle - the steps/mm in it are also about 90-100 last I set them. The TronXY uses a very similar (virtually identical) extruder setup as the Ender 3, and it achieved printed lines of about 0.3 mm length at 0.1 mm layer height somewhat reliable, but the retraction made huge issues, which might also mask the problem.</p>
<p>I believe that it needs these smaller nozzles to amplify the problems to make them noticeable. It also should become more noticeable if you'd use 2.85 mm or 3 mm filament.</p>
<h2>Ways to improve resolution</h2>
<p>However, if printing with smaller nozzles, it might be a good idea to think about how one could improve the accuracy of the extruder system.</p>
<p>The most-easy way would be to alter the extruder and swap the gear to one of a <em>smaller</em> effective diameter - That way a single step accounts to <em>less</em> extrusion, which means, in turn, a higher number of steps/mm, and thus allowing for shorter extrusions that can be still achieved.</p>
<p>Next one might think about getting a different motor/driver setup that might have either more microsteps or generally a smaller step size.</p>
<p>Quadrupling the effective (micros)steps/mm would allow us to print about a 0.25 mm line on the 0.22 mm nozzle I proposed, being pretty much a spot - if it wouldn't be partially masked in other issues as I experience.</p>
| 1,602
|
<p>So I have a pointer to an array of pointers. If I delete it like this:</p>
<pre><code>delete [] PointerToPointers;
</code></pre>
<p>Will that delete all the pointed to pointers as well? If not, do I have to loop over all of the pointers and delete them as well, or is there an easier way to do it? My google-fu doesn't seem to give me any good answers to this question.</p>
<p>(And yeah, I know I need to use a vector. This is one of those "catch up on C++" type assignments in school.)</p>
|
<p>Yes you have to loop over the pointers, deleting individually.</p>
<p>Reason: What if other code had pointers to the objects in your array? The C++ compiler doesn't know if that's true or not, so you have to be explicit.</p>
<p>For an "easier way," two suggestions: (1) Make a subroutine for this purpose so at least you won't have to write the code more than once. (2) Use the "smart pointer" design paradigm where you hold an array of objects with reference-counters, then the objects are deleted when the objects are no longer referenced by any code. </p>
|
<p>I don't know why this was answered so confusingly long.</p>
<p>If you delete the array of pointers, you will free
the memory used for an array of usually ints.<br>
a pointer to an object is an integer containing the adress.</p>
<p>You deleted a bunch of adresses, but no objects.</p>
<p>delete does not care about the content of a memory space,
it calls a destructor(s) and marks the mem as free.</p>
<p>It does not care that it just deleted a bunch of adresses
of objects, it merely sees ints.</p>
<p>That's why you have to cycle through the array first! and call delete
on every element, then you can delete the storage of the array itself.</p>
<p>Well, now <em>my</em> answer got somewhat long... .... strange... ;)</p>
<p>Edit:
Jason's answer is not wrong, it just fails to hit the spot. Neither
the compiler nor anything else in c(++) cares about you deleting stuff that is elsewhere
pointed to. You can just do it. Other program parts trying to use the deleted objects
will segfault on you. But no one will hinder you.
Neither will it be a problem to destroy an array of pointers to objects, when the objects
are referenced elsewhere.</p>
| 7,046
|
<p>I'd like to add some functionality to a site that would allow users to record video using their webcam and easily store it online. I don't even know if this is possible right now, but I think flash has access to local webcams running through the browser.</p>
<p>Do you have any suggestions or resources to get me started on this? I'm primarily a java developer so If I could do it in an applet that would be great, but It may be easier to accomplish this using flash or some other technology.</p>
<p>This would mean streaming the video back to the webserver and storing it there.
Uploading a file is easy enough, but I'd rather the user not have to deal with that if it's possible.</p>
<p>Just to be clear. I'm not talking about uploading a video. I'm talking about allowing the user to click "record" in a web application and having the video streamed to the server and stored when the user clicks "stop".</p>
|
<p>This is possible with <a href="http://www.adobe.com/products/flashmediaserver/" rel="nofollow noreferrer">Adobe's Flash Media Server</a>. <a href="http://osflash.org/red5" rel="nofollow noreferrer">Red5</a> is an open source alternative. The protocol they use for this is <a href="http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol" rel="nofollow noreferrer">RTMP</a>.</p>
|
<p>On the server side, you have three alternatives:</p>
<ol>
<li><a href="http://www.adobe.com/products/flashmediaserver/" rel="nofollow noreferrer">Adobe's Flash Media Server</a></li>
<li><a href="http://osflash.org/red5" rel="nofollow noreferrer">Red5</a>, an open source version</li>
<li><a href="http://www.wowzamedia.com/products.html" rel="nofollow noreferrer">Wowza Media Server Pro</a>, a commercial alternative</li>
</ol>
<p>You can either run any of these on your own server or else go for a web provider (I found <a href="http://www.flashcomguru.com/articles/hosts.cfm" rel="nofollow noreferrer">this list</a> to be helpful)</p>
<p>On the client side, you'll need a flash file for the user interface. Red5 and Wowza some with the source code for their example recorders so it's easy to customize these for your own use.</p>
| 7,785
|
<p>Yes, it sounds crazy....It might be.</p>
<p>The final updatepanel does not appear to trigger anything, it just refreshes the update panels and does not call back to the usercontrol hosting it.</p>
<p>Any ideas?</p>
<p>EDIT: I got it posting back, however the controls inside the final usercontrol have lost their data...I'm thinking its because the main repeater is rebinding on each postback...Not sure where to take this one now.</p>
|
<p>I would suggest you start by removing the UpdatePanels at first, and make sure your control orgy is working correctly with postbacks. Once you have that working, try adding the UpdatePanels back in from the bottom up.</p>
|
<p>If you set the UpdateMode property to Conditional (default is Always) on both UpdatePanels it should stop the outer UpdatePanel triggering when only the usercontrols updatepanel should have refreshed.</p>
| 5,063
|
<p>I have a solution in Visual Studio 2005(professional Edition) which in turn has 8 projects.I am facing a problem that even after i set the Command Arguments in the Project settings of the relevant project, it doesnt accept those command line arguments and it shows argc = 1, inspite of me giving more than 1 command arguments. Tried making the settings of this Solution similar to a working solution, but no success.
Any pointers?</p>
<p>-Ajit.</p>
|
<p>Hmm.. Are you sure the specified project is set as the start project (right click > set as startup project) ??</p>
<p>Oh, and obviously you need to be in the correct configuration mode ^_^</p>
<p>(Notice it can be changed to <em>debug | build | all configurations</em> )</p>
|
<p>Are you sure you are setting the command arguments on the same configuration (Debug|Release) you are debugging? As far as I remember command arguments are per configuration.</p>
| 4,956
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.