instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
---|---|---|---|
<p>I noticed that one edge (which is also the starting point of the print) is always bigger than the other three. Additionally, the walls do not have the same thickness as well. The wall thickness (starting from the thick edge) starts very thin and gets thicker till reaching the thick edge again. Does anyone have a clue whats the issue?</p>
<p><a href="https://i.stack.imgur.com/oeept.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oeept.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/CEvrT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CEvrT.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/eZmxi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eZmxi.jpg" alt="enter image description here"></a></p>
| <p>As Fernando suggests, the problem is likely with your source file. One easy way to verify this is to slice twice, rotating the STL by 90 degrees. If both prints produce fat/thin sides in the same dimension on the print bed, then it's a printer problem. If the fat side rotated with the STL orientation, then the STL is at fault. </p>
| <p>As Fernando suggests, the problem is likely with your source file. One easy way to verify this is to slice twice, rotating the STL by 90 degrees. If both prints produce fat/thin sides in the same dimension on the print bed, then it's a printer problem. If the fat side rotated with the STL orientation, then the STL is at fault. </p>
| 906 |
<p>How should I describe this part which looks like a small gear so that I can research replacements?</p>
<p><a href="https://i.stack.imgur.com/51BdD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/51BdD.jpg" alt="image of a pulley"></a></p>
<p>This came with my FLSUN 3D printer, which may be based on a Prusa design.</p>
| <p>This is a timing belt pulley.</p>
<p>Specifically, is a GT2 timing pulley, 2 mm pitch (between teeth), 6 mm wide. The drive diameter is measured by the number of teeth (16 in this case) , the shaft diameter (bore) is measured in mm.</p>
<p>The 'GT2' part refers to the tooth profile, some other examples are shown half way down <a href="https://www.pfeiferindustries.com/timing-belt-identification-and-replacement" rel="nofollow noreferrer">this page</a>.</p>
| <p>It is an "aluminum timing pulley"</p>
<p><a href="https://www.google.com/search?psb=1&tbm=shop&q=aluminum%20timing%20pulley&ved=0CAMQr4sDKAFqFwoTCMis1KHmiuMCFRoMswAdMqUElxAB" rel="nofollow noreferrer">https://www.google.com/search?psb=1&tbm=shop&q=aluminum%20timing%20pulley&ved=0CAMQr4sDKAFqFwoTCMis1KHmiuMCFRoMswAdMqUElxAB</a></p>
<p><a href="https://www.ebay.com/i/152446519860?chn=ps&var=453435947176" rel="nofollow noreferrer">https://www.ebay.com/i/152446519860?chn=ps&var=453435947176</a></p>
| 1,382 |
<p>Has anyone had any luck of using Oracle from .Net on a 64 bit machine, and using the UDT capabilities of Oracle?</p>
<p>I've been able to use an x64 ODP.Net client, but cannot find one with any support for UDTs.</p>
<p>Thanks</p>
<p>Nick</p>
<p>[Edit]
I've posted an answer below. The latest (as of December 2008) release is 11.1.0.7. This has support for 64 bit and UDT.</p>
| <p>You need to use 11.1.0.7 release. This has UDT support and works with 32 and 64 bit.</p>
| <p>I've been trying for some time to get the 64-bit edition of Windows Server 2003 to connect to an Oracle 8i instance. It doesn't seem to be possible other than doing it through a 32-bit VM.</p>
<p>Forced upgrading can really suck!</p>
| 8,138 |
<p>I recently bought some SUNLU PLA black filament and was attempting a small print with it and it started to come out in strings and lumps and was incredibly inconsistent. Before this I'd been using some Eryone PLA and those prints were superb, been printing back to back successfully but after using the SUNLU all of my prints since have been having layer separation issues. I've cleaned the extruder, taken off the fan and cleared out the hotend of some wisps of filament, then flushed it through with some more reliable filament which looked better and replaced my magnetic bed sticker with a new one as the adhesion on the initial layer was poor even though the bed looked level. Once I replaced the sticker, the adhesion on the first layer is excellent. I thought I'd fixed the problems so tried an XYZ cube and still getting serious layering issues and the infill is thin. Any ideas what else I could do to fix this problem? I've put slicer settings below:</p>
<ul>
<li>Hot end temp: 210 °C</li>
<li>Bed temp: 60 °C</li>
<li>Fan speed: 100 %</li>
<li>Print speed: 50 mm/s</li>
</ul>
<p>No custom modifications to the standard Cura profile for the Ender 3.</p>
<p>My filament diameter setting in Cura is 1.75 mm and so is my filament.</p>
<p><a href="https://i.stack.imgur.com/ja49h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ja49h.jpg" alt="xyz cube" /></a></p>
<p><a href="https://i.stack.imgur.com/so9S3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/so9S3.jpg" alt="inside xyz cube" /></a></p>
| <p>This is under extrusion, not delamination. Delamination is the result of the under extrusion.</p>
<p>It typically happens when the wrong filament diameter has been set in the slicer (a larger diameter than used, e.g 2.85 mm instead of 1.75 mm). Another option is that you accidentally put the printer in volumetric printing mode which is accessible through the display of the printer:</p>
<p><code>Control -> Filament -> E in mm³ -> Disable</code></p>
<p>Other solutions may be found in the extrusion process, e.g. the extruder may be skipping.</p>
| <p>This is under extrusion, not delamination. Delamination is the result of the under extrusion.</p>
<p>It typically happens when the wrong filament diameter has been set in the slicer (a larger diameter than used, e.g 2.85 mm instead of 1.75 mm). Another option is that you accidentally put the printer in volumetric printing mode which is accessible through the display of the printer:</p>
<p><code>Control -> Filament -> E in mm³ -> Disable</code></p>
<p>Other solutions may be found in the extrusion process, e.g. the extruder may be skipping.</p>
| 1,699 |
<p>So my site uses <a href="http://mjijackson.com/shadowbox/" rel="nofollow noreferrer">shadowbox</a> to do display some dynamic text. Problem is I need the user to be able to copy and paste that text. </p>
<p>Right-clicking and selecting copy works but <kbd>Ctrl</kbd>+<kbd>C</kbd> doesn't (no keyboard shortcuts do) and most people use <kbd>Ctrl</kbd>+<kbd>C</kbd>? You can see an example of what I'm talking about <a href="http://mjijackson.com/shadowbox/" rel="nofollow noreferrer">here</a>. </p>
<p>Just go to the "web" examples and click "inline". Notice keyboard shortcuts do work on the "this page" example. The only difference between the two I see is the player js files they use. "Inline" uses the html.js player and "this page" uses iframe.js. Also, I believe it uses the mootools library. Any ideas?</p>
| <p>The best option is to disable keyboard navigation shortcuts in the shadowbox by setting the "enableKeys" option to false (see <a href="http://mjijackson.com/shadowbox/doc/api.html" rel="nofollow noreferrer">this page</a>).</p>
<p>Alternatively you could do what Robby suggests and modify the shadowbox.js file, <strong>but only do this if you need to have the shadowbox keyboard navigation</strong>. I think that you want to search for this block of code and modify it so that it only cancels the default event if one of the shortcuts is used (I've added some line breaks and indention):</p>
<pre><code>var handleKey=function(e){
var code=SL.keyCode(e);
SL.preventDefault(e);
if(code==81||code==88||code==27){
SB.close()
}else{
if(code==37){
SB.previous()
}else{
if(code==39){
SB.next()
}else{
if(code==32){
SB[(typeof slide_timer=="number"?"pause":"play")]()
}
}
}
}
};
</code></pre>
<p>I think you could change it to look more like this:</p>
<pre><code>var handleKey=function(e){
switch(SL.keyCode(e)) {
case 81:
case 88:
case 27:
SB.close()
SL.preventDefault(e);
break;
case 37:
SB.previous()
SL.preventDefault(e);
break;
case 39:
SB.next()
SL.preventDefault(e);
break;
case 32:
SB[(typeof slide_timer=="number"?"pause":"play")]()
SL.preventDefault(e);
break;
}
};
</code></pre>
<p>This should prevent the shadowbox event handler from swallowing any keystrokes that it doesn't care about.</p>
| <p>The solution is to set the enableKeys option to false. However, this doesn't seem to work on an open() call for inline HTML. It does work, however, if you set it in your init() call.</p>
| 7,276 |
<p>How do I use the profiler in Visual Studio 2008?</p>
<p>I know theres a build option in Config Properties -> Linker -> Advanced -> Profile (/PROFILE), however I can't find anything about actauly using it, only articles I was able to find appear to only apply to older versions of Visual Studio (eg most say to goto Build->Profile to bring up the profile dialog box, yet in 2008 there is no such menu item).</p>
<p>Is this because Visual Studio 2008 does not include a profiler, and if it does where is it and where is the documentation for it?</p>
| <p>Microsoft has released stand-alone Profiler for VS 2008 <a href="http://www.microsoft.com/downloads/details.aspx?familyid=fd02c7d6-5306-41f2-a1be-b7dcb74c9c0b&displaylang=en" rel="noreferrer">here</a></p>
| <p>As I understood from reading a few sites, when you use VS 2008 stand alone profiler to create <code>.vsp</code> files, you will need either VS2008 Premium or Ultimate to view <code>.vsp</code> files.</p>
<p>By the way, I installed VS2012 Release candidate which is available for free (trial version?) and I can use its profiling engine.</p>
| 8,689 |
<p>Does Delphi call inherited on overridden procedures if there is no explicit call in the code ie (inherited;), I have the following structure (from super to sub class)</p>
<p>TForm >> TBaseForm >> TAnyOtherForm</p>
<p>All the forms in the project will be derived from TBaseForm, as this will have all the standard set-up and destructive parts that are used for every form (security, validation ect). </p>
<p>TBaseForm has onCreate and onDestroy procedures with the code to do this, but if someone (ie me) forgot to add inherited to the onCreate on TAnyOtherForm would Delphi call it for me? I have found references on the web that say it is not required, but nowhere says if it gets called if it is omitted from the code.</p>
<p>Also if it does call inherited for me, when will it call it?</p>
| <p>No, if you leave the call to inherited away, it will not be called. Otherwise it would not be possible to override a method and totally ommit the parent version of it.</p>
| <p>No. That's the whole point of overriding.</p>
| 7,725 |
<p>I have a .Net compact framework application with a frankly unimpressive UI.</p>
<p>My win32 app uses Dev Express components and looks great, but I can't find anything similar for the compact framework.</p>
<p>Can anyone recommend components that will jazz up my UI?</p>
<p>Does such a thing exist, oram I going to have to owner draw my components or even worse use native code?</p>
| <p><a href="http://www.opennetcf.com/" rel="nofollow noreferrer">OpenNETCF</a> is a large collection of classes, components and controls for the compact framework. I'm not sure that they have anything that'll jazz up your UI, but it'd be worth a look.</p>
| <p>I really like Resco's mobile controls. They are solid and the support is good.</p>
<p>I purchased a few controls from Pocket PC Controls. They are not bad, but if you run into bugs its hit or miss if you hear back from the developer. Basically, it doesn't seem like the components are constantly being updated.</p>
<p>Resco on the otherhand has frequent updates, new features and new components. </p>
| 5,650 |
<p>I was just working on fixing up exception handling in a .NET 2.0 app, and I stumbled onto some weird issue with <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx" rel="nofollow noreferrer">Application.ThreadException</a>.</p>
<p>What I want is to be able to catch all exceptions from events behind GUI elements (e.g. button_Click, etc.). I then want to filter these exceptions on 'fatality', e.g. with some types of Exceptions the application should keep running and with others it should exit.</p>
<p>In another .NET 2.0 app I learned that, by default, only in debug mode the exceptions actually leave an Application.Run or Application.DoEvents call. In release mode this does not happen, and the exceptions have to be 'caught' using the Application.ThreadException event.</p>
<p>Now, however, I noticed that <strong>the exception object passed in the ThreadExceptionEventArgs of the Application.ThreadException event is always the innermost exception in the exception chain</strong>. For logging/debugging/design purposes I really want the entire chain of exceptions though. It isn't easy to determine what external system failed for example when you just get to handle a SocketException: when it's wrapped as e.g. a NpgsqlException, then at least you know it's a database problem.</p>
<p><strong>So, how to get to the entire chain of exceptions from this event?</strong> Is it even possible or do I need to design my excepion handling in another way?</p>
<p>Note that I do -sort of- have a <a href="https://stackoverflow.com/questions/61366/rolling-your-own-message-loop-any-pitfalls">workaround</a> using <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.setunhandledexceptionmode.aspx" rel="nofollow noreferrer">Application.SetUnhandledExceptionMode</a>, but this is far from ideal because I'd have to roll my own message loop.</p>
<p>EDIT: to prevent more mistakes, <strong>the GetBaseException() method does NOT do what I want</strong>: it just returns the innermost exception, while the only thing I already have is the innermost exception. I want to get at the outermost exception!</p>
| <p>This question is more usefully phrased and answered here: </p>
<p><a href="https://stackoverflow.com/questions/347502/why-does-the-inner-exception-reach-the-threadexception-handler-and-not-the-actual">Why does the inner exception reach the ThreadException handler and not the actual thrown exception?</a></p>
| <p>According to the MSDN documentation:</p>
<p><em>When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.</em> </p>
<pre><code> Public Overridable Function GetBaseException() As Exception
Dim innerException As Exception = Me.InnerException
Dim exception2 As Exception = Me
Do While (Not innerException Is Nothing)
exception2 = innerException
innerException = innerException.InnerException
Loop
Return exception2
End Function
</code></pre>
<p>You could use a variation on this to parse the exception chain. </p>
<pre><code>Public Sub LogExceptionChain(ByVal CurrentException As Exception)
Dim innerException As Exception = CurrentException.InnerException
Dim exception2 As Exception = CurrentException
Debug.Print(exception2.Message) 'Log the Exception
Do While (Not innerException Is Nothing)
exception2 = innerException
Debug.Print(exception2.Message) 'Log the Exception
'Move to the next exception
innerException = innerException.InnerException
Loop
End Sub
</code></pre>
<p>This would strike me as exactly what you are looking for.</p>
| 8,653 |
<p>I've been having a hard time lately getting the raft off of my ABS prints.</p>
<p>Is that a symptom of either a nozzle or bed that are too hot? Or is there some other factor I should be looking in to?</p>
<p>I have an UP mini that I've modified both the nozzle and bed to customize the temperatures on.</p>
<p>Bed gets heated to 100˚C and nozzle is either 266˚C for UP ABS filament or 236˚C for off-brand ABS filament.</p>
| <p>A couple things to consider:</p>
<ul>
<li>Ensure that your build plate is flat and level. An un-parallel HBP could result in the object "welding" to the raft.</li>
<li>Turn down your nozzle temperature. It is likely that the material is hotter than it needs as it is extruding. This results in a slower "cool-down rate". So, if it takes longer for the filament to cool between the raft and the first layers of the object. Therefore, cooling together in a manner that somewhat binds them.</li>
<li>Personally, 266C seems VERY high to me. I've primarily only used ABS on my MakerBot and have successfully printed with 225C +-5C nozzle temperature and 110C +-2C HBP temperature.</li>
<li>Typically you want to extrude slightly above the melting point. You don't want to liquefy the material, but make it pliable enough to bond it to other layers of material (or a BP).</li>
</ul>
| <p>I haven't got a printer with a heated bed so have only tested this on PLA but I have found editing the G code so the printer cools the nozzle down and then heats it up again gives the raft enough time to cool down so that it peels off easier when the print is finished. </p>
| 300 |
<p>What's the best way to close the loop and have a desktop app "call home" with customer feedback? Right now our code will login to our SMTP server and send me some email.</p>
| <p>The site GetSatisfaction has been an increasingly popular way to get customer feedback.</p>
<p><a href="http://getsatisfaction.com/" rel="nofollow noreferrer">http://getsatisfaction.com/</a></p>
<p>GetSatisfaction is a community based site that builds a community around your application. Users can post questions, comments, and feedback about and application and get answers to their questions either from other members or from members of the development team themselves.</p>
<p>They also have an API so you can incorporate GetSatifaction into your app, and/or your site.</p>
<p>I've been playing with it for a couple of weeks and it is pretty cool. Kind of like stackoverflow, but for customer feedback.</p>
| <p>Personally, I would also POST the information. However, I would send it to a PHP script that would then insert it into a mySQL database. This way, your data can be pre-sorted and pre-categorized for analysis later. It also gives you the potential to track multiple entries by single users.</p>
| 5,034 |
<p>I'm new to the 3D printing world and got my first Ender 3 (with the 32-bit controller board).</p>
<p>I have a problem with every single print. I've upgraded to the newest Marlin firmware, did the mesh leveling then started printing and fix the Z bed option in "Tune - Z bed" during the print (so the first layer is perfect). Please note that I save all the data of the mesh before end of the print. Then, when I start the same print again, the nozzle height is wrong. This happens every single print. The strange thing is that I need to adjust the height differently after every print. Like, the first print was -0.055 mm, second print was 0.30 mm, then it was +0.25 mm somehow.</p>
<p>I really like to print without these constant adjustments.</p>
| <p>It sounds like your bed is unstable. This is what I had to do with my Tronxy X1, and I fixed it by installing a decent bed stabiliser. Now that I have a stable bed, I only have to re-level it occasionally. However, the Tronxy X1 is a cantilever printer with a single rail for the bed, not an Ender 3.</p>
<p>I would suggest that you tighten the bed-levelling springs as far as they will go whilst still leaving sufficient movement for bed levelling, and re-position the end-stop switch. Then re-level the bed. If that doesn't work, try fitting stiffer springs. Upgrades are available for the Ender 3. If that still doesn't work, look for bed stabilisation solutions for your printer.</p>
<p>Note also that the bed-levelling knobs have a reputation for coming loose on the Ender 3. Tightening the springs (or fitting stiffer springs) may cure this, but some users fit locking nuts to stop the knobs moving.</p>
| <p>Thanks everybody for their help, but apparently it was a slicer/software/gcode (i don't really know :D) issue...</p>
<p>So i just added this line M420 S1 after the G28 command to my Cura printer settings and now the nozzle height is always at the point i set before, no changing every print.</p>
<p>Hope my solve will help somebody who is struggling with this too!</p>
| 1,902 |
<p>How do I create a self signed SSL certificate for an Apache Server to use while testing a web app?</p>
| <blockquote>
<p><strong>How do I create a self-signed SSL
Certificate for testing purposes?</strong></p>
</blockquote>
<p>from <a href="http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#selfcert" rel="noreferrer" title="How do I create a self-signed SSL Certificate for testing purposes?">http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#selfcert</a>:</p>
<ol>
<li><p>Make sure OpenSSL is installed and in your PATH.</p></li>
<li><p>Run the following command, to create server.key and server.crt
files:</p>
<pre><code>openssl req -new -x509 -nodes -out server.crt -keyout server.key
</code></pre>
<p>These can be used as follows in your httpd.conf file:</p>
<pre><code>SSLCertificateFile /path/to/this/server.crt
SSLCertificateKeyFile /path/to/this/server.key
</code></pre></li>
<li><p>It is important that you are aware that this server.key does not have any passphrase. To add a passphrase to the key, you should run the following command, and enter & verify the passphrase as requested.</p>
<pre><code>openssl rsa -des3 -in server.key -out server.key.new
mv server.key.new server.key
</code></pre>
<p>Please backup the server.key file, and the passphrase you entered,
in a secure location.</p></li>
</ol>
| <p>Use OpenSSL (<a href="http://www.openssl.org/" rel="nofollow noreferrer">http://www.openssl.org/</a>)</p>
<p>Here's a tutorial: <a href="http://novosial.org/openssl/self-signed/" rel="nofollow noreferrer">http://novosial.org/openssl/self-signed/</a></p>
<p>Here is the good tutorial to start with: <a href="http://www.akadia.com/services/ssh_test_certificate.html" rel="nofollow noreferrer">SSH localhost</a>.</p>
| 3,865 |
<p>One of the fun parts of multi-cultural programming is number formats.</p>
<ul>
<li>Americans use 10,000.50</li>
<li>Germans use 10.000,50</li>
<li>French use 10 000,50</li>
</ul>
<p>My first approach would be to take the string, parse it backwards until I encounter a separator and use this as my decimal separator. There is an obvious flaw with that: 10.000 would be interpreted as 10.</p>
<p>Another approach: if the string contains 2 different non-numeric characters, use the last one as the decimal separator and discard the others. If I only have one, check if it occurs more than once and discards it if it does. If it only appears once, check if it has 3 digits after it. If yes, discard it, otherwise, use it as decimal separator.</p>
<p>The obvious "best solution" would be to detect the User's culture or Browser, but that does not work if you have a Frenchman using an en-US Windows/Browser.</p>
<p>Does the .net Framework contain some mythical black magic floating point parser that is better than <code>Double.(Try)Parse()</code> in trying to auto-detect the number format?</p>
| <p>I think the best you can do in this case is to take their input and then show them what you think they meant. If they disagree, show them the format you're expecting and get them to enter it again.</p>
| <p>The difference between 12.345 in French and English is a factor of 1000. If you supply an expected range where max < 1000*min, you can easily guess. </p>
<p>Take for example the height of a person (including babies and children) in mm.</p>
<p>By using a range of 200-3000, an input of 1.800 or 1,800 can unambiguously be interpreted as 1 meter and 80 centimeters, whereas an input of 912.300 or 912,300 can unambiguously be interpreted as 91 centimeters and 2.3 millimeters.</p>
| 2,269 |
<p>My organization has a form to allow users to update their email address with us.
It's suggested that we have two input boxes for email: the second as an email confirmation.</p>
<p>I always copy/paste my email address when faced with the confirmation.
I'm assuming most of our users are not so savvy.</p>
<p>Regardless, is this considered a good practice?
I can't stand it personally, but I also realize it probably isn't meant for me.
If someone screws up their email, they can't login, and they must call to sort things out.</p>
| <p>I would just use one input box. The "Confirm" input is a remnant form the "Confirm Password" method. </p>
<p>With passwords, this is useful because they are usually typed as little circles. So, you can't just look at it to make sure that you typed it correctly. </p>
<p>With a regular text box, you can visually check your input. So, there is no need for a confirmation input box.</p>
| <p>I'd say that this is ok but should only be reserved for forms where the email is essential. If you mistype your email for your flight booking then you have severed the two-way link between yourself and the other party and risk not getting the confirmation number, here on StackOverflow it would only mean your Gravatar would not be loaded ...</p>
<p>I'd consider myself fairly techie but I always fill in both fields /wo cut-paste if I regard it to be important enough.</p>
| 2,686 |
<p>Why can't you do this and is there are work around?</p>
<p>You get this error.</p>
<p>Msg 2714, Level 16, State 1, Line 13
There is already an object named '#temptable' in the database.</p>
<pre><code>declare @x int
set @x = 1
if (@x = 0)
begin
select 1 as Value into #temptable
end
else
begin
select 2 as Value into #temptable
end
select * from #temptable
drop table #temptable
</code></pre>
| <p>This is a two-part question and while Kev Fairchild provides a good answer to the second question he totally ignores the first - <em>why is the error produced?</em></p>
<p>The answer lies in the way the preprocessor works. This</p>
<pre><code>SELECT field-list INTO #symbol ...
</code></pre>
<p>is resolved into a parse-tree that is directly equivalent to </p>
<pre><code>DECLARE #symbol_sessionid TABLE(field-list)
INSERT INTO #symbol_sessionid SELECT field-list ...
</code></pre>
<p>and this puts #symbol into the local scope's name table. The business with _sessionid is to provide each user session with a private namespace; if you specify two hashes (##symbol) this behaviour is suppressed. Munging and unmunging of the sessionid extension is (ovbiously) transparent.</p>
<p>The upshot of all this is that multiple INTO #symbol clauses produce multiple declarations in the same scope, leading to Msg 2714.</p>
| <p>I am going to guess that the issue is that you haven't created the #temptable.</p>
<p>Sorry I can't be more detailed but since you haven't even tried to explain what you are seeing you get a less than stellar answer.</p>
| 6,863 |
<p>I've just started using Linq to SQL, and I'm wondering if anyone has any best practices they can share for managing dbml files.</p>
<ul>
<li>How do you keep them up to date with the database?</li>
<li>Do you have a single dbml file for the entire database, or is it split into multiple logical units? </li>
<li>How does managing this file work in a team environment?</li>
</ul>
<p>Any other tips and tricks welcome.</p>
| <p>Have you looked at <a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx" rel="nofollow noreferrer">SqlMetal</a>? It's officially supported, although not promoted too much. You can use it to build dbmls from the commandline - we've used it as part of a db's continous integration updates (make sure you have really good code separation if you do this though - partial classes are a saviour - as the dbml will get overwritten).</p>
<p>If I recall correctly it doesn't have quite the same features as the model designer in Visual Studio (I think it handles pluralisation differently). There a <a href="http://blog.benhall.me.uk/2007/08/power-of-sqlmetal.html" rel="nofollow noreferrer">good post about it on Ben Hall's blog</a>.</p>
| <p>Here is a link that provides good information about LINQ to SQL best practices</p>
<p><a href="http://www.a2zmenu.com/LINQ/LINQ%20to%20SQL%20Best%20Practice.aspx" rel="nofollow">http://www.a2zmenu.com/LINQ/LINQ%20to%20SQL%20Best%20Practice.aspx</a></p>
| 5,373 |
<p>Since both a <code>Table Scan</code> and a <code>Clustered Index Scan</code> essentially scan all records in the table, why is a Clustered Index Scan supposedly better?</p>
<p>As an example - what's the performance difference between the following when there are many records?:</p>
<pre><code>declare @temp table(
SomeColumn varchar(50)
)
insert into @temp
select 'SomeVal'
select * from @temp
-----------------------------
declare @temp table(
RowID int not null identity(1,1) primary key,
SomeColumn varchar(50)
)
insert into @temp
select 'SomeVal'
select * from @temp
</code></pre>
| <p>In a table without a clustered index (a heap table), data pages are not linked together - so traversing pages requires a <a href="http://msdn.microsoft.com/en-us/library/ms188270.aspx" rel="noreferrer">lookup into the Index Allocation Map</a>.</p>
<p>A clustered table, however, has it's <a href="http://msdn.microsoft.com/en-us/library/ms177443.aspx" rel="noreferrer">data pages linked in a doubly linked list</a> - making sequential scans a bit faster. Of course, in exchange, you have the overhead of dealing with keeping the data pages in order on <code>INSERT</code>, <code>UPDATE</code>, and <code>DELETE</code>. A heap table, however, requires a second write to the IAM.</p>
<p>If your query has a <code>RANGE</code> operator (e.g.: <code>SELECT * FROM TABLE WHERE Id BETWEEN 1 AND 100</code>), then a clustered table (being in a guaranteed order) would be more efficient - as it could use the index pages to find the relevant data page(s). A heap would have to scan all rows, since it cannot rely on ordering.</p>
<p>And, of course, a clustered index lets you do a CLUSTERED INDEX SEEK, which is pretty much optimal for performance...a heap with no indexes would always result in a table scan.</p>
<p>So:</p>
<ul>
<li><p>For your example query where you select all rows, the only difference is the doubly linked list a clustered index maintains. This should make your clustered table just a tiny bit faster than a heap with a large number of rows.</p></li>
<li><p>For a query with a <code>WHERE</code> clause that can be (at least partially) satisfied by the clustered index, you'll come out ahead because of the ordering - so you won't have to scan the entire table.</p></li>
<li><p>For a query that is not satisified by the clustered index, you're pretty much even...again, the only difference being that doubly linked list for sequential scanning. In either case, you're suboptimal.</p></li>
<li><p>For <code>INSERT</code>, <code>UPDATE</code>, and <code>DELETE</code> a heap may or may not win. The heap doesn't have to maintain order, but does require a second write to the IAM. I think the relative performance difference would be negligible, but also pretty data dependent.</p></li>
</ul>
<p>Microsoft has a <a href="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/clusivsh.mspx" rel="noreferrer">whitepaper</a> which compares a clustered index to an equivalent non-clustered index on a heap (not exactly the same as I discussed above, but close). Their conclusion is basically to put a clustered index on all tables. I'll do my best to summarize their results (again, note that they're really comparing a non-clustered index to a clustered index here - but I think it's relatively comparable):</p>
<ul>
<li><code>INSERT</code> performance: clustered index wins by about 3% due to the second write needed for a heap.</li>
<li><code>UPDATE</code> performance: clustered index wins by about 8% due to the second lookup needed for a heap.</li>
<li><code>DELETE</code> performance: clustered index wins by about 18% due to the second lookup needed and the second delete needed from the IAM for a heap.</li>
<li>single <code>SELECT</code> performance: clustered index wins by about 16% due to the second lookup needed for a heap.</li>
<li>range <code>SELECT</code> performance: clustered index wins by about 29% due to the random ordering for a heap.</li>
<li>concurrent <code>INSERT</code>: heap table wins by 30% under load due to page splits for the clustered index.</li>
</ul>
| <p>A table scan has to examine every single row of the table. The clustered index scan only needs to scan the index. It doesn't scan every record in the table. That's the point, really, of indices.</p>
| 3,930 |
<p>I've been having some bed adhesion problems that I have been trying to solve by leveling the bed. I think that it's pretty level now but when I start a print the lines seem pretty flat. Is this true? I used a feeler gauge to have a 0.2 mm gap between the bed and nozzle, but the center feels as though there's more space, despite the tape (ie I didn't feel any resistance when leveling the center) so I'm not sure if the plastic is too squished or not.</p>
<p><a href="https://i.stack.imgur.com/GKkPC.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/GKkPC.jpg" alt="Top View"></a>
<a href="https://i.stack.imgur.com/3SbVq.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/3SbVq.jpg" alt="Side View"></a></p>
<p>I am printing PLA with 210 °C at Nozzle and 60 °C on bed. I also used a 130% extrusion factor for the first layer on a Creality CR-10S. It did come without a black print surface but with a glass sheet and a roll of painters tape instead, so I opted for Blue-tape.</p>
<p>Also, I see some stringing, which seems to happen with skirts and brims (this is my first brim) and a bit of under extrusion in the center. But those are probably concerns fit for a separate question.</p>
| <p><strong>No</strong>, the <strong>bed does not look too close to the nozzle</strong>, it could well be that it is <strong>too far</strong> from the nozzle. However, the brim looks okay, but the method you follow is questionable. </p>
<p>Using a feeler gauge of 0.2 mm is larger than the recommended paper method which is in the order of half that value (0.1 mm). You compensate this larger leveling gap with an over-extrusion of 130 %. The preferred method is using a thinner feeler gauge or a sheet of paper without over-extrusion. The reasoning is that if you have a 0.2 mm to start with, adding the first layer thickness (e.g. 0.2 mm) would imply that you are already starting at a 0.4 mm gap on your first layer. You now try to push out more filament to fill that gap (resulting in not really pressing the filament to the plate).</p>
<p>Furthermore, your tape does not look like it is laid down next to each other, it looks as though it is laid over each other. This creates an uneven bed surface.</p>
<p>Finalizing, you should do whatever you do to get the filament to stick to the build plate, if it works for you, use it. If it doesn't produce viable prints, or you are not satisfied with the surface finish, change it.</p>
| <p>I cannot stress enough how much purple glue stick helps with this exact problem.</p>
<p>I had a cheap XYZ printer that I used nearly half a spool of filament on trying to align and get prints to stick. After ten hours straight of hair pulling and desperation, I smeared some purple glue stick across the build plate -- worked like a charm. Works great even just on bare glass, although I usually use blue tape underneath.</p>
<p>Also had one of those cheap Monoprice MP Mini and a 3D Solutions Cube which both benefited greatly from the glue stick.</p>
<p>I've had a few cheap printers that I carried with me for educational purposes in a backpack and I'm sure the alignment wasn't ideal, but the glue always made it work perfectly.</p>
<p>Elmer's makes one, I picked up a 3 pack of cheap ones on Amazon with great success.</p>
| 1,173 |
<p>Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like:</p>
<pre><code>class MyStruct():
def __init__(self, field1, field2, field3):
self.field1 = field1
self.field2 = field2
self.field3 = field3
</code></pre>
| <p>Use a <a href="https://docs.python.org/2/library/collections.html#collections.namedtuple" rel="noreferrer">named tuple</a>, which was added to the <a href="http://docs.python.org/library/collections.html" rel="noreferrer">collections module</a> in the standard library in Python 2.6. It's also possible to use Raymond Hettinger's <a href="http://code.activestate.com/recipes/500261/" rel="noreferrer">named tuple</a> recipe if you need to support Python 2.4.</p>
<p>It's nice for your basic example, but also covers a bunch of edge cases you might run into later as well. Your fragment above would be written as:</p>
<pre><code>from collections import namedtuple
MyStruct = namedtuple("MyStruct", "field1 field2 field3")
</code></pre>
<p>The newly created type can be used like this:</p>
<pre><code>m = MyStruct("foo", "bar", "baz")
</code></pre>
<p>You can also use named arguments:</p>
<pre><code>m = MyStruct(field1="foo", field2="bar", field3="baz")
</code></pre>
| <p>I think Python structure dictionary is suitable for this requirement.</p>
<pre class="lang-py prettyprint-override"><code>d = dict{}
d[field1] = field1
d[field2] = field2
d[field2] = field3
</code></pre>
| 5,660 |
<p>How do you get around this Ajax cross site scripting problem on FireFox 3?</p>
| <p>If you're using jQuery it has a callback function to overcome this:</p>
<p><a href="http://docs.jquery.com/Ajax/jQuery.ajax#options" rel="noreferrer">http://docs.jquery.com/Ajax/jQuery.ajax#options</a></p>
<blockquote>
<p>As of jQuery 1.2, you can load JSON
data located on another domain if you
specify a JSONP callback, which can be
done like so: "myurl?callback=?".
jQuery automatically replaces the ?
with the correct method name to call,
calling your specified callback. Or,
if you set the dataType to "jsonp" a
callback will be automatically added
to your Ajax request.</p>
</blockquote>
<p>Alternatively you could make your ajax request to a server-side script which does the cross-domain call for you, then passes the data back to your script</p>
| <p>Some more details would be nice: which AJAX library are you using, what would you like to achive, how you do it.</p>
<p>For example it can be a cross-domain Ajax request, which is not allowed. In this case use <a href="http://www.json.org/" rel="nofollow noreferrer">JSON</a>.</p>
| 7,432 |
<p>I have several wpf pages with update/delete/add buttons. I want to display to the user messages like "successful delete", etc. How can I best implement this so the message is defined in a single place (similar to an asp.net master page) and I can update this message from anywhere?</p>
| <p>You may want to consider doing a publish/subscribe ("Observer" pattern) -- define a "status changed" event on a base page, and create a custom control that sets up a delegate and event handler to listen for status updates.</p>
<p>Then you could drop the custom control on any page that inherits from the base, and it would automatically listen for and display status messages whenever the event is fired.</p>
<p><strong>Edit:</strong> I put together a sample implementation of this pattern and <a href="http://weblogs.asp.net/guystarbuck/archive/2008/10/08/shared-message-area-in-wpf-using-publish-subscribe.aspx" rel="nofollow noreferrer">published a blog post</a> walking through the code.</p>
| <p>I don't think you have the ASP.Net master pages translated to the <em>WPF Page</em> world just yet.<br>
A workaround till MS gets there, I would probably put a Control at the top of the page (or wherever) that just displays a particular User-level "<a href="http://msdn.microsoft.com/en-us/library/ms171565.aspx" rel="nofollow noreferrer">Application Setting</a>". You can update the string property like</p>
<pre><code>MyAppUserSettings.StatusMessage = "You just deleted the administrator!"
</code></pre>
<p>Crude but will get the job done I think!</p>
| 7,284 |
<p>I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine. </p>
<p>Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is performing. </p>
<p>Is there any way to see debug output from GraphBuilder when it assembles a graph?</p>
<p>Is there a way to dump a working graph to see how it was put together?</p>
<p>Any other ideas for unraveling the mystery that lives in the DirectShow box?</p>
<p>Thanks!
-Z</p>
| <p>You can watch the graph you created using GraphEdit, a tool from the DirectShow SDK. In GraphEdit, select File->Connect to remote Graph...</p>
<p>In order to find your graph in the list, you have to register it in the running object table:</p>
<pre><code>void AddToRot( IUnknown *pUnkGraph, DWORD *pdwRegister )
{
IMoniker* pMoniker;
IRunningObjectTable* pROT;
GetRunningObjectTable( 0, &pROT );
WCHAR wsz[256];
swprintf_s( wsz, L"FilterGraph %08p pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId() );
CreateItemMoniker( L"!", wsz, &pMoniker );
pROT->Register( 0, pUnkGraph, pMoniker, pdwRegister );
// Clean up any COM stuff here ...
}
</code></pre>
<p>After destroying your graph, you should remove it from the ROT by calling IRunningObjectTable::Revoke</p>
| <p>Older versions of DirectX, I belive 9a, but not 9b had a "debug mode" for dshow. It would output logs of debug info into the debug console. </p>
<p>So download an older version, set it to debug. then open up debugview or load graphedt.exe in visual studio to see the debug info.</p>
| 4,748 |
<p>I've recently switched to PETG , and I'm using Cura as slicer and Ender 3 as printer.</p>
<p>I'm printing a model which Cura declares to be <strong>35 g</strong>, but if I weigh the printed model it weighs <strong>23 g</strong>.</p>
<p>I'm printing with just 1 line of skirt, so its weight is negligible on total weight.
I've replaced the stock plastic extruder with a double gears metal extruder (3Dman 11 Dual Gear Extruder ).</p>
<p><a href="https://i.stack.imgur.com/22V5v.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/22V5v.jpg" alt="enter image description here" /></a></p>
<p>I've also replaced the stock springs with metals ones.</p>
<p>I'm not having a quality problem, just I want to understand if this difference is caused by a bad configuration that could be improved.</p>
<p>Which are the corrections/checks that I need to do in my setup (both printer and Cura) for fixing this difference?</p>
| <p>The density of the filament can be specified in the material model of the filament in Cura (Preferences -> Configure Cura... -> Materials and click on the material/filament you are using to slice your model for PETG), look at the value behind <em>Density</em>, the PETG filament I use is using 1.28 g/cm³ (<a href="https://colorfabb.com/petg-economy-black" rel="nofollow noreferrer">PETG Economy Black -> Specification ></a>).</p>
<p><a href="https://i.stack.imgur.com/vy283.png" rel="nofollow noreferrer" title="Cura materials window"><img src="https://i.stack.imgur.com/vy283.png" alt="Cura materials window" title="Cura materials window" /></a></p>
<p>This field is user editable, so you can change it to your needs. Cura calculates the weight based on the deposited volume.</p>
| <p>The density of the filament can be specified in the material model of the filament in Cura (Preferences -> Configure Cura... -> Materials and click on the material/filament you are using to slice your model for PETG), look at the value behind <em>Density</em>, the PETG filament I use is using 1.28 g/cm³ (<a href="https://colorfabb.com/petg-economy-black" rel="nofollow noreferrer">PETG Economy Black -> Specification ></a>).</p>
<p><a href="https://i.stack.imgur.com/vy283.png" rel="nofollow noreferrer" title="Cura materials window"><img src="https://i.stack.imgur.com/vy283.png" alt="Cura materials window" title="Cura materials window" /></a></p>
<p>This field is user editable, so you can change it to your needs. Cura calculates the weight based on the deposited volume.</p>
| 1,923 |
<p>I have been reading through the <a href="http://yosefk.com/c++fqa/" rel="noreferrer">C++ FAQ</a> and was curious about the <a href="http://yosefk.com/c++fqa/friend.html" rel="noreferrer"><code>friend</code></a> declaration. I personally have never used it, however I am interested in exploring the language. </p>
<p>What is a good example of using <code>friend</code>?</p>
<hr>
<p>Reading the FAQ a bit longer I like the idea of the <code><<</code> <code>>></code> operator overloading and adding as a friend of those classes. However I am not sure how this doesn't break encapsulation. When can these exceptions stay within the strictness that is OOP?</p>
| <p>Firstly (IMO) don't listen to people who say <code>friend</code> is not useful. It IS useful. In many situations you will have objects with data or functionality that are not intended to be publicly available. This is particularly true of large codebases with many authors who may only be superficially familiar with different areas. </p>
<p>There ARE alternatives to the friend specifier, but often they are cumbersome (cpp-level concrete classes/masked typedefs) or not foolproof (comments or function name conventions).</p>
<p>Onto the answer; </p>
<p>The <code>friend</code> specifier allows the designated class access to protected data or functionality within the class making the friend statement. For example in the below code anyone may ask a child for their name, but only the mother and the child may change the name. </p>
<p>You can take this simple example further by considering a more complex class such as a Window. Quite likely a Window will have many function/data elements that should not be publicly accessible, but ARE needed by a related class such as a WindowManager.</p>
<pre><code>class Child
{
//Mother class members can access the private parts of class Child.
friend class Mother;
public:
string name( void );
protected:
void setName( string newName );
};
</code></pre>
| <p>Friends are also useful for callbacks. You could implement callbacks as static methods</p>
<pre><code>class MyFoo
{
private:
static void callback(void * data, void * clientData);
void localCallback();
...
};
</code></pre>
<p>where <code>callback</code> calls <code>localCallback</code> internally, and the <code>clientData</code> has your instance in it. In my opinion, </p>
<p>or...</p>
<pre><code>class MyFoo
{
friend void callback(void * data, void * callData);
void localCallback();
}
</code></pre>
<p>What this allows is for the friend to be a defined purely in the cpp as a c-style function, and not clutter up the class.</p>
<p>Similarly, a pattern I've seen very often is to put all the <em>really</em> private members of a class into another class, which is declared in the header, defined in the cpp, and friended. This allows the coder to hide a lot of the complexity and internal working of the class from the user of the header.</p>
<p>In the header:</p>
<pre><code>class MyFooPrivate;
class MyFoo
{
friend class MyFooPrivate;
public:
MyFoo();
// Public stuff
private:
MyFooPrivate _private;
// Other private members as needed
};
</code></pre>
<p>In the cpp,</p>
<pre><code>class MyFooPrivate
{
public:
MyFoo *owner;
// Your complexity here
};
MyFoo::MyFoo()
{
this->_private->owner = this;
}
</code></pre>
<p>It becomes easier to hide things that the downstream needn't see this way.</p>
| 3,809 |
<p>I mean 3D forms like these? In a small scale (height: 1-2 cm, width: 0.5 cm).</p>
<p><a href="https://i.stack.imgur.com/Yd8Cl.png" rel="nofollow noreferrer" title="Detailed 3D form#1"><img src="https://i.stack.imgur.com/Yd8Cl.png" alt="Detailed 3D form#1" title="Detailed 3D form#1"></a></p>
<p><a href="https://i.stack.imgur.com/qV4Np.png" rel="nofollow noreferrer" title="Detailed 3D form#2"><img src="https://i.stack.imgur.com/qV4Np.png" alt="Detailed 3D form#2" title="Detailed 3D form#2"></a></p>
<p>I want to keep all the form's details.</p>
<p>If it is possible, what printer do you advise? How much does it cost to print one piece like that in terms of ink? And what is the most permissive software for this kind of printing?</p>
| <p>Best option for something like this would be to use an SLA printer. They can do sharper image detail compared to FDM style printers.</p>
<p>That being said, printing something like this poses its own set of challenges. In order to print a part, some surface needs to be in contact with the built platform, and depending on which surface chosen, you will end up with having some amount of overhang, or undercut. Not an issue in and of itself as these can be supported with support structures. For the size that you're looking at printing though, removal of the support material will be a bigger challenge. </p>
<p>As for costing of this, that's not something that this forum is used for, but these structures don't look absurdly difficult to print. If you were to contact a local print shop, or check on Google for an online print house, they will be able to give you costing on printing these. </p>
| <p>You could use something like a Stratsys Objet 30 Pro. </p>
<p>The printer uses layers of liquid deposited on a bed and cured with UV light, instead of extruded plastics. This just means that the level of detail you can achieve is far higher than that typically achieved by a conventional ABS or PLA printer. That being said, the materials and machine hours tend to be more expensive than conventional printers (about 40% higher in the specific facility I am exposed to). </p>
<p>If you are well versed in 3D printing, you could play around with the air-gapping (forced overlapping of layers due to z-axis head positioning in ABS and PLA). Can cause wear on the head, and takes some playing with but in some cases has yielded me a higher perceived level of detail. Also, makes some part features stronger. </p>
| 575 |
<p>Hoping to get some help with something I'm trying to accomplish. Unfortunately, due to my being a noob with 3D modeling in general, I'm coming here for hopefully more direct help.</p>
<pre><code>Env. Details: OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13541 (Git)
Build type: Release
Branch: releases/FreeCAD-0-17
Hash: 9948ee4f1570df9216862a79705afb367b2c6ffb
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
</code></pre>
<p>Essentially, I have a need to design some housing for a small electornics board. Due to the nature of 3D printing being less than ideal for bending/snapping locks, I've decided to use small screws to hold multiple layers of housing together.
<a href="https://i.stack.imgur.com/CBSLA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CBSLA.png" alt="Placements to bore threaded holes"></a></p>
<p>SketchUp Free proved to be a super intuitive, easy to understand 3D modeling software, tho is limited in functionality due to paid tiers.
Unfortunately, FreeCAD felt like a confusing cross between early 2000s Microsoft Paint and Eclipse (Java). However as the open source alternative, I understand it's incredibly powerful and can/should be able to do what most 3D modeling software is capable of, if you know how to use it properly - and that's where my lack of understanding shines through. Research into my use case revealed a plugin (Fasteners Workbench) which seemed purpose built for dealing with screws/threads, and I greatly prefer this approach due to being able to select standardized sizes.</p>
<p>On to the problem:
I decided to sketch out the main design for the housing in Sketchup, and am happy with it, though I am missing the holes in the four corners. To add this, I decided to export the file from Sketchup as STL and import it to FreeCAD. Once in FreeCAD, I switched to the fasteners workbench and created a screwtap of arbitrary length. Now, from most tutorials I've watched, removing one piece from another is a boolean operation, often a cut or an intersection. However, when I highlight both the part object and the screwtap and select the CUT boolean operation, what I expect to happen (the screwtap was "cut" or carved out of the part object) did not.
<a href="https://i.stack.imgur.com/fWykE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fWykE.png" alt="Intersecting components selected, deciding on boolean operation"></a>
<a href="https://i.stack.imgur.com/BqkC7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BqkC7.png" alt="enter image description here"></a></p>
<p>I'm wondering if:
- My understanding of the boolean operation is wrong. There is a different function that is used for "boring" threaded holes?
- My process is wrong. Does exporting an STL from sketchup free not work for certain operations when importing to FreeCAD?
- My models are off. I have an understanding that "grouping" parts of models is big when putting a model together from parts, so as to simplify life. I'm wondering if it's also required in these cases? Attempting to do the boolean operation in sketchup failed but did require having grouped components. I'm not sure this is the case in FreeCAD, or if I'm already doing this?</p>
<p>Would appreciate any help with this. Attaching the FreeCAD file <a href="https://drive.google.com/file/d/17_NEe8SXjl54cQzKhfzkMZsMBHSc9e5X/view?usp=sharing" rel="nofollow noreferrer">here</a>.</p>
| <p>A wide line works if there is something below it to squeeze the filament against, but if you don't have a full layer below it, it will stay thinner and it will droop. I would not use extreme ratios on overhangs. Still, do a parametric test: a overhang tower (a compact one) at different line widths and layer heights. If you test 3 layer heights and 3 line widths, it's only 9 short prints.</p>
<p>However, as you can see in filament reviews, different materials behave differently. I think there is no <em>a priori</em> optimal value.</p>
| <p>In terms of Cura's model for showing overhangs, I'm nearly sure it's just the ratio - rise over run, or rather run over rise. And indeed that's what makes sense mathematically:</p>
<p>At least some portion of the wall extrusion in layer N+1 needs to sit on top of the corresponding wall extrusion in layer N. For a given 3D surface slope, the "run" - the distance the cross-section moves from one layer to the next, which needs to be bounded by some fraction of the line width - varies proportionally to the "rise" - the layer height.</p>
| 1,666 |
<p>I have a list of addresses from a Database for which I'd like to put markers on a Yahoo Map. The <a href="http://developer.yahoo.com/maps/ajax/V3.8/index.html#YMap" rel="nofollow noreferrer"><code>addMarker()</code> method</a> on YMap takes a YGeoPoint, which requires a latitude and longitude. However, Yahoo Maps must know how to convert from addresses because <code>drawZoomAndCenter(LocationType,ZoomLevel)</code> can take an address. I could convert by using <code>drawZoomAndCenter()</code> then <code>getCenterLatLon()</code> but is there a better way, which doesn't require a draw?</p>
| <p>You can ask the map object to do the geoCoding, and catch the callback:</p>
<pre><code><script type="text/javascript">
var map = new YMap(document.getElementById('map'));
map.drawZoomAndCenter("Algeria", 17);
map.geoCodeAddress("Cambridge, UK");
YEvent.Capture(map, EventsList.onEndGeoCode, function(geoCode) {
if (geoCode.success)
map.addOverlay(new YMarker(geoCode.GeoPoint));
});
</script>
</code></pre>
<p>One thing to beware of -- in this example the <code>drawAndZoom</code> call will itself make a geoCoding request, so you'll get the callback from that too. You might want to filter that out, or set the map's centre based on a GeoPoint.</p>
| <p>If you're working with U.S. addresses, you can use <a href="http://geocoder.us/" rel="nofollow noreferrer">geocoder.us</a>, which has <a href="http://geocoder.us/help/" rel="nofollow noreferrer">APIs</a>.</p>
<p>Also, <em>Google Maps Hacks</em> has a hack, <a href="http://safari.oreilly.com/0596101619/googlemapshks-CHP-7-SECT-2" rel="nofollow noreferrer">"Hack 62. Find the Latitude and Longitude of a Street Address"</a>, for that.</p>
| 9,925 |
<p>The Add view and the Edit view are often incredibly similar that it is unwarranted to write 2 views. As the app evolves you would be making the same changes to both.</p>
<p>However, there are usually subtle differences. For instance, a field might be read-only once it's been added, and if that field is a DropDownList you no longer need that List in the ViewData.</p>
<p>So, should I create a view data class which contains all the information for both views, where, depending on the operation you're performing, certain properties will be null?<br>
Should I include the operation in the view data as an enum?<br>
Should I surround all the subtle differences with <em><% if( ViewData.Model.Op == Ops.Editing ) { %></em> ?</p>
<p>Or is there a better way?</p>
| <p>It's pretty easy really. Let's assume you're editing a blog post.</p>
<p>Here's your 2 actions for new/edit:</p>
<pre><code>public class BlogController : Controller
{
public ActionResult New()
{
var post = new Post();
return View("Edit", post);
}
public ActionResult Edit(int id)
{
var post = _repository.Get(id);
return View(post);
}
....
}
</code></pre>
<p>And here's the view:</p>
<pre><code><% using(Html.Form("save")) { %>
<%= Html.Hidden("Id") %>
<label for="Title">Title</label>
<%= Html.TextBox("Title") %>
<label for="Body">Body</label>
<%= Html.TextArea("Body") %>
<%= Html.Submit("Submit") %>
<% } %>
</code></pre>
<p>And here's the Save action that the view submits to:</p>
<pre><code>public ActionResult Save(int id, string title, string body)
{
var post = id == 0 ? new Post() : _repository.Get(id);
post.Title = title;
post.Body = body;
_repository.Save(post);
return RedirectToAction("list");
}
</code></pre>
| <p>You can specify a CustomViewData class and pass the parameters here.</p>
<pre><code>
public class MyViewData {
public bool IsReadOnly { get; set; }
public ModelObject MyObject { get; set; }
}
</code></pre>
<p>And both views should implement this ViewData.
As a result you can use provided IsReadOnly property to manage the UserControl result.</p>
<p>As the controller uses this, you can unit test it and your views doesn't have implementation, so you can respect the MVC principles.</p>
| 3,929 |
<p>We have a situation where users are allowed to upload content, and then separately make some changes, then submit a form based on those changes.</p>
<p>This works fine in a single-server, non-failover environment, however we would like some sort of solution for sharing the files between servers that supports failover.</p>
<p>Has anyone run into this in the past? And what kind of solutions were you able to develop? Obviously persisting to the database is one option, but we'd prefer to avoid that.</p>
| <p>At a former job we had a cluster of web servers with an F5 load balancer in front of them. We had a very similar problem in that our applications allowed users to upload content which might include photo's and such. These were legacy applications and we did not want to edit them to use a database and a SAN solution was too expensive for our situation.</p>
<p>We ended up using a file replication service on the two clustered servers. This ran as a service on both machines using an account that had network access to paths on the opposite server. When a file was uploaded, this backend service sync'd the data in the file system folders making it available to be served from either web server.</p>
<p>Two of the products we reviewed were <a href="http://www.tgrmn.com/" rel="nofollow noreferrer">ViceVersa</a> and <a href="http://www.peersoftware.com/products/peersync/peersync.aspx" rel="nofollow noreferrer">PeerSync</a>. I think we ended up using PeerSync.</p>
<hr>
| <p>The best solution for this is usually to provide the shared area on some form of SAN, which will be accessible from all servers and contain failover.</p>
<p>This also has the benefit that you don't have to provide sticky load balancing, the upload can be handled by one server, and the edit by another.</p>
| 4,263 |
<p>So, we have <a href="https://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read">coding books</a>, <a href="https://stackoverflow.com/questions/5119/what-are-the-best-rss-feeds-for-programmersdevelopers">coding RSS feeds</a>, and <a href="https://stackoverflow.com/questions/3947/coding-music">music to code by</a>. Are there any coding magazines that anyone would recommend?</p>
| <p>The venerable <a href="http://www.ddj.com/" rel="noreferrer">Dr. Dobbs Journal</a> is still pretty good. It covers multiple platforms, and mixes some fairly hard-core technical articles with lighter fare (interviews with notables, a "Developer Diaries" column that profiles regular-Joe (and Jane) developers from a range of fields). If you are employed and have authority to spend some non-trivial amount of money on tools (or are willing to claim that you do), you can probably get them to send it to you for free.</p>
<p>For the Microsoft world, <a href="http://msdn.microsoft.com/en-us/magazine/default.aspx" rel="noreferrer">MSDN Magazine</a> is very useful. Some of their columns are excellent, particularly Jeff Richter's <a href="http://msdn.microsoft.com/en-us/magazine/cc501041.aspx" rel="noreferrer">Concurrent Affairs</a>.</p>
| <p>I like Embedded Systems. Even if you don't program for embedded systems, the software articles are excellent. <a href="http://www.embedded.com/" rel="nofollow noreferrer">http://www.embedded.com/</a></p>
| 6,157 |
<p>I am working on an ASP.NET web application, it seems to be working properly when I try to debug it in Visual Studio. However when I emulate heavy load, IIS crashes without any trace -- log entry in the system journal is very generic, "The World Wide Web Publishing service terminated unexpectedly. It has done this 4 time(s)."
How is it possible to get more information from IIS to troubleshoot this problem?</p>
| <p>Crash dump of <a href="http://blogs.msdn.com/tess/archive/tags/ASP.NET/default.aspx" rel="nofollow noreferrer">asp.net process</a> should give you <a href="http://blogs.msdn.com/tess/pages/net-debugging-demos-information-and-setup-instructions.aspx" rel="nofollow noreferrer">tons of info</a>..If you want to quickly get some info on why the process got recycled, <a href="http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx" rel="nofollow noreferrer">try this tip from Scott Gu</a>..
<a href="http://odetocode.com/Blogs/scott/archive/2005/11/01/2402.aspx" rel="nofollow noreferrer">Health monitoring</a> feature of asp.net 2.0 is also worth looking at..</p>
| <p>The key is <em>"without any trace"</em>. You need to put your own trace logging in to create some chatter. Then you'll be able to spot where the chatter stops.</p>
| 8,823 |
<p>Given the URL (single line):<br>
<a href="http://test.example.com/dir/subdir/file.html" rel="noreferrer">http://test.example.com/dir/subdir/file.html</a></p>
<p>How can I extract the following parts using regular expressions:</p>
<ol>
<li>The Subdomain (test)</li>
<li>The Domain (example.com)</li>
<li>The path without the file (/dir/subdir/)</li>
<li>The file (file.html)</li>
<li>The path with the file (/dir/subdir/file.html)</li>
<li>The URL without the path (<a href="http://test.example.com" rel="noreferrer">http://test.example.com</a>)</li>
<li>(add any other that you think would be useful)</li>
</ol>
<p>The regex should work correctly even if I enter the following URL: </p>
<pre><code>http://example.example.com/example/example/example.html
</code></pre>
| <blockquote>
<p>A single regex to parse and breakup a
full URL including query parameters
and anchors e.g.</p>
<p><a href="https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash" rel="noreferrer">https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash</a> </p>
<p><code>^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$</code></p>
<p>RexEx positions:</p>
<p>url: RegExp['$&'], </p>
<p>protocol:RegExp.$2,</p>
<p>host:RegExp.$3, </p>
<p>path:RegExp.$4,</p>
<p>file:RegExp.$6, </p>
<p>query:RegExp.$7,</p>
<p>hash:RegExp.$8</p>
</blockquote>
<p>you could then further parse the host ('.' delimited) quite easily.</p>
<p>What <strong>I</strong> would do is use something like this:</p>
<pre><code>/*
^(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)$
*/
proto $1
host $2
port $3
the-rest $4
</code></pre>
<p>the further parse 'the rest' to be as specific as possible. Doing it in one regex is, well, a bit crazy.</p>
| <pre><code>String s = "https://www.thomas-bayer.com/axis2/services/BLZService?wsdl";
String regex = "(^http.?://)(.*?)([/\\?]{1,})(.*)";
System.out.println("1: " + s.replaceAll(regex, "$1"));
System.out.println("2: " + s.replaceAll(regex, "$2"));
System.out.println("3: " + s.replaceAll(regex, "$3"));
System.out.println("4: " + s.replaceAll(regex, "$4"));
</code></pre>
<p>Will provide the following output:<br>
1: https://<br>
2: www.thomas-bayer.com<br>
3: /<br>
4: axis2/services/BLZService?wsdl<br>
<br>
If you change the URL to <br>
String s = "<a href="https://www.thomas-bayer.com?wsdl=qwerwer&ttt=888" rel="nofollow">https://www.thomas-bayer.com?wsdl=qwerwer&ttt=888</a>";
the output will be the following :<br>
1: https://<br>
2: www.thomas-bayer.com<br>
3: ?<br>
4: wsdl=qwerwer&ttt=888<br></p>
<p>enjoy..<br>
Yosi Lev</p>
| 4,741 |
<p>My company is using CVS as our de-facto standard for source control. However, I've heard a lot of people say that SVN is better.</p>
<p>I know SVN is newer, but other than that, I'm unfamiliar with its benefits.</p>
<p>What I'm looking for is a good, succinct comparison of the two systems, noting any advantages or disadvantages of each in a Java/Eclipse development environment.</p>
| <p>CVS only tracks modification on a file-by-file basis, while SVN tracks a whole commit as a new revision, which means that it is easier to follow the history of your project. Add the fact that all modern source control software use the concept of revision so it is far easier to migrate from SVN than it is from CVS.</p>
<p>There is also the atomic commit problem. While I only encountered it once, it is possible that 2 people committing together in CVS can conflict each other, losing some data and putting your client in an inconsistent state. When detected early, these problems are not major because your data is still out there somewhere, but it can be a pain in a stressful environment.</p>
<p>And finally, not many tools are developed around CVS anymore. While the new and shiny-new tools like Git or Mercurial definitely lack tools yet, SVN has a pretty large application base on any system.</p>
<p><strong>EDIT 2020</strong>: Seriously, this answer is 12 years old now. Forget SVN, go use Git like everyone else!</p>
| <p>you might also choose to migrate only the latest code from CVS into SVN and freeze your current CVS repo. this will make migration easier and you might also build your legacy releases in the old CVS repo.</p>
| 2,365 |
<p>I have an Anet A8 with the Anet 1.7 board, Skynet3d v2.3.2, and the stock sensor. I originally had this configuration with the stock extruder, but recently purchased an E3D v6 clone with a Bowden extruder. After installing a new bracket I had printed (<a href="https://www.thingiverse.com/thing:2099577" rel="nofollow noreferrer">TNS E3D v6 Bracket</a>) with the <a href="https://www.thingiverse.com/thing:2283440" rel="nofollow noreferrer">adjustable stock sensor mount</a>. I installed the extruder and sensor.</p>
<p>I knew I had to adjust sensor position. I went through the <a href="/q/8153/">3DStackExchange post on Z probe boundary limits</a> as well, and added all of the end positions and probe to nozzle offsets (I will list below) to my <code>Configuration.h</code> file, saved, checked the changes were there in the <code>Configuration.h</code> tab in the Arduino IDE and uploaded the firmware. After this I went to hit auto leveling in the prepare menu, and the positions were different from the stock extruder and mount, but when it got to the third position, the sensor was off the bed, and the nozzle dug into the bed.</p>
<p>The configuration I was editing was from the Anet A8 5 button stock sensor <code>Configuration.h</code> file.</p>
<p>My probe is (When looking from the front of the Anet A8) forward and right of the nozzle.</p>
<ul>
<li>My Y-axis offset is -3 (the sensor is 3 mm in front of the nozzle when looking from the front)</li>
<li>My X-axis offset is +37 (the sensor is 37 mm to the right of the nozzle when looking from the front)</li>
</ul>
<p>The stock <code>min_probe_edge</code> is 10 mm, so with my math my Left Probe Bed Position is 47, Right is 210, Back is 207, and front is 10.</p>
<p>I want to get my probe settings properly set up so I get my bed leveling back and I do not want to ruin my bed while leveling. </p>
| <p>If you have done major revisions to the printhead by changing to another carriage, it could be that the nozzle in the carriage is not at the exact position as in the previous carriage.</p>
<p>So, have you made sure that the new carriage has the appropriate values so that the nozzle is at (0, 0) when commanded to that position? Alternatively, in different wordings, this translates to: "Is the printer printing in the center?/Are the prints centered on the build plate?". See e.g. <a href="/6375">"How to center my prints on the build platform? (Re-calibrate homing offset)"</a>. </p>
<p>From the Thingiverse link van be read that this carriage requires an offset. The carriage design mentions a shift of the X axis: </p>
<pre><code>#define X_MIN_POS -10
</code></pre>
<p>Is that working for you? </p>
<hr>
<p><em>General remarks regarding the firmware update:
Have you also loaded all values from firmware using <code>M502</code> and then <code>M500</code>? (if <code>M500</code> commands are enabled). Also, <a href="/a/6200">Skynet3D is obsolete!</a>, use Marlin instead!</em></p>
| <p>Do you have eeprom enabled? Because if you do, you can change configuration.h all you want but it's always gonna use the values from eeprom. I advise you to install repetier and change the eeprom values with that. Or maybe you can use the display if you have one.</p>
| 1,517 |
<p>I would like to gauge what solutions other people put in place to get Team System functionality. We all know that Team System can be pricey for some of us. I know they offer a small team edition with five licenses with a MSDN subscription, but what if your team is bigger than five or you don't want to use Team System?</p>
| <p>I'm stunned that nobody has mentioned the <strong>free</strong> and excellent <a href="http://www.jetbrains.com/teamcity/index.html" rel="noreferrer">TeamCity</a> product from JetBrains. It includes:</p>
<ul>
<li>Continous Integration </li>
<li>Software Build management</li>
<li>Project Management, Monitoring and Statistical Reports</li>
<li>Integration with many IDEs, Sourcecode control systems, and Testing Frameworks</li>
</ul>
<p>For project management / bug tracking / Git or Subversion repository I also use <a href="http://unfuddle.com/" rel="noreferrer">Unfuddle</a> (<strong>free</strong> for small personal projects!)</p>
| <p>SVN with the TortoiseSVN add-on makes for a solid and easy to use interface. WinMerge is a great tool to thrown in that mix as well.</p>
| 3,297 |
<p>I want to be able to get an estimate of how much code & static data is used by my C++ program?</p>
<p>Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime?</p>
<p>Will objdump & readelf help?</p>
| <p>"size" is the traditional tool. "readelf" has a lot of options.</p>
<pre><code>$ size /bin/sh
text data bss dec hex filename
712739 37524 21832 772095 bc7ff /bin/sh
</code></pre>
| <p><code>readelf</code> will indeed help. You can use the <code>-S</code> option; that will show the sizes of all sections. <code>.text</code> is (the bulk of) your executable code. <code>.data</code> and <code>.rodata</code> is your static data. There are other sections too, some of which are used at runtime, others only at link time.</p>
| 5,596 |
<p>When I'm working with DataBound controls in ASP.NET 2.0 such as a Repeater, I know the fastest way to retrieve a property of a bound object (instead of using Reflection with the Eval() function) is to cast the DataItem object to the type it is and then use that object natively, like the following:</p>
<pre><code><%#((MyType)Container.DataItem).PropertyOfMyType%>
</code></pre>
<p>The problem is, if this type is in a namespace (which is the case 99.99% of the time) then this single statement because a lot longer due to the fact that the ASP page has no concept of class scope so all of my types need to be fully qualified.</p>
<pre><code><%#((RootNamespace.SubNamespace1.SubNamspace2.SubNamespace3.MyType)Container.DataItem).PropertyOfMyType%>
</code></pre>
<p>Is there any kind of <code>using</code> directive or some equivalent I could place somewhere in an ASP.NET page so I don't need to use the full namespace every time?</p>
| <p>I believe you can add something like:</p>
<pre><code><%@ Import Namespace="RootNamespace.SubNamespace1" %>
</code></pre>
<p>At the top of the page.</p>
| <p>What you're looking for is the <a href="http://msdn.microsoft.com/en-us/library/eb44kack(v=VS.80).aspx" rel="nofollow noreferrer" title="MSDN">@Import page directive</a>.</p>
| 4,138 |
<p>I had been happily coding along on a decent sized solution (just over 13k LOC, 5 projects) which utilizes Linq to Sql for it's data access. All of sudden I performed a normal build and I received a sweet, sweet ambiguous message:</p>
<p><strong>Error 1 Build failed due to validation errors in C:\xxx\xxx.dbml. Open the file and resolve the issues in the Error List, then try rebuilding the project. C:\xxx\xxx.dbml</strong> </p>
<p>I had not touched my data access layer for weeks and no adjustments had been made to the DBML file. I tried plenty of foolhardy tricks like re-creating the layout file, making copies and re-adding the existing files back to the project after restarting Visual Studio (in case of some file-level corruption); all to no avail.</p>
<p>I forgot to wear my Visual Studio Skills +5 talismans, so I began searching around and the only answer that I found which made sense was to reset my packages because Visual Studio was not loading an assembly correctly. After running "<em>devenv.exe /resetskippkgs</em>" I was, in fact, able to add the dbml file back to the DAL project and rebuild the solution.</p>
<p>I’m glad it’s fixed, but I would rather also gain a deeper understand from this experience. <strong>Does anyone know how or why this happens in Visual Studio 2008?</strong></p>
<p><strong>New Edit: 10/30/2008</strong>
<strong>THIS WAS NOT SOMETHING THAT JUST HAPPENED TO ME.</strong>
Rich Strahl recently wrote on his "web log" <a href="http://www.west-wind.com/Weblog/posts/505990.aspx" rel="nofollow noreferrer">about the same experience</a>. He links to another <a href="http://blog.mjjames.co.uk/2008/07/build-failed-due-to-validation-errors.html" rel="nofollow noreferrer">blog with the same issue and used the same action</a>.</p>
<p>I have encountered this issue a few times since this original post as well, making me think that this is not some random issue. If anyone finds the definitive answer please post.</p>
| <p>TBH, I have had a couple of instances like this where files "seemed to go crazy".. However, upon investigation it has appeared that the files have changed in some way, shape or form.. (e.g. sometimes changes can be made to the file by inadvertantly changing a property somewhere that <em>seems</em> unrelated).</p>
<p>I think there are too many possible issues that could really cause this, and based on the fact that the problem has been resovled, it seems like an answer will not be found..</p>
| <p>I had the same issue in VS 2010 (build failed due to validation errors in dbml file). I resolved this by viewing the designer view of the dbml file and dragging a table slightly to a different location so that it refreshed the dbml layout etc files. This seemed to do the trick, but was a bit of a weird issue.</p>
| 4,848 |
<p>Is there available any tool for PHP which can be used to generate code for consuming a <a href="http://en.wikipedia.org/wiki/Web_service" rel="noreferrer">web service</a> based on its <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a>? Something comparable to clicking "Add Web Reference" in Visual Studio or the Eclipse plugin which does the same thing for Java.</p>
| <p>In PHP 5 you can use <a href="http://www.php.net/manual/en/ref.soap.php" rel="noreferrer">SoapClient</a> on the WSDL to call the web service functions. <a href="http://www.php.net/manual/en/soapclient.construct.php" rel="noreferrer">For example</a>:</p>
<pre><code>$client = new SoapClient("some.wsdl");
</code></pre>
<p>and $client is now an object which has class methods as defined in some.wsdl. So if there was a method called getTime in the WSDL then you would just call:</p>
<pre><code>$result = $client->getTime();
</code></pre>
<p>And the result of that would (obviously) be in the $result variable. You can use the __getFunctions method to return a list of all the available methods.</p>
| <p>Well, those features are specific to a tool that you are using for development in those languages.</p>
<p>You wouldn't have those tools if (for example) you were using notepad to write code. So, maybe you should ask the question for the tool you are using.</p>
<p>For PHP: <a href="http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html" rel="nofollow noreferrer">http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html</a></p>
| 2,643 |
<p>On my side job as programmer, I am to write a program in C++ to convert audio files from/to various formats. Probably, this will involve building a simple GUI.</p>
<p>Will it be a great effort to build seperate GUIs for Mac and Windows using Cocoa and WinForms instead of a cross-platform toolkit like Qt or GTK? <br />(I will have to maintain a seperate Windows-version and Mac-Version anyway)<br>
The GUI will probably be very simple and only need very basic functionality.</p>
<p>I always felt that native GUIs feel far more intuitive than its cross-platform brethren...</p>
| <p>If you have the expertise, use native frontends, it'll effectively double the job you have to do for UI but from my experience non-native UI is a little bit clunkier than their native counterparts.</p>
| <p>wxWidgets used standard c++ syntax and preprocessor thus make you easily alter from plain C or C++. And will produce very native look where is appear, be it on GTK, X11, MS-Windows or Mac.</p>
<p>It's mature since 20yrs of 1rst release, has complete documentation with easy navigating, and supported by large community arround the world.
Coding in your favorite IDE or use prominent Eclipse-IDE and wxFormBuilder as GUI designer. Build wx library and IDE/Toolchain setup could be found on this link: <a href="http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html" rel="nofollow">http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html</a></p>
<p>Develop your application in Linux desktop and also provided compiler for Raspberry Pi2 (target application tested work smootly on Raspbian Jessie) ............</p>
| 5,454 |
<p>What is the easiest way to merge XML from two distinct DOM Documents? Is there a way other than using the Canonical <a href="http://support.microsoft.com/kb/311530" rel="nofollow noreferrer">DataReader</a> approach and then messing with the outputted DOM. What I basically want is to AppendChild to XmlElements without getting: <code>The node to be inserted is from a different document context.</code> Here is C# code that I want to work, that obviously won't (what I am doing is merging two documents which have bunch of nodes that I am interested in parts of):</p>
<pre><code>XmlDocument doc1 = new XmlDocument();
doc1.LoadXml("<a><items><item1/><item2/><item3/></items></a>");
XmlDocument doc2 = new XmlDocument();
doc2.LoadXml("<b><items><item4/><item5/><item6/></items></b>");
XmlNode doc2Node = doc2.SelectSingleNode("/b/items");
XmlNodeList doc1Nodes = doc1.SelectNodes("/a/items/*");
foreach (XmlNode doc1Node in doc1Nodes)
{
doc2Node.AppendChild(doc1Node);
}
</code></pre>
| <p>You can use the XmlDocument.ImportNode method to copy a node from a XmlDocument to another.</p>
| <p>You might be interested in <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx</a>. But take a close look at the "The following table describes the specific behavior for each XmlNodeType."-part of that document.</p>
| 8,189 |
<p>Using Vim I often want to replace a block of code with a block that I just yanked.</p>
<p>But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of yanking, then inserting, then deleting what I didn't want, but with large blocks of code this gets messy trying to keep the inserted block and the block to delete separate.</p>
<p>So what is the slickest and quickest way to replace text in Vim?</p>
<ul>
<li>is there a way to delete text without putting it into the register?</li>
<li>is there a way to say e.g. "replace next word" or "replace up to next paragraph"</li>
<li>or is the best way to somehow use the multi-register feature?</li>
</ul>
| <p>To delete something without saving it in a register, you can use the "black hole register":</p>
<pre><code>"_d
</code></pre>
<p>Of course you could also use any of the other registers that don't hold anything you are interested in.</p>
| <p>You can make a simple macro with:
<code>q"_dwq</code></p>
<p>Now to delete the next word without overwriting the register, you can use <code>@d</code></p>
| 7,789 |
<p>Is there any UI library that can be to build both a text user interface (ncurses) and graphical user interface (GTK? QT?) from the same source?
I know that debconf can be used with various frontends, I would like to build something similar but programmable.</p>
| <p>you could write your program to uses ncurses, and then use <a href="http://pdcurses.sourceforge.net/" rel="nofollow noreferrer">PDCurses</a> to convert it to an X11 application - as the readme advertise.</p>
<p>I know it because I've used it as portable curses, though I've never tested its X11 capabilities</p>
| <p>Maybe tcl/tk would provide what you want <a href="http://www.tcl.tk/" rel="nofollow noreferrer">http://www.tcl.tk/</a></p>
<p>Here's the page on interfacing with curses. There is a claim there of integration with ncurses.</p>
<p><a href="http://www2.tcl.tk/2372" rel="nofollow noreferrer">http://www2.tcl.tk/2372</a></p>
| 6,147 |
<p>I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"?</p>
<pre><code>var selectVar = arrayVar.Select( (a,i) => new { Line = a });
var selectVar =
from s in arrayVar
select new { Line = s };
</code></pre>
| <ul>
<li>First - calling an extension method.
This style of coding is called "<a href="http://www.martinfowler.com/bliki/FluentInterface.html" rel="nofollow noreferrer">fluent interface</a>" as you mentioned.</li>
<li>Second method is called <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="nofollow noreferrer">language integrated query</a></li>
</ul>
| <p>The first isn't even really LINQ, it's a lambda expression, with a type invariant object created. </p>
<pre><code>(a) => new { blah = b}
</code></pre>
<p>The second is a LINQ query filling an on the fly class that has a property Line.<br>
There is no hashrocket operator in this one, so this one is just plain old linq.</p>
| 6,813 |
<p>Which files should I include in <code>.gitignore</code> when using <em>Git</em> in conjunction with <em>Xcode</em>?</p>
|
<p>I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is redone for Xcode 4, with some improvements.</p>
<p>I've researched <em>every</em> file in this list, but several of them do not exist in Apple's official Xcode documentation, so I had to go on Apple mailing lists.</p>
<p>Apple continues to add undocumented files, potentially corrupting our live projects. This IMHO is unacceptable, and I've now started logging bugs against it each time they do so. I know they don't care, but maybe it'll shame one of them into treating developers more fairly.</p>
<hr>
<p>If you need to customize, here's a gist you can fork: <a href="https://gist.github.com/3786883" rel="noreferrer">https://gist.github.com/3786883</a></p>
<hr>
<pre><code>#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2015 updates:
# - Fixed typo in "xccheckout" line - thanks to @lyck for pointing it out!
# - Fixed the .idea optional ignore. Thanks to @hashier for pointing this out
# - Finally added "xccheckout" to the ignore. Apple still refuses to answer support requests about this, but in practice it seems you should ignore it.
# - minor tweaks from Jona and Coeur (slightly more precise xc* filtering/names)
# 2014 updates:
# - appended non-standard items DISABLED by default (uncomment if you use those tools)
# - removed the edit that an SO.com moderator made without bothering to ask me
# - researched CocoaPods .lock more carefully, thanks to Gokhan Celiker
# 2013 updates:
# - fixed the broken "save personal Schemes"
# - added line-by-line explanations for EVERYTHING (some were missing)
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
#########################
#####
# OS X temporary files that should never be committed
#
# c.f. http://www.westwind.com/reference/os-x/invisibles.html
.DS_Store
# c.f. http://www.westwind.com/reference/os-x/invisibles.html
.Trashes
# c.f. http://www.westwind.com/reference/os-x/invisibles.html
*.swp
#
# *.lock - this is used and abused by many editors for many different things.
# For the main ones I use (e.g. Eclipse), it should be excluded
# from source-control, but YMMV.
# (lock files are usually local-only file-synchronization on the local FS that should NOT go in git)
# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations!
#
# In particular, if you're using CocoaPods, you'll want to comment-out this line:
*.lock
#
# profile - REMOVED temporarily (on double-checking, I can't find it in OS X docs?)
#profile
####
# Xcode temporary files that should never be committed
#
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...
*~.nib
####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"
DerivedData/
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"
build/
#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
# saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
# ..but if you're in the 1%, comment out the line "*.pbxuser"
# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html
*.pbxuser
# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html
*.mode1v3
# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html
*.mode2v3
# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file
*.perspectivev3
# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
####
# Xcode 4 - semi-personal settings
#
# Apple Shared data that Apple put in the wrong folder
# c.f. http://stackoverflow.com/a/19260712/153422
# FROM ANSWER: Apple says "don't ignore it"
# FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode
# Up to you, but ... current advice: ignore it.
*.xccheckout
#
#
# OPTION 1: ---------------------------------
# throw away ALL personal settings (including custom schemes!
# - unless they are "shared")
# As per build/ and DerivedData/, this ought to have a trailing slash
#
# NB: this is exclusive with OPTION 2 below
xcuserdata/
# OPTION 2: ---------------------------------
# get rid of ALL personal settings, but KEEP SOME OF THEM
# - NB: you must manually uncomment the bits you want to keep
#
# NB: this *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,
# or manually install git over the top of the OS X version
# NB: this is exclusive with OPTION 1 above
#
#xcuserdata/**/*
# (requires option 2 above): Personal Schemes
#
#!xcuserdata/**/xcschemes/*
####
# Xcode 4 workspaces - more detailed
#
# Workspaces are important! They are a core feature of Xcode - don't exclude them :)
#
# Workspace layout is quite spammy. For reference:
#
# /(root)/
# /(project-name).xcodeproj/
# project.pbxproj
# /project.xcworkspace/
# contents.xcworkspacedata
# /xcuserdata/
# /(your name)/xcuserdatad/
# UserInterfaceState.xcuserstate
# /xcshareddata/
# /xcschemes/
# (shared scheme name).xcscheme
# /xcuserdata/
# /(your name)/xcuserdatad/
# (private scheme).xcscheme
# xcschememanagement.plist
#
#
####
# Xcode 4 - Deprecated classes
#
# Allegedly, if you manually "deprecate" your classes, they get moved here.
#
# We're using source-control, so this is a "feature" that we do not want!
*.moved-aside
####
# OPTIONAL: Some well-known tools that people use side-by-side with Xcode / iOS development
#
# NB: I'd rather not include these here, but gitignore's design is weak and doesn't allow
# modular gitignore: you have to put EVERYTHING in one file.
#
# COCOAPODS:
#
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
#!Podfile.lock
#
# RUBY:
#
# c.f. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
#
#!Gemfile.lock
#
# IDEA:
#
# c.f. https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml
#
#.idea/workspace.xml
#
# TEXTMATE:
#
# -- UNVERIFIED: c.f. http://stackoverflow.com/a/50283/153422
#
#tm_build_errors
####
# UNKNOWN: recommended by others, but I can't discover what these files are
#
</code></pre>
| <blockquote>
<p><em>A Structure of a standerd .gitignore file for Xcode project ></em></p>
</blockquote>
<pre><code>.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
</code></pre>
| 7,209 |
<p>When editing XAML in VS2008 SP1, the editor is really slow. devenv process seems to be around at 40% CPU (the machine I’m using at the moment is only dual core, so that’s almost maxing out one core) most of the time. It spikes up a bit more when I switch to another XAML file. I do also have ReSharper installed, but I think I’d rather put up with the slowness than remove that :)</p>
<p>Any suggestions on how I can speed things up a bit?</p>
<p>Edited to add:
I'm already using the Xaml only view, which did speed it up from what I remember - but it's still to sluggish. Also, the Xaml files aren't massive - only 100 to 200 lines.</p>
| <p>You can speed it up a lot by only viewing the XML view. Tools / Options / Text Editor / XAML / Always open documents in full XAML view (check this box).</p>
| <p>Maybe you can edit the XAML file outside Visual Studio. Use tools like:</p>
<ul>
<li><a href="http://blogs.msdn.com/llobo/archive/2008/08/25/xamlpadx-4-0.aspx" rel="nofollow noreferrer">XamlPadX 4</a></li>
<li><a href="http://www.kaxaml.com/" rel="nofollow noreferrer">Kaxaml</a></li>
</ul>
| 6,004 |
<p>I have only just set up my Anet A6 today. I am trying to print a calibration box, but the print is moving around the bed while trying to print. Any ideas how to fix this? The documentation is very vague.</p>
<p>Basically I am very new to 3D printing. I purchased an Anet A6 and have set it up stock. I am trying to just print the box directly from the demo models on the SD card. I'm using the standard filament that comes with the printer. I'm not sure what type it is.</p>
<p>All settings are default.</p>
| <p>If the printed material moves with the nozzle, you might have several problems at hand, e.g.:</p>
<ul>
<li>adhesion, </li>
<li>nozzle to bed distance and </li>
<li>overall level.</li>
</ul>
<p>Nozzle to bed distance needs to be the thickness of a plain A4 or Letter paper. This needs to be at the same distance (when pulling the sheet of paper you need to feel a little drag) at the complete area of the bed. This is sometimes difficult as not all beds are perfectly flat from itself. Finally, you need to pull some tricks out of your sleeve to get the filament to adhere to the bed. Many example can be found, popular ones are using blue tape, glass bed, glue stick, PVA based spray (e.g. strong hairspray or dedicated spray cans like 3DLAC or Dimafix, etc.), or a combination of these. You just need to experiment some more what works best for you, but it is good to start with a correctly levelled bed with the proper nozzle gap. Sometimes, increasing the bed and filament temperature with 5 °C for the first layer also helps.</p>
| <p>Chances are, you're not levelled close enough. try levelling your bed when it's heated around 60C (or as high as you can get if your machine's FW won't let it go that high) with a piece of standard printer paper. you should get a bit of resistance, and play around with the paper for a bit, find a happy medium. Try spreading glue stick on your bed, or spray it with hairspray. If you have BuildTak or some form of PEI, wipe it with some 99% rubbing alcohol. Lastly, find a fairly simple model on thingiverse.com or myminifactory.com, and slice it using either Raft or Skirt as build plate adhesion. I prefer a skirt because you can actively be checking how your bed levelling is, and adjust it. And make sure your first layer flow or extrusion multiplier is slightly higher is about 110-120%. This can get you good sticking almost every time.</p>
| 1,231 |
<p>I originally posted this on Meta StackExchange to judge whether my thoughts fit within SE and have been redirected back to our Meta.</p>
<p>We've received a few questions along the lines of purchasing references since we've opened in Beta. While I personally don't think direct questions about "<em>What is the best 3D printer to buy?</em>" are appropriate questions, I'm curious about a potential middle ground.</p>
<p>Should we consider including tags such as <a href="https://3dprinting.stackexchange.com/questions/tagged/printer-review" class="post-tag" title="show questions tagged 'printer-review'" rel="tag">printer-review</a>, <a href="https://3dprinting.stackexchange.com/questions/tagged/buyer-review" class="post-tag" title="show questions tagged 'buyer-review'" rel="tag">buyer-review</a>, or <a href="https://3dprinting.stackexchange.com/questions/tagged/printer-reference" class="post-tag" title="show questions tagged 'printer-reference'" rel="tag">printer-reference</a>? The idea being that certain questions would inherit one of these tags (or something similar) to help facilitate traffic to specific questions. These questions would pose ideally be (in the OP's eyes) useful in making a purchase decision. </p>
<p>Case in point:
<a href="https://3dprinting.stackexchange.com/questions/801/cons-to-uv-printing">This question</a>, outlining some of the potential relative cons to UV printing compared to FDM/FFF printing, could prove useful to someone looking into purchasing a new UV printer.</p>
<p>This idea can be combined with those proposed <a href="https://3dprinting.meta.stackexchange.com/questions/159/is-there-any-way-to-prevent-endless-best-first-printer-posts">here</a>, such as @TomvanderZanden's suggestion to create a series of controlled "best" questions.</p>
<p><strong>Amendment</strong></p>
<p>I might also suggest that if we, as a community, decide to use such a system have moderators lock these questions to avoid any sort of spam (unnecessary answers). These questions should also be set to <strong><em>community wiki</em></strong> to ensure that any bias is dealt with as a community.</p>
| <h2>I like the idea of incorporating product reviews into the 3dprinting StackExchange</h2>
<p><strong>Why?</strong></p>
<ol>
<li>It fits the Q&A model of Stack Exchange</li>
<li>Product pre-purchase questions are probably the number 1 question every new user wants to ask and needs to know (<a href="https://3dprinting.meta.stackexchange.com/questions/159/is-there-any-way-to-prevent-endless-best-first-printer-posts">as Ryan noted</a>). We should attempt to find a way to help provide that answer.</li>
<li>It provides a bridge to further questions. Once they purchase a printer, they will have questions.</li>
<li>Since it is the number 1 question for new users, what a great way to draw them to the site. When they search, they should find this site has the answer. </li>
<li>It gives us a way to point people on forums here. I often see links to reviews on forums. Why can't those point here? Once they are here, hopefully we will stay and contribute.</li>
<li>It would provide a great source of new content. The number of new products and new users are growing at an exponential rate. </li>
<li>If we do it right, it will help users and help move us forward on our Beta Goals.</li>
</ol>
<p><strong>Challenges</strong> </p>
<ol>
<li>We need to make sure the reviews are well done and are StackExchange style answers. What I mean by that is that where they will likely have some opinion-based content, the primary content should be based primarily on objective qualities. Maybe some sort of a "Style Guide", limitations on who can post, and peer review would help mitigate that. I am not that familiar with how to manage that on a StackExchange.</li>
<li>Maybe this is a repeat of #1 - UNIFORMITY. </li>
<li>Making sure the reviews doesn't become product advertisement / self promotions.</li>
</ol>
| <p>I've seen a few questions in the past week or so of people asking questions that would fit under the printer-review or buyer review tags you've suggested. However I don't think they are quite within the scope of the main site. </p>
<p>Specific questions regarding the benefits of one style of printer over another would be well suited to the site simply because they're less opinion based than than what a 'review' tag would tend to suggest. </p>
<p>The question you've posted as a reference, I would say is well suited to the SE since it's asking specific and quantifiable questions with potentially correct or incorrect answers. I think any question posed that could fit under a tag of "printer-review" would tend to be more opinion based regardless of how the question is phrased. I'm probably the worst out there for posting answers that are a mix of fact and opinion already, no need to encourage me to be more opinionated!</p>
| 33 |
<p>What is the best approach to write <strong>hooks</strong> for <strong>Subversion</strong> in <strong>Windows</strong>? As far as I know, only executable files can be used. So what is the best choice? </p>
<ul>
<li>Plain batch files (very limited but perhaps OK for very simple solutions)</li>
<li>Dedicated compiled executable applications (sledgehammer to crack a nutshell?)</li>
<li>Some other hybrid choice (like a batch file running a Powershell script)</li>
</ul>
| <p>I’ve just spent several days procrastinating about exactly this question. There are third party products available and plenty of PERL and Python scripts but I wanted something simple and a language I was familiar with so ended up just writing hooks in a C# console app. It’s very straight forward:</p>
<pre><code>public void Main(string[] args)
{
string repositories = args[0];
string transaction = args[1];
var processStartInfo = new ProcessStartInfo
{
FileName = "svnlook.exe",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = String.Format("log -t \"{0}\" \"{1}\"", transaction, repositories)
};
var p = Process.Start(processStartInfo);
var s = p.StandardOutput.ReadToEnd();
p.WaitForExit();
if (s == string.Empty)
{
Console.Error.WriteLine("Message must be provided");
Environment.Exit(1);
}
Environment.Exit(0);
}
</code></pre>
<p>You can then invoke this on pre commit by adding a pre-commit.cmd file to the hooks folder of the repo with the following line:</p>
<pre><code>[path]\PreCommit.exe %1 %2
</code></pre>
<p>You may consider this overkill but ultimately it’s only a few minutes of coding. What’s more, you get the advantage of the .NET language suite which IMHO is far preferable to the alternatives. I’ll expand my hooks out significantly and write appropriate tests against them as well – bit hard to do this with a DOS batch file!</p>
<p>BTW, the code has been adapted from <a href="http://irwinj.blogspot.com/2008/04/simple-subversion-trigger.html" rel="noreferrer">this post</a>.</p>
| <p>Depending on the complexity, each situation is different, If I am just simply moving files around, I'll write a quick batch file. If I want to do something more complex Ill normally just skip the scripting part and write a quick c# program that can handle it. </p>
<p>The question then is do you put that c# program in svn and have it versioned :)</p>
<p><strong>edit:</strong> The benefits of a dedicated c# application is that I can reuse code fragments to create new hooks later, including a simple log output I created to handle hook logging.</p>
| 2,711 |
<p>Recently I was talking to a co-worker about C++ and lamented that there was no way to take a string with the name of a class field and extract the field with that name; in other words, it lacks reflection. He gave me a baffled look and asked when anyone would ever need to do such a thing.</p>
<p>Off the top of my head I didn't have a good answer for him, other than "hey, I need to do it right now". So I sat down and came up with a list of some of the things I've actually done with reflection in various languages. Unfortunately, most of my examples come from my web programming in Python, and I was hoping that the people here would have more examples. Here's the list I came up with:</p>
<ol>
<li><p>Given a config file with lines like<br>
x = "Hello World!"<br>
y = 5.0<br>
dynamically set the fields of some <code>config</code> object equal to the values in that file. (This was what I wished I could do in C++, but actually couldn't do.)</p></li>
<li><p>When sorting a list of objects, sort based on an arbitrary attribute given that attribute's name from a config file or web request.</p></li>
<li><p>When writing software that uses a network protocol, reflection lets you call methods based on string values from that protocol. For example, I wrote an IRC bot that would translate<br>
<code>!some_command arg1 arg2</code><br>
into a method call <code>actions.some_command(arg1, arg2)</code> and print whatever that function returned back to the IRC channel.</p></li>
<li><p>When using Python's __getattr__ function (which is sort of like method_missing in Ruby/Smalltalk) I was working with a class with a whole lot of statistics, such as late_total. For every statistic, I wanted to be able to add _percent to get that statistic as a percentage of the total things I was counting (for example, stats.late_total_percent). Reflection made this very easy.</p></li>
</ol>
<p>So can anyone here give any examples from their own programming experiences of times when reflection has been helpful? The next time a co-worker asks me why I'd "ever want to do something like that" I'd like to be more prepared.</p>
| <p>I can list following usage for reflection:</p>
<ul>
<li>Late binding</li>
<li>Security (introspect code for security reasons)</li>
<li>Code analysis</li>
<li>Dynamic typing (duck typing is not possible without reflection)</li>
<li>Metaprogramming</li>
</ul>
<p>Some real-world usages of reflection from my personal experience:</p>
<ul>
<li>Developed plugin system based on reflection</li>
<li>Used aspect-oriented programming model</li>
<li>Performed static code analysis</li>
<li>Used various Dependency Injection frameworks</li>
<li>...</li>
</ul>
<p>Reflection is good thing :)</p>
| <p>Writing dispatchers. Twisted uses python's reflective capabilities to dispatch XML-RPC and SOAP calls. RMI uses Java's reflection api for dispatch.</p>
<p>Command line parsing. Building up a config object based on the command line parameters that are passed in.</p>
<p>When writing unit tests, it can be helpful to use reflection, though mostly I've used this to bypass access modifiers (Java).</p>
| 7,235 |
<p>I wonder what the best practice for this scenario is:</p>
<p>I have a Sharepoint Site (MOSS2007) with an ASPX Page on it. However, I cannot use any inline source and stuff like Event handlers do not work, because Sharepoint does not allow Server Side Script on ASPX Pages per default.</p>
<p>Two solutions:</p>
<ol>
<li><p>Change the <code>PageParserPath</code> in <em>web.config</em> as per <a href="http://blogs.msdn.com/kaevans/archive/2007/04/26/code-blocks-are-not-allowed-in-this-file-using-server-side-code-with-sharepoint.aspx" rel="nofollow noreferrer">this site</a> </p>
<pre><code><PageParserPaths>
<PageParserPath VirtualPath="/pages/test.aspx"
CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>
</code></pre></li>
<li><p>Create all the controls and Wire them up to Events in the <em>.CS</em> File, thus completely eliminating some of the benefits of ASP.net</p></li>
</ol>
<p>I wonder, what the best practice would be? Number one looks like it's the correct choice, but changing the <em>web.config</em> is something I want to use sparingly whenever possible.</p>
| <p>So in that case I would wrap it up in a feature and deploy it via a solution. This way I think you will avoid the issue you are seeing. This is especially useful if you plan to use this functionality within other sites too. </p>
<p>You can also embed web parts directly in the page, much like you do a WebControl, thereby avoiding any gallery clutter.</p>
| <p>Well, it's a page that hosts user controls. It's a custom .aspx Page that will be created on the site, specially because I do not want to create WebParts.</p>
<p>It's essentially an application running within Sharepoint, utilizing Lists and other functions, but all the functionality is only useful within the application, so flooding the web part gallery with countless web parts that only work in one place is something i'd like to avoid.</p>
| 6,290 |
<p>When creating a web application, and lets say you have a User object denoting a single user, what do you think is the best way to store that the user has logged in?</p>
<p>Two ways I've thought about have been:</p>
<ul>
<li>Stored the user database id in a session variable</li>
<li>Stored the entire user object in a session variable</li>
</ul>
<p>Any better suggestions, any issues with using the above ways? Perhaps security issues or memory issues, etc, etc.</p>
| <p>I recommend storing the id rather than the object. The downside is that you have to hit the database every time you want to get that user's information. However, unless every millisecond counts in your page, the performance shouldn't be an issue. Here are two advantages:</p>
<ol>
<li><p>If the user's information changes somehow, then you won't be storing out-of-date information in your session. For example, if a user is granted extra privileges by an admin, then those will be immediately available without the user needing to log out and then log back in.</p></li>
<li><p>If your session information is stored on the hard drive, then you can only store serializable data. So if your User object ever contains anything like a database connection, open socket, file descriptor, etc then this will not be stored properly and may not be cleaned up properly either.</p></li>
</ol>
<p>In most cases these concerns won't be an issue and either approach would be fine.</p>
| <p>I store the user in the session, usually. The can't-change-until login problem can be solved by replacing the object in the session with a new copy after you've made changes.</p>
| 4,135 |
<p>I've just noticed this Meta post, <a href="https://meta.stackexchange.com/q/364007/280335">Testing three-vote close and reopen on 13 network sites</a> and I wondered whether we should employ it here, and what do other people think?</p>
<p>We are a smallish site, with a smallish number of active users (although it isn't <em>that</em> small, and is slowly growing over time, it should be noted). We don't have a problem with review queues building up <em>except</em> with the close votes. Some questions do seem to hang around for a while in the close queue.</p>
<p>The problem with the close vote review queue requiring 5 votes when there is a <em>limited</em> number of active reviewers (where two of which are moderators) is this: If a moderator votes, then the question is automatically closed, even if there aren't 5 votes - if a moderator casts the first vote to close then the question is closed straight away, without waiting for another four votes - so the vote is not democratic, but instead, dictatorial in nature. As such, moderators tend to not vote, unless the question blatantly needs closing (i.e. spam, vulgarity, etc.).</p>
<p>There are ways around this problem:</p>
<ul>
<li>sock puppets (moderators have a fake account to cast votes only in the review queue), or;</li>
<li>waiting for four votes and then a moderator casting the fifth vote (or waiting for three votes and then moderators agreeing (behind the scenes) to cast the final two votes, etc.)</li>
</ul>
<p>However, these aren't ideal, and just shortening the queue might make things better. This need not be a permanent change, I guess, so if this site, for some reason, eventually exploded in popularity, the review queue <em>could</em> go back to five votes (but I'm not 100 % sure about that, see the SE.Meta post above to check).</p>
<p>So... should SE.3DP jump on the "three votes to close" train? Or are things OK as they are? What do other users think? <em>Please</em> leave a comment or answer.</p>
<p>To make things super simple, and if you don't have time to write a comment or answer, you can just vote on the <strong>Yes</strong> answer or the <strong>No</strong> answer.</p>
<h3>End of voting date</h3>
<p>To give this vote an end point, and not make it so opened-ended, I guess we should tally a "final" vote on the 1<sup>st</sup> July 2021 - which is May 6 (trial start date) plus 45 days (length of trial) plus a little bit more. As we can't join the trial halfway through, there isn't much point to tallying up the votes before that.</p>
<p>At that point Catija will be sent the results.</p>
| <h2>Yes, we should have a <em>three</em> vote close question review queue</h2>
| <h2>No, we should stay with the <em>five</em> vote close question review queue</h2>
| 79 |
<p>I need advice on how to have my C# console application display text to the user through the standard output while still being able access it later on. The actual feature I would like to implement is to dump the entire output buffer to a text file at the end of program execution.</p>
<p>The workaround I use while I don't find a cleaner approach is to subclass <code>TextWriter</code> overriding the writing methods so they would both write to a file and call the original stdout writer. Something like this:</p>
<pre><code>public class DirtyWorkaround {
private class DirtyWriter : TextWriter {
private TextWriter stdoutWriter;
private StreamWriter fileWriter;
public DirtyWriter(string path, TextWriter stdoutWriter) {
this.stdoutWriter = stdoutWriter;
this.fileWriter = new StreamWriter(path);
}
override public void Write(string s) {
stdoutWriter.Write(s);
fileWriter.Write(s);
fileWriter.Flush();
}
// Same as above for WriteLine() and WriteLine(string),
// plus whatever methods I need to override to inherit
// from TextWriter (Encoding.Get I guess).
}
public static void Main(string[] args) {
using (DirtyWriter dw = new DirtyWriter("path", Console.Out)) {
Console.SetOut(dw);
// Teh codez
}
}
}
</code></pre>
<p>See that it writes to and flushes the file all the time. I'd love to do it only at the end of the execution, but I couldn't find any way to access to the output buffer.</p>
<p>Also, excuse inaccuracies with the above code (had to write it <em>ad hoc</em>, sorry ;).</p>
| <p>The perfect solution for this is to use <a href="http://logging.apache.org/log4net/" rel="noreferrer">log4net</a> with a console appender and a file appender. There are many other appenders available as well. It also allows you to turn the different appenders off and on at runtime. </p>
| <p>Consider refactoring your application to separate the user-interaction portions from the business logic. In my experience, such a separation is quite beneficial to the structure of your program.</p>
<p>For the particular problem you're trying to solve here, it becomes straightforward for the user-interaction part to change its behavior from <code>Console.WriteLine</code> to file I/O.</p>
| 8,624 |
<p>I switched to the dvorak keyboard layout about a year ago. I now use <a href="https://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard" rel="nofollow noreferrer">dvorak</a> full-time at work and at home.</p>
<p>Recently, I went on vacation to Peru and found myself in quite a conundrum. Internet cafes were qwerty-only (and Spanish qwerty, at that). I was stuck with a hunt-and-peck routine that grew old fairly quickly.</p>
<p>That said, is it possible to be "fluent" in both qwerty and dvorak at the same time? If not, are there any good solutions to the situation I found myself in?</p>
| <h2>Web</h2>
<p>For your situation of being at a public computer that you cannot switch the keyboard layout on, you can go to this website:
<a href="http://www.dvzine.org/type/DVconverter.html" rel="noreferrer">http://www.dvzine.org/type/DVconverter.html</a></p>
<p>Use this to translate your typing and then use copy paste. I found this very useful when I was out of the country and had to write a bunch of emails at public computers.</p>
<h2>USB Drive</h2>
<p>Put this <a href="http://typedvorak.com/2007/07/22/the-best-way-to-use-dvorak-on-windows-dvassist/" rel="noreferrer">Dvorak Utility</a> on your USB drive. </p>
<p>Run this app and it will put a icon in the system tray on windows. This icon will switch the computer between the two keyboard layouts and it works. (If you have tried switching back and forth from dvorak to qwerty you will know what I mean. Windows does the worst job of this one bit of functionality.)</p>
| <p>I've never used a public computer, but carry a keyboard and(/or, if you are good enough) just change the settings on the machine.</p>
| 3,261 |
<p>Does anyone have any information about using a soldering iron to fix and retouch 3D prints?
On the market, for example, we can find Modifi3D pen. Why has nobody created a simple soldering tip for this use?</p>
<p>I have a TS100 soldering iron which has great temperature control and I think it would be perfect for this use.</p>
<p>Does anyone think it's a bad idea?</p>
| <p>I have used a standard soldering iron to modify and fix 3D prints in the past. You have to keep some things in mind when doing so:</p>
<ul>
<li>Don't overheat your material. PLA can take a soldering iron of about 230 °C before charring.</li>
<li>Don't use a tip with solder, or you will get grey deposits in the plastic.</li>
<li>Round tips or flat tips both work fine, but you want to not dump <em>too</em> much heat into the model or you start to deform the print as it needs to cool again.</li>
<li>Using snippets from the end of the spool for soldering is a good way to recycle the "waste".</li>
</ul>
| <p>Cutting materials with a 'hot knife' isn't anything new. There should be a fairly established toolset for working foam. For 3D prints, I prefer to add coatings rather than modify surfaces with a hand held tool after. I do run a drill bit through printed holes though.</p>
| 1,911 |
<p>I want to compress some files (into the <a href="http://en.wikipedia.org/wiki/ZIP_%28file_format%29" rel="nofollow noreferrer">ZIP</a> format) and encrypt them if possible using C#. Is there some way to do this?</p>
<p>Can encryption be done as a part of the compression itself?</p>
| <p>For compression, look at the <a href="http://msdn.microsoft.com/en-us/library/system.io.compression.aspx" rel="nofollow noreferrer"><code>System.IO.Compression</code></a> namespace and for encryption look at <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.aspx" rel="nofollow noreferrer"><code>System.Security.Cryptography</code></a>.</p>
| <p>Here is a useful topic:</p>
<p><a href="https://stackoverflow.com/questions/71000/help-in-creating-zip-files-from-net-and-reading-them-from-java">Help in creating Zip files from .Net and reading them from Java</a></p>
<p>System.IO.Packaging namespace gives you useful classes to compress data in zip format and <a href="http://msdn.microsoft.com/en-us/library/ms580548.aspx" rel="nofollow noreferrer">support</a> rights management.</p>
| 9,652 |
<p>I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it should interface with Visual Studio either naively or through another plug-in, outside of that, anything that works would be nice to be replace Gmail as source control.</p>
| <p>You can use <a href="http://www.assembla.com/home" rel="nofollow noreferrer">assembla.com</a> to host your project. They offer subversion, git and mercurial hosting. I personally use their subversion hosting for a free and private one-man project. As an added bonus, you also get a wiki and a ticketing system. Which can help you manage your stuff.</p>
<p>And the best thing is that you don't have to setup your subversion server and it is hosted off-site.</p>
<p>It's really good for a free service. </p>
<p>Personnaly, i use <a href="http://tortoisesvn.tigris.org/" rel="nofollow noreferrer">TortoiseSVN</a> as my client but it isn't integrated in visual studio.</p>
<p>For the integration, you can try <a href="http://www.visualsvn.com/visualsvn/" rel="nofollow noreferrer">VisualSVN</a> (not free) or <a href="http://ankhsvn.open.collab.net/" rel="nofollow noreferrer">AnkhSVN</a> (free)</p>
| <p>i will never use SVN again for a personal project - ya its great compared to CVS, but isn't even in the same class as the modern breed of distributed version control systems. GIT has been mentioned already but a) it has shaky windows support b) complicated learning curve. I now use BZR which "just works".</p>
<p><a href="http://bazaar-vcs.org/BzrVsGit" rel="nofollow noreferrer">bzr vs git</a><br>
<a href="http://doc.bazaar-vcs.org/latest/en/mini-tutorial/index.html" rel="nofollow noreferrer">bzr in 5 minutes</a></p>
| 3,753 |
<p>What are the pros / cons of using <code>pthread_cond_wait</code> or using a semaphore ?
I am waiting for a state change like this :</p>
<pre><code>pthread_mutex_lock(&cam->video_lock);
while(cam->status == WAIT_DISPLAY) {
pthread_cond_wait(&cam->video_cond, &cam->video_lock);
}
pthread_mutex_unlock(&cam->video_lock);
</code></pre>
<p>Using a properly initialised semaphore, I think I could do it like this :</p>
<pre><code>while(cam->status == WAIT_DISPLAY) {
sem_wait(&some_semaphore);
}
</code></pre>
<p>What are the pros and cons of each method ?</p>
| <p>A semaphore is suited cleanly to a producer-consumer model, although it has other uses. Your program logic is responsible for ensuring that the right number of posts are made for the number of waits. If you post a semaphore and nobody is waiting on it yet, then when they do wait they continue immediately. If your problem is such that it can be explained in terms of the count value of a semaphore, then it should be easy to solve with a semaphore.</p>
<p>A condition variable is a bit more forgiving in some respects. You can for example use cond_broadcast to wake up all waiters, without the producer knowing how many there are. And if you cond_signal a condvar with nobody waiting on it then nothing happens. This is good if you don't know whether there's going to be a listener interested. It is also why the listener should always check the state with the mutex held before waiting - if they don't then they can miss a signal and not wake up until the next one (which could be never).</p>
<p>So a condition variable is suitable for notifying interested parties that state has changed: you acquire the mutex, change the state, signal (or broadcast) the condvar and release the mutex. If this describes your problem you're in condvar territory. If different listeners are interested in different states you can just broadcast and they'll each in turn wake up, figure out whether they've found the state they want, and if not wait again.</p>
<p>It's very gnarly indeed to attempt this sort of thing with a mutex and a semaphore. The problem comes when you want to take the mutex, check some state, then wait on the semaphore for changes. Unless you can atomically release the mutex and wait on the semaphore (which in pthreads you can't), you end up waiting on the semaphore while holding the mutex. This blocks the mutex, meaning that others can't take it to make the change you care about. So you will be tempted to add another mutex in a way which depends on your specific requirements. And maybe another semaphore. The result is generally incorrect code with harmful race conditions.</p>
<p>Condition variables escape this problem, because calling cond_wait automatically releases the mutex, freeing it for use by others. The mutex is regained before cond_wait returns.</p>
<p>IIRC it is possible to implement a kind of condvar using only semaphores, but if the mutex you're implementing to go with the condvar is required to have trylock, then it's a serious head-scratcher, and timed waits are out. Not recommended. So don't assume that anything you can do with a condvar can be done with semaphores. Plus of course mutexes can have nice behaviours that semaphores lack, principally priority-inversion avoidance.</p>
| <p>In your second snippet, you're getting the lock multitude of times, never releasing it.</p>
<p>In general, the state you're waintin on can be completely expressed by a semaphore, then you can use just that. A lock structure is smaller in size, and it requires less atomic operations to check/set/release.</p>
<p>Otherwise, if the state is complex, and different parts of the code wait on different conditions of the same variable (eg, here you want x<10; there you want y>x), use cond_wait.</p>
| 9,624 |
<p>I've noticed a lot of sites, SO included, use XHTML as their mark-up language and then fail to adhere to the spec. Just browsing the source for SO there are missing closing tags for paragraphs, invalid elements, etc.</p>
<p>So should tools (and developers) use the XHTML doctype if they are going to produce invalid mark up? And should browsers be more firm in their acceptance of poor mark-up?</p>
<p>And before anyone shouts hypocrite, my blog has one piece of invalid mark-up involving the captha (or it did the last time I checked) which involves styling the noscript tag.</p>
| <p>There are <a href="https://validator.w3.org/docs/why.html" rel="nofollow noreferrer">many reasons</a> to use valid markup. My favorite is that it allows you to use validation as a form of regression testing, preventing the markup equivalent of "delta rot" from leading to real rendering problems once the errors reach some critical mass. And really, it's just plain sloppy to allow "lazy" errors like typos and mis-nested/unclosed tags to accumulate. Valid markup is one way to identify <a href="https://web.archive.org/web/20100913081355/http://stackoverflow.com:80/questions/3247/identifying-passionate-programmers" rel="nofollow noreferrer">passionate programmers</a>.</p>
<p>There's also the issue of debugging: valid markup also gives you a stable baseline from which to work on the inevitable cross-browser compatibility woes. No web developer who values his time should begin debugging browser compatibility problems without first ensuring that the markup is at least <em>syntactically</em> valid—and any other invalid markup should have a good reason for being there.</p>
<p>(Incidentally, stackoverflow.com fails both these tests, and suggestions to fix the problems <a href="http://stackoverflow.uservoice.com/pages/general/suggestions/14739" rel="nofollow noreferrer">were</a> <a href="http://stackoverflow.uservoice.com/pages/general/suggestions/14740" rel="nofollow noreferrer">declined</a>.)</p>
<p>All of that said, to answer your specific question, it's probably not worthwhile to use one of the XHTML doctypes unless you plan to produce valid (or at <em>least</em> well-formed) markup. XHTML's primary advantages are derived from the fact that XHTML is XML, allowing it to be processed and transformed by tools and technologies that work with XML. If you don't plan to make your XHTML well-formed XML, then there's little point in choosing that doctype. The latest HTML 4 spec will probably do everything you need, and it's much more forgiving.</p>
| <p>It depends. I had that <a href="http://www.stum.de/2008/02/29/valid-xhtml-and-youtube-embedding/" rel="nofollow noreferrer">issue with my blog</a> where a YouTube video caused invalid XHTML, but it rendered fine. On the other hand, I have a "Valid XHTML" link, and a combination of a "Valid XHTML" claim and invalid XHTML is not professional.</p>
<p>As SO does not claim to be valid, I think it's acceptable, but personally if I were Jeff i would be bothered and try to fix it even if it looks good in modern browsers, but some people rather just move on and actually get things done instead of fixing non-existent bugs.</p>
| 2,557 |
<p>Is there a way of getting the process id of my C++ application? I am using the Carbon framework, but not Cocoa…</p>
| <p>can you use the getpid() function found in unistd.h ?</p>
<p><a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpid.2.html" rel="nofollow noreferrer">osx reference</a></p>
| <p>GetProcessPID is what you need. This takes a ProcessSerialNumber, which you can obtain from GetCurrentProcess.</p>
| 6,305 |
<p>I keep reading about people who are "test infected", meaning that they don't just "get" TDD but also can't live without it. They've "had the makeover" as it were. The question is, how do I get like that?</p>
| <p>Part of the point of being "test infected" is that you've used TDD enough and seen the successes enough that <strong>you don't want to code without it</strong>. Once you've gone through a cycle of writing tests first, then coding and refactoring and seeing your bug counts go down and your code get better as a result, not only does it become second nature like Zxaos said, you have a hard time going back to Code First. This is being test infected.</p>
| <p>One word, practice! There is some overhead with doing TDD and the way to overcome it is to practice and make sure you are using tools to help the process. You need to learn the tools like the back of your hand. Once you learn the tools to go along with the process you are learning, then it will click and you will get fluent with writing tests first to flush the code out. Then you will be "test infected".</p>
<p>I <a href="https://stackoverflow.com/questions/24965/beginning-tdd-challenges-solutions-recommendations#25203">answered</a> a question similar to this a while back. You may want to check it out also. I mention some tools and explain learning TDD. Out of these tools, Resharper and picking a good mocking framework are critical for doing TDD. I can't stress learning these tools to go along with the testing framework you are using enough.</p>
| 6,995 |
<p>I've always been intrigued by Map Routing, but I've never found any good introductory (or even advanced!) level tutorials on it. Does anybody have any pointers, hints, etc?</p>
<p><strong>Update:</strong> I'm primarily looking for pointers as to how a map system is implemented (data structures, algorithms, etc).</p>
| <p>Take a look at the <a href="http://www.openstreetmap.org/" rel="noreferrer">open street map project</a> to see how this sort of thing is being tackled in a truely free software project using only user supplied and licensed data and have a <a href="http://wiki.openstreetmap.org/index.php/Main_Page" rel="noreferrer">wiki containing stuff you might find interesting</a>.</p>
<p>A few years back the guys involved where pretty easy going and answered lots of questions I had so I see no reason why they still aren't a nice bunch.</p>
| <p>Another thought occurs to me regarding the cost of each traversal, but would increase the time and processing power required to compute. </p>
<p><strong>Example:</strong> There are 3 ways I can take (where I live) to go from point A to B, according to the GoogleMaps. Garmin units offer each of these 3 paths in the <code>Quickest</code> route calculation. After traversing each of these routes many times and averaging (obviously there will be errors depending on the time of day, amount of caffeine etc.), I feel the algorithms could take into account the number of bends in the road for high level of accuracy, <strong>e.g.</strong> <em>straight road of 1 mile will be quicker than a 1 mile road with sharp bends in it</em>.
Not a practical suggestion but certainly one I use to improve the result set of my daily commute.</p>
| 2,493 |
<p>All my prints come out about 1 mm too short in the Z dimension. So for example a 20 mm cube comes out 19 mm high. A 10 mm cube comes out 9 mm high. The X and Y dimensions are fine. There's a little bit of visible elephant's foot at the bottom, so I assume whatever is happening is in the first couple of layers. The problem is fairly consistently around 1 mm even for larger prints.</p>
<p><a href="https://i.stack.imgur.com/Pjuev.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pjuev.jpg" alt="10 mm test cube" /></a>
<a href="https://i.stack.imgur.com/RSPfi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RSPfi.jpg" alt="20 mm test cube" /></a></p>
<p>The printer is an Ender 3 Pro with a glass bed and BLTouch for automatic leveling, but otherwise stock.</p>
<p>I had a <a href="https://3dprinting.stackexchange.com/questions/13940/expansion-in-bottom-skin-after-first-layer">similar issue with another Ender 3 Pro</a> that was resolved thanks to a link to <a href="https://3dprinting.stackexchange.com/questions/8022/first-3-mm-prints-poorly-then-fine-after-that">this question about problems in the first 3 mm</a>. The solution was turning the eccentric nuts on the left and right to loosen the rollers that connect the X-axis gantry to the vertical posts. There the Z issue was not as pronounced, and I was getting really messy prints in the first few Z layers. Here that is not an issue; the first few layers look fine while they're printing. Loosening the rollers did not resolve it.</p>
<p>Things I've tried:</p>
<ul>
<li>Tightening and loosening the gantry rollers using the eccentric nuts. They're currently just tight enough that turning them moves the gantry, but loose enough that I can turn them without moving the gantry if I hold it still.</li>
<li>Tightening and loosening the two little screws that attach the extruder mount to the Z-axis lead screw. Currently I made them just tight, then backed off 1/4 turn.</li>
<li>Adding a shim between the vertical post and the Z-axis lead screw. The lead screw is now pretty much parallel to the post.</li>
<li>Slowly turning the lead screw by hand to raise and lower the gantry. There's no noticeable catching or increased resistance anywhere.</li>
<li>Varying the brand and type of PLA filament.</li>
<li>Varying the temperature from 190 °C to 210 °C.</li>
<li>Obsessively leveling and re-leveling the bed. Manually leveling, auto leveling with the BLTouch, and adjusting the z-offset.</li>
</ul>
<p>I'm using the stock Ender 3 Pro profile in Cura, and printing at 0.2 mm layer height. I've kind of run out of things to check. What else can cause Z height loss in the first few layers like this?</p>
| <p>Do you have any “slop” on the right side (non motor) of the gantry?</p>
<p>I’ve noticed that my gantry will settle on the right side and lag behind the motor driven - ever so slightly - when it starts to drive up. It will, after that first lag, move fine for the rest of the time. Z axis travel seems barely affected but all my prints are consistently about 0.5 mm short.</p>
| <p>I have the exact same issue on my Ender 3 V2, perfect bed level using a dial gauge,
perfect first layer test prints (printing 9 squares all 1 layer high).</p>
<p>I can only get rid of it two ways:</p>
<ol>
<li>Using a Raft as you have said (annoying).</li>
<li>Adjusting the Z-height Just exactly as the 1st layer finishes. I raise the height by 0.15-0.20 mm (in my case), and the resulting elephant foot is about 80-90 % better.</li>
</ol>
<p>I recommend you follow Luke Hatfields guide on Ender 3 rework for The X-Gantry, as well as his other sections. Youtube channel "Edge Of Tech" does a decent job covering the rework in video form. Following most of these reworks I have made everything else in the print absolutely perfect, unfortunately EF remains.</p>
| 1,701 |
<p>I have a printer with a 0.1 mm typical layer thickness. Of course I can choose some different sizes in Cura or other slicing software, but most prints on this machine will be .1mm. In my (admittedly limited) experience thus far, the 0.1 mm seems typical for other printers, too.</p>
<p>I want to get a sense of just how thick this is. I know about the paper trick for leveling the print bed, but my understanding is the first layer pushes into the bed a little, meaning it's less than 0.1 mm and so paper isn't a good example for the typical layer. </p>
<p>Is there a similar item with close to 0.1 mm thickness I can use to visualize this?</p>
| <p>I'm not sure exactly what you mean by your comment to Davo's answer, but with respect to your use of a sheet of paper reference, it seems like you can still use <em>80 gsm</em> paper as a reference for 0.1 mm layers.</p>
<p>From <a href="http://www.printware.co.uk/Blog/311/Paper-Sizes-Explained.html" rel="nofollow noreferrer">Paper Sizes Explained</a> (emphasis is mine):</p>
<blockquote>
<p>There is no universal calculation for the thickness of paper based on the gsm as varitaions in paper composition can affect the weight, so two different brands of 120gsm paper could have slightly different thicknesses. However, <strong>an average sheet of 80gsm paper, the most commonly used weight, measures approximately 0.1mm in thickness</strong>, which means that <em>10 sheets would measure 1mm</em>. By comparison, <em>10 sheets of 120gsm paper would be 1.5mm thick</em>, assuming the paper composition was the same.</p>
</blockquote>
<p>So, given that:</p>
<ul>
<li>80 gsm => 0.1 mm</li>
<li>120 gsm => 0.15 mm</li>
</ul>
<p>Then </p>
<ul>
<li>40 gsm => 0.05 mm</li>
<li>60 gsm => 0.075 mm</li>
</ul>
<p>From <a href="http://www.officexpress.co.uk/paper-guide/" rel="nofollow noreferrer">A Guide to Paper Types and Sizes</a></p>
<pre><code>Paper Weight Descriptions
Weight Feels Similar to:
35-55 gsm Most newspapers
90 gsm Mid-market magazine inner pages
130-250 gsm A good quality promotional poster
180-250 gsm Mid-market magazine cover
350 gsm Most reasonable quality business cards
</code></pre>
<p>So, it would appear that you could use a newspaper sheet (or two) to test for layers of less than 0.1 mm. Obviously this would depend upon where in the world you are, and the (physical) quality of your newspapers. Here in the UK, or rather Europe, the <em>exported version</em> of the Guardian used to be printed on some extremely lightweight paper (almost transparent tissue thin), in order to keep the costs of transport down to a minimum. So a folded sheet of that would certainly be in the range of 0.75 - 0.99 mm (which seems to be the range that you are looking for). However, given that the printed media (as opposed to the online version) is currently in decline, I am not entirely sure if it is still available.</p>
<p>Or, how about grease proof paper? From the <a href="https://en.wikipedia.org/wiki/Greaseproof_paper" rel="nofollow noreferrer">Wikipedia entry</a>:</p>
<blockquote>
<p>Basis weights are usually 30–50 g/m²</p>
</blockquote>
<p>Although, this paper has been processed (<a href="https://en.wikipedia.org/wiki/Supercalendered" rel="nofollow noreferrer">supercalandered</a>) and treated with starch, which will increase the density, so the thickness will not correlate to the table above (i.e. it will be thinner).</p>
<p>Giftwrap paper (not the really thick stuff) could be another option.</p>
<p>After having doing some long winded googling, I guess that the best bet would be to get hold of a micrometer and measure whatever paper yourself, as the specifications of paper are generally given in <code>gsm</code> and not <code>mm</code> (which is a bit annoying), and so it is somewhat difficult to provide you with a definitive answer (without physically measuring it).</p>
| <p>IMO, better way for the thickness visualization is the <a href="https://en.wikipedia.org/wiki/Feeler_gauge" rel="nofollow noreferrer">feeler gauge</a>. Also it can be successfully used for the calibration of gap between the nozzle and the hotbed (instead paper)</p>
| 993 |
<p>I am currently working on a project that is moving from .NET 2.0 to 3.5 across the board.</p>
<p>I am well aware that 3.5 is basically a set of added functionality (libraries, if you will) on top of what 2.0 offers.</p>
<p>Are there any gotchas that I might hit by simply re-targeting the compiler to 3.5?</p>
| <p>This isn't a gotcha, it's more of a heads up. .NET v3.0 and v3.5 are not new CLRs but simply an added set up assemblies, compilers, resources etc...</p>
<p><strong>Both .NET v3.0 AND v3.5 use the v2.0 CLR.</strong> Because of this you won't be able to say set an IIS App Pool to use a v3.5 CLR...cause it doesn't exist.</p>
<p>Discussed in a little more detail here:
<a href="http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx" rel="noreferrer">http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx</a></p>
| <p>Nope</p>
<p>3.5 is completely compatible with 2.0, not the other way around of course</p>
| 8,168 |
<p>I have a scenario where I need to make a call to a telephone(landline/mobile) or send SMS to a particular set of users only using ASP.NET and C#. The web application is not a mobile application.</p>
<p>How do I go about doing these? What typically would be the hardware requirements? I would be <strong>extremely grateful</strong> if you could provide me with pointers and reference websites.</p>
| <p>Most carriers provide an email address that you can send text messages to — for example, with Verizon, you can send an email to <em>[email protected]</em> and it will show up as a text message to that number.</p>
<p><a href="http://en.wikipedia.org/wiki/SMS_gateway#Carrier-provided_Email_or_Web_to_SMS_gateways" rel="nofollow noreferrer">Wikipedia</a> has a full list of the carrier-provided email addresses.</p>
<p>By sending text messages as "emails" you can take advantage of <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.aspx" rel="nofollow noreferrer">System.Net.Mail</a> and the like.</p>
| <p>Via <a href="http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=20" rel="nofollow noreferrer">WebServiceX</a>, you can send SMS messages anywhere in the world. For phone calls I'd use <a href="http://www.codeproject.com/KB/IP/AsteriskIAXClientWrapper.aspx" rel="nofollow noreferrer">Asterisk</a>.</p>
| 6,714 |
<p>I was considering printing some pieces for my irrigation system, like tube connectors and such. I am aware that PLA is hydrophilic so I was wondering with what kind of product I could coat the pieces, non-toxicity is a requirement because it will water edible greens.</p>
<p>So, what kind of non-toxic product can I use to coat PLA to make it hydrophobic?</p>
| <p>Before worrying too much about the hydrophilic properties of PLA, it might be worthwhile to test a fitting.</p>
<p>First, print a fitting and see that the freshly made print is strong enough to carry the pressure of the water, and the compression force of hose clamp you may need to connect the stiff irrigation hose to the printed fitting. </p>
<p>Second, soak the printed fitting in water for month or two, perhaps at an elevated temperature to match the higher ground temperature in the summer. You could put the part in a closed mason jar and leave it in the sun. You might add a little salt and fertilizer to the water to simulate ground conditions.</p>
<p>After this aging process, you could test to see if it withstands the pressure of the domestic water system.</p>
<p>You might also measure the ground temperatures where you intend to use the fittings. I find that PLA has no structural strength above about 150 degrees Fahrenheit (65 degrees Centigrade), and the inability to resist slow plastic may start at an even lower temperature. [For example, I print structural PLA parts with negative clearances and then dip them in 160 degree F water to soften them.]</p>
<p>If the printed fittings are strong enough but suffer from water absorption, I would either print them of ABS or coat them with an ABS coating. To make the coating, dissolve ABS in acetone until it is the consistency of thick cream, dip your fitting in the mixture, and allow them to dry. It will take longer than you think it should to dry, and the solution will take more ABS plastic than you might expect.</p>
<p>ABS is not generally considered to be "food safe", but this isn't a potable water system. The FDA lists ABS as conditionally food safe, and I would be comfortable using it to irrigate my lawn and vegetables.</p>
| <p>PLA will biodegrade over time. ABS would last longer, and stand up to higher temps.</p>
| 887 |
<p>I'm using TinyMCE in an ASP.Net project, and I need a spell check. The only TinyMCE plugins I've found use PHP on the server side, and I guess I could just break down and install PHP on my server and do that, but quite frankly, what a pain. I don't want to do that.</p>
<p>As it turns out, Firefox's built-in spell check will work fine for me, but it doesn't seem to work on TinyMCE editor boxes. I've enabled the gecko_spellcheck option, which is supposed to fix it, but it doesn't.</p>
<p>Does anybody know of a nice rich-text editor that doesn't break the browser's spell check?</p>
| <p>TinyMCE only goes out of its way to disable spell-checking when you don't specify the <code>gecko_spellcheck</code> option (i verified this with their example code). Might want to double-check your <code>tinyMCE.init()</code> call - it should look something like this:</p>
<pre><code>tinyMCE.init({
mode : "textareas",
theme : "simple",
gecko_spellcheck : true
});
</code></pre>
| <p>I know at least <a href="http://developer.yahoo.com/yui/editor/" rel="nofollow noreferrer">yahoo!'s Rich Text Editor</a> will let you use the included spell checker in FireFox.</p>
<p>I also tested FCKeditor, but that requires the users to install additional plugins on their computer.</p>
| 4,353 |
<p>How can I go about hosting flash content inside a WPF form and still use transparency/alpha on my WPF window? Hosting a WinForms flash controls does not allow this.</p>
| <p>Unless the control you use to display the Flash content is built in WPF, you will run in to these "airspace" issues. Every display technology from Win32 to WinForms used HWNDs "under the hood", but WPF uses DirectX. The Window Manager in Windows however, still only understands HWNDs, so WPF apps have one top-level HWND-based window, and everything under that is done in DirectX (actually things like context menus and tooltips also have top-level HWNDs as well). Adam Nathan has a very good description of WPF interop in <a href="http://www.ddj.com/windows/197003872?pgno=1" rel="nofollow noreferrer">this article</a>.</p>
| <p>Just have been struggling with same problem of how to upload & Make WPF transparent with ability of displaying Flash, because if you enable on your MainWindow "Allow transparency" Flash will not show once the application will run.</p>
<p><strong>1)</strong> I used WebBrowser Control to play Flash(.swf) files. They are on my PC, however it can play from internet or wherever you have hosted them. Don't forget to name your WebBrowser Control to get to it in C#.</p>
<pre><code> private void Window_Loaded(object sender, RoutedEventArgs e)
{
MyHelper.ExtendFrame(this, new Thickness(-1));
this.MyBrowser.Navigate(@"C:\Happy\Download\flash\PlayWithMEGame.swf");
}
</code></pre>
<p><strong>2)</strong> Now for transparency. I have set in WPF 'false' to "Allow Transparency" and set "Window Style" to 'None'. After that I have used information from <a href="https://stackoverflow.com/questions/4253665/wpf-window-transparency-while-hosting-a-flash-activex-component?rq=1">HERE</a> and <a href="http://blogs.msdn.com/b/adam_nathan/archive/2006/05/04/589686.aspx" rel="nofollow noreferrer">HERE</a> and created a following code that produced desired effect of allowing transparency on MainWindow and running Flash at same time, here is my code:</p>
<pre><code>public class MyHelper
{
public static bool ExtendFrame(Window window, Thickness margin)
{
IntPtr hwnd = new WindowInteropHelper(window).Handle;
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
return true;
}
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
}
struct MARGINS
{
public MARGINS(Thickness t)
{
Left = (int)t.Left;
Right = (int)t.Right;
Top = (int)t.Top;
Bottom = (int)t.Bottom;
}
public int Left;
public int Right;
public int Top;
public int Bottom;
}
</code></pre>
<p>And called it from Window_Loaded() + you need 'below' line for 'DllImport' to work.</p>
<pre><code>using System.Runtime.InteropServices;
using System.Windows.Interop;
</code></pre>
| 9,273 |
<p>I will be creating a small tube styled piece to use as a junction between two pieces of plastic. The idea is to reattach the two pieces and provide strength so they don't break apart again. I plan on using PLA.</p>
<p>My question is, will superglue (cyanoacrylate) work best for this or are there better choices for attaching PLA to hard (injected molded) plastic? The big thing I'm wanting to make sure is if any of these glues will dissolve the PLA and whether some glues might bond better than others.</p>
| <p>PLA is a nice one, and gluing has been a topic on some of our most favorite maker's channels. For example Stefan from CNC kitchen (<a href="https://www.youtube.com/watch?v=JSff8OMRHtw" rel="nofollow noreferrer">this video</a>) and Joel the 3DPrinting Nerd (<a href="https://www.youtube.com/watch?v=s1q2D_pK0BE" rel="nofollow noreferrer">this video</a>). Also, in 2022, <a href="https://youtu.be/dGE509zjf7E" rel="nofollow noreferrer">Tom's 3D</a> ran a test on glues for PLA, PETG and resin prints. Here some information from them together with my own experiences. Most of these glues are not exactly PLA specific by the way and work for many other materials too. Be careful with PLA containing infil though, as that can seriously alter the properties.</p>
<h2>Step 0: Safety First!</h2>
<p>Some of these methods are working with chemicals that can irritate the skin (resin, cyanoacrylate), have irritating fumes (acetone), or are flammable (acetone). Others (Cyanoacrylate) are not heat-stable and break down into their components under heat.</p>
<h3>Use proper protection when working with glue! Eye protection and respiratory protection, as well as gloves, are to be used when necessary. Read the manual of the products you are working with!</h3>
<h2>Preparations</h2>
<p>For most glues, it is advisable to prepare the surface: sand it to increase the surface area, remove grease from fingerprints etc. Follow the manual!</p>
<h2>Glues</h2>
<ul>
<li>Cyanoacrylate - yep, the "one kind for all" is a solution for PLA too: Superglue. However, look out for what type you get! Some are clearly better than others, and using an accelerator can change the properties of the glue spot.
<ul>
<li>Together with talcum powder, CA glue ("superglue") can fill gaps easily. However, a gap-bridging bond isn't the strongest, and working can be finicky. Yet if the parts do sit flush, a CA glue bond can be a almost as strong as any 2-component glue bond tested, according to Tom.</li>
<li><strong>CA is not stable under heating and when heated too much it breaks apart into a rather noxious fume!</strong> This can be handy to break metal-CA-metal bonds in machining of small parts but keep this in mind if you want to use inserts or plastic-soler pieces on the same areas! Don't tack with CA in those cases.</li>
</ul>
</li>
<li>Epoxy resin - Epoxy is a favorite for very tough gluing, a few droplets can stick a car to the roof... and it warms up in curing. If you take a slow
curing resin, you can safely use it to glue PLA without the part deforming.
<ul>
<li><strong>Uncured Resin and their hardeners are strong skin irritants.</strong></li>
</ul>
</li>
<li>2-Component Acrylic resin is just as good as epoxy often, as Tom noticed. It's very comparable to Epoxy in performance.</li>
<li><a href="http://www.adhesives.org/adhesives-sealants/adhesives-sealants-overview/adhesive-technologies/chemically-curing/two-component-(2-c)/urethane-adhesives" rel="nofollow noreferrer">Urethanes</a> - 2 Component Urethanes offer strong but flexible bonds and work great according to Joel. Their curing process is also exothermic, so take care to not 'cook' your piece.</li>
<li>2-phase Putty - in a similar vein come 2-phase putties like <a href="https://www.games-workshop.com/en-FI/Green-Stuff" rel="nofollow noreferrer">Green Stuff</a> or <a href="https://www.milliput.com/" rel="nofollow noreferrer">Miliputt</a>, which harden after mixing. Their heat generation isn't too big and they allow to fill gaps easily. My favorite stuff though is not the expensive modeling putty but the stuff from the home depot: stuff like <a href="http://www.pattex.de/do-it-yourself-mit-pattex-klebstoffe-produkte-new/pattex-klebstoffe/reparaturkleber/repair-express.html" rel="nofollow noreferrer">Pattex Repair</a><sup>sorry, no English site for this</sup> or <a href="http://www.uhu.com/en/products/epoxy-adhesives-2-component/detail/uhu-repair-all-powerkitt-1.html?cHash=e0f929a3ec974e591e89c5e1987a30ab&step=70" rel="nofollow noreferrer">UHU Repair All Powerkitt</a> harden within an hour, are surprisingly cheap and get a smooth surface.</li>
<li>Acetone - We all know that you can smooth and glue ABS with Acetone or an acetone-ABS slurry. <a href="https://www.youtube.com/watch?v=VZUfq0yrtv4" rel="nofollow noreferrer">Tom (Thomas Sanladerer)</a> made a few experiments with it. He discovered that it works for at least <em>some</em> types of PLA in the following fashion: apply some acetone to a spot and press the second piece (that also was prepared this way) to it and they might melt themselves together after some time.
<ul>
<li>Effectivity of this depends <strong>very highly</strong> on the exact PLA you got.</li>
<li><strong>Acetone is highly flammable.</strong></li>
</ul>
</li>
<li>There's a type of glues commonly called "Kraftkleber" or "Alleskleber" in Germany, for example, <a href="http://www.uhu.com/en/products/special-adhesives/detail/uhu-hart-kunststoff-1.html?cHash=9e818145273de580c4e3c132faad3710&step=202" rel="nofollow noreferrer">UHU Hart</a> or <a href="http://www.pattex.de/do-it-yourself-mit-pattex-klebstoffe-produkte-new/pattex-klebstoffe/kontaktkleber-gel-fuer-schwierige-oberflaechen/kraftkleber-transparent.html" rel="nofollow noreferrer">Pattex Kraftkleber</a><sup>German</sup>. While they often <em>stick</em> to PLA, I personally don't like their gluing power and find them often quite messy to work with. Also, they very much fail in loadbearing joints.</li>
<li>Wood Glue - Yes, Wood Glue. PVA Wood glue as well as its non-water-soluble cousin ("Express") have proven themselves to me as a rather nice surface coating to smooth over print lines as well as a good solution to affix paper and wood to prints. It is less of a solution for plastic-plastic bonds but works OK-ish.</li>
</ul>
<h2>Glue? Why glue?!</h2>
<h3>"Solder"</h3>
<p>What better way is there to combine parts than welding or soldering?! Often none. My personal all-time-favorite PLA <em>glue</em> is PLA itself, by using it as <strong>PLA solder</strong>. This method also works for most other filament types, but is not advisable for ABS and other plastics that emit fumes without wearing respiratory protection! In any case, you need to work with an exhaust, as you heat your plastic in a not always fully controllable way. If you can, use a soldering station where you can set the temperature of the iron.</p>
<ul>
<li>Take the pieces and make sure on both sides is a cavity that can be filled.</li>
<li>Take a soldering iron and set it to around 200°C.</li>
<li>Take a length of PLA filament.</li>
<li>Melt the filament with the soldering iron and use it as solder when combining the two pieces. Make sure that at least some filament gets into the cavities and sticks there - it can help to stick the soldering iron into the goop in there to force it to merge with the infill/walls and press together to hot PLA goop filled pieces against the iron before pulling it away, pressing the pieces together.</li>
<li>As the PLA cools and hardens, the joint is usually tougher than the actual layer boundaries.</li>
</ul>
<h3>Pen</h3>
<p>Instead of using a soldering iron, one might also use a 3D printing pen<sup>One that eats filament, not one for PCL or some gel!</sup>, but I don't like those personally.</p>
<h3>Inserts!</h3>
<p>On a different note, a soldering iron is also a very good solution to make inserts into PLA - heat up the metal insert (like a nut) and press it into an undersized hole, and it will mold the plastic around itself into a perfect fit without any glue.</p>
<h3>Friction Welding</h3>
<p>An alternative to using direct heat from a soldering iron is <strong>friction welding</strong>. For this, take a rotary power tool and some filament. Insert the filament into the tool, tighten and cut so that about an inch is reaching out of the claw. Turn it on at medium speed, about 800 to 1200 RPM. Now, once you press the tip of the spinning filament against other PLA it gets hot and melts, creating a welding seam. <a href="https://www.youtube.com/watch?v=Pa2DoE3sirU" rel="nofollow noreferrer">Joel</a> has a good explanation.</p>
| <p><a href="https://www.3dgloop.com/shop/pla-gloop" rel="nofollow noreferrer">PLA Gloop</a> is dedicated glue for PLA. It contains chloroform, so be careful.</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=gTtW_NXFMCY" rel="nofollow noreferrer">3D Gloop! // 3D Printing Adhesive Spotlight</a></li>
<li><a href="https://www.youtube.com/watch?v=vQc5TBPF8uw" rel="nofollow noreferrer">PLA Smoothing 3D Prints with 3D Gloop!</a></li>
</ul>
<p>Additionally a PrusaPrinters guide: <a href="https://blog.prusaprinters.org/the-great-guide-to-gluing-and-assembling-3d-prints_44908/" rel="nofollow noreferrer">The Great Guide to Gluing and Assembling 3D Prints</a></p>
| 1,011 |
<p>How can I use the nifty JavaScript date and time widgets that the default admin uses with my custom view?</p>
<p>I have looked through <a href="https://docs.djangoproject.com/en/dev/topics/forms/" rel="noreferrer">the Django forms documentation</a>, and it briefly mentions django.contrib.admin.widgets, but I don't know how to use it?</p>
<p>Here is my template that I want it applied on.</p>
<pre><code><form action="." method="POST">
<table>
{% for f in form %}
<tr> <td> {{ f.name }}</td> <td>{{ f }}</td> </tr>
{% endfor %}
</table>
<input type="submit" name="submit" value="Add Product">
</form>
</code></pre>
<p>Also, I think it should be noted that I haven't really written a view up myself for this form, I am using a generic view. Here is the entry from the url.py:</p>
<pre><code>(r'^admin/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),
</code></pre>
<p>And I am relevantly new to the whole Django/MVC/MTV thing, so please go easy...</p>
| <p>The growing complexity of this answer over time, and the many hacks required, probably ought to caution you against doing this at all. It's relying on undocumented internal implementation details of the admin, is likely to break again in future versions of Django, and is no easier to implement than just finding another JS calendar widget and using that.</p>
<p>That said, here's what you have to do if you're determined to make this work:</p>
<ol>
<li><p>Define your own <code>ModelForm</code> subclass for your model (best to put it in forms.py in your app), and tell it to use the <code>AdminDateWidget</code> / <code>AdminTimeWidget</code> / <code>AdminSplitDateTime</code> (replace 'mydate' etc with the proper field names from your model):</p>
<pre><code> from django import forms
from my_app.models import Product
from django.contrib.admin import widgets
class ProductForm(forms.ModelForm):
class Meta:
model = Product
def __init__(self, *args, **kwargs):
super(ProductForm, self).__init__(*args, **kwargs)
self.fields['mydate'].widget = widgets.AdminDateWidget()
self.fields['mytime'].widget = widgets.AdminTimeWidget()
self.fields['mydatetime'].widget = widgets.AdminSplitDateTime()
</code></pre>
</li>
<li><p>Change your URLconf to pass <code>'form_class': ProductForm</code> instead of <code>'model': Product</code> to the generic <code>create_object</code> view (that'll mean <code>from my_app.forms import ProductForm</code> instead of <code>from my_app.models import Product</code>, of course).</p>
</li>
<li><p>In the head of your template, include <code>{{ form.media }}</code> to output the links to the Javascript files.</p>
</li>
<li><p>And the hacky part: the admin date/time widgets presume that the i18n JS stuff has been loaded, and also require core.js, but don't provide either one automatically. So in your template above <code>{{ form.media }}</code> you'll need:</p>
<pre><code> <script type="text/javascript" src="/my_admin/jsi18n/"></script>
<script type="text/javascript" src="/media/admin/js/core.js"></script>
</code></pre>
</li>
</ol>
<p>You may also wish to use the following admin CSS (thanks <a href="https://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form/719583#719583">Alex</a> for mentioning this):</p>
<pre><code> <link rel="stylesheet" type="text/css" href="/media/admin/css/forms.css"/>
<link rel="stylesheet" type="text/css" href="/media/admin/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/media/admin/css/global.css"/>
<link rel="stylesheet" type="text/css" href="/media/admin/css/widgets.css"/>
</code></pre>
<p>This implies that Django's admin media (<code>ADMIN_MEDIA_PREFIX</code>) is at /media/admin/ - you can change that for your setup. Ideally you'd use a context processor to pass this values to your template instead of hardcoding it, but that's beyond the scope of this question.</p>
<p>This also requires that the URL /my_admin/jsi18n/ be manually wired up to the django.views.i18n.javascript_catalog view (or null_javascript_catalog if you aren't using I18N). You have to do this yourself instead of going through the admin application so it's accessible regardless of whether you're logged into the admin (thanks <a href="https://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form/408230#408230">Jeremy</a> for pointing this out). Sample code for your URLconf:</p>
<pre><code>(r'^my_admin/jsi18n', 'django.views.i18n.javascript_catalog'),
</code></pre>
<p>Lastly, if you are using Django 1.2 or later, you need some additional code in your template to help the widgets find their media:</p>
<pre><code>{% load adminmedia %} /* At the top of the template. */
/* In the head section of the template. */
<script type="text/javascript">
window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
</script>
</code></pre>
<p>Thanks <a href="https://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form/2818128#2818128">lupefiasco</a> for this addition.</p>
| <p>In Django 10.
myproject/urls.py:
at the beginning of urlpatterns</p>
<pre><code> from django.views.i18n import JavaScriptCatalog
urlpatterns = [
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
.
.
.]
</code></pre>
<p>In my template.html:</p>
<pre><code>{% load staticfiles %}
<script src="{% static "js/jquery-2.2.3.min.js" %}"></script>
<script src="{% static "js/bootstrap.min.js" %}"></script>
{# Loading internazionalization for js #}
{% load i18n admin_modify %}
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script type="text/javascript" src="{% static "/admin/js/jquery.init.js" %}"></script>
<link rel="stylesheet" type="text/css" href="{% static "/admin/css/base.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "/admin/css/forms.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "/admin/css/login.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "/admin/css/widgets.css" %}">
<script type="text/javascript" src="{% static "/admin/js/core.js" %}"></script>
<script type="text/javascript" src="{% static "/admin/js/SelectFilter2.js" %}"></script>
<script type="text/javascript" src="{% static "/admin/js/admin/RelatedObjectLookups.js" %}"></script>
<script type="text/javascript" src="{% static "/admin/js/actions.js" %}"></script>
<script type="text/javascript" src="{% static "/admin/js/calendar.js" %}"></script>
<script type="text/javascript" src="{% static "/admin/js/admin/DateTimeShortcuts.js" %}"></script>
</code></pre>
| 5,950 |
<p>I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks!</p>
| <blockquote>
<p>Or is it only useful as a transport mechanism for code?</p>
</blockquote>
<p>It's useful as an <em>execution mechanism</em> for code. Using the <a href="http://en.wikipedia.org/wiki/Interpreter_pattern" rel="noreferrer">interpreter pattern</a>, expression trees can directly be interpreted. This is useful because it's very easy and fast to implement. Such interpreters are ubiquitous and used even in cases that don't seem to “interpret” anything, e.g. for printing nested structures.</p>
| <p>Expression trees are useful when you need to access function logic in order to alter or reapply it in some way.</p>
<p>Linq to SQL is a good example:</p>
<pre><code>//a linq to sql statement
var recs (
from rec in LinqDataContext.Table
where rec.IntField > 5
select rec );
</code></pre>
<p>If we didn't have expression trees this statement would have to return all the records, and then apply the C# where logic to each.</p>
<p>With expression trees that <code>where rec.IntField > 5</code> can be parsed into SQL:</p>
<pre><code>--SQL statment executed
select *
from [table]
where [table].[IntField] > 5
</code></pre>
| 4,736 |
<p>I have the following query:</p>
<pre><code>select column_name, count(column_name)
from table
group by column_name
having count(column_name) > 1;
</code></pre>
<p>What would be the difference if I replaced all calls to <code>count(column_name)</code> to <code>count(*)</code>?</p>
<p>This question was inspired by <a href="https://stackoverflow.com/questions/59232/how-do-i-find-duplicate-values-in-a-table-in-oracle">How do I find duplicate values in a table in Oracle?</a>.</p>
<hr>
<p>To clarify the accepted answer (and maybe my question), replacing <code>count(column_name)</code> with <code>count(*)</code> would return an extra row in the result that contains a <code>null</code> and the count of <code>null</code> values in the column.</p>
| <p><code>count(*)</code> counts NULLs and <code>count(column)</code> does not</p>
<p>[edit] added this code so that people can run it</p>
<pre><code>create table #bla(id int,id2 int)
insert #bla values(null,null)
insert #bla values(1,null)
insert #bla values(null,1)
insert #bla values(1,null)
insert #bla values(null,1)
insert #bla values(1,null)
insert #bla values(null,null)
select count(*),count(id),count(id2)
from #bla
</code></pre>
<p>results
7 3 2</p>
| <p>It is best to use</p>
<pre><code>Count(1) in place of column name or *
</code></pre>
<p>to count the number of rows in a table, it is faster than any format because it never go to check the column name into table exists or not</p>
| 8,383 |
<p>What's the best way to asynchronously load an BitmapImage in C# using WPF? </p>
| <p>I was just looking into this and had to throw in my two cents, though a few years after the original post (just in case any one else comes looking for this same thing I was looking into). </p>
<p>I have an <strong>Image</strong> control that needs to have it's image loaded in the background using a <strong>Stream</strong>, and then displayed. </p>
<p>The problem that I kept running into is that the <strong>BitmapSource</strong>, it's <strong>Stream</strong> source and the <strong>Image</strong> control all had to be on the same thread.</p>
<p>In this case, using a Binding and setting it's IsAsynch = true will throw a cross thread exception. </p>
<p>A BackgroundWorker is great for WinForms, and you can use this in WPF, but I prefer to avoid using the WinForm assemblies in WPF (bloating of a project is not recommended, and it's a good rule of thumb too). This should throw an invalid cross reference exception in this case too, but I didn't test it.</p>
<p>Turns out that one line of code will make any of these work:</p>
<pre><code>//Create the image control
Image img = new Image {HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = System.Windows.VerticalAlignment.Stretch};
//Create a seperate thread to load the image
ThreadStart thread = delegate
{
//Load the image in a seperate thread
BitmapImage bmpImage = new BitmapImage();
MemoryStream ms = new MemoryStream();
//A custom class that reads the bytes of off the HD and shoves them into the MemoryStream. You could just replace the MemoryStream with something like this: FileStream fs = File.Open(@"C:\ImageFileName.jpg", FileMode.Open);
MediaCoder.MediaDecoder.DecodeMediaWithStream(ImageItem, true, ms);
bmpImage.BeginInit();
bmpImage.StreamSource = ms;
bmpImage.EndInit();
//**THIS LINE locks the BitmapImage so that it can be transported across threads!!
bmpImage.Freeze();
//Call the UI thread using the Dispatcher to update the Image control
Dispatcher.BeginInvoke(new ThreadStart(delegate
{
img.Source = bmpImage;
img.Unloaded += delegate
{
ms.Close();
ms.Dispose();
};
grdImageContainer.Children.Add(img);
}));
};
//Start previously mentioned thread...
new Thread(thread).Start();
</code></pre>
| <p>Use or extend System.ComponentModel.BackgroundWorker:<br>
<a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx</a></p>
<p>Personally, I find this to be the easiest way to perform asynchronous operations in client apps. (I've used this in WinForms, but not WPF. I'm assuming this will work in WPF as well.)</p>
<p>I usually extend Backgroundworker, but you dont' have to.</p>
<pre><code>public class ResizeFolderBackgroundWorker : BackgroundWorker
{
public ResizeFolderBackgroundWorker(string sourceFolder, int resizeTo)
{
this.sourceFolder = sourceFolder;
this.destinationFolder = destinationFolder;
this.resizeTo = resizeTo;
this.WorkerReportsProgress = true;
this.DoWork += new DoWorkEventHandler(ResizeFolderBackgroundWorker_DoWork);
}
void ResizeFolderBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
DirectoryInfo dirInfo = new DirectoryInfo(sourceFolder);
FileInfo[] files = dirInfo.GetFiles("*.jpg");
foreach (FileInfo fileInfo in files)
{
/* iterate over each file and resizing it */
}
}
}
</code></pre>
<p>This is how you would use it in your form:</p>
<pre><code> //handle a button click to start lengthy operation
private void resizeImageButtonClick(object sender, EventArgs e)
{
string sourceFolder = getSourceFolderSomehow();
resizer = new ResizeFolderBackgroundWorker(sourceFolder,290);
resizer.ProgressChanged += new progressChangedEventHandler(genericProgressChanged);
resizer.RunWorkerCompleted += new RunWorkerCompletedEventHandler(genericRunWorkerCompleted);
progressBar1.Value = 0;
progressBar1.Visible = true;
resizer.RunWorkerAsync();
}
void genericRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
progressBar1.Visible = false;
//signal to user that operation has completed
}
void genericProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
//I just update a progress bar
}
</code></pre>
| 5,736 |
<p>We are looking for a way to automate windows forms for acceptance testing. Our requirements are:</p>
<ul>
<li><strong>Must be usable by non-developers</strong> (ie: people with no development environment installed)</li>
<li>Must have a recorder</li>
<li>Must support third-party controls</li>
<li>Must have basic functionality (allow clicking on buttons, inputing text, validating results, accros multiple windows if necessary)</li>
</ul>
<p>Basically, something like <a href="http://selenium.openqa.org/" rel="nofollow noreferrer">Selenium</a>, but for windows forms.</p>
| <blockquote>
<p>Must be usable by non-developers</p>
</blockquote>
<p>Any not-web test automation tool will need either dev`s well-known ide (Eclipse etc.) or test tool ide. SilkTest, TestComplete etc. will also make u to write some code.</p>
<p>U can separate work between devs and testers using tool for creating "executable requirements" like <a href="http://fitnesse.org" rel="nofollow noreferrer">"Fitnesse"</a> or <a href="http://www.concordion.org/" rel="nofollow noreferrer">Concordion</a></p>
| <p>The Vermont HighTest:
<a href="http://www.vtsoft.com/vcsproducts/index.html" rel="nofollow noreferrer">http://www.vtsoft.com/vcsproducts/index.html</a></p>
<p>The 30 day trial looked pretty good!</p>
| 9,758 |
<p>Is it ready for that?</p>
<p>I've been playing with it for a short amount of time and it seems quite reasonable. Is anyone using it for live sites?</p>
<p>any issues to be aware of?</p>
| <p>Well, <a href="http://stackoverflow.com">stackoverflow.com</a> is.</p>
| <p>Stackoverflow uses ASP.Net MVC. Seems to be doing pretty well here from my experience with the site.</p>
| 9,394 |
<p>I have a small JS function that does Ajax for me and another like it that adds in POST data to the request. With Ajax being such a big topic with so many libraries about it, what am I missing from my function, is it insecure or something else worrying?</p>
<pre><code>function loadPage(pagePath, displayElement)
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById(displayElement).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", pagePath, true);
xmlHttp.send(null);
}
</code></pre>
| <p>I strongly recommend you not roll your own Ajax code. Instead, use a framework such as Prototype, Dojo, or any of the others. They've taken care of handling all the ReadyStates you're not handling (2 means it's been sent, 3 means it's in process, etc.), and they should escape the reponse you're getting so you don't insert potentially insecure javascript or something into your page.</p>
<p>Another thing a more robust framework will give you is the ability to do more than just use innerHTML to replace items in the DOM. Your function here can only be used to replace one element with the response from the ajax call. There's a lot more you can do with Ajax.</p>
| <p>If you really want to see what you are missing, read the jQuery or Prototype source code for their ajax routines. If there are bug numbers in the comments, look those up as well.</p>
| 5,471 |
<p>I thought that I had the latest CTP of PowerShell 2 but when I try the command:</p>
<p><code>invoke-expression –computername Server01 –command 'get-process PowerShell'</code></p>
<p>I get an error message:<br>
<strong>A parameter cannot be found that matches parameter name 'computername'.</strong></p>
<p>So the question is: How can I tell which version of PowerShell I have installed? And what the latest version is?</p>
| <p><code>$host.version.tostring()</code> will return the version number.</p>
<p>RTM of v1 is 1.0.0.0</p>
<p>Couldn't honestly tell you what the latest version of the previews are because I haven't had a chance to play yet.</p>
| <p>I'm guessing that this is a change to the cmdlet made during the configuration process Configure-Wsman.ps1. I don't have an environment setup to test right now, but I'm guessing something went wrong with the configuration. I can verify that on XP the parameter is not available (duh). I'd assume that you will find the same on Vista/08 without the configuration completed.</p>
| 3,352 |
<p>I would like to create an SSL connection for generic TCP communication. I think I figured out how to do it in the code, using the info here: <a href="http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.aspx</a>
What I'm having trouble with is creating a cert so I can test this out. I tried makecert.exe testCert, and that created a cert, but apparently it doesn't have a private key associated with it. So what I'm looking for is the simplest procedure to create a cert and get the connection to work.</p>
| <p>I haven't found a <em>simple</em> way to do this yet, but I found <a href="http://www.herongyang.com/crypto/openssl_crt.html" rel="nofollow noreferrer">this site</a> helpful a few months back.</p>
<p>O'Reilly also published a book called Network Security Hacks (available on Safari) that has a section starting at Hack #45 on creating your own certificate authority.</p>
| <p>For anybody else attempting this the pkcs12 certificate created as detailed here <a href="https://stackoverflow.com/questions/440762/openssl-command-line-troubles">openssl question</a> and using the X509Certificate2.CreateFromCertFile method gets past the private key problem. Note I used openssl with cygwin on Windows.</p>
| 4,114 |
<p>I wondered if anyone can give an example of a professional use of RSS/Atom feeds in a company product. Does anyone use feeds for other things than updating news?</p>
<p>For example, did you create a product that gives results as RSS/Atom feeds? Like price listings or current inventory, or maybe dates of training lessons?</p>
<p>Or am I thinking in a wrong way of use cases for RSS/Atom feeds anyway?</p>
<p><strong>edit</strong> @<a href="https://stackoverflow.com/users/573/abyx">abyx</a> has a really good example of a somewhat unexpected use of RSS as a way to get <em>debug</em> information from program transactions. I like the idea of this process. This is the type of use I was thinking of - besides publishing search results or last changes (like <a href="http://www.mediawiki.org" rel="nofollow noreferrer">mediawiki</a>)</p>
| <p>Some of my team's new systems generate RSS feeds that the developers syndicate.
These feeds push out events that interest the developers at certain times and the information is controlled using different loggers. Thus when debugging you can get the debugging feed, when you want to see completed transactions you go to the transactions feeds etc.
This allows all the developers to get the information they want in a comfortable way and without any need to mess a lot with configuration. If you don't want to get it there's no need to remove yourself from a mailing list or edit a configuration file - simply remove the feed and <em>be done with it</em>.</p>
<p>Very cool, and the idea was stolen from Pragmatic Project Automation.</p>
| <p>I have seen RSS used to syndicate gas prices from a service for a specific zip code.</p>
| 3,691 |
<p>I understand how JS is run and I think I understand most of the DOM but I've no idea about animation. Does anybody here know of a good guide that can explain to me how it's done in Javascript?</p>
<p>In addition, should I even consider Javascript for animation? Should I instead be looking to learn flash?</p>
| <p>Avoid flash, its a horrible requirement, uncrawlable by Google, unsopported by a bunch of browsers and systems (eg iPhone) and most importantly: it forces you to reinvent web standards (e.g. scroll bars and whatnot), Javascript on the other hand is easier to maintain and code for in the noscript case.</p>
<p>try <a href="http://script.aculo.us/" rel="nofollow noreferrer">scriptaculous</a> for your animations;</p>
<ul>
<li><a href="http://woork.blogspot.com/2008/01/toggle-effect-using-scriptaculous.html" rel="nofollow noreferrer">here's a quickie 3-line tutorial so
you can see it working</a></li>
<li><a href="http://www.tutorialspoint.com/script.aculo.us/index.htm" rel="nofollow noreferrer">here's a more complete tutorial</a></li>
<li><a href="http://github.com/madrobby/scriptaculous/wikis" rel="nofollow noreferrer">here's the scriptaculous wiki</a></li>
</ul>
<p>note that there are a gazillion JS animation libraries, some really good <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a> comes to mind. Usually they're just a script tag and an onclick event to setup.</p>
<p>Good luck!</p>
<p>/mp</p>
| <p>If you aren't concerned with IE support, you could also try experimenting with the canvas element:</p>
<p>MOZILLA DEVELOPER NETWORK <a href="https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations" rel="nofollow noreferrer">Basic animations</a></p>
| 3,130 |
<p>Although I'm specifically interested in web application information, I would also be somewhat curious about desktop application development as well. This question is driven by my work on my personal website as well as my job, where I have developed a few features, but left it to others to integrate into the look and feel of the site.</p>
<p>Are there any guides or rules of thumb for things like color schemes, layouts, formatting, etc? I want to ensure readability and clarity for visitors, but not be bland and dull at the same time.</p>
<p>As for my knowledge in this area - If you hand me a picture, I have enough knowledge to reproduce it on the screen, but if you ask me to design a new interface or redesign an existing one, I wouldn't know where to begin.</p>
| <p>Usually, each operating System has user Interface Guidelines. For Windows, have a <a href="http://blogs.msdn.com/acoat/archive/2006/09/27/773148.aspx" rel="nofollow noreferrer">look here</a>. (Edit: The links in that post are broken. But a Search for "<a href="http://search.msdn.microsoft.com/Default.aspx?query=User+Interface+Guidelines&brand=msdn&locale=en-us&refinement=" rel="nofollow noreferrer">User Interface Guidelines</a>" on MSDN has articles about everything)</p>
<p>Apple has it's own as well. Also, you may want to keep <a href="https://developer.gnome.org/accessibility-devel-guide/stable/gad-ui-guidelines.html.en" rel="nofollow noreferrer">accessibility</a> in mind.</p>
| <p>As for desktop applications: Whatever you do, do not use hand-picked colors. Stick with the named system colors such as "Window Background", "Menu Text", etc. Otherwise, people relying on OS accessibility features will be locked with your color choices (unable to choose a high-contrast theme, for instance) and to people who like to customize their desktop themes will think your application is fugly.</p>
| 2,721 |
<p>I want our team to develop against local instances of an Oracle database. With MS SQL, I can use SQL Express Edition. What are my options?</p>
| <p>Oracle has an express edition as well. I believe it is more limited though (IIRC, you can only have one database on an instance)</p>
<p><a href="http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html" rel="noreferrer">Oracle XE</a></p>
| <p>I don't recommend Oracle XE. My co-workers and I have been doing a project in Oracle and got severely tripped up after trying to use XE for our local development instances. The database worked fine until we started running local stress tests, at which point it started dropping connections.</p>
<p>I don't know whether this is an intentional, documented limitation or if perhaps we each just hit a weird bug, but I strongly recommend that you stay away from XE. When we both switched over to the full version, our problems immediately went away.</p>
<p>Also, Oracle doesn't require any kind of licensing confirmation for the full server; you have to click something to say that you have indeed acquired a license, but it doesn't make you prove it. So if you indeed have a license to use Oracle, there's no reason why you can't just install the full version on your development machines.</p>
| 4,558 |
<p>I'm having some inheritance issues as I've got a group of inter-related abstract classes that need to all be overridden together to create a client implementation. Ideally I would like to do something like the following:</p>
<pre><code>abstract class Animal
{
public Leg GetLeg() {...}
}
abstract class Leg { }
class Dog : Animal
{
public override DogLeg Leg() {...}
}
class DogLeg : Leg { }
</code></pre>
<p>This would allow anyone using the Dog class to automatically get DogLegs and anyone using the Animal class to get Legs. The problem is that the overridden function has to have the same type as the base class so this will not compile. I don't see why it shouldn't though, since DogLeg is implicitly castable to Leg. I know there are plenty of ways around this, but I'm more curious why this isn't possible/implemented in C#.</p>
<p><strong>EDIT</strong>: I modified this somewhat, since I'm actually using properties instead of functions in my code. </p>
<p><strong>EDIT</strong>: I changed it back to functions, because the answer only applies to that situation (covariance on the value parameter of a property's set function <strong>shouldn't</strong> work). Sorry for the fluctuations! I realize it makes a lot of the answers seem irrelevant.</p>
| <p>The short answer is that GetLeg is invariant in its return type. The long answer can be found here: <a href="http://blogs.msdn.com/ericlippert/archive/2007/10/16/covariance-and-contravariance-in-c-part-one.aspx" rel="noreferrer">Covariance and contravariance</a></p>
<p>I'd like to add that while inheritance is usually the first abstraction tool that most developers pull out of their toolbox, it is almost always possible to use composition instead. Composition is slightly more work for the API developer, but makes the API more useful for its consumers.</p>
| <p>Right, I understand that I can just cast, but that means the client has to know that Dogs have DogLegs. What I'm wondering is if there are technical reasons why this isn't possible, given that an implicit conversion exists.</p>
| 6,913 |
<p>When launching a process from Java, both stderr and stdout can block on output if I don't read from the pipes. Currently I have a thread that pro-actively reads from one and the main thread blocks on the other.</p>
<p>Is there an easy way to join the two streams or otherwise cause the subprocess to continue while not losing the data in stderr? </p>
| <p>Set the redirectErrorStream property on ProcessBuilder to send stderr output to stdout:</p>
<pre><code>ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectErrorStream(true);
</code></pre>
<p>You should then create a thread to deal with the process stream, something like the following:</p>
<pre><code>Process p = builder.start();
InputHandler outHandler = new InputHandler(p.getInputStream());
</code></pre>
<p>Where InputHandler is defined as:</p>
<pre><code>private static class InputHandler extends Thread {
private final InputStream is;
private final ByteArrayOutputStream os;
public InputHandler(InputStream input) {
this.is = input;
this.os = new ByteArrayOutputStream();
}
public void run() {
try {
int c;
while ((c = is.read()) != -1) {
os.write(c);
}
} catch (Throwable t) {
throw new IllegalStateException(t);
}
}
public String getOutput() {
try {
os.flush();
} catch (Throwable t) {
throw new IllegalStateException(t);
}
return os.toString();
}
}
</code></pre>
<p>Alternatively, just create two InputHandlers for the InputStream and ErrorStream. Knowing that the program will block if you don't read them is 90% of the battle :)</p>
| <p>Just have two threads, one reading from stdout, one from stderr?</p>
| 8,946 |
<p>I'm trying to use the following code but it's returning the wrong day of month.</p>
<pre><code>Calendar cal = Calendar.getInstance();
cal.setTime(sampleDay.getTime());
cal.set(Calendar.MONTH, sampleDay.get(Calendar.MONTH)+1);
cal.set(Calendar.DAY_OF_MONTH, 0);
return cal.getTime();
</code></pre>
| <p>Get the number of days for this month:</p>
<p><pre><code>
Calendar cal = Calendar.getInstance();
cal.setTime(sampleDay.getTime());
int noOfLastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
</pre></code></p>
<p>Set the Calendar to the last day of this month:</p>
<p><pre><code>
Calendar cal = Calendar.getInstance();
cal.setTime(sampleDay.getTime());
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
</pre></code></p>
| <p>I think this should work nicely:</p>
<pre><code>Dim MyDate As Date = #11/14/2012# 'This is just an example date
MyDate = MyDate.AddDays(DateTime.DaysInMonth(MyDate.Year, MyDate.Month) - MyDate.Day)
</code></pre>
| 9,800 |
<p>I've been using Emacs's sql interactive mode to talk to the MySQL db server and gotten to enjoy it. A developer has set up another db on a new non-default port number but I don't know how to access it using sql-mysql.</p>
<p>How do I specify a port number when I'm trying to connect to a database?</p>
<p>It would be even better if Emacs can prompt me for a port number and just use the default if I don't specify. Any chances of that?</p>
| <p>After digging through the sql.el file, I found a variable that allows me to specify a port when I try to create a connection.</p>
<p>This option was added GNU Emacs 24.1.</p>
<blockquote>
<p><strong>sql-mysql-login-params</strong></p>
<p>List of login parameters needed to connect to MySQL.</p>
</blockquote>
<p>I added this to my Emacs init file:</p>
<pre><code>(setq sql-mysql-login-params (append sql-mysql-login-params '(port)))
</code></pre>
<p>The default port is 0. If you'd like to set that to the default MySQL port you can customize <code>sql-port</code></p>
<pre><code>(setq sql-port 3306) ;; default MySQL port
</code></pre>
<p>There is a <code>sql-*-login-params</code> variable for all the popular RDMS systems in GNU Emacs 24.1. <code>sql-port</code> is used for both MySQL and PostreSQL</p>
| <pre><code>(setq sql-mysql-options (list "-P <port number>"))
</code></pre>
| 3,369 |
<p>I've just built my son's A6 and have connected all cables apart from the last power cables. The mainboard says hotbed line and extruder line but the cable says heatbed.</p>
<p>The cables are two red which are crimped together and two black crimped together.</p>
<p>All of the videos online show a different mainboard and connections.
There are more connections than cables because the wires are crimped.</p>
<p>I can't get my head around which wires go where, any ideas?</p>
| <p>The manual appears to be available here, <a href="https://www.elektor.com/amfile/file/download/file/1606/product/8457/&usg=AOvVaw3bQeEWg--MsnW9KbsTKc_c" rel="nofollow noreferrer">Installation Instruction_Anet A6 3D Printer - Elektor</a></p>
<p>However, according to <a href="https://www.thingiverse.com/groups/anet-a6/forums/general/topic:15480#comment-1342949" rel="nofollow noreferrer">this comment</a> from <a href="https://www.thingiverse.com/groups/anet-a6/forums/general/topic:15480" rel="nofollow noreferrer">Hard copy of the build guide?</a>, there is a mistake in the PDF of the manual, with respect to the heatbed, and as such, it is better to follow the videos:</p>
<blockquote>
<p>I find it is better to use the 3 videos:</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=hOasLyRQk3E" rel="nofollow noreferrer">3D Printer Instruction--Anet 3D Printer A6 Assembly Video 1</a></li>
<li><a href="https://www.youtube.com/watch?v=mQzOHL_89nc" rel="nofollow noreferrer">3D Printer Instruction--Anet 3D Printer A6 Assembly Video 2</a></li>
<li><a href="https://www.youtube.com/watch?v=uars72RdzK8" rel="nofollow noreferrer">Printer Instruction- A6 - Hot Bed Level Adjustment and Print Test</a></li>
</ul>
<p>Only errors in the videos and i believe the instuction the Hetbed
fixing plate i have build diffrently , rotated by 180 degrees
vertical, since it is better for the belt and somewhere in the video
during fixating of the end-switch and the blower he interchanged the
screws.</p>
</blockquote>
<p>However, looking at the manual, if it is to be believed, then be aware that <em>as well as</em> one connection for the extruder motor, there are two connectors <em>each</em> for <em>both</em> the extruder and the hotbed heaters:</p>
<ul>
<li>One for the separate heating elements, of the extruder and hotbed respectively, and;</li>
<li>One for the thermistor sensor (both the extruder <em>and</em> the hotbed have separate thermistors).</li>
</ul>
<p>This makes <em>five in total</em> for the extruder and the hotbed combined.</p>
<p><a href="https://i.stack.imgur.com/WCBtC.jpg" rel="nofollow noreferrer" title="Mainboard A6"><img src="https://i.stack.imgur.com/WCBtC.jpg" alt="Mainboard A6" title="Mainboard A6" /></a></p>
<p>However, the power connections for the Extruder <em>motor</em> has four pins (in white at the top), whereas the heating elements for the hotbed and the extruder have two pins and are of a different shape (in green on the left). The sensor connections for both the extruder and the sensor have three pins (in white at the bottom), but it should be easy not to confuse them, so long as you follow the wires to check to which component they go to.</p>
<hr />
<h3>Additional points to be aware of</h3>
<p>From <a href="https://www.thingiverse.com/groups/anet-a6/forums/general/topic:15480#comment-1343762" rel="nofollow noreferrer">this comment</a> in the same thread:</p>
<blockquote>
<p>I just built an A6 three weeks ago and with the videos it is really a
breeze to assemble the unit.</p>
<p>Just pay attention to the heat bed mounting plate as it is installed
bottoms up in the video. The bar connecting the outer two plates where
the heat bed is finally mounted should be below the plates, not above
as in the video.</p>
<p>Also, if you still have time, order some decent toothed belt, Igus
Drylin RJ4JP-01, and toothwheels for the Y and X belts and replace the
original pulleys, bearings, and belts before you even assemble the
unit. I just changed mine last week and it does make a hell of a
difference - with this little upgrades (cost me less than 30$ for
everything - at Amazon) you upgrade from an okay printer to a really
decent machine.</p>
<ul>
<li>The belt: <a href="https://rads.stackoverflow.com/amzn/click/com/B0152ZNDLK" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Anycubic-Meters-Timing-Pulleys-Printer/dp/B0152ZNDLK</a></li>
<li>The pulleys: <a href="https://rads.stackoverflow.com/amzn/click/com/B0188HW4Z0" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Aluminum-Bearing-Timing-3D-printers/dp/B0188HW4Z0</a></li>
<li>The bearings: <a href="https://rads.stackoverflow.com/amzn/click/com/B06XPRCMJS" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Printer-Solid-Polymer-LM8UU-Bearing/dp/B06XPRCMJS</a>
(actually, you need 8 pieces - not seven as in the images - 4 for the
Y-axis and 4 for the X-axis)</li>
</ul>
<p>The above are not the actual articles I've bought because I am from
Europe where Amazon sells in different quantities.</p>
<p>If you want to go on the safe side, grab a second power supply and two
MOSFET boards to remove the high current from the mainboard:</p>
<ul>
<li>PSU: <a href="https://rads.stackoverflow.com/amzn/click/com/B00D7CWSCG" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/eTopxizu-Universal-Regulated-Switching-Computer/dp/B00D7CWSCG</a>
(just as an example)</li>
<li>MOSFET: <a href="https://rads.stackoverflow.com/amzn/click/com/B01MY50JL3" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Wangdd22-Printer-Expansion-Heatbed-Current/dp/B01MY50JL3</a></li>
<li>Power socket and switch: <a href="https://rads.stackoverflow.com/amzn/click/com/B00ME5YAPK" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/URBEST-Module-Switch-Certification-Socket/dp/B00ME5YAPK</a></li>
</ul>
<p>Last recommendation: get some 3mm borosilicate glass to lay (clip)
over the heatbed. This will make the prints stick better and also
provide a perfectly flat surface for the builds (still, you'll need to
do the levelling)</p>
<p>Glass:
<a href="https://rads.stackoverflow.com/amzn/click/com/B00QQ5Q3BI" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Signstek-Printer-Tempered-Borosilicate-2132003mm/dp/B00QQ5Q3BI</a></p>
<p>When assembling the heatbed mount, pay lots of attention to the 16
screws. Tighten them one by one diagonally and move the bed around. If
the bed feels stuck, loosen the last screws and shift the mounts
around a bit. The lighter this mount moves, the better your prints
will be.</p>
<p>One thing that you must be aware: This printer is a great little unit,
but it needs love, dedication and plenty upgrades. Out of the box it
works okay, but with the upgrades it becomes a really good unit.</p>
</blockquote>
| <p>Thanx for the help, got it running now.
The board in the pic is the older version, my problem was the wires for the extruder had been cut really short for some reason and not labled.</p>
| 1,455 |
<p>I would like to be able to embed a command line interpreter inside a dockable window in Visual Studio. Is there any nice way to do this?</p>
| <p>See the <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=VSCmdShell" rel="noreferrer">VS Command shell</a> project</p>
| <p>Checkout <a href="https://marketplace.visualstudio.com/items?itemName=MadsKristensen.OpenCommandLine" rel="nofollow noreferrer">Open Command Line</a> by Mads Kristensen. <strong>note</strong> it doesn't really "embed" the shell in VS, rather it adds a keyboard shortcut to open the shell at the project directory</p>
<p>it supports bash, powershell, git bash, ...etc</p>
| 8,247 |
<p>I'm trying to fetch some HTML from various blogs and have noticed that different providers use the same tag in different ways.</p>
<p>For example, here are two major providers that use the meta name generator tag differently:</p>
<ul>
<li>Blogger: <code><meta content='blogger' name='generator'/></code> (content first, name later and, yes, single quotes!) </li>
<li>WordPress: <code><meta name="generator" content="WordPress.com" /></code> (name first, content later)</li>
</ul>
<p>Is there a way to extract the value of content for all cases (single/double quotes, first/last in the row)?</p>
<p>P.S. Although I'm using Java, the answer would probably help more people if it where for regular expressions generally.</p>
| <p>The answer is: <strong>don't use regular expressions</strong>.</p>
<p>Seriously. Use a SGML parser, or an XML parser if you happen to know it's valid XML (probably almost never true). You will absolutely screw up and waste tons of time trying to get it right. Just use what's already available.</p>
| <p>Ok, since you are looking for language-agnostic then you can try a REGEX like <code>/<meta\s.*content=.*>/</code> and take the result from that and parse out the specific values that you are looking for. I'm by no means a REGEX expert so there is probably a better way but in using the tool at <a href="http://www.codehouse.com/webmaster_tools/regex/" rel="nofollow noreferrer">http://www.codehouse.com/webmaster_tools/regex/</a> I matched both of the strings you provided.</p>
| 5,148 |
<p>I purchased a (very) low tier printer a while back, and now I am looking to start upgrading. First on my list is to upgrade the controller<sup>1)</sup>.</p>
<p>My initial plan was to upgrade to an Arduino Mega with a RAMPS 1.4 running Marlin, but as I started to try to find a RAMPS 1.4 board I started questioning my plan. Almost every source I could find for the board was either out of stock or very sketchy. Then I discovered that RAMPS 1.6 exists, but I can find even fewer places with it in stock.</p>
<p>Is the Mega + RAMPS combo still what people are using? I made a printer 4 years ago and that was what I used, but due to the scarcity of RAMPS boards for sale I am now unsure if it is still being used by the community.</p>
<p>If RAMPS still is the recommendation, what brands are reputable? (I'm trying to figure out if using RAMPS 1.4 with a Mega is an outdated solution and if there are better solutions these days.)</p>
<hr>
<p><em><sup>1)</sup> Upgrading is necessary for:<br>
Temperature/humidity sensors for monitoring/feedback; enclosure heaters (plan on having enclosed build space, work in a relative cold space); larger display with plenty of tactile switches; light sensor so the LEDs illuminating the enclosure can be modulated to provide more constant light levels for a webcam; possibly some joy sticks to manually maneuver the extruder and bed; etc. Basically I want something that can feasibly handle any unnecessary sensor/input I may eventually want to add. I'm familiar with Arduino and know it has those capabilities, but have no clue about other controllers.</em></p>
| <p>If you own a Raspberry Pi , you may first want to try Klipper firmware. This firmware does the heavy lifting on the RPi itself and sends commands to the printer board via USB. </p>
<p>My Ender 3 pro works much better with this firmware. </p>
| <p>As per <a href="https://reprap.org/wiki/RAMPS_1.6" rel="nofollow noreferrer">https://reprap.org/wiki/RAMPS_1.6</a>,</p>
<blockquote>
<p>The RAMPS 1.6 is the second RAMPS iteration released by BIQU/BIGTREETECH. It replaces the original green power connector with a pair of screw terminals, adds a larger heatsink over the MOSFETS, and has a larger bed MOSFET. It maintains the surface-mounted fuses and flush MOSFETS of the RAMPS 1.5.</p>
<p>Also, the positions of the D1 and D2 diodes have been swapped from the positions in RAMPS 1.4, the D1 diode is now the diode closest to fuse F2. The same is true for RAMPS 1.5, also manufactured by BIQU/BIGTREETECH.</p>
</blockquote>
<p>In other words, RAMPS 1.6 is pretty much the same as the 1.4 board. It just has some minor changes.</p>
<p>As for availability, I have found numerous listings for RAMPS 1.4 and RAMPS 1.6 on Amazon (US) and Ebay (US) for under $10.</p>
| 1,587 |
<p>I have been in both situations: </p>
<ul>
<li>Creating too many custom Exceptions</li>
<li>Using too many general Exception class</li>
</ul>
<p>In both cases the project started OK but soon became an overhead to maintain (and refactor).</p>
<p>So what is the best practice regarding the creation of your own Exception classes?</p>
| <p><a href="http://www.javaspecialists.eu/" rel="noreferrer">The Java Specialists</a> wrote a post about <a href="http://www.javaspecialists.eu/archive/Issue162.html" rel="noreferrer">Exceptions in Java</a>, and in it they list a few "best practices" for creating Exceptions, summarized below:</p>
<ul>
<li><p>Don't Write Own Exceptions (there are lots of useful Exceptions that are already part of the Java API)</p></li>
<li><p>Write Useful Exceptions (if you have to write your own Exceptions, make sure they provide useful information about the problem that occurred)</p></li>
</ul>
| <h3>Don't eat exceptions, throw them <a href="https://stackoverflow.com/a/921583/1097600">https://stackoverflow.com/a/921583/1097600</a></h3>
<p>Avoid creating your own exception. Use the below ones that are already there.</p>
<pre><code>IllegalStateException
UnsupportedOperationException
IllegalArgumentException
NoSuchElementException
NullPointerException
</code></pre>
<p>Throw unchecked exceptions.</p>
<h3>Example</h3>
<pre><code>public void validate(MyObject myObjectInstance) {
if (!myObjectList.contains(myObjectInstance))
throw new NoSuchElementException("object not present in list");
}
</code></pre>
| 4,662 |
<p>C# doesn't require you to specify a generic type parameter if the compiler can infer it, for instance:</p>
<pre><code>List<int> myInts = new List<int> {0,1,1,
2,3,5,8,13,21,34,55,89,144,233,377,
610,987,1597,2584,4181,6765};
//this statement is clunky
List<string> myStrings = myInts.
Select<int,string>( i => i.ToString() ).
ToList<string>();
//the type is inferred from the lambda expression
//the compiler knows that it's taking an int and
//returning a string
List<string> myStrings = myInts.
Select( i => i.ToString() ).
ToList();
</code></pre>
<p>This is needed for anonymous types where you don't know what the type parameter would be (in intellisense it shows up as <code>'a</code>) because it's added by the compiler.</p>
<p>Class-level type parameters don't let you do this:</p>
<pre><code>//sample generic class
public class GenericDemo<T>
{
public GenericDemo ( T value )
{
GenericTypedProperty = value;
}
public T GenericTypedProperty {get; set;}
}
//why can't I do:
int anIntValue = 4181;
var item = new GenericDemo( anIntValue ); //type inference fails
//however I can create a wrapper like this:
public static GenericDemo<T> Create<T> ( T value )
{
return new GenericDemo<T> ( value );
}
//then this works - type inference on the method compiles
var item = Create( anIntValue );
</code></pre>
<p>Why doesn't C# support this class level generic type inference?</p>
| <p>Actually, your question isn't bad. I've been toying with a generic programming language for last few years and although I've never come around to actually develop it (and probably never will), I've thought a lot about generic type inference and one of my top priorities has always been to allow the construction of classes without having to specify the generic type.</p>
<p>C# simply lacks the set of rules to make this possible. I think the developers never saw the neccesity to include this. Actually, the following code would be very near to your proposition and solve the problem. All C# needs is an added syntax support.</p>
<pre><code>class Foo<T> {
public Foo(T x) { … }
}
// Notice: non-generic class overload. Possible in C#!
class Foo {
public static Foo<T> ctor<T>(T x) { return new Foo<T>(x); }
}
var x = Foo.ctor(42);
</code></pre>
<p>Since this code actually works, we've shown that the problem is not one of semantics but simply one of lacking support. I guess I have to take back my previous posting. ;-)</p>
| <p>Thanks Konrad, that's a good response (+1), but just to expand on it.</p>
<p>Let's pretend that C# has an explicit constructor function:</p>
<pre><code>//your example
var x = new Foo( 1 );
//becomes
var x = Foo.ctor( 1 );
//your problem is valid because this would be
var x = Foo<T>.ctor<int>( 1 );
//and T can't be inferred
</code></pre>
<p>You're quite right that the first constructor can't be inferred.</p>
<p>Now let's go back to the class</p>
<pre><code>class Foo<T>
{
//<T> can't mean anything else in this context
public Foo(T x) { }
}
//this would now throw an exception unless the
//typeparam matches the parameter
var x = Foo<int>.ctor( 1 );
//so why wouldn't this work?
var x = Foo.ctor( 1 );
</code></pre>
<p>Of course, if I add your constructor back in (with its alternate type) we have an ambiguous call - exactly as if a normal method overload couldn't be resolved.</p>
| 6,753 |
<p>I use <a href="http://rsync.samba.org/" rel="nofollow noreferrer">rsync</a> to synchronize files to Windows clients in a server agnostic way. What methods are available to send the progress of rsync to the parent process for display in a gui progress bar?</p>
<p>I imagine two or three choices exist. (1) Watch STDOUT (2) Watch rsync.exe log file, similar to unix <code>tail</code> (3) Watch rsync console output in memory.</p>
<p>Which one is best/preferred?</p>
| <p>For this type of tasks, I use my own <a href="http://www.autoitscript.com/autoit3/" rel="nofollow noreferrer">AutoIt</a> script (freeware, Windows only). The script redirects the standard output into a graphical window, displaying it with the ability to scroll back, etc (very useful in long processes like XCOPYs / PKZIPs to check if any error did happen).</p>
<p>I use AutoIt because it's free, very easy to use, and can compile quickly into an .EXE. I think it's an excellent alternative to a complete programming language for this type of tasks. The downside is that it's for Windows only.</p>
<pre><code>$sCmd = "DIR E:\*.AU3 /S" ; Test command
$nAutoTimeout = 10 ; Time in seconds to close window after finish
$nDeskPct = 60 ; % of desktop size (if percent)
; $nHeight = 480 ; height/width of the main window (if fixed)
; $nWidth = 480
$sTitRun = "Executing process. Wait...." ;
$sTitDone = "Process done" ;
$sSound = @WindowsDir & "\Media\Ding.wav" ; End Sound
$sButRun = "Cancel" ; Caption of "Exec" button
$sButDone = "Close" ; Caption of "Close" button
#include <GUIConstants.au3>
#include <Constants.au3>
#Include <GuiList.au3>
Opt("GUIOnEventMode", 1)
if $nDeskPct > 0 Then
$nHeight = @DesktopHeight * ($nDeskPct / 100)
$nWidth = @DesktopWidth * ($nDeskPct / 100)
EndIf
If $CmdLine[0] > 0 Then
$sCmd = ""
For $nCmd = 1 To $CmdLine[0]
$sCmd = $sCmd & " " & $CmdLine[$nCmd]
Next
; MsgBox (1,"",$sCmd)
EndIf
; AutoItSetOption("GUIDataSeparatorChar", Chr(13)+Chr(10))
$nForm = GUICreate($sTitRun, $nWidth, $nHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseForm")
$nList = GUICtrlCreateList ("", 10, 10, $nWidth - 20, $nHeight - 50, $WS_BORDER + $WS_VSCROLL)
GUICtrlSetFont (-1, 9, 0, 0, "Courier New")
$nClose = GUICtrlCreateButton ($sButRun, $nWidth - 100, $nHeight - 40, 80, 30)
GUICtrlSetOnEvent (-1, "CloseForm")
GUISetState(@SW_SHOW) ;, $nForm)
$nPID = Run(@ComSpec & " /C " & $sCmd, ".", @SW_HIDE, $STDOUT_CHILD)
; $nPID = Run(@ComSpec & " /C _RunErrl.bat " & $sCmd, ".", @SW_HIDE, $STDOUT_CHILD) ; # Con ésto devuelve el errorlevel en _ERRL.TMP
While 1
$sLine = StdoutRead($nPID)
If @error Then ExitLoop
If StringLen ($sLine) > 0 then
$sLine = StringReplace ($sLine, Chr(13), "|")
$sLine = StringReplace ($sLine, Chr(10), "")
if StringLeft($sLine, 1)="|" Then
$sLine = " " & $sLine
endif
GUICtrlSetData ($nList, $sLine)
_GUICtrlListSelectIndex ($nList, _GUICtrlListCount ($nList) - 1)
EndIf
Wend
$sLine = " ||"
GUICtrlSetData ($nList, $sLine)
_GUICtrlListSelectIndex ($nList, _GUICtrlListCount ($nList) - 1)
GUICtrlSetData ($nClose, $sButDone)
WinSetTitle ($sTitRun, "", $sTitDone)
If $sSound <> "" Then
SoundPlay ($sSound)
EndIf
$rInfo = DllStructCreate("uint;dword") ; # LASTINPUTINFO
DllStructSetData($rInfo, 1, DllStructGetSize($rInfo));
DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($rInfo))
$nLastInput = DllStructGetData($rInfo, 2)
$nTime = TimerInit()
While 1
If $nAutoTimeout > 0 Then
DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($rInfo))
If DllStructGetData($rInfo, 2) <> $nLastInput Then
; Tocó una tecla
$nAutoTimeout = 0
EndIf
EndIf
If $nAutoTimeout > 0 And TimerDiff ($nTime) > $nAutoTimeOut * 1000 Then
ExitLoop
EndIf
Sleep (100)
Wend
Func CloseForm()
Exit
EndFunc
</code></pre>
| <p>Check out <a href="http://www.download.com/DeltaCopy/3000-2242_4-10471616.html" rel="nofollow noreferrer">DeltaCopy</a>. It is a Windows GUI for rsync.</p>
| 2,955 |
<p>I have an SSIS Package that sets some variable data from a SQL Server Package Configuration Table. (Selecting the "Specify configuration setings directly" option)</p>
<p>This works well when I'm using the Database connection that I specified when developing the package. However when I run it on a server (64 bit) in the testing environment (either as an Agent job or running the package directly) and I Specify the new connection string in the Connection managers, the package still reads the settings from the DB server that I specified in development.</p>
<p>All the other Connections take up the correct connection strings, it only seems to be the Package Configuration that reads from the wrong place.</p>
<p>Any ideas or am I doing something really wrong?</p>
| <p>The only way I was able to do this was to use Windows Environment Variables. You can specify things like connection strings and user preferences in environment variables, and then pick up those environment variables from your SSIS Task.</p>
| <p>We want to keep our package configs in a database table, we know it gets backuped with our other data and we know where to find it. Just a preference.</p>
<p>I have found that to get this to work I can use an environment variable configuration to set the connection string of the connection manager that I am reading my package config from. (Although I had to restart the SQL Server agent before it could find the new environment variable. Not ideal when I deploy this to Production)</p>
<p>Looks Like when you run an SSIS package as a step in a scheduled task it works in this order:</p>
<ul>
<li>Load each of the Package Configs in the order they appear in the Package Configuations Organiser</li>
<li>Set the Connection Strings from the Data sources tab in the Job Step properties of the Scheduled Job</li>
<li>Start running package.</li>
</ul>
<p>I would have expected the first 2 to be the other way around so that I can set the data source for my package config from the scheduled job. That is where I would expect other people to look for it when maintaining the package.</p>
| 5,972 |
<p>I'm considering moving a number of small client sites to an unmanaged VPS hosting provider. I haven't decided which one yet, but my understanding is that they'll give me a base OS install (I'd prefer Debian or Ubuntu), an IP address, a root account, SSH, and that's about it.</p>
<p>Ideally, I would like to create a complete VM image of my configured setup and just ship those bits to the provider. Has anyone had any experience with this? I've seen <a href="http://www.codinghorror.com/blog/archives/000984.html" rel="nofollow noreferrer">Jeff talk about something like this in Coding Horror</a>. But I'm not sure if his experience is typical. I suppose it also depends on the type of VM server used by the host.</p>
<p>Also, do such hosts provide reverse-DNS? That's kinda useful for sites that send out e-mails. I know GMail tends to bounce anything originating from a server without it.</p>
<p>Finally, I'd probably need multiple IP addresses as at least a couple of the sites have SSL protection which doesn't work with name-based virtual hosts. Has anyone run into trouble with multiple IPs through VPS? I wouldn't think so, but I've heard whisperings to the contrary.</p>
| <p>Quick Answer: <a href="http://www.riastats.com" rel="nofollow noreferrer">www.riastats.com</a></p>
<p>This site compares the different RIA plugins using graphical charts and graphs.</p>
<p>It gets its data from small snippets of javascripts running on sites accross the web (approx 400,000 last time I looked)</p>
<p>At the time of this post, Silverlight 2 was sitting at close to 11%.</p>
<p>I would not take this as the end-all, be-all in RIA stats, but it's the best site I've found so far.</p>
| <p>The larger question is how many users will your site lose if implemented in Silverlight. And, it very much depends on your audience.</p>
<p>If you're running a site about the joys of Linux kernel hacking or the virtues of Internet security, you'll probably lose a significant chunk of your audience. If you're running a more mainstream site, my experience is that, sadly, people will download anything they're told to most of the time. That's why spyware and malware work. And, as the NBC/Olympics deal shows, Microsoft will aggressively push its partners to use Silverlight until it's fairly ubiquitous.</p>
<p>I won't be using Silverlight until it's more mature because I <em>do</em> cater to a fair number of Linux users, but I might for a less technically-oriented site.</p>
| 8,495 |
<p>Right now I'm working with an ASP.NET website that automatically generates images and stores them in a temporary folder. When working on my local system these go going into a temporary folder that gets picked up by Visual Source Safe which then wants to check them in. As such, I am wondering if there is a way to just exclude that particular folder from source control?</p>
<p>I've done a bit of reading and found that there are ways to do this for <a href="http://forums.msdn.microsoft.com/en-US/vssourcecontrol/thread/6cc4aab0-e7bc-44e8-baa3-045c9cd82e9a/" rel="nofollow noreferrer">individual files</a>, but I haven't found anything yet about an entire folder.</p>
| <p>I think you've found one of the main reasons MS went back to projects in VS2008 and in MVC.</p>
<p>It's been a long time since I've used VSS (mainly because it's really out of date now), but most source providers let you exclude files and folders as a setting of the provider, rather than the project under control.</p>
<p>If you can switch to a Web Project rather than a WebSite then do so, otherwise I'd look at updating your source control provider, as this sort of exclusion is easy with Vault, CSV, SVN, Git, VSTS and so on (to name but a few).</p>
| <p>I'm not sure if this is an option for you, but if you exclude your temporary folder from VSS (delete the folder inside VSS using the VSS UI), the files that go into it should not get "picked up" again.</p>
| 6,310 |
<p>What's going on here?</p>
<p>printf.sh:</p>
<pre><code>#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" $NAME
</code></pre>
<p>Command line session:</p>
<pre><code>$ ./printf.sh
Hello, George
Hello, W.
Hello, Bush
</code></pre>
<p>UPDATE: <code>printf "Hello, %s\n" "$NAME"</code> works. For why I'm not using <code>echo</code>, consider</p>
<p>echo.sh:</p>
<pre><code>#! /bin/sh
FILE="C:\tmp"
echo "Filename: $FILE"
</code></pre>
<p>Command-line:</p>
<pre><code>$ ./echo.sh
Filename: C: mp
</code></pre>
<p>The <a href="http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html" rel="noreferrer">POSIX spec for <code>echo</code></a> says, "New applications are encouraged to use <code>printf</code> instead of <code>echo</code>" (for this and other reasons). </p>
| <p>Your NAME variable is being substituted like this:</p>
<pre><code>printf "Hello, %s\n" George W. Bush
</code></pre>
<p>Use this:</p>
<pre><code>#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" "$NAME"
</code></pre>
| <p>If you want all of those words to be printed out on their own, use <strong>print</strong> instead of <strong>printf</strong> </p>
<p><strong>printf</strong> takes the formatting specification and applies it to each argument that you pass in. Since you have three arguments {George, W., Bush}, it outputs the string three times using the different arguments.</p>
| 6,346 |