instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I need to be able to find the last occurrence of a character within an element.</p> <p>For example:</p> <pre><code>&lt;mediaurl&gt;http://www.blah.com/path/to/file/media.jpg&lt;/mediaurl&gt; </code></pre> <p>If I try to locate it through using <code>substring-before(mediaurl, '.')</code> and <code>substring-after(mediaurl, '.')</code> then it will, of course, match on the first dot. </p> <p>How would I get the file extension? Essentially, I need to get the file name and the extension from a path like this, but I am quite stumped as to how to do it using XSLT.</p>
<p>The following is an example of a template that would produce the required output in XSLT 1.0:</p> <pre><code>&lt;xsl:template name="getExtension"&gt; &lt;xsl:param name="filename"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($filename, '.')"&gt; &lt;xsl:call-template name="getExtension"&gt; &lt;xsl:with-param name="filename" select="substring-after($filename, '.')"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$filename"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/"&gt; &lt;xsl:call-template name="getExtension"&gt; &lt;xsl:with-param name="filename" select="'http://www.blah.com/path/to/file/media.jpg'"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; </code></pre>
<p>How about tokenize with "/" and take the last element from the array ?</p> <pre><code>Example: tokenize("XPath is fun", "\s+") Result: ("XPath", "is", "fun") </code></pre> <p>Was an XSLT fiddler sometime back... lost touch now. But HTH</p>
3,534
<p>As many of you probably know, online banks nowadays have a security system whereby you are asked some personal questions before you even enter your password. Once you have answered them, you can choose for the bank to "remember this computer" so that in the future you can login by only entering your password.</p> <p>How does the "remember this computer" part work? I know it cannot be cookies, because the feature still works despite the fact that I clear all of my cookies. I thought it might be by IP address, but my friend with a dynamic IP claims it works for him, too (but maybe he's wrong). He thought it was MAC address or something, but I strongly doubt that! So, is there a concept of https-only cookies that I don't clear?</p> <p>Finally, the programming part of the question: how can I do something similar myself in, say, PHP?</p>
<p>In fact they most probably use cookies. An alternative for them would be to use "<a href="http://www.bestflashanimationsite.com/tutorials/4/" rel="noreferrer">flash cookies</a>" (officially called "<a href="http://www.adobe.com/support/flash/action_scripts/local_shared_object/" rel="noreferrer">Local Shared Objects</a>"). They are similar to cookies in that they are tied to a website and have an upper size limit, but they are maintained by the flash player, so they are invisible to any browser tools.</p> <p>To clear them (and test this theory), you can use <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=52697ee8&amp;sliceId=2" rel="noreferrer">the instructions provided by Adobe</a>. An other nifty (or maybe worrying, depending on your viewpoint) feature is that the LSO storage is shared by all browsers, so using LSO you can identify users <em>even if they switched browser</em> (as long as they are logged in as the same user).</p>
<p>MAC address is possible.</p> <p>IP to physical location mapping is also a possibility.</p> <p>User agents and other HTTP headers are quiet unique to each of the machines too.</p> <p>I'm thinking about those websites that prevents you from using an accelerating download managers. There must be a way.</p>
5,299
<p>The <code>.XFDL</code> file extension identifies <code>XFDL</code> Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications.</p> <p>I know how to view XFDL files using a file viewer I found <a href="http://web.archive.org/web/20170903022252/http://www.e-publishing.af.mil:80/viewerdownload.asp" rel="nofollow noreferrer">here</a>. I can also modify and save these files by doing File:Save/Save As. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?</p> <p>Update #1: I have now successfully decoded and unziped a <code>.xfdl</code> into an XML file which I can then edit. Now, I am looking for a way to re-encode the modified XML file back into base64-gzip (using Ruby or the command line)</p>
<p>If the encoding is <strong>base64</strong> then this is the solution I've stumbled upon on the web:</p> <p>"Decoding XDFL files saved with 'encoding=base64'. Files saved with: </p> <pre><code>application/vnd.xfdl;content-encoding="base64-gzip" </code></pre> <p>are simple base64-encoded gzip files. They can be easily restored to XML by first decoding and then unzipping them. This can be done as follows on Ubuntu:</p> <pre><code>sudo apt-get install uudeview uudeview -i yourform.xfdl gunzip -S "" &lt; UNKNOWN.001 &gt; yourform-unpacked.xfdl </code></pre> <p>The first command will install uudeview, a package that can decode base64, among others. You can skip this step once it is installed.</p> <p>Assuming your form is saved as 'yourform.xfdl', the uudeview command will decode the contents as 'UNKNOWN.001', since the xfdl file doesn't contain a file name. The '-i' option makes uudeview uninteractive, remove that option for more control.</p> <p>The last command gunzips the decoded file into a file named 'yourform-unpacked.xfdl'.</p> <p><strong>Another</strong> possible solution - <a href="http://www.chilkatsoft.com/p/p_531.asp" rel="nofollow noreferrer">here</a></p> <p><em>Side Note: Block quoted &lt; code > doesn't work for long strings of code</em></p>
<p>You don't have to get out of Ruby to do this, can use the Base64 module in Ruby to encode the document like this:</p> <pre><code>irb(main):005:0&gt; require 'base64' =&gt; true irb(main):007:0&gt; Base64.encode64("Hello World") =&gt; "SGVsbG8gV29ybGQ=\n" irb(main):008:0&gt; Base64.decode64("SGVsbG8gV29ybGQ=\n") =&gt; "Hello World" </code></pre> <p>And you can call gzip/gunzip using Kernel#system:</p> <pre><code>system("gzip foo.something") system("gunzip foo.something.gz") </code></pre>
2,395
<p>.NET, Java and other high level database API's in various language often provide techniques known as prepared statements and parameter binding as opposed to sending plain text commands to the Database server. What I would like to know is what happens when you execute a statement like this:</p> <pre><code>SqlCommand cmd = new SqlCommand("GetMemberByID"); cmd.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter("@ID", memberID); para.DbType = DbType.Integer; cmd.Parameters.Add(param); </code></pre> <p>I know this is a best practice. SQL injection attacks are minimized this way. But what exactly happens under the hood when you execute these statements? Is the end result still a SQL safe string? If not, what is the end result? And is this enough to prevent SQL injection attacks?</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statements.html" rel="nofollow noreferrer">The MySQL manual page</a> on prepared statements provides lots of information (which should apply to any other RDBMS).</p> <p>Basically, your statement is parsed and processed ahead of time, and the parameters are sent separately instead of being handled along with the SQL code. This eliminates SQL-injection attacks because the SQL is parsed before the parameters are even set.</p>
<p>If you're using MS SQL, load up the profiler and you'll see what SQL statements are generated when you use parameterised queries. Here's an example (I'm using Enterprise Libary 3.1, but the results are the same using SqlParameters directly) against SQL Server 2005:</p> <pre><code>string sql = "SELECT * FROM tblDomains WHERE DomainName = @DomName AND DomainID = @Did"; Database db = DatabaseFactory.CreateDatabase(); using(DbCommand cmd = db.GetSqlStringCommand(sql)) { db.AddInParameter(cmd, "DomName", DbType.String, "xxxxx.net"); db.AddInParameter(cmd, "Did", DbType.Int32, 500204); DataSet ds = db.ExecuteDataSet(cmd); } </code></pre> <p>This generates:</p> <pre><code>exec sp[underscore]executesql N'SELECT * FROM tblDomains WHERE DomainName = @DomName AND DomainID = @Did', N'@DomName nvarchar(9), @Did int', @DomName=N'xxxxx.net', @Did=500204 </code></pre> <p>You can also see here, if quotation characters were passed as parameters, they are escaped accordingly:</p> <pre><code>db.AddInParameter(cmd, "DomName", DbType.String, "'xxxxx.net"); exec sp[underscore]executesql N'SELECT * FROM tblDomains WHERE DomainName = @DomName AND DomainID = @Did', N'@DomName nvarchar(10), @Did int', @DomName=N'''xxxxx.net', @Did=500204 </code></pre>
3,572
<p>My question is simple; is it possible to over object-orient your code? </p> <p>How much is too much? At what point are you giving up readability and maintainability for the sake of OO? </p> <p>I am a huge OO person but sometimes I wonder if I am over-complicating my code.... </p> <p>Thoughts?</p>
<blockquote> <p>is it possible to over object-orient your code</p> </blockquote> <p>Yes</p>
<p>I guess it is possible, but its hard to answer your in abstract terms (no pun intended). Give an example of over OO.</p>
7,793
<p>Basically we need a custom diagram component in our new WPF based application.<br> <strong>Needs</strong> to show text/lines, linked 2D Nodes and custom images apart from the other diagramming features like Undo/Redo, Align, Group, etc.. ala Visio.</p> <p>The initial team did a bit of investigation and settled on the WinForms Northwoods GoDiagrams suite... a solution to embed it in our WPF application. Are there any equivalent WPF diagramming packages out there yet? Preferably tried ones. Thanks..</p>
<p>My colleague has been using <a href="http://www.mindfusion.org/wpfdiagram.html" rel="nofollow noreferrer">WpfDiagram</a> from MindFusion for the last two weeks and says that it's an excellent product.</p>
<p>Just remember DO NOT choose Syncfusion. </p> <p>I've been suffering from it when developing WPF Application. There are so many bugs in it.</p>
6,523
<p>Is there a .NET variable that returns the "All Users" directory?</p>
<p>You'll want to use the <code>system.environment</code> variables.<br> Most of the predefined ones are <a href="http://msdn.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx" rel="nofollow noreferrer">shown here</a>. </p> <p>For the "<strong>All Users</strong>" you would use:</p> <pre><code>System.Environment.GetEnvironmentVariable("ALLUSERSPROFILE") </code></pre> <p>I know I got a lot of upmods and a correct answer for my other stuff, but this actually works. where as the other <a href="http://msdn.microsoft.com/en-us/library/ms933062.aspx" rel="nofollow noreferrer">environment variables</a> I linked to previously don't seem to work with that function call.</p>
<p>Or, </p> <pre><code>Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) </code></pre> <p>You can then pass this result to System.IO.Directory.GetParent() to get the root "All Users" folder.</p>
4,317
<p>Is there any Visual Studio Add-In that can do the remove method refactoring?<br> Suppose you have the following method: </p> <pre><code>Result DoSomething(parameters) { return ComputeResult(parameters); } </code></pre> <p>Or the variant where Result is void.</p> <p>The purpose of the refactoring is to replace all the calls to DoSomething with calls to ComputeResult or the expression that uses the parameters if ComputeResult is not a method call.</p>
<p>If I understand the question, then Resharper calls this 'inline method' - <kbd>Ctrl</kbd> - <kbd>R</kbd> + <kbd>I</kbd></p>
<p>You can also right click the method name and click "Find all References" in Visual Studio.</p> <p>I personally would just do a <kbd>CTRL</kbd> + <kbd>SHIFT</kbd> + <kbd>H</kbd> to <code>Find &amp; Replace</code></p>
3,000
<p>I've got an upcoming project wherein I will need to connect our website (<code>PHP5/Apache 1.3/OpenBSD 4.1</code>) to our back-end system running on an iSeries with OS400 V5R3 so that I can access some tables stored there. I've done some checking around but am running into some roadblocks.</p> <p>From what I've seen the DB2 extensions and DB2 software from IBM only run under Linux. I've tried compiling the extensions with all the software from IBM and even tried their precompiled ibm_db2 extension with no luck. IBM only supports Linux so I turned on the Linux emulation in the kernel but that didn't seem to help anything.</p> <p>If anyone has run across getting everything to run natively under OpenBSD that would be great, but what I think I may have to do is setting up a second server running CentOS with DB2 installed (most likely via ZendCore for IBM since it seems to do all this for me) and the driver so that I can set up a small transaction server that I can post against and get a JSON representation of the DB2 data that I need.</p> <p>Does the second option seem overkill or does anyone else have any better ideas?</p>
<p>Have you looked at connecting to the server using <a href="http://www.unixodbc.org/" rel="noreferrer">unixODBC</a>? If I remember correctly it has support for IBM DB2 and compiles on OpenBSD. Check out <a href="http://www.php.net/odbc" rel="noreferrer">http://www.php.net/odbc</a> for more information regarding the PHP side.</p> <p>If you can't get that to work, the option to setup a web service on a Linux server may be all you can do.</p>
<p>A web service is almost certainly the way to go. I'm sure you've already thought of this, but since you're doing PHP on both sides, you can shortcut things a little bit by using serialize() to build your response data instead of building a proper XML document. It's less flexible over the long run, but it will probably get you up and running more quickly.</p>
2,311
<p>I'm trying to print a small box with 1 mm thick walls. The box has rounded corners.</p> <p>Cura slices the rounded corners with straight internal lines instead of rounded lines:</p> <p><a href="https://i.stack.imgur.com/5Kw87.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Kw87.jpg" alt="Rounded Corners with infill" /></a></p> <p>The reason for these straight lines is that Cura is using infill to fill the walls, because it determines that there's not enough space in a 1 mm wall for three 0.4 mm passes.</p> <p><a href="https://i.stack.imgur.com/dDQAc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dDQAc.png" alt="Rounded Corners without infill" /></a></p> <p>This causes the walls to have small imperfections in the final print. I was able to solve this by increasing the model wall thickness to 1.2 mm (to allow for 3 0.4 mm lines), but even then it wasn't doing it as a single continuous line, but instead breaking it into short lines at the corner:</p> <p><a href="https://i.stack.imgur.com/zqSAN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zqSAN.png" alt="Rounded corners for 1.2 mm thick walls" /></a></p> <p>Is there a way to avoid this issue without increasing the wall thickness, and have 3 continuous lines?</p>
<p>I found the solution : It was the option &quot;avoid crossing perimeters&quot; that seems to do exactly the contrary of what it means. Thank you all for your answers.</p>
<p>Enable Z-Hop. I don't know what the actual parameter is called but it should say something like &quot;Z-Hop&quot;.</p>
1,760
<p>I want to call a function from a .NET DLL (coded in C#) from an Inno Setup script.</p> <p>I have:</p> <ol> <li>marked the <em>Register for COM interop</em> option in the project properties,</li> <li>changed the <em>ComVisible</em> setting in the <em>AssemblyInfo.cs</em> file,</li> <li>added these lines to the ISS script:</li> </ol> <blockquote> <p>[Files]</p> <p>Source: c:\temp\1\MyDLL.dll; Flags: dontcopy</p> <p>[Code]</p> <p>function MyFunction(): string;</p> <p>external 'MyFunction@files:MyDLL.dll stdcall setuponly';</p> </blockquote> <p>but I still get the following error:</p> <blockquote> <p>Runtime Error (at -1:0):</p> <p>Cannot Import dll:C:\DOCUME~1\foo\LOCALS~1\Temp\is-LRL3E.tmp\MyDLL.dll.</p> </blockquote> <p>What am I doing wrong?</p>
<p>Oops, my bad, it's been too long since I've read pascal! So, if you need to get the value then there are a couple of possibilities:</p> <ol> <li>Write the functionality in C/C++ and export the function, that's definitely supported.</li> <li>Use a Managed C++ dll to shim to your .NET dll, and expose the call as a C interface point (this should work, but it's getting messy)</li> <li>Use an .exe to store the result of your code in a .INI file or the registry or in a temp file and read the result in the setup code section (this is now properly nasty)</li> </ol> <p>When I last worked with InnoSetup it didn't support your scenario directly (calling .NET code from setup).</p>
<p>A .NET dll can be best called from any other programming language by exposing it as a COM object. Take a look at this example: <a href="http://support.microsoft.com/kb/828736" rel="nofollow noreferrer">http://support.microsoft.com/kb/828736</a>. This shows how to call a ".NET dll" from "unmanaged C++". You can replace the "unamanged C++" by any other programming language, that can be used as a COM client.</p>
6,741
<p>I'm using the GoDiagrams suite which seems to recommend .emf files for node images since they scale better on resizing. Bitmaps get all blurry.<br> Google doesn't show up any good tools that seem to do this... So to reiterate I'm looking for a image converter (preferably free) that converts an image (in one of the common formats like Bitmaps or JPEGs or GIFs) to an .EMF File.</p> <p><em>Update: I dont need to do it via code. Simple batch-conversion of images will do.</em></p>
<p><a href="http://www.inkscape.org/" rel="nofollow noreferrer">Inkscape</a> works well, it was recommended to me <a href="https://stackoverflow.com/questions/28872/free-windows-based-emf-editor">here</a>. </p>
<p>Really funny one Microsoft. Now this might seem outlandish but it works... (I have Visio2007). Just found this out from a colleague</p> <p>You can drop a JPEG into <strong>Microsoft Visio</strong> (no less), Do a 'Save As' to .emf and voila! nice quality of a picture too.</p>
7,750
<p>I know you can use several different view engines with ASP.NET MVC:</p> <ul> <li>ASPX, obviously</li> <li>NVelocity</li> <li>Brail</li> <li>NHaml</li> <li>et al...</li> </ul> <p>The default ASPX view engine seems to make the most sense to me, coming from an ASP.NET WebForms background. </p> <p>But, I wanted to get an idea of the pros and cons of each and see what most people are using. </p> <p>Which does StackOverflow use?</p>
<p>I use <a href="http://dev.dejardin.org/" rel="nofollow noreferrer">Spark</a>. It has nice flow between HTML and code. Scott Hanselman also did a <a href="http://www.hanselman.com/blog/TheWeeklySourceCode30SparkAndNHamlCrazyASPNETMVCViewEngines.aspx" rel="nofollow noreferrer">post</a> on it with his weekly source code review posts. I am really digging it a lot. One of the major features is <a href="http://dev.dejardin.org/documentation/precompiling" rel="nofollow noreferrer">pre-compilation</a> of your views.</p>
<p>I've used NVelocity with MonoRail for some time but have recently switched to <a href="http://dev.dejardin.org" rel="nofollow noreferrer">Spark</a> for both Asp.Net MVC and MonoRail. The syntax seems very natural to me, but I guess that's to be expected. ;)</p>
6,414
<p>As we all know numbers can be written either in numerics, or called by their names. While there are a lot of examples to be found that convert 123 into one hundred twenty three, I could not find good examples of how to convert it the other way around.</p> <p>Some of the caveats:</p> <ol> <li>cardinal/nominal or ordinal: "one" and "first"</li> <li>common spelling mistakes: "forty"/"fourty"</li> <li>hundreds/thousands: 2100 -> "twenty one hundred" and also "two thousand and one hundred"</li> <li>separators: "eleven hundred fifty two", but also "elevenhundred fiftytwo" or "eleven-hundred fifty-two" and whatnot</li> <li>colloquialisms: "thirty-something"</li> <li>fractions: 'one third', 'two fifths'</li> <li>common names: 'a dozen', 'half'</li> </ol> <p>And there are probably more caveats possible that are not yet listed. Suppose the algorithm needs to be very robust, and even understand spelling mistakes.</p> <p>What fields/papers/studies/algorithms should I read to learn how to write all this? Where is the information?</p> <blockquote> <p>PS: My final parser should actually understand 3 different languages, English, Russian and Hebrew. And maybe at a later stage more languages will be added. Hebrew also has male/female numbers, like "one man" and "one woman" have a different "one" — "ehad" and "ahat". Russian also has some of its own complexities.</p> </blockquote> <p>Google does a great job at this. For example:</p> <p><a href="http://www.google.com/search?q=two+thousand+and+one+hundred+plus+five+dozen+and+four+fifths+in+decimal" rel="noreferrer">http://www.google.com/search?q=two+thousand+and+one+hundred+plus+five+dozen+and+four+fifths+in+decimal</a></p> <p>(the reverse is also possible <a href="http://www.google.com/search?q=999999999999+in+english" rel="noreferrer">http://www.google.com/search?q=999999999999+in+english</a>)</p>
<p>I was playing around with a PEG parser to do what you wanted (and may post that as a separate answer later) when I noticed that there's a very simple algorithm that does a remarkably good job with common forms of numbers in English, Spanish, and German, at the very least.</p> <p>Working with English for example, you need a dictionary that maps words to values in the obvious way:</p> <pre><code>"one" -&gt; 1, "two" -&gt; 2, ... "twenty" -&gt; 20, "dozen" -&gt; 12, "score" -&gt; 20, ... "hundred" -&gt; 100, "thousand" -&gt; 1000, "million" -&gt; 1000000 </code></pre> <p>...and so forth</p> <p>The algorithm is just:</p> <pre><code>total = 0 prior = null for each word w v &lt;- value(w) or next if no value defined prior &lt;- case when prior is null: v when prior &gt; v: prior+v else prior*v else if w in {thousand,million,billion,trillion...} total &lt;- total + prior prior &lt;- null total = total + prior unless prior is null </code></pre> <p>For example, this progresses as follows:</p> <pre><code>total prior v unconsumed string 0 _ four score and seven 4 score and seven 0 4 20 and seven 0 80 _ seven 0 80 7 0 87 87 total prior v unconsumed string 0 _ two million four hundred twelve thousand eight hundred seven 2 million four hundred twelve thousand eight hundred seven 0 2 1000000 four hundred twelve thousand eight hundred seven 2000000 _ 4 hundred twelve thousand eight hundred seven 2000000 4 100 twelve thousand eight hundred seven 2000000 400 12 thousand eight hundred seven 2000000 412 1000 eight hundred seven 2000000 412000 1000 eight hundred seven 2412000 _ 8 hundred seven 2412000 8 100 seven 2412000 800 7 2412000 807 2412807 </code></pre> <p>And so on. I'm not saying it's perfect, but for a quick and dirty it does quite well.</p> <hr> <p>Addressing your specific list on edit:</p> <ol> <li>cardinal/nominal or ordinal: "one" and "first" -- <strong>just put them in the dictionary</strong></li> <li>english/british: "fourty"/"forty" -- <strong>ditto</strong></li> <li>hundreds/thousands: 2100 -> "twenty one hundred" and also "two thousand and one hundred" -- <strong>works as is</strong></li> <li>separators: "eleven hundred fifty two", but also "elevenhundred fiftytwo" or "eleven-hundred fifty-two" and whatnot -- <strong>just define "next word" to be the longest prefix that matches a defined word, or up to the next non-word if none do, for a start</strong></li> <li>colloqialisms: "thirty-something" -- <strong>works</strong></li> <li>fragments: 'one third', 'two fifths' -- <strong>uh, not yet...</strong></li> <li>common names: 'a dozen', 'half' -- <strong>works; you can even do things like "a half dozen"</strong></li> </ol> <p>Number 6 is the only one I don't have a ready answer for, and that's because of the ambiguity between ordinals and fractions (in English at least) added to the fact that my last cup of coffee was <em>many</em> hours ago.</p>
<p>One place to start looking is the <a href="http://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html" rel="nofollow noreferrer">gnu get_date lib</a>, which can parse <a href="http://php-date.com/#strtotime" rel="nofollow noreferrer">just about any</a> English textual date into a timestamp. While not exactly what you're looking for, their solution to a similar problem could provide a lot of useful clues.</p>
9,556
<p>I would like to test a string containing a path to a file for existence of that file (something like the <code>-e</code> test in Perl or the <code>os.path.exists()</code> in Python) in C#.</p>
<p>Use:</p> <pre><code>File.Exists(path) </code></pre> <p>MSDN: <a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx</a></p> <p>Edit: In System.IO</p>
<p>I use WinForms and my way to use File.Exists(string path) is the next one:</p> <pre><code>public bool FileExists(string fileName) { var workingDirectory = Environment.CurrentDirectory; var file = $&quot;{workingDirectory}\{fileName}&quot;; return File.Exists(file); } </code></pre> <p>fileName <strong>must</strong> include the extension like <code>myfile.txt</code></p>
5,998
<p>How do I turn a python program into an .egg file?</p>
<p><a href="http://peak.telecommunity.com/DevCenter/setuptools" rel="noreferrer">Setuptools</a> is the software that creates <a href="http://peak.telecommunity.com/DevCenter/PythonEggs" rel="noreferrer">.egg files</a>. It's an extension of the <a href="http://docs.python.org/lib/module-distutils.html" rel="noreferrer"><code>distutils</code></a> package in the standard library.</p> <p>The process involves creating a <code>setup.py</code> file, then <code>python setup.py bdist_egg</code> creates an .egg package.</p>
<p>Python has its own package for creating distributions that is called distutils. However instead of using Python’s distutils’ setup function, we’re using setuptools’ setup. We’re also using setuptools’ find_packages function which will automatically look for any packages in the current directory and add them to the egg. To create said egg, you’ll need to run the following from the command line:</p> <pre><code>c:\Python34\python.exe setup.py bdist_egg </code></pre>
7,161
<p>Since CS3 doesn't have a web service component, as previous versions had, is there a good, feature-complete, AS3-only (no Flex dependencies) library for accessing web services with AS3?</p>
<p>You may want to check out <a href="http://alducente.wordpress.com/2007/10/27/web-service-in-as3-release-10/" rel="nofollow noreferrer">http://alducente.wordpress.com/2007/10/27/web-service-in-as3-release-10/</a></p>
<p>What type of service are you trying to consume? URLLoader can handle soap requests (<code>urlRequest.requestHeaders.push(new URLRequestHeader("Content-Type", "application/soap+xml"));</code>) and NetConnection can handle most other stuff (AMF/Remoting).</p>
7,526
<p>I'm trying to figure out if it's worth buying a 3D printer or using an online printing service like e.g. <a href="https://treddy.it" rel="nofollow noreferrer">this one</a> in the long run. Anyone have any cost analysis?</p>
<h1>It depends</h1> <p>If it is worth to invest in a print made for you compared to getting a printer depends on the needs you have. Thee can be informed by the type of material you want to print and the requirements that has on you. Let me give you some examples when it is simply worth it to pay:</p> <ul> <li>A metal printer costs in the thousands: upper five-digit for the most baseline and <a href="https://all3dp.com/2/how-much-does-a-metal-3d-printer-cost/" rel="nofollow noreferrer">averaging in the low to mid-6-digit</a>. Ordering a single or few printed pieces will be economical, and even ordering <strong>many</strong> parts will still be well below break-even, considering that the material sets you back by up to 600 \$ per kilo!</li> <li>A nylon powder printer <a href="https://all3dp.com/1/best-sls-3d-printer-desktop-industrial/" rel="nofollow noreferrer">starts in the middle 4-digits but easily goes up to upper 5-digits and even middle 6 digits</a>. Ordering for a small-scale production this way still will be economical.</li> <li>Some specialty plastics need printers with very high-temperature chambers and hotends with extreme wear resistance. Such machinery can easily cost five digits, especially in large dimensions where it goes to six. Compared to purchasing price of the machine, ordering the part will be cheaper.</li> </ul> <p>On the other hand, getting a printer gets cheaper once you:</p> <ul> <li>use it sufficiently, for example, to iteratively modify a designed part or produce a medium variety of parts.</li> <li>have the time and money to spare to learn and tweak your machine to do what you want.</li> <li>the amount of parts you want to make would cost you more to have ordered than a new printer, or a substantial portion thereof. For an FDM machine, the first useful machines can be priced as low as 150 \$, while 300 \$ gets you a somewhat capable Ender 3 v2 - which has developed into some kind of <em>standard unit</em> for printers.</li> </ul> <p>Also note, that some printing services have limits on what they will produce. Commonly they will not provide services to manufacture tools or items that might violate local law or make it trivially to do so, for example copying keys or even manufacturing Keyblanks.</p>
<p>I would think it depends on your future needs. If you will rarely need things printed then online is more convenient than buying a printer and doing the whole learning curve, storing materials etc,.</p> <p>From what I have seen online, most people printing are not printing things they actually need.</p> <p>If you want to produce things to sell, then you're better off doing it yourself.</p>
2,131
<p>In C# are the nullable primitive types (i.e. <code>bool?</code>) just aliases for their corresponding <code>Nullable&lt;T&gt;</code> type or is there a difference between the two?</p>
<p>If you look at the IL using <a href="http://msdn.microsoft.com/en-us/library/f7dy01k1%28v=vs.100%29.aspx" rel="noreferrer">Ildasm</a>, you'll find that they both compile down to <code>Nullable&lt;bool&gt;</code>.</p>
<p>No difference. Take a look here: <a href="http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx</a></p> <p>"The syntax T? is shorthand for Nullable, where T is a value type. The two forms are interchangeable."</p>
8,045
<p>I have an Ajax.Net enabled ASP.Net 2.0 web site. Hosting for both the site and the database are out of my control as is the database's schema. In testing on hardware I do control the site performs well however on the client's hardware, there are noticeable delays when reloading or changing pages. </p> <p>What I would like to do is make my application as compact and speedy as possible when I deliver it. One idea is to set expiration dates for all of the site's static resources so they aren't recalled on page loads. By resources I mean images, linked style sheets and JavaScript source files. Is there an easy way to do this?</p> <p>What other ways are there to optimize a .Net web site?</p> <p>UPDATE: I've run YSlow on the site and the areas where I am getting hit the hardest are in the number of JavaScript and Style Sheets being loaded (23 JS files and 5 style sheets). All but one (the main style sheet) has been inserted by Ajax.net and Asp. Why so many? </p>
<ol> <li><a href="http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx" rel="noreferrer">Script Combining in .net 3.5 SP1</a></li> <li><a href="http://developer.yahoo.com/performance/rules.html" rel="noreferrer">Best Practices for fast websites</a></li> <li>HTTP Compression (gzip)</li> <li>Compress JS / CSS (different than http compression, minify javascript) <ol> <li><a href="http://developer.yahoo.com/yui/compressor/" rel="noreferrer">YUI Compressor</a></li> <li><a href="http://www.codeplex.com/YUICompressor" rel="noreferrer">.NET YUI Compressor</a></li> </ol></li> </ol> <p>My best advice is to check out the <a href="http://developer.yahoo.com/YUI" rel="noreferrer">YUI content</a>. They have some great articles that talk about things like <a href="http://www.alistapart.com/articles/sprites/" rel="noreferrer">CSS sprites</a> and have some <a href="http://developer.yahoo.com/yui/imageloader/" rel="noreferrer">nice javascript libraries to help reduce the number of requests</a> the browser is making.</p>
<p>You could turn on compression based on your client supporting it. See this article: <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true" rel="nofollow noreferrer">link text</a></p>
3,260
<p>Some prints take a long time and, as I'm not in a workshop, I need to pause the print sometimes.</p> <p>Are there any special considerations I should take when pausing, or can I literally just click pause, leave it for twelve hours or so, and it'll continue without any ill effects?</p> <p>I'm using PLA at present.</p>
<p>If you keep the head hot during the pause, and over the print, you will melt the material already deposited.</p> <p>If you move to X0 Y0 (like on a layer change) and pause there, you can cool off the head (or not), but will want to prime (advance) some material before resuming your print - or risk an initial void, as the heated material will expand and drip to some extent.</p> <p>If you move to X0 Y0, retract, and cool off for your pause, you should be able to heat up, advance, and resume with few issues. You will probably still need to some manual cleaning where the resume was, as there is likely to be some buildup.</p> <p>Also, if you let the bed cool during your pause, your print may become unstuck from the bed.</p>
<p>It is not recommended to pause prints a considerable amount of time as the printed model will shrink and might warp during the pause. Also, layer bonding between the old and the new art after resuming will be weak, but this can be used to induce planned breaking layers.</p> <p>On the other hand, <strong>if</strong> you have set up your printer properly, it is quite safe to leave the room even during the print:</p> <ul> <li>Maxtemp and Thermal Runaway Protection need to be set</li> <li>a smoke detector over the printer should be installed</li> <li>the printer should be placed in a way that no flammable objects can get in contact with it</li> </ul>
1,136
<p>We would like to have user defined formulas in our c++ program. e.g. The value <em>v = x + ( y - (z - 2)) / 2</em>. Later in the program the user would define x,y and z -> the program should return the result of the calculation. <br />Somewhen later the formula may get changed, so the next time the program should parse the formula and add the new values. <br/><br/> Any ideas / hints how to do something like this ? <br/><br/> So far I just came to the solution to write a parser to calculate these formulas - maybe any ideas about that ?</p>
<p>If it will be used frequently and if it will be extended in the future, I would almost recommend adding either Python or Lua into your code. <a href="http://www.lua.org/" rel="nofollow noreferrer">Lua</a> is a very lightweight scripting language which you can hook into and provide new functions, operators etc. If you want to do more robust and complicated things, use Python instead.</p>
<p>Using <a href="http://spirit.sourceforge.net/" rel="nofollow noreferrer">Spirit</a> (for example) to parse (and the 'semantic actions' it provides to construct an expression tree that you can then manipulate, e.g., evaluate) seems like quite a simple solution. You can find a grammar for arithmetic expressions <a href="http://www.cs.sunysb.edu/~warren/xsbbook/node24.html" rel="nofollow noreferrer">there</a> for example, if needed... (it's quite simple to come up with your own).</p> <p>Note: Spirit is <em>very</em> simple to learn, and quite adapted for such tasks.</p>
4,777
<p>I'm trying to use the CoreCon API in Visual Studio 2008 to programmatically launch device emulators. When I call <code>device.Connect()</code>, I inexplicably get a DirectoryNotFoundException. I get it if I try it in PowerShell or in C# Console Application. Here's the code I'm using:</p> <pre><code>static void Main(string[] args) { DatastoreManager dm = new DatastoreManager(1033); Collection&lt;Platform&gt; platforms = dm.GetPlatforms(); foreach (var p in platforms) { Console.WriteLine("{0} {1}", p.Name, p.Id); } Platform platform = platforms[3]; Console.WriteLine("Selected {0}", platform.Name); Device device = platform.GetDevices()[0]; device.Connect(); Console.WriteLine("Device Connected"); SystemInfo info = device.GetSystemInfo(); Console.WriteLine("System OS Version:{0}.{1}.{2}",info.OSMajor, info.OSMinor, info.OSBuildNo); Console.ReadLine(); } </code></pre> <p>Does anyone know why I'm getting this error? I'm running this on WinXP 32-bit, plain jane Visual Studio 2008 Pro. I imagine it's some config issue since I can't do it from a Console app or PowerShell.</p> <p>Here's the stack trace:</p> <pre><code>System.IO.DirectoryNotFoundException was unhandled Message="The system cannot find the path specified.\r\n" Source="Device Connection Manager" StackTrace: at Microsoft.VisualStudio.DeviceConnectivity.Interop.ConManServerClass.ConnectDevice() at Microsoft.SmartDevice.Connectivity.Device.Connect() at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\Thomas\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs:line 23 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() </code></pre>
<p>It can be found at <code>&lt;systemdrive&gt;:\Program files\Common Files\Microsoft Shared\CoreCon\1.0\Bin</code>.</p> <p>This is the path where you can get this dll, so add this dll to your project.</p>
<p>I tried this and it works ok. Can you paste in the whole exception and stack trace?</p> <p><strong>Updated:</strong> Strangely I can't find that interop assy on my machine either other than under the c:\windows\assembly\GAC_MSIL folders.</p> <p>Why not fire up SysInternals FileMon or Process Monitor, it'd save some guesswork.</p>
2,859
<p>Does anybody know a "technique" to discover memory leaks caused by smart pointers? I am currently working on a large project written in <strong>C++</strong> that heavily uses smart pointers with reference counting. Obviously we have some memory leaks caused by smart pointers, that are still referenced somewhere in the code, so that their memory does not get free'd. It's very hard to find the line of code with the "needless" reference, that causes the corresponding object not to be free'd (although it's not of use any longer).</p> <p>I found some advice in the web, that proposed to collect call stacks of the increment/decrement operations of the reference counter. This gives me a good hint, which piece of code has caused the reference counter to get increased or decreased.</p> <p>But what I need is some kind of algorithm that groups the corresponding "increase/decrease call stacks" together. After removing these pairs of call stacks, I hopefully have (at least) one "increase call stack" left over, that shows me the piece of code with the "needless" reference, that caused the corresponding object not to be freed. Now it will be no big deal to fix the leak!</p> <p>But has anybody an idea for an "algorithm" that does the grouping?</p> <p>Development takes place under <strong>Windows XP</strong>.</p> <p>(I hope someone understood, what I tried to explain ...)</p> <p>EDIt: I am talking about leaks caused by circular references.</p>
<p>Note that one source of leaks with <strong>reference-counting smart pointers</strong> are pointers with <strong>circular dependancies</strong>. For example, A have a smart pointer to B, and B have a smart pointer to A. Neither A nor B will be destroyed. You will have to find, and then break the dependancies.</p> <p>If possible, use boost smart pointers, and use shared_ptr for pointers which are supposed to be owners of the data, and weak_ptr for pointers not supposed to call delete.</p>
<p>First step could be to know what class is leaking. Once you know it, you can find who is increasing the reference: 1. put a breakpoint on the constructor of class that is wrapped by shared_ptr. 2. step in with debugger inside shared_ptr when its increasing the reference count: look at variable pn->pi_->use_count_ Take the address of that variable by evaluating expression (something like this: &amp;this->pn->pi_.use_count_), you will get an address 3. In visual studio debugger, go to Debug->New Breakpoint->New Data Breakpoint... Enter the address of the variable 4. Run the program. Your program will stop every time when some point in the code is increasing and decreasing the reference counter. Then you need to check if those are matching.</p>
9,276
<p>I'm developing a client/server app that will communicate via rest. Some custom request data will be stored in the header of the request. Both the server sending the request and the receiving server have an SSL certificate - will the headers be encrypted, or just the content?</p>
<p>SSL encrypts the entire communications path from the client to the server and back, so yes - the headers will be encrypted.</p> <p>By the way, if you develop networked applications and care about data security, the least you should do is read a book like Practical Cryptography, by Niels Ferguson and Bruce Schneier, and probably further reading that's more focused on web application security would be a good idea. If I may make an observation - and please, I don't mean that as a personal criticism - your question indicates a fundamental lack of understanding of very basic web security technologies, and that's never a good sign.</p> <p>Also, it's never a bad idea to confirm that data which is assumed to be encrypted is indeed encrypted. You can use a network analyzer to monitor traffic on the wire and watch out for anything sensitive being sent in the clear. I've used Wireshark to do this before - the results can be surprising, sometimes.</p>
<p>Not <em>everything</em> is encrypted: the request query string is not encrypted. Believe me, I've seen requests like this:</p> <p><a href="https://mydomain.com/authenticate?user=username&amp;password=MyStrongPasswordSentInTheClear" rel="nofollow">https://mydomain.com/authenticate?user=username&amp;password=MyStrongPasswordSentInTheClear</a></p> <p>Please don't put sensitive data as parameters in the query string.</p>
9,927
<p>While setting up CruiseControl, I added a buildpublisher block to the publisher tasks:</p> <pre><code>&lt;buildpublisher&gt; &lt;sourceDir&gt;C:\MyBuild\&lt;/sourceDir&gt; &lt;publishDir&gt;C:\MyBuildPublished\&lt;/publishDir&gt; &lt;alwaysPublish&gt;false&lt;/alwaysPublish&gt; &lt;/buildpublisher&gt; </code></pre> <p>This works, but it copies the entire file contents of the build, I only want to copy the DLL's and .aspx pages, I don't need the source code to get published.</p> <p>Does anyone know of a way to filter this, or do I need to setup a task to run a RoboCopy script instead?</p>
<p>I set up a task to do this. I'm not aware of any way to make CruiseControl be that specific. I usually just chain a batch file to do the copy to the CC.net task.</p>
<p>The default build publisher in CC.NET does not provide a way to do this. You have a few options:</p> <ul> <li>Create your own build publisher with the desired functionality</li> <li>Create a custom NAnt/MSBuild task</li> <li>Use a scripting technology (RoboCopy, batch file, etc.) to create a script file and run an "Executable" task for CC.NET, or an "exec" task for NAnt/MSBuild</li> </ul>
4,302
<p>I want to expand my programming horizons to Linux. A good, dependable basic toolset is important, and what is more basic than an IDE?</p> <p>I could find these SO topics:</p> <ul> <li><a href="https://stackoverflow.com/questions/2756/lightweight-ide-for-linux">Lightweight IDE for linux</a> and</li> <li><a href="https://stackoverflow.com/questions/17228/what-tools-do-you-use-to-develop-c-applications-on-linux">What tools do you use to develop C++ applications on Linux?</a></li> </ul> <p>I'm not looking for a <em>lightweight</em> IDE. If an IDE is worth the money, then I will pay for it, so it need not be free.</p> <p>My question, then:</p> <blockquote> <p><em>What good, C++ programming IDE is available for Linux?</em></p> </blockquote> <p>The minimums are fairly standard: syntax highlighting, code completion (like <a href="http://en.wikipedia.org/wiki/IntelliSense" rel="nofollow noreferrer">intellisense</a> or its Eclipse counterpart) and integrated debugging (e.g., basic breakpoints).</p> <p>I have searched for it myself, but there are so many that it is almost impossible to separate the good from the bads by hand, especially for someone like me who has little C++ coding experience in Linux. I know that <a href="http://www.eclipse.org/cdt/" rel="nofollow noreferrer">Eclipse supports C++</a>, and I really like that IDE for Java, but is it any good for C++ and is there something better?</p> <p>The second post actually has some good suggestions, but what I am missing is what exactly makes the sugested IDE so good for the user, what are its (dis)advantages?</p> <p>Maybe my question should therefore be:</p> <blockquote> <p><em>What IDE do you propose (given your experiences), and why?</em></p> </blockquote>
<h2>Initially: confusion</h2> <p>When originally writing this answer, I had recently made the switch from Visual Studio (with years of experience) to Linux and the first thing I did was try to find a reasonable IDE. At the time this was impossible: no good IDE existed.</p> <h2>Epiphany: UNIX is an IDE. <em>All of it.</em><sup>1</sup></h2> <p>And then I realised that the IDE in Linux is the command line with its tools:</p> <ul> <li>First you set up your shell <ul> <li>Bash, in my case, but many people prefer</li> <li><a href="https://fishshell.com/" rel="noreferrer">fish</a> or</li> <li><a href="https://github.com/robbyrussell/oh-my-zsh" rel="noreferrer">(Oh My) Zsh</a>;</li> </ul></li> <li>and your editor; pick your poison — both are state of the art: <ul> <li><a href="https://neovim.io/" rel="noreferrer">Neovim</a><sup>2</sup> or</li> <li><a href="https://www.gnu.org/software/emacs/" rel="noreferrer">Emacs</a>.</li> </ul></li> </ul> <p>Depending on your needs, you will then have to install and configure several plugins to make the editor work nicely (that’s the one annoying part). For example, most programmers on Vim will benefit from the <a href="https://valloric.github.io/YouCompleteMe/" rel="noreferrer">YouCompleteMe</a> plugin for smart autocompletion.</p> <p>Once that’s done, the shell is your command interface to interact with the various tools — Debuggers (gdb), Profilers (gprof, valgrind), etc. You set up your project/build environment using <a href="https://www.gnu.org/software/make/" rel="noreferrer">Make</a>, <a href="https://bitbucket.org/snakemake/snakemake/wiki/Home" rel="noreferrer">CMake</a>, <a href="https://bitbucket.org/snakemake/snakemake/wiki/Home" rel="noreferrer">SnakeMake</a> or any of the various alternatives. And you manage your code with a version control system (most people use <a href="https://git-scm.com/" rel="noreferrer">Git</a>). You also use <a href="https://tmux.github.io/" rel="noreferrer">tmux</a> (previously also screen) to multiplex (= think multiple windows/tabs/panels) and persist your terminal session.</p> <p>The point is that, thanks to the shell and a few tool writing conventions, these all <em>integrate with each other</em>. And that way <strong>the Linux shell is a truly integrated development environment</strong>, completely on par with other modern IDEs. (This doesn’t mean that individual IDEs don’t have features that the command line may be lacking, but the inverse is also true.)</p> <h2>To each their own</h2> <p>I cannot overstate how well the above workflow functions once you’ve gotten into the habit. But some people simply prefer graphical editors, and in the years since this answer was originally written, Linux has gained a suite of excellent graphical IDEs for several different programming languages (but not, as far as I’m aware, for C++). Do give them a try even if — like me — you end up not using them. Here’s just a small and biased selection:</p> <ul> <li>For Python development, there’s <a href="https://www.jetbrains.com/pycharm/" rel="noreferrer">PyCharm</a></li> <li>For R, there’s <a href="https://www.rstudio.com/" rel="noreferrer">RStudio</a></li> <li>For JavaScript and TypeScript, there’s <a href="https://code.visualstudio.com/" rel="noreferrer">Visual Studio Code</a> (which is also a good all-round editor)</li> <li>And finally, many people love the <a href="https://www.sublimetext.com/" rel="noreferrer">Sublime Text editor</a> for general code editing.</li> </ul> <p>Keep in mind that this list is far from complete.</p> <hr> <p><sup>1</sup> I stole that title from dsm’s comment.</p> <p><sup>2</sup> I used to refer to Vim here. And while plain Vim is still more than capable, Neovim is a promising restart, and it’s modernised a few old warts.</p>
<blockquote> <p><a href="https://stackoverflow.com/questions/24109/c-ide-for-linux#219039">why wouldn't you also use it for C++? CDT meets every requirement you've mentioned.</a></p> </blockquote> <p>I didn't use eclipse at first because I wasn't sure that it was equally good at giving me the means of developing in C++ (efficiently). Besides that, I was also convinced that there had to be better, more specialized tools available for c++ development in Linux: </p> <blockquote> <p>and I really like that [eclipse] IDE for java, but is it any good for c++ and won't I miss out on something that is even better?</p> </blockquote> <p>I honestly believe that, although some tools (like eclipse) are great at many things, it is best to look for other options as well (and I don't mean that for IDE's only, but in general and even in <em>real life</em>)...<br> Like in this case, vim is really great, and I would have missed out on it if I sticked to something I already knew. </p>
4,386
<p>I've been looking into different web statistics programs for my site, and one promising one is <a href="http://www.hping.org/visitors/" rel="nofollow noreferrer">Visitors</a>. Unfortunately, it's a C program and I don't know how to call it from the web server. I've tried using PHP's <a href="http://us.php.net/manual/en/function.shell-exec.php" rel="nofollow noreferrer">shell_exec</a>, but my web host (<a href="https://www.nearlyfreespeech.net/" rel="nofollow noreferrer">NFSN</a>) has PHP's <a href="http://us2.php.net/features.safe-mode" rel="nofollow noreferrer">safe mode</a> on and it's giving me an error message.</p> <p>Is there a way to execute the program within safe mode? If not, can it work with CGI? If so, how? (I've never used CGI before)</p>
<p>Visitors looks like a log analyzer and report generator. Its probably best setup as a chron job to create static HTML pages once a day or so.</p> <p>If you don't have shell access to your hosting account, or some sort of control panel that lets you setup up chron jobs, you'll be out of luck.</p>
<p>Is there any reason not to just use <a href="http://www.google.com/analytics/" rel="nofollow noreferrer">Google Analytics</a>? It's free, and you don't have to write it yourself. I use it, and it gives you a lot of information.</p> <p>Sorry, I know it's not a "programming" answer ;)</p>
7,100
<p>How are callbacks written in PHP?</p>
<p>The manual uses the terms "callback" and "callable" interchangeably, however, "callback" traditionally refers to a string or array value that acts like a <a href="http://en.wikipedia.org/wiki/Function_pointer" rel="noreferrer">function pointer</a>, referencing a function or class method for future invocation. This has allowed some elements of functional programming since PHP 4. The flavors are:</p> <pre><code>$cb1 = 'someGlobalFunction'; $cb2 = ['ClassName', 'someStaticMethod']; $cb3 = [$object, 'somePublicMethod']; // this syntax is callable since PHP 5.2.3 but a string containing it // cannot be called directly $cb2 = 'ClassName::someStaticMethod'; $cb2(); // fatal error // legacy syntax for PHP 4 $cb3 = array(&amp;$object, 'somePublicMethod'); </code></pre> <p>This is a safe way to use callable values in general:</p> <pre><code>if (is_callable($cb2)) { // Autoloading will be invoked to load the class "ClassName" if it's not // yet defined, and PHP will check that the class has a method // "someStaticMethod". Note that is_callable() will NOT verify that the // method can safely be executed in static context. $returnValue = call_user_func($cb2, $arg1, $arg2); } </code></pre> <p>Modern PHP versions allow the first three formats above to be invoked directly as <code>$cb()</code>. <code>call_user_func</code> and <code>call_user_func_array</code> support all the above.</p> <p>See: <a href="http://php.net/manual/en/language.types.callable.php" rel="noreferrer">http://php.net/manual/en/language.types.callable.php</a></p> <p>Notes/Caveats: </p> <ol> <li>If the function/class is namespaced, the string must contain the fully-qualified name. E.g. <code>['Vendor\Package\Foo', 'method']</code></li> <li><code>call_user_func</code> does not support passing non-objects by reference, so you can either use <code>call_user_func_array</code> or, in later PHP versions, save the callback to a var and use the direct syntax: <code>$cb()</code>;</li> <li>Objects with an <a href="http://us2.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.invoke" rel="noreferrer"><code>__invoke()</code></a> method (including anonymous functions) fall under the category "callable" and can be used the same way, but I personally don't associate these with the legacy "callback" term.</li> <li>The legacy <code>create_function()</code> creates a global function and returns its name. It's a wrapper for <code>eval()</code> and anonymous functions should be used instead.</li> </ol>
<p>I cringe every time I use <code>create_function()</code> in php. </p> <p>Parameters are a coma separated string, the whole function body in a string... Argh... I think they could not have made it uglier even if they tried.</p> <p>Unfortunately, it is the only choice when creating a named function is not worth the trouble.</p>
7,139
<p>Both the jQuery and Prototpye JavaScript libraries refuse to allow me to use a variable to select an list item element by index number although they accept a hard coded number. </p> <p>For example, in Prototype this works:</p> <pre><code>$$('li')[5].addClassName('active'); </code></pre> <p>But this will not work no matter how I try to cast the variable as a number or integer:</p> <pre><code>$$('li')[currentPage].addClassName('active'); </code></pre> <p>In jQuery I get similar weirdness. This will work:</p> <pre><code>jQuery('li').eq(5).addClass("active"); </code></pre> <p>But this will not work again even though the value of currentPage is 5 and its type is number:</p> <pre><code>jQuery('li').eq(currentPage).addClass("active"); </code></pre> <p>I'm trying to create a JavaScript pagination system and I need to set the class on the active page button. The list item elements are created dynamically depending upon the number of pages I need.</p>
<p>Are you certain that <code>currentPage</code> is an integer? Try something like:</p> <pre><code>var currentPage = 5; jQuery('li').eq(currentPage); </code></pre> <p>as a simple sanity check. If that works, you should try casting to <code>Integer</code>.</p>
<p>Make sure that the currentPage variable is correctly scoped in the code where it is being accessed. Could the variable be changed somewhere else in the code before you are accessing it? Tools like <a href="https://addons.mozilla.org/firefox/addon/1843" rel="nofollow noreferrer">Firebug</a> can help you to add a breakpoint at the point of execution and see the value of your variable.</p>
6,181
<p>In Java, static and transient fields are not serialized. However, I found out that initialization of static fields causes the generated serialVersionUID to be changed. For example, <code>static int MYINT = 3;</code> causes the serialVersionUID to change. In this example, it makes sense because different versions of the class would get different initial values. Why does any initialization change the serialVersionUID? For example, <code>static String MYSTRING = System.getProperty("foo");</code> also causes the serialVersionUID to change.</p> <p>To be specific, my question is why does initialization with a method cause the serialVersionUID to change. The problem I hit is that I added a new static field that was initialized with a system property value (getProperty). That change caused a serialization exception on a remote call.</p>
<p>You can find some information about that in the <a href="http://bugs.sun.com/view_bug.do?bug_id=4365406" rel="nofollow noreferrer">bug 4365406</a> and in the <a href="http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html#4100" rel="nofollow noreferrer">algorithm for computing <strong>serialVersionUID</strong></a>. Basically, when changing the initialization of your <code>static</code> member with <code>System.getProperty()</code>, the compiler introduces a new <code>static</code> property in your class referencing the <code>System</code> class (I assume that the <code>System</code> class was previously unreferenced in your class), and since this property introduced by the compiler is not private, it takes part in the <code>serialVersionUID</code> computation.</p> <p><strong>Morality</strong>: always use explicit <code>serialVersionUID</code>, you'll save some CPU cycles and some headaches :)</p>
<p>If I read the spec correctly the automatic <code>serialVersionUID</code> shouldn't change if you change the value of a static of transient field. Take a look at <a href="http://java.sun.com/javase/6/docs/platform/serialization/spec/version.html#6678" rel="nofollow noreferrer">Chapter 5.6</a> of the Spec.</p> <p><strong>However</strong>, if you think about this a bit - you start by serializing an object that has <code>static int MYINT = 3</code>, when you then deserialize the class you expect to get the same object back, that is, with <code>MYINT = 3</code>. So, if you change the static initialization you would expect the <code>serialVersionUID</code> to change because you can't get the same object back again.</p> <p><strong>Anyways</strong>, keep this in all your serializable classes and you can control the <code>serialVersionUID</code>:</p> <pre><code>private static final long serialVersionUID = 7526472295622776147L; </code></pre>
6,281
<p>When I've printed an object I've had to choose between high resolution and quick prints. What techniques or technologies can I use or deploy to speed up my high resolution prints?</p>
<p>You could experiment with slicing. For example, you might not need high resolution all over the object, but you can speed up some straight parts by using greater layer high there. See a <a href="http://manual.slic3r.org/expert-mode/variable-layer-height">part of Slic3r manual</a> about such thing.</p> <p>It is also possible to print thicker infill every Nth layer, see <a href="http://manual.slic3r.org/expert-mode/infill-optimization">Infill optimization</a> in Slic3r.</p> <p>Other slicers might have those features as well.</p>
<p>For FDM technologies in general with a single extruder, slicing modifications is your only options. However there will be a trade off between quality and speed. For ABS, changing to a machine with a enclosed build (such as a zortrax) chamber may help and a heated build chamber (Stratasys machine) will help the quality and reliability but not the print speed directly. As ABS has a tendency to warp vase mode is not the best idea either.</p> <p>If you only need high resolution and not strength then reducing the infill percentage or even using vase mode will speed up the print. Also changing to a material that you can print at higher speeds like PLA will magnify any of the previous settings.</p> <p>If you have two extruders then changing to a wider nozzle and using that for infill may speed up the print, heating and cooling time during extruder changeover may actually make it slower.</p> <p>For other technologies there are lots of options digital light projection (DLP) and stereolithography (SLA) both provide significantly higher resolution then FDM, with DLP being the faster of the two, <a href="https://formlabs.com/blog/3d-printing-technology-comparison-sla-dlp/" rel="nofollow noreferrer">comparison</a>. Take the review with a grain of salt though as the technologies are far from standardised, for example out DLP at work offers far higher resolution and speed then our SLA which is quite old.</p> <p>Sintering or melting technologies can scan the outline every layer then perform a infill of multiple layers at once to speed up the process. </p>
82
<p>I have</p> <pre><code>class Foo &lt; ActiveRecord::Base named_scope :a, lambda { |a| :conditions =&gt; { :a =&gt; a } } named_scope :b, lambda { |b| :conditions =&gt; { :b =&gt; b } } end </code></pre> <p>I'd like</p> <pre><code>class Foo &lt; ActiveRecord::Base named_scope :ab, lambda { |a,b| :conditions =&gt; { :a =&gt; a, :b =&gt; b } } end </code></pre> <p>but I'd prefer to do it in a DRY fashion. I can get the same effect by using</p> <pre><code> Foo.a(something).b(something_else) </code></pre> <p>but it's not particularly lovely.</p>
<p>At least since 3.2 there is a clever solution :</p> <pre><code>scope :optional, -&gt;() {where(option: true)} scope :accepted, -&gt;() {where(accepted: true)} scope :optional_and_accepted, -&gt;() { self.optional.merge(self.accepted) } </code></pre>
<p>@<a href="https://stackoverflow.com/questions/29011/is-there-a-way-to-combine-named-scopes-into-a-new-named-scope#30719">PJ</a>: you know, I had considered that, but dismissed it because I thought I wouldn't be able to later chain on a <em>third</em> named scope, like so:</p> <pre><code>Foo.ab(x, y).c(z) </code></pre> <p>But since <code>ab(x, y)</code> returns whatever <code>b(y)</code> would return, I think the chain would work. Way to make me rethink the obvious!</p>
4,868
<p>I'm looking for a quality WinForms component that supports syntax highlighting, code folding and the like. The key criteria are:</p> <ol> <li>Stability </li> <li>Value (price)</li> <li>Ability to easily customize syntax to highlight</li> <li>Light weight</li> </ol>
<p><a href="http://www.icsharpcode.net/OpenSource/SD/" rel="nofollow noreferrer">ICSharpCode.TextEditor</a> is free and pretty stable.<br> As for commercial solution Actipro's <a href="http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx" rel="nofollow noreferrer">SyntaxEditor</a> might be a best choice</p>
<p>Try out <a href="http://www.codeplex.com/ScintillaNET" rel="nofollow noreferrer">ScintillaNET</a> it's a .NET WinForms wrapper around the excellent <a href="http://scintilla.org/" rel="nofollow noreferrer">Scintilla</a> control. Scintilla itself is a free source code editor component that is very customisable and has all the features you asked for. See <a href="http://scintilla.sourceforge.net/SciTEImage.html" rel="nofollow noreferrer">here</a> for a screenshot.</p>
6,319
<p>I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two?</p> <p>table def:</p> <pre><code>CREATE TABLE feed_tbl ( code varchar(15), name varchar(40), status char(1), update char(1) CONSTRAINT feed_tbl_PK PRIMARY KEY (code) CREATE TABLE data_tbl ( code varchar(15), name varchar(40), status char(1), update char(1) CONSTRAINT data_tbl_PK PRIMARY KEY (code) </code></pre> <p>Here is my solution, as a view using three queries joined by unions. The <code>diff_type</code> specified is how the record needs updated: deleted from <code>_data(2)</code>, updated in <code>_data(1)</code>, or added to <code>_data(0)</code></p> <pre><code>CREATE VIEW delta_vw AS ( SELECT feed_tbl.code, feed_tbl.name, feed_tbl.status, feed_tbl.update, 0 as diff_type FROM feed_tbl LEFT OUTER JOIN data_tbl ON feed_tbl.code = data_tbl.code WHERE (data_tbl.code IS NULL) UNION SELECT feed_tbl.code, feed_tbl.name, feed_tbl.status, feed_tbl.update, 1 as diff_type FROM data_tbl RIGHT OUTER JOIN feed_tbl ON data_tbl.code = feed_tbl.code where (feed_tbl.name &lt;&gt; data_tbl.name) OR (data_tbl.status &lt;&gt; feed_tbl.status) OR (data_tbl.update &lt;&gt; feed_tbl.update) UNION SELECT data_tbl.code, data_tbl.name, data_tbl.status, data_tbl.update, 2 as diff_type FROM feed_tbl LEFT OUTER JOIN data_tbl ON data_tbl.code = feed_tbl.code WHERE (feed_tbl.code IS NULL) ) </code></pre>
<p>UNION will remove duplicates, so just UNION the two together, then search for anything with more than one entry. Given "code" as a primary key, you can say:</p> <p><em>edit 0: modified to include differences in the PK field itself</em></p> <p><em>edit 1: if you use this in real life, be sure to list the actual column names. Dont use dot-star, since the UNION operation requires result sets to have exactly matching columns. This example would break if you added / removed a column from one of the tables.</em></p> <pre><code>select dt.* from data_tbl dt ,( select code from ( select * from feed_tbl union select * from data_tbl ) group by code having count(*) &gt; 1 ) diffs --"diffs" will return all differences *except* those in the primary key itself where diffs.code = dt.code union --plus the ones that are only in feed, but not in data select * from feed_tbl ft where not exists(select code from data_tbl dt where dt.code = ft.code) union --plus the ones that are only in data, but not in feed select * from data_tbl dt where not exists(select code from feed_tbl ft where ft.code = dt.code) </code></pre>
<p>I would use a minor variation in the second <code>union</code>:</p> <pre><code>where (ISNULL(feed_tbl.name, 'NONAME') &lt;&gt; ISNULL(data_tbl.name, 'NONAME')) OR (ISNULL(data_tbl.status, 'NOSTATUS') &lt;&gt; ISNULL(feed_tbl.status, 'NOSTATUS')) OR (ISNULL(data_tbl.update, '12/31/2039') &lt;&gt; ISNULL(feed_tbl.update, '12/31/2039')) </code></pre> <p>For reasons I have never understood, <code>NULL</code> does not equal <code>NULL</code> (at least in SQL Server).</p>
5,084
<p>I have an array with holes that I have to fill with different materials. My question is there is an easy way to fill them directly? I tried array, array draft and it is annoying to adjust them. In Blender, it easy to select the vertices and fill. Maybe it is a stupid question, but I am not really an expert.</p> <p><a href="https://i.stack.imgur.com/7VwUW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7VwUW.png" alt="enter image description here" /></a></p>
<h1>The problem</h1> <p>FDM printers slice models in STL or OBJ format. Neither of these formats can transmit properties like <em>Materials</em>: they consist <strong>fully</strong> of surface definitions.</p> <h1>But... Multi-Material printing is a thing, yes?</h1> <p>Yes, but Multi-material prints use a simple trick: a single STL object can contain <em>more</em> than one surface definition, and you can slice more than one STL at once. But since slicers usually can't separate these from one another, they usually load multiple STLs and define the materials for each differently. For example, <a href="https://www.thingiverse.com/thing:3197896" rel="nofollow noreferrer">Adalinda</a> has 4 different STLs, some containing multiple chunks of material, each STL corresponding to one printed color. And <a href="https://youtu.be/MnOWX4Ujtv8?list=TLPQMDIwMjIwMjHXGYYAQZ7qbw" rel="nofollow noreferrer">in this video Joel</a> explains how printing that way works for an older version of the MMU.</p> <p>So, to print the &quot;cubes&quot; in a different material, you'd need to have two STLs: The grid as one export, and the cubes as another. Then the <strong>Rest</strong> is slicing.</p> <h1>Way around?</h1> <p>Now, you might not have a Multi-Material Printer? Then you might want to design your item in parts that snap into place or have an interference fit. For example, you might print a plate with all the cubes on one side, and a grid that has a relief on the back where the plate goes. Then you print two times with different materials and push the cube part into the grate, some glue in between, and voila! It looks like one print from the surface. With a clamshell design, you might even completely hide the existence of the carrier plate - by having two grates that surround a hollow cavity for the cube-plate, and the cube plate pushes out into either of the clamshells.</p>
<p>If you are asking for print then it is yes with FDM (fused deposition modeling) with multiple extrusion you can fill with different material easily. But if you are trying to change the material in your digital design then you need to work on every hole in the array, especially with FreeCAD. If you find any, please update here.</p>
1,830
<p>I recently upgraded to a E3D full hotend and I started to have problems with slowly printed parts. After I print first object and start next one, then the first layer has serious issue.</p> <p><a href="https://i.stack.imgur.com/wSSm4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wSSm4.jpg" alt="enter image description here"></a></p> <p>The first two test were extruded around 10mm/s, the right one around 15mm/s. The material is PLA (fillamentum.com) at temperature 210°C and nozzle diameter is 0.4mm. The Rebel II RepRap printer uses RAMPS with marlin firmware. I use Slic3r and Pronterface SW. </p> <p>I didn't find answer in following troubleshooting guides:</p> <ul> <li><a href="https://www.simplify3d.com/support/print-quality-troubleshooting/" rel="nofollow noreferrer">Simplify3D - Print Quality Troubleshooting Guide</a></li> <li><a href="http://support.3dverkstan.se/article/23-a-visual-ultimaker-troubleshooting-guide" rel="nofollow noreferrer">A visual Ultimaker troubleshooting guide</a></li> <li><a href="http://reprap.org/wiki/Print_Troubleshooting_Pictorial_Guide" rel="nofollow noreferrer">RepRap - Print Troubleshooting Pictorial Guide</a></li> <li><a href="https://all3dp.com/common-3d-printing-problems-and-their-solutions" rel="nofollow noreferrer">all3dp.com - 16 Common 3D Printing Problems (And Solutions)</a></li> </ul> <p>Do you have an idea what can cause this issue?</p> <h2>Update</h2> <p>I did a new print, where I just heat the hotend and start printing immediately. This is the result: </p> <p><a href="https://i.stack.imgur.com/Tqugj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tqugj.jpg" alt="enter image description here"></a></p>
<p>I use cosmetic vaseline - <a href="https://en.wikipedia.org/wiki/Petroleum_jelly" rel="noreferrer">petroleum jelly</a>. Usually it is white to transparent and odorless. It's cheap and available in all drugstores and cosmetics stores.</p> <p>As suggested by Tom van der Zanden I'm adding additional info about interactions of vaseline and plastics. I've found many web sites which claim that vaseline can damage plastics but none of them really proved that statement. There is nothing about it neither on producers sites nor wikipedia or any other believable sources I've found. So according to it and my practice I'm pretty sure that vaseline won't damage popular plastics (including common filaments).</p> <p>The only information I've found is that vaseline can damage natural rubber but I cannot confirm that on my own.</p> <p>Of course it might not be true for some materials so be careful and check the interactions first on invisible side or on refuses.</p>
<p>I have been using <em>sewing machine oil</em> for my 3D printed extruder gear for a couple of years, without any noticeable wear so far.</p> <p>In general, I believe any kind of low viscosity oil would do, but then again, it also depends on the environment in which you plan to use the model. If you plan on using it outside, for instance, you probably should get some grease that does not attract dirt, as the dirt itself will grind down the gears quickly.</p>
299
<p>How do I create class (i.e. <a href="https://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods" rel="nofollow noreferrer">static</a>) variables or methods in Python?</p>
<p>Variables declared inside the class definition, but not inside a method are class or static variables:</p> <pre><code>&gt;&gt;&gt; class MyClass: ... i = 3 ... &gt;&gt;&gt; MyClass.i 3 </code></pre> <p>As @<a href="https://stackoverflow.com/questions/68645/static-class-variables-in-python#answer-69067">millerdev</a> points out, this creates a class-level <code>i</code> variable, but this is distinct from any instance-level <code>i</code> variable, so you could have</p> <pre><code>&gt;&gt;&gt; m = MyClass() &gt;&gt;&gt; m.i = 4 &gt;&gt;&gt; MyClass.i, m.i &gt;&gt;&gt; (3, 4) </code></pre> <p>This is different from C++ and Java, but not so different from C#, where a static member can't be accessed using a reference to an instance.</p> <p>See <a href="https://docs.python.org/3/tutorial/classes.html#class-objects" rel="noreferrer">what the Python tutorial has to say on the subject of classes and class objects</a>.</p> <p>@Steve Johnson has already answered regarding <a href="http://web.archive.org/web/20090214211613/http://pyref.infogami.com/staticmethod" rel="noreferrer">static methods</a>, also documented under <a href="https://docs.python.org/3/library/functions.html#staticmethod" rel="noreferrer">&quot;Built-in Functions&quot; in the Python Library Reference</a>.</p> <pre><code>class C: @staticmethod def f(arg1, arg2, ...): ... </code></pre> <p>@beidy recommends <a href="https://docs.python.org/3/library/functions.html#classmethod" rel="noreferrer">classmethod</a>s over staticmethod, as the method then receives the class type as the first argument.</p>
<p>Not like the <code>@staticmethod</code> but class variables are static method of class and are shared with all the instances.</p> <p>Now you can access it like</p> <pre><code>instance = MyClass() print(instance.i) </code></pre> <p>or</p> <pre><code>print(MyClass.i) </code></pre> <p>you have to assign the value to these variables</p> <p>I was trying</p> <pre><code>class MyClass: i: str </code></pre> <p>and assigning the value in one method call, in that case it will not work and will throw an error</p> <pre><code>i is not attribute of MyClass </code></pre>
9,420
<p>I'm trying to write a custom WPF ValidationRule to enforce that a certain property is unique within the context of a given collection. For example: I am editing a collection of custom objects bound to a ListView and I need to ensure that the Name property of each object in the collection is unique. Does anyone know how to do this?</p>
<p>First, I'd create a simple DependencyObject class to hold your collection: </p> <pre><code>class YourCollectionType : DependencyObject { [PROPERTY DEPENDENCY OF ObservableCollection&lt;YourType&gt; NAMED: BoundList] } </code></pre> <p>Then, on your ValidationRule-derived class, create a property:</p> <pre><code>YourCollectionType ListToCheck { get; set; } </code></pre> <p>Then, in the XAML, do this:</p> <pre><code>&lt;Binding.ValidationRules&gt; &lt;YourValidationRule&gt; &lt;YourValidationRule.ListToCheck&gt; &lt;YourCollectionType BoundList="{Binding Path=TheCollectionYouWantToCheck}" /&gt; &lt;/YourValidationRule.ListToCheck&gt; &lt;/YourValidationRule&gt; &lt;/Binding.ValidationRules&gt; </code></pre> <p>Then in your validation, look at ListToCheck's BoundList property's collection for the item that you're validating against. If it's in there, obviously return a false validation result. If it's not, return true.</p>
<p>I would only create a custom dependency object if there were other properties I wanted to bind to the rule. Since in this case all we're doing is attaching a single collection of values to check against, I made my <code>&lt;UniqueValueValidationRule.OtherValues&gt;</code> property a <code>&lt;CollectionContainer&gt;</code>.</p> <p>From there, to get past the problem of the <code>DataContext</code> not being inherited, <code>&lt;TextBox.Resources&gt;</code> needed to have a <code>&lt;CollectionViewSource&gt;</code> to hold the actual binding and give it a <code>{StaticResource}</code> key, which <code>OtherValues</code> could then use as binding source.</p> <p>The validation rule itself then need only loop through <code>OtherValues.Collection</code> and perform equality checks.</p> <p>Observe:</p> <pre><code> &lt;TextBox&gt; &lt;TextBox.Resources&gt; &lt;CollectionViewSource x:Key="otherNames" Source="{Binding OtherNames}"/&gt; &lt;/TextBox.Resources&gt; &lt;TextBox.Text&gt; &lt;Binding Path="Name"&gt; &lt;Binding.ValidationRules&gt; &lt;t:UniqueValueValidationRule&gt; &lt;t:UniqueValueValidationRule.OtherValues&gt; &lt;CollectionContainer Collection="{Binding Source={StaticResource otherNames}}"/&gt; &lt;/t:UniqueValueValidationRule.OtherValues&gt; &lt;/t:UniqueValueValidationRule&gt; &lt;/Binding.ValidationRules&gt; &lt;/Binding&gt; &lt;/TextBox.Text&gt; &lt;/TextBox&gt; </code></pre>
5,517
<p>Is it still worth to add the log4j library to a Java 5 project just to log let's say some exceptions to a file with some nice rollover settings. Or will the standard util.logging facility do the job as well?</p> <p>What do you think?</p>
<p>I'd say you're probably fine with util.logging for the needs you describe.</p> <p>For a good decision tree, have a look at <a href="http://web.archive.org/web/20190320144728/http://java.sys-con.com/node/48541" rel="noreferrer">Log4j vs java.util.logging</a></p> <blockquote> <p>Question One : Do you anticipate a need for any of the clever handlers that Log4j has that JUL does not have, such as the SMTPHandler, NTEventLogHandler, or any of the very convenient FileHandlers?</p> </blockquote> <blockquote> <p>Question Two : Do you see yourself wanting to frequently switch the format of your logging output? Will you need an easy, flexible way to do so? In other words, do you need Log4j's PatternLayout?</p> </blockquote> <blockquote> <p>Question Three : Do you anticipate a definite need for the ability to change complex logging configurations in your applications, after they are compiled and deployed in a production environment? Does your configuration sound something like, &quot;Severe messages from this class get sent via e-mail to the support guy; severe messages from a subset of classes get logged to a syslog deamon on our server; warning messages from another subset of classes get logged to a file on network drive A; and then all messages from everywhere get logged to a file on network drive B&quot;? And do you see yourself tweaking it every couple of days?</p> </blockquote> <blockquote> <p>If you can answer yes to any of the above questions, go with Log4j. If you answer a definite no to all of them, JUL will be more than adequate and it's conveniently already included in the SDK.</p> </blockquote> <p>That said, pretty much every project these days seems to wind up including log4j, if only because some other library uses it.</p>
<p>I would go with log4j. The possibilites with log4j is not obsolete at all!</p>
5,174
<p>Using a Gearman RepRap with Slic3r, printing from an SD card, with an uniterupted power supply (UPS), and both PLA and ABS filaments, short power outages often result in x/y-axis offsets (see image). During an outage the power is not as clear from a UPS as from a power conditioner. If both x and y axes offset the results look like <a href="https://3dprinting.stackexchange.com/questions/10432/why-did-my-print-fall-off-its-raft?noredirect=1#comment17398_10432">Why did my print fall off its raft?</a>. Are you experiencing these same issues? Have you solved the issue. </p> <p><a href="https://i.stack.imgur.com/cSUVd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cSUVd.jpg" alt="Shows x-axis offset (ABS)"></a></p> <p>The image above shows an x-axis shift that occurred evenly across eight parts distributed across the bed. The filament was ABS. The parts still adhered to the bed. Note: the G-code file normally prints well. Thus, the file is not corrupt. </p>
<p>Part of your self-answer:</p> <blockquote> <p>What is puzzling is why did the 3D printer run as if the computer was still operating it, when is was printing from the SD card? Was the circuitry getting power from the USB cable from the computer?</p> </blockquote> <p>is more of an extension of the question, which I'll answer. Generally, yes, the logic of many (most?) 3D printers can be powered by the USB connection. You can try it sometime with the printer not plugged in to the AC power source at all. Under such a power configuration, the motors (not to mention the heating elements) should not operate at all, and I think the firmware has logic to detect this condition and not try to print under it, but I may be mistaken. However, in any case, in the event of an outage during printing, the logic board will remain powered if it's connected by USB, and especially if the outage is short enough, it might not even notice that the motors and heating elements are not functioning, yielding a result like what you saw.</p>
<p>I believe I resolved this issue. The next power outage will tell. After getting a larger UPS used for robotic testers, when swapping out the UPS, I noticed the 3D printer was plugged in to the surge protector side without the battery, probably because the smaller UPS was only rated for power to the computer. Now, with the larger UPS, the 3D printer also has power backup. What is puzzling is why did the 3D printer run as if the computer was still operating it, when is was printing from the SD card? Was the circuitry getting power from the USB cable from the computer?</p> <p>Note: If one is running their 3D printer using a notebook with a charged battery and the 3D printer doesn't have a UPS, it would have similar behavior. </p>
1,417
<p>I've heard rumors that PHP is planning on introducing a "goto" command. What is it supposed to be doing?</p> <p>I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "<code>GOTO 10</code>"-like command...</p>
<p>They are not adding a real GOTO, but extending the BREAK keyword to use static labels. Basically, it will be enhancing the ability to break out of <s>switch</s> nested if statements. Here's the concept example I found:</p> <pre><code>&lt;?php for ($i = 0; $i &lt; 9; $i++) { if (true) { break blah; } echo "not shown"; blah: echo "iteration $i\n"; } ?&gt; </code></pre> <p>Of course, once the GOTO "rumor" was out, there was nothing to stop some evil guys to propagate an additional <strong>COMEFROM</strong> joke. Be on your toes.</p> <p>See also:</p> <p><a href="http://www.php.net/~derick/meeting-notes.html#adding-goto" rel="nofollow noreferrer">http://www.php.net/~derick/meeting-notes.html#adding-goto</a></p>
<p>It <a href="http://wiki.php.net/doc/todo/undocumented#php_5.3" rel="nofollow noreferrer">looks</a> like it's currently in PHP 5.3, but is not fully documented yet. From what I can tell it shares its goto syntax with C, so it should be easy to pick up and use. Just remember Dijkstra's <a href="http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF" rel="nofollow noreferrer">warning</a> and use it only when necessary.</p>
3,983
<p>How can I find out which Service Pack is installed on my copy of SQL Server?</p>
<p>From TechNet: <a href="https://gallery.technet.microsoft.com/Determining-which-version-af0f16f6" rel="noreferrer">Determining which version and edition of SQL Server Database Engine is running</a></p> <pre><code>-- SQL Server 2000/2005 SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') -- SQL Server 6.5/7.0 SELECT @@VERSION </code></pre>
<pre><code>Select @@Version </code></pre> <blockquote> <p>Ex: My machine has the following one installed.</p> <p>Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86) Apr 2 2010 15:53:02 Copyright (c) Microsoft Corporation Enterprise Edition on Windows NT 6.1 (Build 7601: Service Pack 1)</p> </blockquote>
5,171
<p>I want to link to bookmark on a page (mysite.com/mypage.htm#bookmark) AND visually highlight the item that was bookmarked (maybe having a red border). Naturally, there would be multiple items bookmarked. So that if someone clicked on #bookmark2 then <em>that</em> other area would be highlighted). </p> <p>I can see how to do that with .asp or .aspx but I'd like to do it more simply than that. I thought maybe there was a clever way to do it with CSS.</p> <p>WHY I'm interested: - I want to have our programs link to a shopping page that lists all the programs on it. I'm using a bookmark so they're jumping to the particular program area (site.com/shoppingpage#Programx) but just to make it <em>obvious</em> I'd like to actually highlight the page being linked to.</p>
<p>In your css you need to define </p> <pre class="lang-css prettyprint-override"><code>a.highlight {border:1px solid red;} </code></pre> <p>or something similar</p> <p>Then using jQuery, </p> <pre><code>$(document).ready ( function () { //Work as soon as the DOM is ready for parsing var id = location.hash.substr(1); //Get the word after the hash from the url if (id) $('#'+id).addClass('highlight'); // add class highlight to element whose id is the word after the hash }); </code></pre> <p>To highlight the targets on mouse over also add:</p> <pre><code>$("a[href^='#']") .mouseover(function() { var id = $(this).attr('href').substr(1); $('#'+id).addClass('highlight'); }) .mouseout(function() { var id = $(this).attr('href').substr(1); $('#'+id).removeClass('highlight'); }); </code></pre>
<p>I guess if you could store this information with JavaScript and cookies for the functionality of remembering the bookmarks and even add a splash of Ajax if you wanted to interact with a database.</p> <p>CSS would only be able to do styling. You would have to give the bookmarked anchor a class found in your CSS file.</p> <p>CSS also has the a:visited selector which is used for styling links found in the browser's history.</p>
7,788
<p>Can fogbugz track case dependencies?</p>
<p>Yes and no. Cases can be linked to each other, but if you're looking for a tree of cases (prerequisites and such), you need FogBugz 7 or later.</p> <p>If you're using FogBugz 7.3 or greater, you can now use the <a href="http://www.fogcreek.com/fogbugz/plugins/plugin.aspx?ixPlugin=57" rel="nofollow noreferrer">Case Dependency Plugin</a>, which was released in April 2011.</p>
<p>FogBugz 7 now supports sub-cases. This may or may not solve your problem, depending on how you want to handle it.</p>
4,681
<p>Is hot glue suitable for FDM printing, or some process similar to it?</p> <p>I think it has all of the required properties, and could produce a flexible transluscent print. It's cheap, hotends are cheap, and the technology has been around for a while.</p> <p>I couldn't find any examples or anyone talking about such a material for use, on here or the general Internet. I wonder if there are tradeoffs or challenges that make it not worth pursuing.</p>
<p>You could mount a hot glue gun to a 3D positioning frame, but you would immediately notice the following:</p> <ul> <li>Hot glue sticks are fat, so you lose a lot of precision for each feed/retract increment. I.e., it's a lot harder to get precise feeds with a fat stick because the stick size is so much larger than the nozzle.</li> <li>Hot glue sticks are short, so you would to create a filament to spool the stuff or come up with a glue stick feeder.</li> <li>Hot glue melts at 120 &deg;C and common plastics such as nylon melt at much higher temperatures. So hot glue would make an AWFUL structural part like a stepper mount. Even PLA barely deals with stepper temperatures. Note that temperature tolerance is irrelevant for costume parts.</li> <li>Hot glue is soft, which makes it a great glue, but not very stiff for, say, making parts for a 3D printer. However, the parts might be fine for use only in costumes, etc.</li> </ul> <p>But, if you then used your 3D glue printer to dispense glue for gluing stuff together, well...that might be valuable. :D</p>
<p>I think not. Unless you intend to make a very special printer that feeds on glue stick, you must make filament from it. Should be doable.</p> <p>But my experience with cold hot glue, is that it is not very durable. It's a bit elastic but nothing like elastic filament. It breaks instead. So when you have your filament, I think you will have a bit of trouble handling it, feeding it into the printer etc. If you, for instance, clog the nozzle the slightest, the extruder will tear the filament to shreds very quickly.</p>
970
<p>Have any of you tried Hadoop? Can it be used without the distributed filesystem that goes with it, in a Share-nothing architecture? Would that make sense?</p> <p>I'm also interested into any performance results you have...</p>
<p>Yes, you can use Hadoop on a local filesystem by using file URIs instead of hdfs URIs in various places. I think a lot of the examples that come with Hadoop do this.</p> <p>This is probably fine if you just want to learn how Hadoop works and the basic map-reduce paradigm, but you will need multiple machines and a distributed filesystem to get the real benefits of the scalability inherent in the architecture.</p>
<p><strong>Parallel/ Distributed computing = SPEED</strong> &lt;&lt; Hadoop makes this really really easy and cheap since you can just use a bunch of commodity machines!!!</p> <p>Over the years disk storage capacities have increased massively but the speeds at which you read the data have not kept up. The more data you have on one disk, the slower the seeks.</p> <p>Hadoop is a clever variant of the divide an conquer approach to problem solving. You essentially break the problem into smaller chunks and assign the chunks to several different computers to perform processing in parallel to <strong>speed things up</strong> rather than overloading one machine. Each machine processes its own subset of data and the result is combined in the end. Hadoop on a single node isn't going to give you the speed that matters.</p> <p>To see the benefit of hadoop, you should have a cluster with at least 4 - 8 commodity machines (depending on the size of your data) on a the same rack.</p> <p>You no longer need to be a super genius parallel systems engineer to take advantage of distributed computing. Just know hadoop with Hive and your good to go.</p>
3,830
<p>I have an application which <em>really</em> should be installed, but does work fine when deployed using JNLP.</p> <p>However, it would seem that some Java functions such as <code>Runtime.exec</code> don't work using the default security options.</p> <p>I would like to therefore <a href="http://www.joelonsoftware.com/items/2008/07/01.html" rel="nofollow noreferrer">disable</a> UI functionality that relies upon such functions. </p> <p>So my question is, <strong>how do I detect at runtime whether certain functions are available or not?</strong></p> <p>The case study, here of course, is <code>Runtime.exec</code>.</p>
<p>You want to ask to the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/SecurityManager.html" rel="nofollow noreferrer">SecurityManager</a> if you have Exec right with the checkExec method.</p>
<p>For the specific example of Runtime.exec there is a method on the SecurityManager class checkExec(String cmd) that will throw an exception that can be caught to determine if the necessary command can be executed. For more information see the javadoc for Runtime.exec and SecurityManager.checkExec.</p> <p>The more general case requires creating a Permission object representing the task being checked and running SecurityManager's checkPermission method. </p>
5,393
<p>I've seen quite a few posts on changes in .NET 3.5 SP1, but stumbled into one that I've yet to see documentation for yesterday. I had code working just fine on my machine, from VS, msbuild command line, everything, but it failed on the build server (running .NET 3.5 RTM).</p> <pre><code>[XmlRoot("foo")] public class Foo { static void Main() { XmlSerializer serializer = new XmlSerializer(typeof(Foo)); string xml = @"&lt;foo name='ack' /&gt;"; using (StringReader sr = new StringReader(xml)) { Foo foo = serializer.Deserialize(sr) as Foo; } } [XmlAttribute("name")] public string Name { get; set; } public Foo Bar { get; private set; } } </code></pre> <p>In SP1, the above code runs just fine. In RTM, you get an InvalidOperationException:</p> <blockquote> <p>Unable to generate a temporary class (result=1). error CS0200: Property or indexer 'ConsoleApplication2.Foo.Bar' cannot be assign to -- it is read only</p> </blockquote> <p>Of course, all that's needed to make it run under RTM is adding [XmlIgnore] to the Bar property.</p> <p>My google fu is apparently not up to finding documentation of these kinds of changes. Is there a change list anywhere that lists this change (and similar under-the-hood changes that might jump up and shout "gotcha")? Is this a bug or a feature? </p> <p><strong>EDIT</strong>: In SP1, if I added a <code>&lt;Bar /&gt;</code> element, or set [XmlElement] for the Bar property, it won't get deserialized. It doesn't fail pre-SP1 when it tries to deserialize--it throws an exception when the XmlSerializer is constructed.</p> <p>This makes me lean more toward it being a bug, especially if I set an [XmlElement] attribute for Foo.Bar. If it's unable to do what I ask it to do, it should be throwing an exception instead of silently ignoring Foo.Bar. Other invalid combinations/settings of XML serialization attributes result in an exception.</p> <p><strong>EDIT</strong>: Thank you, TonyB, I'd not known about setting the temp files location. For those that come across similar issues in the future, you do need an additional config flag:</p> <pre><code>&lt;system.diagnostics&gt; &lt;switches&gt; &lt;add name="XmlSerialization.Compilation" value="1" /&gt; &lt;/switches&gt; &lt;/system.diagnostics&gt; &lt;system.xml.serialization&gt; &lt;xmlSerializer tempFilesLocation="c:\\foo"/&gt; &lt;/system.xml.serialization&gt; </code></pre> <p>Even with setting an [XmlElement] attribute on the Bar property, no mention was made of it in the generated serialization assembly--which fairly firmly puts this in the realm of a silently swallowed error (aka, a bug). Either that or the designers have decided [XmlIgnore] is no longer necessary for properties that can't be set--and you'd expect to see that in release notes, <a href="http://support.microsoft.com/kb/951847" rel="nofollow noreferrer">change lists</a>, or the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlignoreattribute.aspx" rel="nofollow noreferrer">XmlIgnoreAttribute documentation</a>.</p>
<p>In SP1 does the foo.Bar property get properly deserialized?</p> <p>In pre SP1 you wouldn't be able to deserialize the object because the set method of the Bar property is private so the XmlSerializer doesn't have a way to set that value. I'm not sure how SP1 is pulling it off.</p> <p>You could try adding this to your web.config/app.config</p> <pre><code>&lt;system.xml.serialization&gt; &lt;xmlSerializer tempFilesLocation="c:\\foo"/&gt; &lt;/system.xml.serialization&gt; </code></pre> <p>That will put the class generated by the XmlSerializer into c:\foo so you can see what it is doing in SP1 vs RTM</p>
<p>I rather like this new (?) behavior because the XML document doesn't have any mention of Bar in it, so the deserializer should not even be attempting to set it.</p>
5,532
<p>I would like to use a language that I am familiar with - Java, C#, Ruby, PHP, C/C++, although examples in any language or pseudocode are more than welcome.</p> <p>What is the best way of splitting a large XML document into smaller sections that are still valid XML? For my purposes, I need to split them into roughly thirds or fourths, but for the sake of providing examples, splitting them into n components would be good.</p>
<p>Well of course you can always extract the top-level elements (whether this is the granularity you want is up to you). In C#, you'd use the XmlDocument class. For example, if your XML file looked something like this:</p> <pre><code>&lt;Document&gt; &lt;Piece&gt; Some text &lt;/Piece&gt; &lt;Piece&gt; Some other text &lt;/Piece&gt; &lt;/Document&gt; </code></pre> <p>then you'd use code like this to extract all of the Pieces:</p> <pre><code>XmlDocument doc = new XmlDocument(); doc.Load("&lt;path to xml file&gt;"); XmlNodeList nl = doc.GetElementsByTagName("Piece"); foreach (XmlNode n in nl) { // Do something with each Piece node } </code></pre> <p>Once you've got the nodes, you can do something with them in your code, or you can transfer the entire text of the node to its own XML document and act on that as if it were an independent piece of XML (including saving it back to disk, etc).</p>
<p>It looks like you're working with C# and .NET 3.5. I have come across some posts that suggest using a yield type of algorithm on a file stream with an XmlReader.</p> <p>Here's a couple blog posts to get you started down the path:</p> <ul> <li><a href="http://blogs.msdn.com/xmlteam/archive/2007/03/05/streaming-with-linq-to-xml-part-1.aspx" rel="nofollow noreferrer">Streaming With Linq to SQL Part 1</a> </li> <li><a href="http://blogs.msdn.com/xmlteam/archive/2007/03/24/streaming-with-linq-to-xml-part-2.aspx" rel="nofollow noreferrer">Streaming With Linq To SQL Part 2</a></li> </ul>
2,939
<p>I am setting the <code>.Content</code> value of a Label to a string that contains underscores; the first underscore is being interpreted as an accelerator key.</p> <p>Without changing the underlying string (by replacing all <code>_</code> with <code>__</code>), is there a way to disable the accelerator for Labels?</p>
<p>If you use a TextBlock as the Content of the Label, its Text will not absorb underscores.</p>
<p>Why not like this?</p> <pre><code>public partial class LabelEx : Label { public bool PreventAccessKey { get; set; } = true; public LabelEx() { InitializeComponent(); } public new object Content { get { var content = base.Content; if (content == null || !(content is string)) return content; return PreventAccessKey ? (content as string).Replace("__", "_") : content; } set { if (value == null || !(value is string)) { base.Content = value; return; } base.Content = PreventAccessKey ? (value as string).Replace("_", "__") : value; } } } </code></pre>
6,200
<p>I know what <code>yield</code> does, and I've seen a few examples, but I can't think of real life applications, have you used it to solve some specific problem?</p> <p>(Ideally some problem that cannot be solved some other way)</p>
<p>I realise this is an old question (pre Jon Skeet?) but I have been considering this question myself just lately. Unfortunately the current answers here (in my opinion) don't mention the most obvious advantage of the yield statement.</p> <p>The biggest benefit of the yield statement is that it allows you to iterate over very large lists with much more efficient memory usage then using say a standard list.</p> <p>For example, let's say you have a database query that returns 1 million rows. You could retrieve all rows using a DataReader and store them in a List, therefore requiring list_size * row_size bytes of memory.</p> <p>Or you could use the yield statement to create an Iterator and only ever store one row in memory at a time. In effect this gives you the ability to provide a "streaming" capability over large sets of data. </p> <p>Moreover, in the code that uses the Iterator, you use a simple foreach loop and can decide to break out from the loop as required. If you do break early, you have not forced the retrieval of the entire set of data when you only needed the first 5 rows (for example).</p> <p>Regarding:</p> <pre><code>Ideally some problem that cannot be solved some other way </code></pre> <p>The yield statement does not give you anything you could not do using your own custom iterator implementation, but it saves you needing to write the often complex code needed. There are very few problems (if any) that can't solved more than one way.</p> <p>Here are a couple of more recent questions and answers that provide more detail:</p> <p><a href="https://stackoverflow.com/questions/384392/yield-keyword-value-added">Yield keyword value added?</a></p> <p><a href="https://stackoverflow.com/questions/317619/is-yield-useful-outside-of-linq">Is yield useful outside of LINQ?</a></p>
<p>Using yield can prevent downcasting to a concrete type. This is handy to ensure that the consumer of the collection doesn't manipulate it.</p>
3,783
<p>In my .NET/Forms app I have a DataGridView which is bound to a DataTable. The user selects a row of the DataGridView by double-clicking and does some interaction with the app. After that the content of the row is updated programmatically.</p> <p>When the user selects a new row the changes on the previous one are automagically propagated to the DataTable by the framework. How can I trigger this update from my code so the user does not have to select a new row?</p>
<p>I just had the same issue, and found the answer <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.iscurrentrowdirty.aspx" rel="nofollow noreferrer">here</a>:</p> <blockquote> <p>When the user navigates away from the row, the control commits all row changes. The user can also press CTRL+ENTER to commit row changes without leaving the row. To commit row changes programmatically, call the form's Validate method. If your data source is a BindingSource, you can also call BindingSource.EndEdit.</p> </blockquote> <p>Calling Validate() worked for me.</p>
<p>I guess it depends on what triggers the update to take place, if it is in a validation routine you could simply call that after the user clicks OK on editing the data. Your question is vague it would be easier to answer with more information. What is this interaction? Is it a dialog? What actually updates the data?</p>
9,840
<p>I have a scenario wherein, for example, I need to repeat a list of US states and display a table of cities and city populations after the name of each state. The design requirement dictates that every outer repetition must be the name of a state followed by a table of cities, and that requirement cannot be changed at this time. Are there disadvantages to nesting a GridView within a Repeater and then binding each repeated GridView during the Repeater's <code>ItemDataBound</code> event? What are some alternative solutions?</p>
<p>If it were me, I'd reverse the question and ask why <em>I should</em> use a GridView, If you need a bunch of built-in features like paging and sorting, then the GridView might be a good fit. If you just want tabular data, I'd reconsider. Why? Because with GridView you're getting a whole bunch of stuff you won't use, your ViewState will be potentially huge, and your page performance will be slower. </p> <p>I'm not a bigot when it comes to GridView, but I only use them when there is a damn good reason. </p>
<p>In your above scenario, you'd be better off doing a master-detail style GridView, which will save you the overhead of all those GridView objects that get created.</p> <p>There are various implementation of it (<a href="http://msdn.microsoft.com/en-us/library/aa479344.aspx" rel="nofollow noreferrer">using a drop down for the master</a>, using a <a href="http://mattberseth.com/blog/2008/04/masterdetail_with_the_gridview.html" rel="nofollow noreferrer">modal popup for the detail</a>, etc.), but the main point is that there are implementations available.</p>
7,371
<p>In Ruby, trying to print out the individual elements of a String is giving me trouble. Instead of seeing each character, I'm seeing their ASCII values instead: </p> <pre><code>&gt;&gt; a = "0123" =&gt; "0123" &gt;&gt; a[0] =&gt; 48 </code></pre> <p>I've looked online but can't find any way to get the original "0" back out of it. I'm a little new to Ruby to I know it has to be something simple but I just can't seem to find it.</p>
<p>Or you can convert the integer to its character value:</p> <pre><code>a[0].chr </code></pre>
<p>I think <code>each_char</code> or <code>chars</code> describes better what you want.</p> <pre><code>irb(main):001:0&gt; a = "0123" =&gt; "0123" irb(main):002:0&gt; Array(a.each_char) =&gt; ["0", "1", "2", "3"] irb(main):003:0&gt; puts Array(a.each_char) 0 1 2 3 =&gt; nil </code></pre>
4,917
<p>I'm running some c# .net pages with various gridviews. If I ever leave any of them alone in a web browser for an extended period of time (usually overnight), I get the following error when I click any element on the page.</p> <p>I'm not really sure where to start dealing with the problem. I don't mind resetting the page if it's viewstate has expired, but throwing an error is unacceptable!</p> <pre><code> Error: The state information is invalid for this page and might be corrupted. Target: Void ThrowError(System.Exception, System.String, System.String, Boolean) Data: System.Collections.ListDictionaryInternal Inner: System.Web.UI.ViewStateException: Invalid viewstate. Client IP: 66.35.180.246 Port: 1799 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0 ViewState: (**Very long Gibberish Omitted!**) Offending URL: (**Omitted**) Source: System.Web Message: The state information is invalid for this page and might be corrupted. Stack trace: at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded() at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) at System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) </code></pre>
<p>That is odd as the ViewState is stored as a string in the webpage itself. So I do not see how an extended period of time would cause that error. Perhaps one or more objects on the page have been garbage collected or the application reset, so the viewstate is referencing old controls instead of the controls created when the application restarted. </p> <p>Whatever the case, I feel your pain, these errors are never pleasant to debug, and I have no easy answer as to how to find the problem other than perhaps studying <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx" rel="nofollow noreferrer">how ViewState works</a></p>
<p>Alternatively if you know the time-out length then you could add a bit of javascript to the page which redirects the user to an alternative page if there has been no activity on the page after a preset period of time. You can then extend this to warn the customer that their session / page is about to expire and provide them with a means to extend it (e.g. javascript server call back).</p>
9,905
<p>What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so:</p> <pre><code>INSERT INTO some_table (column1, column2, column3) SELECT Rows.n.value('(@column1)[1]', 'varchar(20)'), Rows.n.value('(@column2)[1]', 'nvarchar(100)'), Rows.n.value('(@column3)[1]', 'int'), FROM @xml.nodes('//Rows') Rows(n) </code></pre> <p>However I find that this is getting very slow for even moderate size xml data.</p>
<p>Stumbled across this question whilst having a very similar problem, I'd been running a query processing a 7.5MB XML file (~approx 10,000 nodes) for around 3.5~4 hours before finally giving up.</p> <p>However, after a little more research I found that having typed the XML using a schema and created an XML Index (I'd bulk inserted into a table) the same query completed in ~ 0.04ms.</p> <p>How's that for a performance improvement!</p> <p>Code to create a schema:</p> <pre><code>IF EXISTS ( SELECT * FROM sys.xml_schema_collections where [name] = 'MyXmlSchema') DROP XML SCHEMA COLLECTION [MyXmlSchema] GO DECLARE @MySchema XML SET @MySchema = ( SELECT * FROM OPENROWSET ( BULK 'C:\Path\To\Schema\MySchema.xsd', SINGLE_CLOB ) AS xmlData ) CREATE XML SCHEMA COLLECTION [MyXmlSchema] AS @MySchema GO </code></pre> <p>Code to create the table with a typed XML column:</p> <pre><code>CREATE TABLE [dbo].[XmlFiles] ( [Id] [uniqueidentifier] NOT NULL, -- Data from CV element [Data] xml(CONTENT dbo.[MyXmlSchema]) NOT NULL, CONSTRAINT [PK_XmlFiles] PRIMARY KEY NONCLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] </code></pre> <p>Code to create Index</p> <pre><code>CREATE PRIMARY XML INDEX PXML_Data ON [dbo].[XmlFiles] (Data) </code></pre> <p>There are a few things to bear in mind though. SQL Server's implementation of Schema doesn't support xsd:include. This means that if you have a schema which references other schema, you'll have to copy all of these into a single schema and add that.</p> <p>Also I would get an error:</p> <pre><code>XQuery [dbo.XmlFiles.Data.value()]: Cannot implicitly atomize or apply 'fn:data()' to complex content elements, found type 'xs:anyType' within inferred type 'element({http://www.mynamespace.fake/schemas}:SequenceNumber,xs:anyType) ?'. </code></pre> <p>if I tried to navigate above the node I had selected with the nodes function. E.g.</p> <pre><code>SELECT ,C.value('CVElementId[1]', 'INT') AS [CVElementId] ,C.value('../SequenceNumber[1]', 'INT') AS [Level] FROM [dbo].[XmlFiles] CROSS APPLY [Data].nodes('/CVSet/Level/CVElement') AS T(C) </code></pre> <p>Found that the best way to handle this was to use the OUTER APPLY to in effect perform an "outer join" on the XML.</p> <pre><code>SELECT ,C.value('CVElementId[1]', 'INT') AS [CVElementId] ,B.value('SequenceNumber[1]', 'INT') AS [Level] FROM [dbo].[XmlFiles] CROSS APPLY [Data].nodes('/CVSet/Level') AS T(B) OUTER APPLY B.nodes ('CVElement') AS S(C) </code></pre> <p>Hope that that helps someone as that's pretty much been my day.</p>
<p>There is an <a href="http://msdn.microsoft.com/en-us/library/ms171769.aspx" rel="nofollow noreferrer">XML Bulk load</a> COM object (<a href="http://msdn.microsoft.com/en-us/library/ms171878.aspx" rel="nofollow noreferrer">.NET Example</a>) </p> <p>From <a href="http://msdn.microsoft.com/en-us/library/ms171721.aspx" rel="nofollow noreferrer">MSDN</a>:</p> <blockquote> <p>You can insert XML data into a SQL Server database by using an INSERT statement and the OPENXML function; however, the Bulk Load utility provides better performance when you need to insert large amounts of XML data.</p> </blockquote>
8,638
<p>My requirements:</p> <ul> <li>Support .NET Compact Framework 2.0 and Windows Mobile 6.0 devices.</li> <li>Only need to unzip the contents to a directory on a storage card. Creation of zip files is not required.</li> <li>Must be able to use in corporate/commercial software.</li> <li>Can be open source, but not have GPL or other viral license.</li> </ul> <p>I've seen the <a href="http://xceed.com/Zip_NET_CF_Intro.html" rel="noreferrer">Xceed Zip for CF</a> library. What other options are there?</p>
<p>Have a look at #ziplib (www.icsharpcode.com). It's GPL, but you can use it in closed-source, commercial applications. They don't say anything specifically on their page about using it with the Compact Framework, so you'd have to give it a test yourself (that said, it's pure C# without any external dependencies, so the chances are somewhat good that it will work).</p>
<p>I use the Resco MobileForms toolkit for a variety of functionality: <a href="http://www.resco.net/developer/mobileformstoolkit/overview.aspx" rel="nofollow noreferrer">http://www.resco.net/developer/mobileformstoolkit/overview.aspx</a></p> <p>It includes a good ZIP library.</p>
2,895
<p>Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX.</p> <p>They print fine in IE7, even IE6.</p> <p>We need these charts to print, but they also have dynamic content. I don't really want to draw them again as images when the user prints - the Flex component should do it.</p> <p>We've found a <a href="http://www.anychart.com/blog/2007/09/23/solving-problem-with-printing-flash-content-in-firefox-browser/" rel="nofollow noreferrer">potential workaround</a>, but unfortunately it doesn't work in FireFox3 (in FireFox2 it sort-of works, but not well enough).</p> <p>Anyone know a workaround?</p>
<p>Using the ACPrintManager I was able to get firefox 3 to print perfectly!</p> <p>The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null.</p> <pre><code>private function initPrint():void { //if we don't have a stage, wait until the next frame and try again if ( stage == null ) { callLater(initPrint); return; } PrintManager.init(stage); var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight); data.draw(myDataGrid); PrintManager.setPrintableContent(data); } </code></pre>
<p>Thanks. A load of <code>callLater</code>-s added to our custom chart code seems to have done it.</p>
3,066
<p>When I try to do that I get the following error:</p> <blockquote> <p>Changes to 64-bit applications are not allowed.</p> </blockquote> <hr /> <p>@Wilka: That option wasn't available until I selected Tools &gt; Options &gt; Projects and Solutions &gt; General and check &quot;Show advanced build configurations&quot;. Though I found this hint from your MSDN link. So if you edit your comment, I can make it the accepted answer...</p> <p>Thanks everybody!</p> <hr /> <p>Please see my first comment on this question, it's not there... Somehow... I can select Target framework though (2.0, 3.0 and 3.5), not that I see any use of that for this particular problem...</p> <hr /> <p>It doesn't have to be a 64bit program, actually, I rather prefer it to be 32bit anyway since it is more like a utility and it should work on 32bit systems.</p> <p>Also, I'm running Vista at 64bit. Maybe that has something to do with it?</p> <p>@Rob Cooper: Now I think of it, I never had the chance of selecting either a 64bit or a 32bit application when creating the solution/project/application... And according to your link &quot;64-Bit Debugging (X64)&quot; is possible with MS VB2008 express edition.</p> <hr /> <p>Oh btw, I found the following:</p> <blockquote> <p>If you are debugging a 64-bit application and want to use Edit and Continue, you must change the target platform and compile the application as a 32-bit application. You can change this setting by opening the Project Properties and going to the Compile page. On that page, click Advanced Compile Options and change the Target CPU setting to x86 in the Advanced Compiler Settings dialog box. <a href="http://msdn.microsoft.com/en-us/library/ba77s56w.aspx" rel="noreferrer">Link</a></p> </blockquote> <p>But I dont see the Target CPU setting...</p>
<p>You could try:</p> <blockquote> <p>In Visual Basic 2008 Express Edition: Build menu > Configuration Manager...</p> <p>Change Active solution platform: to "...", choose "x86", save the new platform.</p> <p>Now the "x86" option is available in the Compile settings.</p> </blockquote> <p>You may need to enable "Show advanced build configurations" first, in Tools > Options > Projects and Solutions > General</p> <p>(from <a href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3711099&amp;SiteID=1" rel="noreferrer">this post</a> on MSDN forums)</p>
<p>AFAIK Visual Studio Express does not come with 64bit support.</p>
5,006
<p>I've recently bought a 3D printer and waiting for it to be delivered I've given quite a lot of time to looking things up on Thingiverse. I see people create incredible models with gears, screws, lids and a lot of very cool and functional connectors (there are some project for boxes with an iris tipe lid that can be printed already assembled as a single model). I'd like to learn to do some of that as well. At the moment I have some proficiency with Blender where I can navigate the interface and sketch up some simple shaped model without any of the functional parts described above. My question therefore is:</p> <p>Are there any tutorials that could help me create better models? If I need to I'm ready to learn to use a software other than Blender. I've tried searching for a similar question but found nothing.</p>
<p>The answer to your question is yes, there are tutorials to help you create better models. Unfortunately, the back-story to the answer is beyond the scope of StackExchange.</p> <p>Don't limit yourself to Blender, especially if you are attempting to create non-organic (engineering-type) models. Blender is great for curves and bulges and bumps (and animation, and so much else) but not so great for parametric modeling. Meshmixer is a useful program, but more organic than engineering.</p> <p>Consider to search for OpenSCAD, Fusion 360, TinkerCAD, but also use terms such as "parametric 3d modeling software" to find a wider range of solutions to your quest. The above programs are free, there are too many paid programs to list even a small number.</p> <p>Oh, yeah, stay away from SketchUp for any 3d print modeling. So many failure modes result from models created with that program.</p>
<p>I think rather than looking for a tutorial at this stage, it might be instructive to watch some videos on tuning and calibration (since these touch on what is difficult). Also download Cura (or some other slicer of your choice) and look into how your existing models would be printed layer by layer. Cura has a layer slider so you can step through the design.</p> <p>So, to make an attempt at answering what I think could be a good question, things to research whilst waiting for your printer are:</p> <ol> <li>Print failure examples and calibration; </li> <li><code>Parametric</code> 3D modelling packages;</li> <li>Slicer operation (this ties in with calibration).</li> </ol>
431
<p>Basically, something better than this:</p> <pre><code>&lt;input type="file" name="myfile" size="50"&gt; </code></pre> <p>First of all, the <code>browse</code> button looks different on every browser. Unlike the <code>submit</code> button on a form, you have to come up with some <a href="http://www.quirksmode.org/dom/inputfile.html" rel="nofollow noreferrer">hack-y</a> way to style it.</p> <p>Secondly, there's no progress indicator showing you how much of the file has uploaded. You usually have to implement some kind of client-side way to disable multiple submits (e.g. change the submit button to a disabled button showing "Form submitting... please wait.") or flash a giant warning.</p> <p>Are there any good solutions to this that don't use Flash or Java?</p> <p><a href="https://stackoverflow.com/questions/11974/what-is-the-best-way-to-upload-a-file-via-an-http-post-with-a-web-form#12005">Yaakov</a>: That product looks to be exactly what I'm looking for, but the cost is $1000 and its specifically for <code>ASP.NET.</code> Are there any open source projects that cover the same or similar functionality?</p>
<p>File upload boxes is where we're currently at if you don't want to involve other technologies like Flash, Java or ActiveX.</p> <p>With plain HTML you are pretty much limited to the experience you've described (no progress bar, double submits, etc). If you are willing to use some javascript, you can solve some of the problems by giving feedback that the upload is in progress and even <a href="http://www.raditha.com/php/progress.php" rel="noreferrer">showing the upload progress</a> (it is a hack because you shouldn't have to do a full round-trip to the server and back, but at least it works).</p> <p>If you are willing to use Flash (which is available pretty much anywhere and on many platforms), you can overcome pretty much all of these problems. A quick googling turned up <a href="http://www.downloadsquad.com/2006/11/16/swfupload-open-source-flash-multi-file-upload/" rel="noreferrer">two</a> <a href="http://www.codeproject.com/KB/aspnet/FlashUpload.aspx" rel="noreferrer">such</a> components, both of them free <em>and</em> open source. I never used any of them, but they look good. BTW, Flash isn't without its problems either, for example when using the multi-file uploader for slide share, the browser kept constantly crashing on me :-(</p> <p>Probably the best solution currently is to detect dynamically if the user has Flash, and if it's the case, give her the flash version of the uploader, while still making it possible to choose the basic HTML one.</p> <p>HTH</p>
<p>It is true, the file upload control is definitely behind the times. Hopefully this will be addressed in a future asp.net version.</p> <p>Though it costs some money, I have found the <a href="http://www.telerik.com/products/aspnet-ajax/controls/upload/overview.aspx" rel="nofollow noreferrer">Telerik upload control</a> to have all of the functionality that you are looking for, including styling and progress updates (it also optimizes memory for large uploads).</p>
3,308
<p>Right now my ant task looks like.</p> <pre><code>&lt;javadoc sourcepath="${source}" destdir="${doc}"&gt; &lt;link href="http://java.sun.com/j2se/1.5.0/docs/api/" /&gt; &lt;/javadoc&gt; </code></pre> <p>And I'm getting this warning:</p> <pre><code>javadoc: warning - Error fetching URL: http://java.sun.com/j2se/1.5.0/docs/api/package-list </code></pre> <p>How do I get the javadoc to properly link to the API? I am behind a proxy.</p>
<p>You probably need the <a href="http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html" rel="noreferrer">http.proxyHost and http.proxyPort system properties</a> set. For example, <code>ANT_OPTS="-Dhttp.proxyHost=proxy.y.com" ant doc</code></p> <p>Alternatively, you could set the "offline" flag and provide a package list, but that could be a pain for the Java core.</p>
<p>You can also use the "offline" mode that allows you to build (faster!) without accessing the internet. Please see this answer: <a href="https://stackoverflow.com/a/24089805/366749">https://stackoverflow.com/a/24089805/366749</a></p>
7,631
<p>How are you handling the entry of numeric values in WPF applications?</p> <p>Without a NumericUpDown control, I've been using a TextBox and handling its PreviewKeyDown event with the code below, but it's pretty ugly.</p> <p>Has anyone found a more graceful way to get numeric data from the user without relying on a third-party control?</p> <pre><code>private void NumericEditPreviewKeyDown(object sender, KeyEventArgs e) { bool isNumPadNumeric = (e.Key &gt;= Key.NumPad0 &amp;&amp; e.Key &lt;= Key.NumPad9) || e.Key == Key.Decimal; bool isNumeric = (e.Key &gt;= Key.D0 &amp;&amp; e.Key &lt;= Key.D9) || e.Key == Key.OemPeriod; if ((isNumeric || isNumPadNumeric) &amp;&amp; Keyboard.Modifiers != ModifierKeys.None) { e.Handled = true; return; } bool isControl = ((Keyboard.Modifiers != ModifierKeys.None &amp;&amp; Keyboard.Modifiers != ModifierKeys.Shift) || e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Insert || e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Tab || e.Key == Key.PageDown || e.Key == Key.PageUp || e.Key == Key.Enter || e.Key == Key.Return || e.Key == Key.Escape || e.Key == Key.Home || e.Key == Key.End); e.Handled = !isControl &amp;&amp; !isNumeric &amp;&amp; !isNumPadNumeric; } </code></pre>
<p>How about:</p> <pre><code>protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e) { e.Handled = !AreAllValidNumericChars(e.Text); base.OnPreviewTextInput(e); } private bool AreAllValidNumericChars(string str) { foreach(char c in str) { if(!Char.IsNumber(c)) return false; } return true; } </code></pre>
<p>Call me crazy, but why not put plus and minus buttons at either side of the TextBox control and simply prevent the TextBox from receiving cursor focus, thereby creating your own cheap NumericUpDown control?</p>
2,742
<p>Say I have an ASMX web service, MyService. The service has a method, MyMethod. I could execute MyMethod on the server side as follows:</p> <pre><code>MyService service = new MyService(); service.MyMethod(); </code></pre> <p>I need to do similar, with service and method not known until runtime. </p> <p>I'm assuming that reflection is the way to go about that. Unfortunately, I'm having a hard time making it work. When I execute this code:</p> <pre><code>Type.GetType("MyService", true); </code></pre> <p>It throws this error:</p> <blockquote> <p>Could not load type 'MyService' from assembly 'App_Web__ktsp_r0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.</p> </blockquote> <p>Any guidance would be appreciated.</p>
<p>I'm not sure if this would be the best way to go about it. The most obvious way to me, would be to make an HTTP Request, and call the webservice using an actual HTTP GET or POST. Using your method, I'm not entirely sure how you'd set up the data you are sending to the web service. I've added some sample code in VB.Net</p> <pre><code>Dim HTTPRequest As HttpWebRequest Dim HTTPResponse As HttpWebResponse Dim ResponseReader As StreamReader Dim URL AS String Dim ResponseText As String URL = "http://www.example.com/MyWebSerivce/MyMethod?arg1=A&amp;arg2=B" HTTPRequest = HttpWebRequest.Create(URL) HTTPRequest.Method = "GET" HTTPResponse = HTTPRequest.GetResponse() ResponseReader = New StreamReader(HTTPResponse.GetResponseStream()) ResponseText = ResponseReader.ReadToEnd() </code></pre>
<p>@Kibbee: I need to avoid the HTTP performance hit. It won't be a remote call, so all of that added overhead <em>should</em> be unnecessary.</p> <p>@Daren: I definitely agree with that design philosophy. The issue here is that I'm not going to be in control of the service or its underlying business logic.</p> <p>This is for <a href="http://codeplex.com/UsernameAvailability" rel="nofollow noreferrer">a server control</a> that will need to execute against an arbitrary service/method, orthogonally to how the web service itself is implemented.</p>
8,775
<p>Is it really advantageous to move to Rake from ant?</p> <p>Anyone migrated from ant and find something monumental?</p> <p>FYI: Current environment is Ant for J2ME builds</p>
<p>I would say yes, but I have a different perspective than a Java-environment guy, because I'm a .NET-environment guy. I had written and maintained a non-trivial build script (clean, generate-assembly-info, build, test, coverage, analysis, package) in msbuild (MS' XML-driven NAnt effort) and it was very painful:</p> <ul> <li>XML isn't friendly; it's very noisy</li> <li>No-one else on the team was interested in learning it to the point of performing more, and more useful, automations; so high bus factor (ie, if I get hit by a bus, they're stuck with it)</li> <li>It did not lend itself to refactoring or improvement - it was one of those 'touch-at-your-peril' things, you know?</li> <li>It needed custom C# tasks to be written to run the various tools the build needed (though to be fair, often these are written by the vendors)</li> </ul> <p>In about a work-week's worth of my time (got to love empty offices at Christmas time!), I've learned enough ruby+rake to replace the whole thing with a shorter (in terms of LOC) script with slightly more functionality, and more understandability (I hope, anyhow; haven't had it reviewed yet).</p> <p>It benefits from: - It's a new language, but a real language. My team-mates like learning new languages, and this, while a thin excuse, is still an excuse ;-) This might mitigate the bus-factor if I'm right. - It's a short hop (I gather) from here to capistrano, the automated/remote/distributed deployment tool from the RoR world. Despite being an MS-stack shop, we're gonna be using that in combination with IIS7 finally having a CLI config tool.</p> <p>So, yeah. Your mileage may vary, but it was worth it for me.</p>
<p>Another tool that you might want to check out is <a href="http://gant.codehaus.org/" rel="nofollow noreferrer">Gant</a> if ant isn't meeting your needs. It adds full blown scripting support to ant but allows you to re-use your ant tasks as needed. It really depends on what you don't like about ant.</p>
9,687
<p>I wanted to create a coin stacking device similar to this one:</p> <p><a href="https://www.thingiverse.com/thing:499177" rel="nofollow noreferrer">https://www.thingiverse.com/thing:499177</a></p> <p>But I wanted to only 3 coins, 5c, 2c, and 1c. Unfortunately the STL came in pretty messy after importing to Blender, which made it difficult to edit the model to have only 3 stacks. So I decided to create my own. I used a box and three cylinders with the diameter of the coins + 2mm so the coins can fall loose into the stack. The cylinders where used for boolean modify the box to create the stack gaps.</p> <p><a href="https://i.stack.imgur.com/1dgA7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1dgA7.jpg" alt="enter image description here"></a></p> <p>Exporting the model as an obj and importing them to Cura showed it getting strange diagonal faces at the stack gaps and at the top. </p> <p><a href="https://i.stack.imgur.com/Xgjzt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xgjzt.jpg" alt="enter image description here"></a></p> <p>After slicing however the faces were gone and the test print came out pretty decent, even on low quality settings the measurement were quite exact.</p> <p><a href="https://i.stack.imgur.com/VPUWI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VPUWI.jpg" alt="enter image description here"></a></p> <p>Still I would like to know why these additional faces appear and how to prevent that. I am not a blender expert, but I guess it has to do something with the topology/faces? I started creating additional edges in Blender for the isolated vertex created by the boolean modifier, but I don't know if that's actually necessary for a 3d printed model that's not going to be textured ect.</p>
<p>It is quite common for modelling operations to result in 'non manifold geometry', meaning that some of the faces intersect or are not perfectly joined.</p> <p>Although there is nothing obvious in your model, you can check in blender by going into edit mode, unselect all, selecting nodes, and 'select all by attribute/non manifold' Ctl-Alt-Shift-M (if I remember right).</p> <p>Usually this happens with boolean operations where you merge the same object twice (i.e. union for the hole, then difference with the cut part). You would need to apply the boolean to see the non-manifold result.</p> <p>Any of the standard mesh fixing tools will attempt to clean up your exported STL, and you could then import the model back into blender (but then it is a one way process, and you can't make updates to the base model). </p>
<p>Not sure about Blender, but MeshMixer has a "Plane Cut" tool that would allow you to take the source STL file and cut off the parts you don't want. That might save you some pain. </p> <p>But if the final sliced <strong>gcode</strong> file works, don't worry too much. </p>
1,055
<p>I am trying to create a horizontal menu with the elements represented by <code>&lt;span&gt;</code>'s. The menu itself (parent <code>&lt;div&gt;</code>) has a fixed width, but the elements number is always different.</p> <p>I would like to have child <code>&lt;span&gt;</code>'s of the same width, independently of how many of them are there.</p> <p>What I've done so far: added a <code>float: left;</code> style for every span and specified its percentage width (percents are more or less fine, as the server knows at the time of the page generation, how many menu items are there and could divide 100% by this number). This works, except for the case when we have a division remainder (like for 3 elements), in this case I have a one-pixel hole to the right of the parent <code>&lt;div&gt;</code>, and if I rounding the percents up, the last menu element is wrapped. I also don't really like style generation on the fly, but if there's no other solution, it's fine.</p> <p>What else could I try?</p> <p>It seems like this is a very common problem, however googling for "child elements of the same width" didn't help.</p>
<p>You might try a table with a fixed table layout. It should calculate the column widths without concerning itself with the cell contents.</p> <pre class="lang-css prettyprint-override"><code>table.ClassName { table-layout: fixed } </code></pre>
<p>have you tried the decimal values, like setting width to 33.33%?</p> <p>As specified in the CSS syntax, the width property (<a href="http://www.w3.org/TR/CSS21/visudet.html#the-width-property" rel="nofollow noreferrer">http://www.w3.org/TR/CSS21/visudet.html#the-width-property</a>) can be given as &lt;percentage&gt; (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-percentage" rel="nofollow noreferrer">http://www.w3.org/TR/CSS21/syndata.html#value-def-percentage</a>), which is stated to be a &lt;number&gt;.</p> <p>As said at the number definition (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-number" rel="nofollow noreferrer">http://www.w3.org/TR/CSS21/syndata.html#value-def-number</a>), there some value types that must be integers, and are stated as &lt;integer&gt;, and the others are real numbers, stated as &lt;number&gt;. The percentage is defined as &lt;number&gt;, not as &lt;integer&gt; so it might work.</p> <p>It will depend on the browser's ability to solve this situation if it can't divide the parent's box by 3 without remaining, will it draw a 1- or 2-pixel space, or make 1 or 2 spans out of three wider than the rest.</p>
6,971
<p>Basically I want tools which generate source code visualization like:</p> <ul> <li>function call graph</li> <li>dependency graph</li> <li>...</li> </ul>
<p><a href="http://www.doxygen.nl/" rel="noreferrer">Doxygen</a> is really excellent for this, although you will need to install <a href="http://www.graphviz.org/" rel="noreferrer">GraphViz</a> to get the the graphs to draw.</p> <p>Once you've got everything installed, it's really rather simple to draw the graphs. Make sure you set <a href="http://www.doxygen.nl/manual/config.html#cfg_extract_all" rel="noreferrer">EXTRACT_ALL</a> and <a href="http://www.doxygen.nl/manual/config.html#cfg_call_graph" rel="noreferrer">CALL_GRAPH</a> to true and you should be good to go.</p> <p>The full documentation on this function for doxygen is <a href="http://www.doxygen.nl/manual/diagrams.html" rel="noreferrer">here</a>.</p>
<p>Might be a duplication, but check out ollydbg, IDA Pro and <a href="http://www.openrce.org/" rel="nofollow noreferrer">this website</a> has a whole bunch of resources with some very sexy images.</p>
4,754
<p>Continuous Integration toolchains for .NET, Java, and other languages are relatively well defined, but the C++ market seems to have a lot of diversity. </p> <p>By CI "toolchain" I specifically mean tools for the build scripts, automated testing, coding standards checking, etc.</p> <p>What are C++ teams using for CI toolchains?</p>
<p>Another option might be <a href="http://buildbot.net/trac" rel="noreferrer">buildbot</a>.</p> <p>It's written in python, but is not just for python apps. It can execute any script for doing your build. If you look at their success stories, there appear to be a wide variety of languages.</p>
<p>As with seemingly every other task in C++, I'm just barely limping along with continuous integration. My setup starts with Eclipse. I set it to generate make files for my projects. I have ant scripts that do the overall build tasks by running 'make all' or 'make clean' on the appropriate makefiles. These ant scripts are part of my project, and I have to update them when I add a new build configuration or a new piece to the system. It's not that bad though. </p> <p>I use CruiseControl to actually run the builds. Each project (all one of them) has an ant script of its own that performs build specific tasks (copying artifacts, processing results), calling into the project ant script to do the building. </p> <p>I had to use cppunit for my testing and process the results with an xslt file I found somewhere. I also have the wrong svn revision label on each build because I can't find a suitable svn labeler. All I can find is half-completed years-old code and people arguing that other people are doing it wrong. </p> <p>It looks to me like CC is a dying system, but I haven't found anything better for C++. Then again, I also feel like C++ is a dying language, so maybe it's bigger than just this. </p>
4,547
<p>Where can I find an online interactive console for programming language or api?</p> <ul> <li><a href="http://tryruby.org/" rel="nofollow noreferrer">Ruby</a></li> <li><a href="http://shell.appspot.com/" rel="nofollow noreferrer">Python</a></li> <li><a href="http://groovyconsole.appspot.com/" rel="nofollow noreferrer">Groovy</a></li> <li>PHP?</li> <li>Perl?</li> <li><a href="http://eval.ironscheme.net/" rel="nofollow noreferrer">Scheme</a></li> <li><a href="http://www.javarepl.com/" rel="nofollow noreferrer">Java</a></li> <li>C?</li> </ul>
<p>@kuszi Put a great answer as a comment to the question, but I almost missed it because it was a comment rather than the answer.</p> <p><a href="http://joel.franusic.com/w/page/26128430/Online-REPs-and-REPLs">This link</a> goes to a huuuge list of REPs and REPLs for tons of languages.</p>
<p><a href="http://getfirebug.com/lite" rel="nofollow noreferrer">Firebug Lite</a> for Javascript. And, <a href="http://vimeo.com/10499321" rel="nofollow noreferrer">Rainbow 9</a> was one of the first examples of online REPLs.</p>
7,150
<p>A fillet is like a rounded corner but on the inside of the corner.</p> <p><a href="https://i.stack.imgur.com/XDTnd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XDTnd.png" alt="enter image description here"></a></p> <p>Does it make a difference (structurally) to use fillets on a 3d printed part?</p>
<p>If your part needs structural support, then the word is: <strong>absolutely</strong>. Fillets provide the added support when you need it. If your part has a meeting line which is sharp - 90° (or perpendicular), there is a natural <a href="https://mechanics.stackexchange.com/q/18183/4152">stress riser</a> in your design. This is a weak spot where a crack can form. If strength is needed and the fillet won't interfere with the design, it's definitely something you should include with your part. </p>
<p>Fillets in X-Y plane (i.e. between two vertical surfaces) work great for 3D prints and increase the strength a lot. They usually also improve the print quality, because the print head can keep a constant speed in the curve instead of slowing down to a sharp corner.</p> <p>However fillets that extend in Z direction (i.e. between a vertical and a horizontal surface) suffer from layer artifacts. Sometimes they can look worse than a sharp corner would. While they do still increase the strength significantly, they are not as strong as similarly sized fillets in X-Y plane are.</p>
1,357
<p>Like the title says: Can reflection give you the name of the currently executing method.</p> <p>I'm inclined to guess not, because of the Heisenberg problem. How do you call a method that will tell you the current method without changing what the current method is? But I'm hoping someone can prove me wrong there.</p> <p><strong>Update:</strong> </p> <ul> <li>Part 2: Could this be used to look inside code for a property as well? </li> <li>Part 3: What would the performance be like?</li> </ul> <p><strong>Final Result</strong><br> I learned about MethodBase.GetCurrentMethod(). I also learned that not only can I create a stack trace, I can create only the exact frame I need if I want. </p> <p>To use this inside a property, just take a .Substring(4) to remove the 'set_' or 'get_'.</p>
<p>For non-<code>async</code> methods one can use</p> <pre><code>System.Reflection.MethodBase.GetCurrentMethod().Name; </code></pre> <p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.getcurrentmethod" rel="noreferrer">https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.getcurrentmethod</a></p> <p>Please remember that for <code>async</code> methods it will return "MoveNext".</p>
<pre><code>new StackTrace().ToString().Split("\r\n",StringSplitOptions.RemoveEmptyEntries)[0].Replace("at ","").Trim() </code></pre>
6,584
<p>Is there a way to perform a full text search of a subversion repository, including all the history?</p> <p>For example, I've written a feature that I used somewhere, but then it wasn't needed, so I svn rm'd the files, but now I need to find it again to use it for something else. The svn log probably says something like "removed unused stuff", and there's loads of checkins like that.</p> <p><strong>Edit 2016-04-15:</strong> Please note that what is asked here by the term "full text search", is to <strong>search the actual diffs of the commit history, and not filenames and/or commit messages</strong>. I'm pointing this out because the author's phrasing above does not reflect that very well - since in his example he might as well be only looking for a filename and/or commit message. Hence a lot of the <code>svn log</code> answers and comments.</p>
<pre><code>git svn clone &lt;svn url&gt; </code></pre> <pre><code>git log -G&lt;some regex&gt; </code></pre>
<p>I came across this <a href="http://www.m0interactive.com/archives/2009/04/23/quick_way_searching_comments_from_svn_using_bash_script.html" rel="nofollow">bash script</a>, but I have not tried it.</p>
6,586
<p>Is anyone using Virtual PC to maintain multiple large .NET 1.1 and 2.0 websites? Are there any lessons learned? I used Virtual PC recently with a small WinForms app and it worked great, but then everything works great with WinForms. ASP.NET development hogs way more resources, requires IIS to be running, requires a ridiculously long wait after recompilations, etc., so I'm a little concerned. And I'll also be using Oracle, if that makes any difference.</p> <p>Also, is there any real reason to use VM Ware instead of Virtual PC?</p>
<p>I've used VirtualPCs for a few years for development of some fairly hefty web apps without much problem. Lots of RAM is important. I keep my VPCs on an external USB drive and they perform great from there. This gives me the flexibility to take the drive with me if I need to do work somewhere else... just install VPC on a host plug in the USB drive and start coding.</p> <p>For servers, we use VMWare and have had little to no trouble with it.</p> <p>Recently I went back to working on my local machine as you lose the benefit of dual monitors with VPCs, and I don't need to be as mobile as I used to.</p>
<p>As long as you have the resources (separate hard disk for the virtual machine, sufficient RAM), I don't see why you would have any problems.</p>
5,119
<p>I am looking for troubleshooting help on my printer. Recently the hot end just can muster the courage to go past about 70 °C.</p> <p>The hardware - Ender 3V2 with a E3D V6 hot end. 24 volts</p> <p>I changed the thermistor to a new one. Before heating, it registers an appropriate 10 °C in line with the bed temp sensor.</p> <p>With the thermistor checked good, I looked at the heater element. It is reading 22 Ω. The documentation from E3D is not clear in what wattage heater I bought, but if it is a 30 W 24 V heater, it's on the high end of acceptable.</p> <ul> <li>A 24 V 30 W heater cartridge will read between 16.7 - 22.6 Ω.</li> <li>A 24 V 40 W heater cartridge will read between 12.3 - 15.1 Ω.</li> </ul> <p>If anyone is able to confirm how to know what my heater wattage is supposed to be, LMK. Options are shown for blue wires, red wires, and yellow. I have yellow.</p> <p>If the resistance is in spec, I checked if the voltage being supplied to the heater is correct. It is reading 23.6 V which seems good.</p> <p>I have attempted to PID autotune in Pronterface which I had also done several times previously before the issue. If I try to target anything over 70 °C, the attempt to tune fails because it can't get hot enough. I can tune if I set the temp to 65 °C by comparison.</p> <p>The temperature trace in Pronterface shows the temp rising quickly through the 30s, 40s, then plateauing and maxing out in the high 60s.</p> <p>I am looking for advice on where to look next for trouble shooting. Seems odd to suddenly have such a low temperature limit capability that I can't root cause.</p>
<h2>TL;DR:</h2> <p>Print more PLA on top of them, and pull it off together.</p> <h2>Preparation</h2> <p>First, of course, clean it well with IPA. This will both ensure there's no oil or other material on top of the PLA that will prevent it from bonding well with new PLA, and start to work underneath it to get it loose.</p> <h2>Printing</h2> <p>Then, print! Do a 2- or 3-layer square covering the whole buildplate if you need to, or just smaller ones in the affected areas. They should bond to whatever is there and pull it up when you peel them off.</p> <h2>Prevention</h2> <p>To avoid this happening in the future, <strong>fix your bed leveling</strong>. The type of tracks that are nearly impossible to remove by themselves normally come from printing with the nozzle so low that the material is forced entirely between the texture irregularities of the build surface, with no significant layer on top, and this means your bed is at least a whole layer-height too high relative to the nozzle.</p>
<p>If you can feel it with your finger, then you can scrape it off. Just be careful. Keep the scraper closer to horizontal and don't dig in. It doesn't really need much effort.</p> <p>If you can't feel it with your finger then it doesn't matter. Just clean as normal and carry on printing over it.</p>
2,117
<p>After reading <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden Features of C#</a> I wondered, What are some of the hidden features of Java?</p>
<p><a href="http://www.c2.com/cgi/wiki?DoubleBraceInitialization" rel="nofollow noreferrer">Double Brace Initialization</a> took me by surprise a few months ago when I first discovered it, never heard of it before.</p> <p><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html" rel="nofollow noreferrer">ThreadLocals</a> are typically not so widely known as a way to store per-thread state.</p> <p>Since JDK 1.5 Java has had extremely well implemented and robust concurrency tools beyond just locks, they live in <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/package-summary.html" rel="nofollow noreferrer">java.util.concurrent</a> and a specifically interesting example is the <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/package-summary.html" rel="nofollow noreferrer">java.util.concurrent.atomic</a> subpackage that contains thread-safe primitives that implement the <a href="http://www.ibm.com/developerworks/java/library/j-jtp11234/" rel="nofollow noreferrer">compare-and-swap</a> operation and can map to actual native hardware-supported versions of these operations.</p>
<p>Surprises me that an interface can extend multiple interfaces but class can extend only one class.</p>
3,631
<p>I'm using Hudson and Maven 2 for my automated build/CI. I can build fine with maven from the command line, but when I run the same goal with Hudson, the build fails complaining of missing artifacts. I'm running Hudson as a windows XP service.</p>
<p>Besides another commercial product, like <a href="http://www.wowzamedia.com/" rel="nofollow noreferrer">Wowza Media Server</a>, you could go with a CDN (Content Delivery Network), like <a href="http://www.limelightnetworks.com/" rel="nofollow noreferrer">Limelight Networks</a> or <a href="http://www.voxel.net/" rel="nofollow noreferrer">Voxel.net</a>. You might even be able to find a local hosting provider that would serve up live Flash video for you.</p> <p>(Live Flash video in a non-trivial thing to do, so the options are a bit limited.)</p>
<p>It looks like WebOrb can do it: <a href="http://www.themidnightcoders.com/weborb/dotnet/faq.shtm" rel="nofollow noreferrer">WebOrb FAQ</a> (last entry)</p> <blockquote> <p>Can I stream Flash video to a Flex/Flash client through WebORB? Yes, WebORB supports FLV video streaming. An example is included with the WebORB for .NET product distribution.</p> </blockquote> <p>I haven't worked with WebOrb though, so I can't say for sure how easy it is.</p>
6,582
<p>I have a sequence of migrations in a rails app which includes the following steps:</p> <ol> <li>Create basic version of the 'user' model</li> <li>Create an instance of this model - there needs to be at least one initial user in my system so that you can log in and start using it</li> <li>Update the 'user' model to add a new field / column.</li> </ol> <p>Now I'm using "validates_inclusion_of" on this new field/column. This worked fine on my initial development machine, which already had a database with these migrations applied. However, if I go to a fresh machine and run all the migrations, step 2 fails, because validates_inclusion_of fails, because the field from migration 3 hasn't been added to the model class yet.</p> <p>As a workaround, I can comment out the "validates_..." line, run the migrations, and uncomment it, but that's not nice.</p> <p>Better would be to re-order my migrations so the user creation (step 2) comes last, after all columns have been added.</p> <p>I'm a rails newbie though, so I thought I'd ask what the preferred way to handle this situation is :)</p>
<p>The easiest way to avoid this issue is to use <code>rake db:schema:load</code> on the second machine, instead of db:migrate. <code>rake db:schema:load</code> uses schema.rb to load the most current version of your schema, as opposed to migrating it up form scratch.</p> <p>If you run into this issue when deploying to a production machine (where preserving data is important), you'll probably have to consolidate your migrations into a single file without conflicts.</p>
<p>I'm having to do this right now. Building upon BiHi's advice, I'm loading the model manually then redefining methods where I need to.</p> <pre><code>load(File.join(RAILS_ROOT,"app/models/user.rb")) class User &lt; ActiveRecord::Base def before_validation; nil; end # clear out the breaking before_validation def column1; "hello"; end # satisfy validates_inclusion_of :column1 end </code></pre>
8,738
<p>I'm working on a Rails app and am looking to include some functionality from "<a href="https://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails">Getting the Hostname or IP in Ruby on Rails</a>" that I asked.</p> <p>I'm having problems getting it to work. I was under the impression that I should just make a file in the lib directory, so I named it 'get_ip.rb', with the contents:</p> <pre><code>require 'socket' module GetIP def local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end end </code></pre> <p>I had also tried defining GetIP as a class but when I do the usual <code>ruby script/console</code>, I'm not able to use the <code>local_ip</code> method at all. Any ideas?</p>
<p>You haven't described how you're trying to use the method, so I apologize in advance if this is stuff you already know.</p> <p>The methods on a module never come into use unless the module is included into a class. Instance methods on a class require there to be an instance of the class. You probably want a class method instead. And the file itself should be loaded, generally through the require statement.</p> <p>If the following code is in the file getip.rb,</p> <pre><code>require 'socket' class GetIP def self.local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end end </code></pre> <p>Then you should be able to run it by saying,</p> <pre><code>require 'getip' GetIP.local_ip </code></pre>
<p><code>require</code> and <code>include</code> are two different things.</p> <p><code>require</code> is to strictly load a file once from a load path. The loadpath is a string and this is the key used to determine if the file has already been loaded.</p> <p><code>include</code> is used to "mix-in" modules into other classes. <code>include</code> is called on a module and the module methods are included as instance methods on the class.</p> <pre><code> module MixInMethods def mixed_in_method "I'm a part of #{self.class}" end end class SampleClass include MixInMethods end mixin_class = SampleClass.new puts my_class.mixed_in_method # &gt;&gt; I'm a part of SampleClass </code></pre> <p>But many times the module you want to mix in is not in the same file as the target class. So you do a <code>require 'module_file_name'</code> and then inside the class you do an <code>include module</code>. </p>
6,709
<p>I recently installed Ubuntu on a VirtualBox VM it installed just fine (much easier than on VirtualPC). However I'm unable to get internet access from the guest OS (ie. Ubuntu). Can anyone give me any pointers on how I might enable this?</p> <p>The Host OS is Windows Vista and the hardware is an IBM Lenovo.</p>
<p>How did you configure networking when you created the guest? The easiest way is to set the network adapter to NAT, if you don't need to access the vm from another pc.</p>
<p>I had a similar issue in windows 7 + ubuntu 12.04 as guest. I resolved by</p> <ul> <li>open 'network and sharing center' in windows</li> <li>right click 'nw-bridge' -> 'properties'</li> <li>Select "virtual box host only network" for the option "select adapters you want to use to connect computers on your local network"</li> <li>go to virtual box.. select the network type as NAT. </li> </ul>
5,586
<p>I'm considering developing a website similar to stackoverflow, but the answers may also consist of drawings (schematics, in this case). I want to have an area in the answer form where they can make this schematic without requiring special plugins, etc. </p> <ol> <li>Are we to the point where SVG has or should have critical mass soon (1-2 years) such that designing a website where script-run SVG as a primary feature is reasonable (ie, requiring Firefox or another SVG/AJAX compliant browser)?</li> <li>What are some good resources for learning cross platform SVG scripting (likely in javascript)?</li> </ol> <p>-Adam Davis</p>
<p>Unfortunately, I don't have an answer, but I do have three pointers to projects that you could look at.</p> <p>The first is the <a href="http://Research.Sun.Com/projects/lively/" rel="noreferrer" title="Lively Kernel">Lively Kernel</a> by Dan Ingalls (yes, <em>the</em> Dan Ingalls) at Sun Labs. It is an implementation of a Smalltalk Virtual World in JavaScript on top of SVG. More precisely, it is an implementation of the Morphic GUI framework from Squeak Smalltalk in JavaScript using SVG and a port of (parts of) Squeak Smalltalk in JavaScript.</p> <p>Or, if you're not a Smalltalker and the above doesn't make sense to you: it's an Operating System, written in JavaScript with the JavaScript interpreter as the CPU, SVG as the graphics card and the browser as the computer.</p> <p>This is about as extreme as it gets, when it comes to JavaScript and SVG. And it only <em>fully</em> works in Safari 3 and partly in Firefox 3, although there is an experimental port to Internet Explorer as well.</p> <p>The second project is John Resig's <a href="http://EJohn.Org/blog/processingjs/" rel="noreferrer" title="Processing.js">Processing.js</a> port of the Processing visualization language to JavaScript. It uses the <code>&lt;canvas&gt;</code> element instead of SVG precisely because of the problems that you mentioned. This one however, only works in Firefox 3.</p> <p>The third one is <a href="http://UselessPickles.Com/triangles/demo.html" rel="noreferrer" title="Triangles in JavaScript">Real-Time 3D in JavaScript</a> by Useless Pickles. It uses <em>only</em> JavaScript, DOM and CSS and <em>no</em> SVG or <code>&lt;canvas&gt;</code> or Flash or whatever. <em>And</em> it is portable to almost any browser, including Internet Explorer 7 and up. Doing 2D should be even easier than this.</p> <p>Between those three projects you should be able to find some inspiration and also to find some people who tried to push the envelope with JavaScript and SVG or JavaScript and Graphics and can tell you what works and what doesn't.</p> <p>Conclusion: doing cross-browser SVG or cross-browser <code>&lt;canvas&gt;</code> is nigh impossible, but with a little bit of craziness, cross-browser graphics <em>without</em> SVG or <code>&lt;canvas&gt;</code> is possible.</p>
<p>1/ probably never - if IE wanted to add it, then I would have though it would have done so by now; but there are workarounds using <a href="http://www.intertwingly.net/blog/2007/05/04/Inline-SVG-in-MSIE" rel="nofollow noreferrer">SilverLight</a> and <a href="http://starkravingfinkle.org/blog/2006/03/svg-in-ie-update/" rel="nofollow noreferrer">Gecko</a> to provide rendering. On the other hand, there are cross-browser graphics APIs available. I've done largish front ends using XULRunner and SVG, but nothing on the web which had to cater for IE.</p> <p>2/ The two I referred to most often were the <a href="http://www.mozilla.org/projects/svg/" rel="nofollow noreferrer">SVG pages on mozilla.org</a> and this <a href="http://phrogz.net/ObjJob/objects.asp?langID=1" rel="nofollow noreferrer">SVG DOM reference</a> . All of my SVG links are here on <a href="http://delicious.com/MachineElf/svg" rel="nofollow noreferrer">delicious</a></p> <p>There's one existing editor at <a href="http://www.bpel4chor.org/editor/" rel="nofollow noreferrer">http://www.bpel4chor.org/editor/</a>; also if all you want is schematics where all arcs are on a grid, you can do that quite well using divs and images without SVG. Or you could just go the <a href="http://www.tincancamera.com/blog/2005/03/lo-fi-uml.html" rel="nofollow noreferrer">lo-fi route</a></p>
5,339
<p>So I am missing small sections of a layer when it prints, after a retraction for a layer change or a move, the extruder stops moving (no it isn't clicking or anything else. Just not moving). Which is fine for a few millimeters because the pressure inside the Bowden setup keeps pushing enough filament through. However, once that isn't enough it starts to make very thin lines with beads of plastic just barely holding things together. Basically this ends up as a good 2 cm or more at times of highly under extruded lines. This happens in the slowdown after the retraction when it is restarting. it simply doesn't move the extruder at all. The reason I know this is because I can see the extruder not moving, in that brief period. I know it is not the extruder clicking or anything else because I can disengage the extruder spring and push filament through manually during this time with no issues.</p> <p>I am using Ideamaker currently because I like it. </p> <p>I have looked at this <a href="https://3dprinting.stackexchange.com/questions/313/holes-missing-layers-after-retraction-in-3d-printed-objects">Holes/ missing layers (after retraction) in 3d printed objects</a> which is somewhat similar in appearance, but not in reason. <a href="https://i.stack.imgur.com/Eq26y.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Eq26y.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/Ag8OA.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Ag8OA.jpg" alt="Just a better image from the other side of the print"></a></p> <p><strong>EDIT:</strong> So I figure it is some form of coasting that IdeaMaker has implemented for their Raise printers. I am going to try and reduce the length of the coaster attempt to convert my Bowden to a direct drive with titan extruder. I have the Titan already, but it has been giving me issues with not having enough power to push filament without ripping it to shreds. That's another thing I have to look at at some point when I have the time.</p>
<p>I have made some learning on mechanical setup and discovered some issues on my printer, there are few:</p> <ol> <li>Bed warped, even with glass (thin thickness), making BAL confused with Z-movement over the bed.</li> <li>Overextrusion making layer oversized in terms of thickness.</li> <li>Some of missing mechanical fine adjustments.</li> </ol> <p>The main reason for this symptom was the overextrusion (that made my X and Y axis jump some steps when hotend collapses in the already-printed materials on their movements).</p> <p>I hope this helps some of those who have this similar problem!</p>
<p>The first picture seems to show layer shift. Usual causes include:</p> <ol> <li>Missed Z movement, so the nozzle hits the build and the layer is offset.</li> <li>Bad acceleration in X/Y, so there is missed X/Y movement, and the layer is offset.</li> </ol> <p>Adjustment: reduce Z G0 speed, and reduce X/Y speeds (G0 and G1) and acceleration, and then repeat.</p> <p>Hopefully, correcting this will make the issue in the second picture easier to diagnose.</p>
698
<p>Or vice versa.</p> <p>Update:<br> Hmm, let's assume I have a shopping cart app, the user clicks on the Checkout button. The next thing I want to do is send the user to a Invoice.aspx page (or similar). When the user hits checkout, I could <code>Button.PostBackURL = "Invoice.aspx"</code></p> <p>or I could do </p> <pre><code>Server.Transfer("Invoice.aspx") </code></pre> <p>(I also changed the title since the method is called Transfer and not TransferURL)</p>
<ul> <li>Server.TransferURL will not result in a roundtrip of HTTP request/response. The address bar will not update, as far as the browser knows it has received only one document. Server.Transfer also retains execution context, so the script "keeps going" as opposed to "starts anew".</li> <li>PostbackURL ensures an HTTP request, resulting in a possibly different URL and of course incurring network latency costs.</li> </ul> <p>Usually when you are attempting to "decide between the two" it means you are better off using PostbackURL. </p> <p>Feel free to expand your question with specifics and we can look at your precise needs.</p>
<p>Server.Transfer is done entirely from the server. Postback is initiated from the client for posting form contents and postback url identifies the page to post to.</p> <p>Maybe you meant to compare with Response.Redirect, which forces the client to submit a new request for a new url.</p>
9,159
<p>When trying to execute from within Visual Studio 2008 your application and you get the (uninformative) message "The operation could not be completed".</p> <p>The solution to this is to turn off the "Visual Studio Hosting Process".</p> <p>The problem with turning off this "hosting process" is that all the "run and rewrite" functionality is no longer available. OK, so this isn't a big deal, but I'm <em>always</em> getting this message no matter what machine I use (and it might be nice once in a while to use the rewrite and execute functionality).</p> <p>Am I doing something wrong? How come this "feature" within VS seems to complain so readily? Do other people have success with enabling the hosting process and making use of it?</p>
<blockquote> <p>The problem with turning off this "hosting process" is that all the "run and rewrite" functionality is no longer available.</p> </blockquote> <p>The Visual Studio Hosting Process is not needed to allow Edit and Continue. It is used for "Design time expression Evalutation" in the case where the project is a dll rather than an EXE. It is also used to provide debugging for partial trust scenarios. See the <a href="http://msdn.microsoft.com/en-us/library/ms242202.aspx" rel="nofollow noreferrer">documentation</a> for everything it does.</p> <p>It is highly unlikely it does anything you need, so don't feel bad <a href="http://msdn.microsoft.com/en-us/library/ms185330.aspx" rel="nofollow noreferrer">turning it off</a>.</p>
<p>Probably your web hosting already turn of the network function, you can open a ticket to contact with your web host to confirm, or anything you did would be useless.</p> <p>Some <a href="http://www.webhost4lifereview.com/visual-studio-hosting/" rel="nofollow">visual studio hosting</a> can be found at here.</p> <p>Good luck,</p> <p>Mark</p>
5,337
<p>When restoring a SQL Server Database, I notice that there are 3 different Recovery States to choose from:</p> <ul> <li>Restore with Recovery</li> <li>Restore with No Recovery</li> <li>Restore with Standby</li> </ul> <p>I've always left it at it's default value, but what do they all mean?</p> <p>(Preferably in layman's terms)</p>
<p>GateKiller,</p> <p>In simple terms (and not a copy-paste out of the SQLBOL) so you can understand the concepts:</p> <p>RESTORE WITH RECOVERY uses the backup media file (eg. fulldata.bak) to restore the database to back to the time that backup file was created. This is great if you want to go back in time to restore the database to an earlier state - like when developing a system.</p> <p>If you want to restore the database TO THE VERY LATEST DATA, (i.e. like if your doing a system Disaster Recovery and you cannot lose any data) then you want to restore that backup AND THEN all the transaction logs created since that backup. This is when you use RESTORE NORECOVERY. It will allow you to restore the later transaction logs right up to the point of failure (as long as you have them).</p> <p>RECOVERY WITH STANDBY is the ability to restore the database up to a parital date (like NORECOVERY above) but to allow the database still to be used READONLY. New transaction logs can still be applied to the database to keep it up to date (a standby server). Use this when it would take too long to restore a full database in order to Return To Operations the system. (ie. if you have a multi TB database that would take 16 hours to restore, but could receive transaction log updates every 15 minutes).</p> <p>This is a bit like a mirror server - but without having "every single transaction" send to the backup server in real time.</p>
<p>From Books On line, i think it is pretty clear after you read it</p> <p><strong>NORECOVERY</strong></p> <p>Instructs the restore operation to not roll back any uncommitted transactions. Either the NORECOVERY or STANDBY option must be specified if another transaction log has to be applied. If neither NORECOVERY, RECOVERY, or STANDBY is specified, RECOVERY is the default.</p> <p>SQL Server requires that the WITH NORECOVERY option be used on all but the final RESTORE statement when restoring a database backup and multiple transaction logs, or when multiple RESTORE statements are needed (for example, a full database backup followed by a differential database backup).</p> <p>Note When specifying the NORECOVERY option, the database is not usable in this intermediate, nonrecovered state.</p> <p>When used with a file or filegroup restore operation, NORECOVERY forces the database to remain in the restoring state after the restore operation. This is useful in either of these situations: </p> <p>A restore script is being run and the log is always being applied.</p> <p>A sequence of file restores is used and the database is not intended to be usable between two of the restore operations. </p> <p><strong>RECOVERY</strong></p> <p>Instructs the restore operation to roll back any uncommitted transactions. After the recovery process, the database is ready for use.</p> <p>If subsequent RESTORE operations (RESTORE LOG, or RESTORE DATABASE from differential) are planned, NORECOVERY or STANDBY should be specified instead.</p> <p>If neither NORECOVERY, RECOVERY, or STANDBY is specified, RECOVERY is the default. When restoring backup sets from an earlier version of SQL Server, a database upgrade may be required. This upgrade is performed automatically when WITH RECOVERY is specified. For more information, see Transaction Log Backups .</p> <p><strong>STANDBY</strong> = undo_file_name</p> <p>Specifies the undo file name so the recovery effects can be undone. The size required for the undo file depends on the volume of undo actions resulting from uncommitted transactions. If neither NORECOVERY, RECOVERY, or STANDBY is specified, RECOVERY is the default.</p> <p>STANDBY allows a database to be brought up for read-only access between transaction log restores and can be used with either warm standby server situations or special recovery situations in which it is useful to inspect the database between log restores.</p> <p>If the specified undo file name does not exist, SQL Server creates it. If the file does exist, SQL Server overwrites it.</p> <p>The same undo file can be used for consecutive restores of the same database. For more information, see Using Standby Servers. </p> <p>Important If free disk space is exhausted on the drive containing the specified undo file name, the restore operation stops.</p> <p>STANDBY is not allowed when a database upgrade is necessary.</p>
2,951
<p>How are people unit testing their business applications? I've seen a lot of examples of unit testing with "simple to test" examples. Ex. a calculator. How are people unit testing data-heavy applications? How are you putting together your sample data? In many cases, data for one test may not work at all for another test which makes it hard to just have one test database?</p> <p>Testing the data access portion of the code is fairly straightforward. It's testing out all the methods that work against the data that seem to be hard to test. For example, imagine a posting process where there is heavy data access to determine what is posted, numbers are adjusted, etc. There are a number of interim steps that occur (and need to be tested) along with tests afterwards that ensure the posting was successful. Some of those steps may actually be stored procedures.</p> <p>In the past I've tried inserting the test data in a test database, then running the test, but honestly it's pretty painful to write this kind of code (and error prone). I've also tried just building a test database up front and rolling back the changes. That works OK but in a number of places you can't easily do this either (and many people would say that's integration testing; so be it, I still need to be able to test this somehow).</p> <p>If the answer is that there isn't a nice way of handling this and it currently just sort of sucks, that would be useful to know as well.</p> <p>Any thoughts, ideas, suggestions, or tips are appreciated.</p>
<p>I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution.</p> <p>I have a very detailed post about integration testing your data access layer <a href="https://stackoverflow.com/questions/12374/has-anyone-had-any-success-in-unit-testing-sql-stored-procedures#25204">here</a></p> <p>I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full CRUD integration test w/ sample data shown. With this approach you don't need multiple test databases as you can control the data going in with each test and after the test is complete the transactions are all rolledback so your DB is clean.</p> <p>About unit testing business logic inside your app, I would also second the comments by @Phil and @Mark because if you mock out all the dependencies your business object has, it becomes very simple to test your application logic one entity at a time ;)</p> <p>Edit: So are you looking for one huge integration test that will verify everything from logic pre-data base / stored procedure run w/ logic and finally a verification on the way back? If so you could break this out into 2 steps:</p> <ul> <li><p>1 - Unit test the logic that happens before the data is pushed into your data access code. For example, if you have some code that calculates some numbers based on some properties -- write a test that only checks to see if the logic for this 1 function does what you asked it to do. Mock out any dependancy on the data access class so you can ignore it for this test of the application logic alone.</p></li> <li><p>2 - Integration test the logic that happens once you take your manipulated data (from the previous method we unit tested) and call the appropriate stored procedure. Do this inside a data specific testing class so you can rollback after it's completed. After your stored procedure has run, do a query against the database to get your object now that we have done some logic against the data and verify it has the values you expected (post-stored procedure logic /etc )</p></li> </ul> <p>If you need an entry in your database for the stored procedure to run, simply insert that data before you run the sproc that has your logic inside it. For example, if you have a product that you need to test, it might require a supplier and category entry to insert so before you insert your product do a quick and dirty insert for a supplier and category so your product insert works as planned.</p>
<p>For lots of different runs over the same logic but with different data you can use CSV, as many columns as you like for the input and the last for the output etc.</p>
5,949
<p>We have an SEO team at my office, and one of their dictums is that having lots of &lt;script&gt; blocks inline with the HTML is apocalypticly bad. As a developer that makes no sense to me at all. Surely the Google search engineers, who are the smartest people on the planet, know how to skip over such blocks? <br /> My gut instinct is that minimizing script blocks is a superstition that comes from the early ages of search engine optimizations, and that in today's world it means nothing. Does anyone have any insight on this?</p> <hr> <p>per our SEO guru, script blocks (especially those that are in-line, or occur before actual content) are very, very bad, and make the google bots give up before processing your actual content. Seems like bull to me, but I'd like to see what others say.</p>
<p>It's been ages since I've played the reading google's tea leafs game, but there are a few reasons your SEO expert might be saying this</p> <ol> <li><p>Three or four years back there was a bit of conventional wisdom floating around that the search engine algorithms would give more weight to search terms that happened sooner in the page. If all other things were equal on Pages A and B, if Page A mentions widgets earlier in the HTML file than Page B, Page A "wins". It's not that Google's engineers and PhD employees couldn't skip over the blocks, it's that they found a valuable metric in their presence. Taking that into account, it's easy to see how unless something "needs" (see #2 below) to be in the head of a document, an SEO obsessed person would want it out.</p></li> <li><p>The SEO people who aren't offering a quick fix tend to be proponents of well-crafted, validating/conforming HTML/XHTML structure. Inline Javascript, particularly the kind web ignorant software engineers tend to favor makes these people (I'm one) seethe. The bias against script tags themselves could also stem from some of the work Yahoo and others have done in optimizing Ajax applications (don't make the browser parse Javascript until is has to). Not necessarily directly related to SEO, but a best practice a white hat SEO type will have picked up. </p></li> <li><p>It's also possible you're misunderstanding each other. <strong>Content</strong> that's generated by Javascript is considered controversial in the SEO world. It's not that Google can't "see" this content, it's that people are unsure how its presence will rank the page, as a lot of black hat SEO games revolve around hiding and showing content with Javascript. </p></li> </ol> <p>SEO is at best Kremlinology and at worse a field that the black hats won over a long time ago. My free unsolicited advice is to stay out of the SEO game, present your managers with estimates as so how long it will take to implement their SEO related changes, and leave it at that.</p>
<p>I've spent some time working on search engines (not Google), but have never really done much from an SEO perspective.</p> <p>Anyway, here are some factors which Google could reasonably use to penalise the page which should be increased by including big blocks of javascript inline.</p> <ul> <li>Overall page size.</li> <li>Page download time (a mix of page size and download speed).</li> <li>How early in the page the search terms occurred (might ignore script tags, but that's a lot more processing).</li> </ul> <p>Script tags with lots of inline javascript might be interpreted to be bad on their own. If users frequently loaded a lot of pages form the site, they'd find it much faster if the script was in a single shared file.</p>
7,022
<p>For those who did not know, linking to off-site content in answers is a no-go at SE sites unless you provide context. From <a href="https://3dprinting.stackexchange.com/help/how-to-answer">help</a>:</p> <blockquote> <p><strong>Provide context for links</strong><br>Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.</p> </blockquote> <p>What about linking to off-site content for questions? <a href="https://3dprinting.stackexchange.com/help/how-to-ask">How do I ask a good question?</a> is not clear about that.</p> <p>A question on meta.stackexchange reads: <a href="https://meta.stackexchange.com/questions/94807/auto-ban-questions-that-use-pastebin">"Auto-ban questions that use pastebin?"</a>. This hints to banning people that use external linking in their answer.</p> <p>I can image for large sites (hundreds to thousands questions a day) or specific sites (about programming) you definitely want a method to shift the quality of questions. But we are small. Furthermore, it is sometimes necessary (as the OP does not have the knowledge, and we don't have the overview) to ask for the complete file (e.g. configuration.h or G-code). You sure don't want people to post their complete configuration.h or G-code file into the question.</p> <p>As links to off-site content seem to die over time, what can we do best to preserve the information for the question?</p>
<p><em>Copied from chat</em></p> <hr> <p>I agree about the posting of the entire configuration file or G-code in a question is too big to fit, etc. What is really needed, and I've thought this for a long time, is a SE sanctioned version of PasteBin [functionality]. A persistent scrapbook/scratchpad site internal to SE (like the i.stack.imgur.com site) where <em>over-sized</em> chunks of code/configs/text can be pasted, without it being an external link (which carry the inherent risk of link death). That would be the correct solution, and I don't understand why that hasn't been set up. Seems odd to me.</p>
<p>A possibility is to allow off-site content for the OP to post. Once the problem is spotted, the one answering the question could update the question with relevant parts of the off-site content, or copy the relevant parts into the answer.</p>
63
<p>I'm struggling with bed adhesion for nylon on a glass bed (122 °C measured) in an enclosed chamber (45 °C near the front, likely more on top of the print bed). I used a glue stick to enhance adhesion, but after around 20 minutes the print comes off the bed.</p> <p>I tried a <a href="https://www.123-3d.nl/123inkt-lijmstift-medium-21-grams-i1326-t7445.html" rel="nofollow noreferrer">no-brand glue stick</a> and a <a href="https://www.123-3d.nl/Pritt-stick-medium-22-gram-i1329-t7445.html" rel="nofollow noreferrer">Pritt glue stick</a>.</p> <p>Now I wonder whether they are suitable for the purpose, because nylon should really be printable in these conditions. Maybe the glue cannot hold those 100+ °C temperatures.</p> <p>How to find out whether a glue stick is PVA-based and suitable for nylon (or polycarbonate, ABS) printing?</p>
<p>Not all glue sticks work! The working ingredient of a glue stick is <a href="http://en.wikipedia.org/wiki/Polyvinylpyrrolidone" rel="nofollow noreferrer">Polyvinylpyrrolidone</a>; a more elaborate answer is found <a href="https://3dprinting.stackexchange.com/a/11183/">here</a> on question: <a href="https://3dprinting.stackexchange.com/questions/11182/why-does-hairspray-work-as-an-adhesive-for-abs/">&quot;Why does hairspray work as an adhesive for ABS?&quot;</a>.</p> <p>There are very good alternatives to glue sticks and hair spray nowadays. Specific adhesion sprays exist for several years now (e.g. Dimafix, 3DLAC, Magigoo for PA, Plasticz, PrintaFix, Dr.Mat, etc.; my personal experience is with the first 2 mentioned, both work for nylon: Dimafix has more tack at higher temperatures &gt; 80 °C, up to 80 °C 3DLAC works perfect).</p> <p>E.g. Dimafix has a higher temperature application range than e.g. 3DLAC. From the <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">manufacturer</a> can be seen that:</p> <p><a href="https://i.stack.imgur.com/ZBZny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZBZny.png" alt="enter image description here" /></a> <em>Source: <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">http://www.dima3d.com/en/home/dimafix/</a></em></p> <p>This image shows that the spray has its maximum tack/adhesion at about 120 °C and holds this adhesion level at least up to about 145 °C according to the image.</p> <p>However, not all glues get stronger with temperature! PVA (also called PVAc) glues soften very quickly, making them good only at low temperature. See &quot;<a href="https://bioresources.cnr.ncsu.edu/resources/influence-of-temperature-on-the-strength-of-bonded-joints/" rel="nofollow noreferrer">Influence of temperature on the strength of bonded joints</a>&quot; which discloses this graph for PVAc Rhenocoll 3W, 4B Plus:</p> <p><a href="https://i.stack.imgur.com/KB1lM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KB1lM.png" alt="enter image description here" /></a></p>
<p>Not all glue sticks work! The working ingredient of a glue stick is <a href="http://en.wikipedia.org/wiki/Polyvinylpyrrolidone" rel="nofollow noreferrer">Polyvinylpyrrolidone</a>; a more elaborate answer is found <a href="https://3dprinting.stackexchange.com/a/11183/">here</a> on question: <a href="https://3dprinting.stackexchange.com/questions/11182/why-does-hairspray-work-as-an-adhesive-for-abs/">&quot;Why does hairspray work as an adhesive for ABS?&quot;</a>.</p> <p>There are very good alternatives to glue sticks and hair spray nowadays. Specific adhesion sprays exist for several years now (e.g. Dimafix, 3DLAC, Magigoo for PA, Plasticz, PrintaFix, Dr.Mat, etc.; my personal experience is with the first 2 mentioned, both work for nylon: Dimafix has more tack at higher temperatures &gt; 80 °C, up to 80 °C 3DLAC works perfect).</p> <p>E.g. Dimafix has a higher temperature application range than e.g. 3DLAC. From the <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">manufacturer</a> can be seen that:</p> <p><a href="https://i.stack.imgur.com/ZBZny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZBZny.png" alt="enter image description here" /></a> <em>Source: <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">http://www.dima3d.com/en/home/dimafix/</a></em></p> <p>This image shows that the spray has its maximum tack/adhesion at about 120 °C and holds this adhesion level at least up to about 145 °C according to the image.</p> <p>However, not all glues get stronger with temperature! PVA (also called PVAc) glues soften very quickly, making them good only at low temperature. See &quot;<a href="https://bioresources.cnr.ncsu.edu/resources/influence-of-temperature-on-the-strength-of-bonded-joints/" rel="nofollow noreferrer">Influence of temperature on the strength of bonded joints</a>&quot; which discloses this graph for PVAc Rhenocoll 3W, 4B Plus:</p> <p><a href="https://i.stack.imgur.com/KB1lM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KB1lM.png" alt="enter image description here" /></a></p>
1,826
<p>I am trying to run this 3D printer:</p> <ul> <li>Fabrikator Mini V2 Turnigy/Malyan M100</li> </ul> <p>Does anyone have the Cura settings?</p>
<p>I googled your machine name and found this HobbyKing page. There is a link here to CURA settings. </p> <p><a href="https://hobbyking.com/en_us/mini-fabrikator-v2-3d-printer-us-plug.html" rel="nofollow noreferrer">Page with CURA settings</a></p>
<p>I thought it better if I included the Cura profile settings, pointed to in <a href="https://3dprinting.stackexchange.com/questions/10157/cura-settings-for-fabrikator-mini-v2-turnigy-or-malyan-m100/10166#10166">cmm's answer</a>, here, in case of link death:</p> <pre><code>[profile] layer_height = 0.2 wall_thickness = 0.8 retraction_enable = True solid_layer_thickness = 1.2 fill_density = 20 nozzle_size = 0.4 print_speed = 60 print_temperature = 200 print_temperature2 = 0 print_temperature3 = 0 print_temperature4 = 0 print_temperature5 = 0 print_bed_temperature = 60 support = Touching buildplate platform_adhesion = Brim support_dual_extrusion = Both wipe_tower = False wipe_tower_volume = 15 ooze_shield = False filament_diameter = 1.75 filament_diameter2 = 0 filament_diameter3 = 0 filament_diameter4 = 0 filament_diameter5 = 0 filament_flow = 100 retraction_speed = 30 retraction_amount = 3 retraction_dual_amount = 16.5 retraction_min_travel = 1.5 retraction_combing = All retraction_minimal_extrusion = 0.02 retraction_hop = 0.0 bottom_thickness = 0.3 layer0_width_factor = 100 object_sink = 0.0 overlap_dual = 0.15 travel_speed = 100 bottom_layer_speed = 20 infill_speed = 0.0 solidarea_speed = 0.0 inset0_speed = 20 insetx_speed = 0 cool_min_layer_time = 3 fan_enabled = True skirt_line_count = 2 skirt_gap = 4.0 skirt_minimal_length = 150.0 fan_full_height = 0.5 fan_speed = 100 fan_speed_max = 100 cool_min_feedrate = 10 cool_head_lift = False solid_top = True solid_bottom = True fill_overlap = 15 perimeter_before_infill = False support_type = Lines support_angle = 60 support_fill_rate = 15 support_xy_distance = 0.7 support_z_distance = 0.15 spiralize = False simple_mode = False brim_line_count = 5 raft_margin = 5.0 raft_line_spacing = 3.0 raft_base_thickness = 0.3 raft_base_linewidth = 1.0 raft_interface_thickness = 0.27 raft_interface_linewidth = 0.4 raft_airgap_all = 0.0 raft_airgap = 0.22 raft_surface_layers = 2 raft_surface_thickness = 0.27 raft_surface_linewidth = 0.4 fix_horrible_union_all_type_a = True fix_horrible_union_all_type_b = False fix_horrible_use_open_bits = False fix_horrible_extensive_stitching = False plugin_config = object_center_x = -1 object_center_y = -1 [alterations] start.gcode = ;Sliced at: {day} {date} {time} ;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density} ;Print time: {print_time} ;Filament used: {filament_amount}m {filament_weight}g ;Filament cost: {filament_cost} ;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line ;M109 S{print_temperature} ;Uncomment to add your own temperature line G21 ;metric values G90 ;absolute positioning M82 ;set extruder to absolute mode M107 ;start with the fan off G28 X0 Y0 ;move X/Y to min endstops G28 Z0 ;move Z to min endstops G1 Z0.2 F{travel_speed} ;move the platform down 15mm G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F{travel_speed} end.gcode = ;End GCode M104 S0 ;extruder heater off M140 S0 ;heated bed heater off (if you have it) G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way M84 ;steppers off G90 ;absolute positioning ;{profile_string} start2.gcode = ;Sliced at: {day} {date} {time} ;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density} ;Print time: {print_time} ;Filament used: {filament_amount}m {filament_weight}g ;Filament cost: {filament_cost} ;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line ;M104 S{print_temperature} ;Uncomment to add your own temperature line ;M109 T1 S{print_temperature2} ;Uncomment to add your own temperature line ;M109 T0 S{print_temperature} ;Uncomment to add your own temperature line G21 ;metric values G90 ;absolute positioning M107 ;start with the fan off G28 X0 Y0 ;move X/Y to min endstops G28 Z0 ;move Z to min endstops G1 Z0.2 F{travel_speed} ;move the platform down 15mm T1 ;Switch to the 2nd extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F200 E-{retraction_dual_amount} T0 ;Switch to the first extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F{travel_speed} end2.gcode = ;End GCode M104 T0 S0 ;extruder heater off M104 T1 S0 ;extruder heater off M140 S0 ;heated bed heater off (if you have it) G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way M84 ;steppers off G90 ;absolute positioning ;{profile_string} start3.gcode = ;Sliced at: {day} {date} {time} ;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density} ;Print time: {print_time} ;Filament used: {filament_amount}m {filament_weight}g ;Filament cost: {filament_cost} ;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line ;M104 S{print_temperature} ;Uncomment to add your own temperature line ;M109 T1 S{print_temperature2} ;Uncomment to add your own temperature line ;M109 T0 S{print_temperature} ;Uncomment to add your own temperature line G21 ;metric values G90 ;absolute positioning M107 ;start with the fan off G28 X0 Y0 ;move X/Y to min endstops G28 Z0 ;move Z to min endstops G1 Z0.2 F{travel_speed} ;move the platform down 15mm T2 ;Switch to the 3rd extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F200 E-{retraction_dual_amount} T1 ;Switch to the 2nd extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F200 E-{retraction_dual_amount} T0 ;Switch to the first extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F{travel_speed} ;Put printing message on LCD screen M117 Printing... end3.gcode = ;End GCode M104 T0 S0 ;extruder heater off M104 T1 S0 ;extruder heater off M104 T2 S0 ;extruder heater off M140 S0 ;heated bed heater off (if you have it) G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way M84 ;steppers off G90 ;absolute positioning ;{profile_string} start4.gcode = ;Sliced at: {day} {date} {time} ;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density} ;Print time: {print_time} ;Filament used: {filament_amount}m {filament_weight}g ;Filament cost: {filament_cost} ;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line ;M104 S{print_temperature} ;Uncomment to add your own temperature line ;M109 T2 S{print_temperature2} ;Uncomment to add your own temperature line ;M109 T1 S{print_temperature2} ;Uncomment to add your own temperature line ;M109 T0 S{print_temperature} ;Uncomment to add your own temperature line G21 ;metric values G90 ;absolute positioning M107 ;start with the fan off G28 X0 Y0 ;move X/Y to min endstops G28 Z0 ;move Z to min endstops G1 Z0.2 F{travel_speed} ;move the platform down 15mm T3 ;Switch to the 4th extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F200 E-{retraction_dual_amount} T2 ;Switch to the 3rd extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F200 E-{retraction_dual_amount} T1 ;Switch to the 2nd extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F200 E-{retraction_dual_amount} T0 ;Switch to the first extruder G92 E0 ;zero the extruded length G1 X75 E10 F{travel_speed} ;extrude 10mm of feed stock G92 E0 ;zero the extruded length again G1 F{travel_speed} ;Put printing message on LCD screen M117 Printing... end4.gcode = ;End GCode M104 T0 S0 ;extruder heater off M104 T1 S0 ;extruder heater off M104 T2 S0 ;extruder heater off M104 T3 S0 ;extruder heater off M140 S0 ;heated bed heater off (if you have it) G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way M84 ;steppers off G90 ;absolute positioning ;{profile_string} support_start.gcode = support_end.gcode = cool_start.gcode = cool_end.gcode = replace.csv = preswitchextruder.gcode = ;Switch between the current extruder and the next extruder, when printing with multiple extruders. ;This code is added before the T(n) postswitchextruder.gcode = ;Switch between the current extruder and the next extruder, when printing with multiple extruders. ;This code is added after the T(n) </code></pre> <p>Note these are some customer uploads, from the HobbyKing page for <a href="https://hobbyking.com/en_us/mini-fabrikator-v2-3d-printer-us-plug.html" rel="nofollow noreferrer">Mini Fabrikator V2 3D Printer - Silver (US Plug)</a>, under the <strong>Upload Files</strong> tab, click the <a href="https://cdn-global-hk.hobbyking.com/media/file/c/u/cura_profile_3.zip" rel="nofollow noreferrer"><code>CURA PROFILE_3.ZIP</code></a> zip file.</p>
1,336
<p>I want to build a lightweight linux configuration to use for development. The first idea is to use it inside a Virtual Machine under Windows, or old Laptops with 1Gb RAM top. Maybe even a distributable environment for developers.</p> <p>So the whole idea is to use a LAMP server, Java Application Server (Tomcat or Jetty) and X Windows (any Window manager, from FVWM to Enlightment), Eclipse, maybe jEdit and of course Firefox.</p> <p>Edit: I am changing this post to compile a possible list of distros and window managers that can be used to configure a real lightweight development environment.</p> <p>I am using as base personal experiences on this matter. Info about the distros can be easily found in their sites. So please, focus on personal use of those systems</p> <hr> <p><h1>Distros</h1></p> <h2>Ubuntu / Xubuntu</h2> <p><strong>Pros</strong>: </p> <ul> <li>Personal Experience in old systems or low RAM environment - @<a href="https://stackoverflow.com/users/2386/schroeder">Schroeder</a>, @<a href="https://stackoverflow.com/users/1666/scdf">SCdF</a></li> <li>Several sugestions based on personal knowledge - @<a href="https://stackoverflow.com/users/658/kyle">Kyle</a>, @<a href="https://stackoverflow.com/users/720/peter-hoffmann">Peter Hoffmann</a></li> </ul> <h2>Gentoo</h2> <p><strong>Pros</strong>: </p> <ul> <li>Not targeted to Desktop Users - @<a href="https://stackoverflow.com/users/2976/paan">paan</a></li> <li>Don't come with a huge ammount of applications - @<a href="https://stackoverflow.com/users/2976/paan">paan</a></li> </ul> <h2>Slackware</h2> <p><strong>Pros</strong>:</p> <ul> <li>Suggested as best performance in a wise install/configuration - @<a href="https://stackoverflow.com/users/1811/ryan-guest">Ryan</a></li> </ul> <h2>Damn Small Linux</h2> <p><strong>Pros</strong>:</p> <ul> <li>Main focus is the lightweight factor - 50MB LiveCD - @<a href="https://stackoverflow.com/users/1811/ryan-guest">Ryan</a></li> </ul> <h2>Debian</h2> <p><strong>Pros</strong>:</p> <ul> <li>Very versatile, can be configured for both heavy and lightweight computers - @<a href="https://stackoverflow.com/users/1811/ryan-guest">Ryan</a></li> <li>APT as package manager - @<a href="https://stackoverflow.com/users/658/kyle">Kyle</a></li> <li>Based on compatibility and usability - @<a href="https://stackoverflow.com/users/658/kyle">Kyle</a></li> </ul> <hr> <p>-- Fell Free to add Prós and Cons on this, so we can compile a good Reference. -- X Windows suggestion keep coming about XFCE. If others are to add here, open a session for it Like the distro one :)</p>
<p>My 2c:</p> <p>I'd recommend basing your system on <a href="http://www.debian.org/" rel="nofollow noreferrer">Debian</a> - the <a href="http://wiki.debian.org/Apt" rel="nofollow noreferrer">apt</a> system has become the de-facto way to quickly install and update programs on Linux. <a href="http://www.ubuntu.com/" rel="nofollow noreferrer">Ubuntu</a> is Debian based with an emphasis on usability and compatibility. As for windowing managers, in my opinion <a href="http://www.xfce.org/" rel="nofollow noreferrer">Xfce</a> hits the right balance between being lightweight and functional. The Ubuntu-based <a href="http://www.xubuntu.org/" rel="nofollow noreferrer">Xubuntu</a> would probably be a good match.</p> <p>Remember - for security only install essential network services like SSH.</p> <p>If it were my decision, I would set up a <a href="http://en.wikipedia.org/wiki/Preboot_Execution_Environment" rel="nofollow noreferrer">PXE boot server</a> to easily install Ubuntu Server Edition to any computer on the network. The reason why I would choose Ubuntu is because it's the one I've had the most experience with and the one I can easily find help for. If I needed a windowing manager for the particular installation, I would also install either Xfce or <a href="http://en.wikipedia.org/wiki/Blackbox" rel="nofollow noreferrer">Blackbox</a>. In fact, I have an old laptop in my basement that I've set up in exactly this way and it's worked out quite well for me.</p>
<p>I suggest you should checkout the following three distros:</p> <ul> <li><p><a href="http://www.damnsmalllinux.org/" rel="nofollow noreferrer">Damn Small Linux</a> - Very lightweight. Includes its own lightweight browser (Dillo), but you can install Firefox easily. The entire distro fits on a 50MB LiveCD.</p></li> <li><p><a href="http://www.slackware.com/" rel="nofollow noreferrer">Slackware</a> - Performance wise Slackware will probably perform the best out of the three, but I'd suggest running your own benchmarks with your hardware.</p></li> <li><p><a href="http://www.debian.org/" rel="nofollow noreferrer">Debian</a>- Debian is extremely versatile. This is the only distro of the three I'd recommend for both a 32 bit 1GB RAM laptop and also a 4GB RAM 64 bit machine.</p></li> </ul>
5,808
<p>I am trying to figure out how to wire up Auto Bed Leveling (ABL) on my Ender 3 using the optocoupler and inductive proximity sensor below. </p> <p>I cannot figure out how to wire it all together, all the tutorials I have found are for 2 and 3 wire per side of the optocoupler.</p> <p><a href="https://i.stack.imgur.com/VL6Ix.jpg" rel="nofollow noreferrer" title="NOYITO Optocoupler Isolation MOS FET 10A DC 2.7-27V High-Power Field Effect Tube Driver Module 0-20Khz PWM Switch Control Board Development Board Module"><img src="https://i.stack.imgur.com/VL6Ix.jpg" alt="NOYITO Optocoupler Isolation MOS FET 10A DC 2.7-27V High-Power Field Effect Tube Driver Module 0-20Khz PWM Switch Control Board Development Board Module" title="NOYITO Optocoupler Isolation MOS FET 10A DC 2.7-27V High-Power Field Effect Tube Driver Module 0-20Khz PWM Switch Control Board Development Board Module"></a></p> <p><a href="https://i.stack.imgur.com/t5FWj.jpg" rel="nofollow noreferrer" title="uxcell 4mm Inductive Proximity Approach Sensor Switch Detector NPN NO DC 6-36V 300mA 3-Wire LJ12A3-4-Z/BX"><img src="https://i.stack.imgur.com/t5FWj.jpg" alt="uxcell 4mm Inductive Proximity Approach Sensor Switch Detector NPN NO DC 6-36V 300mA 3-Wire LJ12A3-4-Z/BX" title="uxcell 4mm Inductive Proximity Approach Sensor Switch Detector NPN NO DC 6-36V 300mA 3-Wire LJ12A3-4-Z/BX"></a></p>
<p>Connecting is pretty straightforward like the other modules, difference is an extra input lead.</p> <p>From e.g. <a href="https://www.desertcart.ae/products/92694483-noyito-optocoupler-isolation-mos-fet-10-a-dc-2-7-27-v-high-power-field-effect-tube-driver-module-0-20-khz-pwm-switch-control-board-development-board-module" rel="nofollow noreferrer">here</a>: Module interface description: </p> <ol> <li>DC+: Positive DC power supply. </li> <li>DC- : Negative DC power supply. </li> <li>PWM: Signal input (connect MCU port, PLC interface, DC power supply, etc.) </li> <li>GND: The negative terminal of the signal </li> <li>OUT+: Positive output terminal (connected to the device positive) </li> <li>OUT-: Negative output terminal (connected to device negative)</li> </ol> <p>So, 1 and 2 connect to your power supply that matches the voltage of the logic of your microprocessor (5&nbsp;V) as this must be linked to 5 and 6 which are connected to the endstop signal and ground respectively.</p> <p>As for the sensor, blue is GND, black is signal (PWM) and brown is power as seen in e.g. <a href="/a/6359">this answer</a>.</p>
<p>This is a bit of an <em>addendum</em> to 0scar's answer, as I didn't want to edit it in to his post.</p> <p>For completion, the sensor's internal schematic is on the side of the sensor itself<sup>1</sup>:</p> <p><a href="https://i.stack.imgur.com/DbsjD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DbsjD.png" alt="Sensor schematic" /></a></p> <p>where:</p> <ul> <li>PNP - 1 BN - Brown - V<sub>SUPPLY</sub></li> <li>N/O - 4 BK - Black - Sensor output</li> <li>4 mm - 3 BU - Blue - GND</li> </ul> <p>However, the complete diagram, taken from <a href="https://www.instructables.com/id/Enable-Auto-Leveling-for-your-3D-Printer-Marlin-Fi/" rel="nofollow noreferrer">Instructables - Enable Auto Leveling for Your 3D Printer With an Inductive Sensor (Marlin Firmware)</a>, can be seen here:</p> <p><a href="https://i.stack.imgur.com/2O66A.jpg" rel="nofollow noreferrer" title="Complete schematic"><img src="https://i.stack.imgur.com/2O66A.jpg" alt="Complete schematic" title="Complete schematic" /></a></p> <hr /> <h3>Footnotes</h3> <p><sup>1</sup> Taken from <a href="https://www.picclickimg.com/d/w1600/pict/273297496840_/4mm-Inductive-Proximity-Approach-Sensor-Switch-PNP-NO.jpg" rel="nofollow noreferrer">this image</a>, which was on this product page, <a href="https://picclick.com/4mm-Inductive-Proximity-Approach-Sensor-Switch-PNP-NO-273297496840.html" rel="nofollow noreferrer">4mm Inductive Proximity Approach Sensor Switch PNP NO DC 6-36V 200mA Cylinder</a>:</p> <p><a href="https://i.stack.imgur.com/nSWyh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nSWyh.jpg" alt="Sensor image#1" /></a></p> <p>There is a bit more to the schematic, which can be glimpsed here (on the left hand side):</p> <p><a href="https://i.stack.imgur.com/2EVa0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2EVa0.jpg" alt="Sensor image#2" /></a></p> <p>A fuller, but blurry, view of the left hand side can be seen <a href="https://images-na.ssl-images-amazon.com/images/I/41kMRIsIl4L.jpg" rel="nofollow noreferrer">here</a>, from this <a href="https://weshop.co.id/amazon/item/uxcell-4mm-inductive-proximity-approach-sensor-switch-pnp-nc-dc-6-36v-200ma-3-wire-lj12a3-4-zay-cylinder-class-B07CWRHG4S.html" rel="nofollow noreferrer">product page</a>:</p> <p><a href="https://i.stack.imgur.com/27t1t.png" rel="nofollow noreferrer" title="Left hand side of sticker on sensor"><img src="https://i.stack.imgur.com/27t1t.png" alt="Left hand side of sticker on sensor" title="Left hand side of sticker on sensor" /></a></p>
1,290
<p>As part of our databuild run a 3rd party program (3D Studio Max) to export a number of assets. Unfortunately if a user is not currently logged in, or the machine is locked, then Max does not run correctly.</p> <p>This can be solved for freshly booted machines by using a method such as TweakUI for automatic login. However when a user connects via Remote Desktop (to initiate a non-scheduled build, change a setting, whatever) then after the session ends the machine is left in a locked state with Max unable to run.</p> <p>I'm looking for a way to configure windows (via fair means or foul) so either it does not lock when the remote session ends, or it "unlocks" itself a short while after. I'm aware of a method under XP where you can run a batchfile on the machine which kicks the remote user off, but this does not appear to work on Windows Server.</p>
<p>There is a separate terminal service connection available called the 'console' connection.</p> <p>You can connect to this space using mstsc /console /v:servername. Use mstsc /? for full command line options.</p> <p>This allows you to connect, open up the terminal services manager and boot the bad sessions.</p>
<p>You might want to look at using the "shadow" utility. This allows you to essentially proxy into an existing remote desktop session. You could log into the console of the machine with the account you need, then users could open non-console remote desktop sessions to the machine (or to another machine) then use shadow to connect to the same console session. The users will have to be in the administrators group on the machine.</p> <p>Although, this might be as simple as telling people not to use the console session when logging into the machine using remote desktop.</p>
3,927
<p>I would like to understand the differences between rafts, skirts and brims. They appear in the software which I'm using to edit my 3D objects.</p> <p>Can anybody elaborate what are these and what are the main differences between them?</p>
<p><strong>Rafts:</strong></p> <p>Rafts are a few layers of plastic a placed on the printing surface before the object is printed. If non water dissoluble filament is used, a bit of an air gap will be placed between the raft and the print itself so it can be removed easily. A raft can help a print stick to the printing surface as it normally has a larger surface area than the bottom of the print. It also allows the bottom layers of the print to contact another layer of plastic so there is less spreading compared to printing on the printing bed itself.</p> <p><a href="https://i.stack.imgur.com/rOghMm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/rOghMm.jpg" alt="A raft in Slic3r (green)"></a></p> <p><strong>Skirts:</strong></p> <p>Skirts are loops of plastic that are extruded around the object that is being printed. On the first layer this allows the filament to get pushed through the extruder so that a steady flow can be established. A multiple layer skirt can be used to create a blockage around the print so there is less air movement on the print and the print can cool slower.</p> <p><a href="https://i.stack.imgur.com/1XEmnm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/1XEmnm.jpg" alt="A skirt in Slic3r (green)"></a></p> <p><strong>Brims:</strong></p> <p>A brim is a layer of plastic that is placed on the first layer of the print go allow for better adhesion to the printing surface. It does not extend under the print as a raft does, but only goes from the edge of the print to a set distance away. </p> <p><a href="https://i.stack.imgur.com/9MnlZm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/9MnlZm.jpg" alt="A brim in Slic3r (green)"></a></p> <p><sup>Credits: Images from Slic3r</sup></p>
<p>All three of these features are used to improve the quality and success rate of prints, especially those failing due to issues on the first few layers, or due to the small size of the first layer.</p> <h1>Raft</h1> <p>A raft is a horizontal feature made as the first few layers of a print, and is used to help with bed adhesion issues, primarily used with ABS. The first few layers printed are the brim (typically prismatic), with the part itself on top of it (with a small separation distance to aid in separation, to allow the part to be removed from the raft). This separation distance needs to be adjusted to allow the first layer of the actual part to adhere, but also for the raft to be removed easily.</p> <h1>Skirt</h1> <p>A skirt is a single-layer feature designed to help extruder priming and to establish a stable filament flow for an optimal first layer. They are generally a few passes around the first layer &quot;footprint&quot; in the rough shape of the first layer, but they do not touch the part itself or help adhesion directly (although having a primed and ready extruder helps extrusion on its own).</p> <h1>Brim</h1> <p>A brim can be considered a skirt touching the first layer shape. It is used to help adhesion, and increases the first layer surface area (thus having more area to adhere to the bed). Brims are best used for parts with small first layers that fail to adhere properly. They are generally done as perimeters (as opposed to the crosshatching of infill) to be easily removable without damaging the part.</p>
94
<p>I'm developing a library alongside several projects that use it, and I've found myself frequently modifying the library at the same time as a project (e.g., adding a function to the library and immediately using it in the project).<br> As a result, the project would no longer compile with previous versions of the library.</p> <p>So if I need to rollback a change or test a previous version of the project, I'd like to know what version of the library was used at check-in.<br> I suppose I could do this manually (by just writing the version number in the log file), but it would be great if this could happen automatically.</p>
<p>I think if I were going to do this, I would use tags. It would be pretty easy to write a script that would tag both repositories with the same ID each time you upgraded the library and used it in the project. Then, if you need to roll back to a previous version, you just see what its most recent tag was, and roll the library back to that version.</p> <p>UPDATE: Sorry, I've been in Mercurial land for a while, and forgot that subversion doesn't directly support tagging. Assuming you use the usual subversion directory structure</p> <pre><code>/ /trunk /tags /branches </code></pre> <p>you just need to run</p> <pre><code>svn copy trunk/ tags/TagName </code></pre> <p>on both repos, with the same tag name. Subversion is pretty good about smart copies, so you don't need to worry about disk space.</p>
<p>One option is to use a single subversion repository and check-in changes that effect both library and project at the same time. That way you know that whatever revision of the project you are on requires the same revision of the library.</p>
4,350
<p>What is the operator precedence order in Visual Basic 6.0 (VB6)?</p> <p>In particular, for the logical operators.</p>
<h3>Arithmetic Operation Precedence Order</h3> <ol> <li><code>^</code></li> <li><code>-</code> (unary negation)</li> <li><code>*</code>, <code>/</code></li> <li><code>\</code></li> <li><code>Mod</code></li> <li><code>+</code>, <code>-</code> (binary addition/subtraction)</li> <li><code>&amp;</code></li> </ol> <h3>Comparison Operation Precedence Order</h3> <ol> <li><code>=</code></li> <li><code>&lt;&gt;</code></li> <li><code>&lt;</code></li> <li><code>&gt;</code></li> <li><code>&lt;=</code></li> <li><code>&gt;=</code></li> <li><code>Like</code>, <code>Is</code></li> </ol> <h3>Logical Operation Precedence Order</h3> <ol> <li><code>Not</code></li> <li><code>And</code></li> <li><code>Or</code></li> <li><code>Xor</code></li> <li><code>Eqv</code></li> <li><code>Imp</code></li> </ol> <p><strong>Source:</strong> <a href="http://www.informit.com/library/content.aspx?b=STY_VB6_24hours&amp;seqNum=247" rel="noreferrer">Sams Teach Yourself Visual Basic 6 in 24 Hours — Appendix A: Operator Precedence</a></p>
<h1><strong>Use parentheses</strong></h1> <hr> <p>EDIT: That's my advice for new code! But Oscar is reading someone else's code, so must figure it out somehow. I suggest the VBA manual topic <a href="https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/operator-precedence" rel="nofollow noreferrer"><em>Operator Precedence</em></a>. VBA is 99% equivalent to VB6 - and expression evaluation is 100% equivalent. I have pasted the logical operator information here. </p> <p>Logical operators are evaluated in the following order of precedence:</p> <pre>Not And Or Xor Eqv Imp </pre> <p>The topic also explains precedence for comparison and arithmetic operators. </p> <p>I would suggest once you have figured out the precendence, you put in parentheses unless there is some good reason not to edit the code.</p>
7,893
<p>My automated script for starting and stopping VMWare Server virtual machines has stopped working. vmware-cmd has started raising the error: </p> <blockquote> <p>The ordinal 3288 could not be located in the dynamic link library LIBEAY32.dll.</p> </blockquote> <p>I am not aware of any specific change or update when this started happening.</p> <p>I have found a bunch of other people reporting this problem (or very similar) but no solution.</p> <p>Do you know what caused this error, and/or how to fix this?</p>
<p>Have discovered that this only occurs when the script is run on a different drive to the one where the EXE is located. As a work around for this I have simply moved the scripts execution.</p> <p>Apparently the DLL relates to SSL, which isn't relevant to what I'm doing, so this is a suitable workaround. I'm guessing that the problem is caused by changes in the EXE for how it determines relative paths (unlikley as nothing (AFAICT) has changed). Or the %PATH% environmental variable has changed (more likely).</p> <p>Hope this helps someone in the future.</p>
<p>Please check your path settings and see if you have included "C:\Program Files\VMware\VMware Workstation" for VMWare management purpose. Once you delete it, you won't see the error no more.</p>
4,976
<p><a href="https://stackoverflow.com/questions/20702/whats-youra-good-limit-for-cyclomatic-complexity">This question</a> on <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity" rel="nofollow noreferrer">Cyclomatic Complexity</a> made me think more about <a href="http://en.wikipedia.org/wiki/Static_code_analysis" rel="nofollow noreferrer">static code analysis</a>. Analyzing code complexity and consistency is occasionally useful, and I'd like to start doing it more. What tools do you recommend (per language) for such analysis? <a href="http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis" rel="nofollow noreferrer">Wikipedia</a> has a large list of tools, but which ones have people tried before?</p> <p><strong>Edit:</strong> As David points out, this is not a completely unasked question when it comes to <a href="https://stackoverflow.com/questions/2873/choosing-a-static-code-analysis-tool">C/UNIX based tools</a>.</p>
<p>I have been setting up a Hudson continuous integration (CI) build system for my Objective-C iPhone projects (iOS apps), and have compiled a varied list of tools that can be used to analyze my projects during a build:</p> <ul> <li><p><strong>Clang static analyzer</strong>: free, up-to-date stand-alone tool that catches more issues than the version of Clang included with Xcode 4. Active project. -- visit <a href="http://clang-analyzer.llvm.org" rel="nofollow noreferrer">http://clang-analyzer.llvm.org</a></p></li> <li><p><strong>Doxygen</strong>: free documentation generation tool that also generates class dependency diagrams. Active project -- visit <a href="http://www.doxygen.nl" rel="nofollow noreferrer">http://www.doxygen.nl</a></p></li> <li><p><strong>HFCCA</strong> (header-free cyclomatic complexity analyzer): free Python script to calculate code complexity, but without header files and pre-processors. Supports output in XML format for Hudson/Jenkins builds. Active project. -- visit <a href="http://code.google.com/p/headerfile-free-cyclomatic-complexity-analyzer" rel="nofollow noreferrer">http://code.google.com/p/headerfile-free-cyclomatic-complexity-analyzer</a></p></li> <li><p><strong>CLOC</strong> (count lines of code): free tool to count files, lines of code, comments, and blank lines. Supports diffing, so you can see the differences between builds. Active project. -- visit <a href="http://cloc.sourceforge.net" rel="nofollow noreferrer">http://cloc.sourceforge.net</a></p></li> <li><p><strong>SLOCcount</strong> (source lines of code count): a free tool to count lines of code and estimate the costs and time associated with a project. Does not appear to be active. -- visit <a href="http://sourceforge.net/projects/sloccount" rel="nofollow noreferrer">http://sourceforge.net/projects/sloccount</a> and <a href="http://www.dwheeler.com/sloccount" rel="nofollow noreferrer">http://www.dwheeler.com/sloccount</a></p></li> <li><p><strong>AnalysisTool</strong>: free code analysis tool that measures code complexity and also generates dependency diagrams. Not active. Does not seem to work with Xcode 4, but I would love to get it working. -- visit <a href="http://www.karppinen.fi/analysistool" rel="nofollow noreferrer">http://www.karppinen.fi/analysistool</a></p></li> </ul>
<p>The only time I've ever used one of those tools is Split (C programming language). I thought it was helpful, but I was by no means a power user and I think I barely scratched the surface of what it could do.</p>
4,113
<p>Say a user is browsing a website, and then performs some action which changes the database (let's say they add a comment). When the request to actually add the comment comes in, however, we find we need to force them to login before they can continue.</p> <p>Assume the login page asks for a username and password, and redirects the user back to the URL they were going to when the login was required. That redirect works find for a URL with only GET parameters, but if the request originally contained some HTTP POST data, that is now lost.</p> <p>Can anyone recommend a way to handle this scenario when HTTP POST data is involved?</p> <p>Obviously, if necessary, the login page could dynamically generate a form with all the POST parameters to pass them along (though that seems messy), but even then, I don't know of any way for the login page to redirect the user on to their intended page while keeping the POST data in the request.</p> <hr> <p><strong>Edit</strong> : One extra constraint I should have made clear - Imagine we don't know if a login will be required until the user submits their comment. For example, their cookie might have expired between when they loaded the form and actually submitted the comment.</p>
<p>This is one good place where Ajax techniques might be helpful. When the user clicks the submit button, show the login dialog on client side and validate with the server before you actually submit the page.</p> <p>Another way I can think of is showing or hiding the login controls in a DIV tag dynamically in the main page itself.</p>
<p>Collect the data on the page they submitted it, and store it in your backend (database?) while they go off through the login sequence, hide a transaction id or similar on the page with the login form. When they're done, return them to the page they asked for by looking it up using the transaction id on the backend, and dump all the data they posted into the form for previewing again, or just run whatever code that page would run.</p> <p>Note that many systems, eg blogs, get around this by having login fields in the same form as the one for posting comments, if the user needs to be logged in to comment and isn't yet.</p>
7,669