instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>Is there a way to easily convert Crystal Reports reports to Reporting Services RDL format?
We have quite a few reports that will be needing conversion soon.</p>
<p>I know about the manual process (which is basically rebuilding all your reports from scratch in SSRS), but my searches pointed to a few possibilities with automatic conversion "acceleration" with several consulting firms. (As described on .... - link broken).</p>
<p>Do any of you have any valid experiences or recomendations regarding this particular issue?
Are there any tools around that I do not know about?</p>
|
<p>I have searched previously for this, with no luck. There does not seem to be any tools available for this conversion, the manual method thereby becomes the only method. And yes, there are consulting firms who will do the manual work for you, but they still do it manually.</p>
<p>Crystal Reports and Reporting Services have different architectural styles, making it a difficult task for a conversion tool, so I view it as unlikely that someone will build one anytime soon.</p>
|
<p>As suggested by <a href="https://msdn.microsoft.com/en-us/library/aa964127(SQL.90).aspx" rel="nofollow noreferrer">Microsoft</a> you may try any of the following migration tools for SAP Crystal Reports to SSRS conversion:</p>
<ol>
<li>Hitachi Consulting <a href="http://www.hitachiconsulting.com/page.cfm?ID=bi" rel="nofollow noreferrer">http://www.hitachiconsulting.com/page.cfm?ID=bi</a></li>
<li>TCS <a href="http://www.tcs.com/Microsoft2005Launch/download/Microsoft_Recast.pdf" rel="nofollow noreferrer">http://www.tcs.com/Microsoft2005Launch/download/Microsoft_Recast.pdf</a></li>
<li>Sonata Software Ltd. <a href="http://microsoftcc.sonata-software.com/html/mcc_bi.htm" rel="nofollow noreferrer">http://microsoftcc.sonata-software.com/html/mcc_bi.htm</a></li>
<li>KTL Solutions <a href="http://www.ktlsolutions.com/t-crystalconverter.aspx" rel="nofollow noreferrer">http://www.ktlsolutions.com/t-crystalconverter.aspx</a></li>
<li>90DegreeSoftware <a href="http://www.90degreesoftware.com" rel="nofollow noreferrer">http://www.90degreesoftware.com</a></li>
<li>Jeff-Net <a href="http://www.rpttosql.com/index.html" rel="nofollow noreferrer">http://www.rpttosql.com/index.html</a></li>
<li>Neudesic <a href="http://www.neudesic.com" rel="nofollow noreferrer">http://www.neudesic.com</a></li>
<li>PLUS-IT <a href="http://www.plus-it.de" rel="nofollow noreferrer">http://www.plus-it.de</a></li>
</ol>
| 3,708
|
<p>Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.</p>
<p>Example input and output:</p>
<pre><code>>>> reverse_words("this is a string")
'string a is this'
</code></pre>
<p>It should be O(N) time and O(1) space (<code>split()</code> and pushing on / popping off the stack are not allowed).</p>
<p>The puzzle is taken from <a href="http://halcyon.usc.edu/~kiran/msqs.html#programming" rel="noreferrer" title="Microsoft Interview Questions">here</a>.</p>
|
<p>A solution in C/C++:</p>
<pre class="lang-cpp prettyprint-override"><code>void swap(char* str, int i, int j){
char t = str[i];
str[i] = str[j];
str[j] = t;
}
void reverse_string(char* str, int length){
for(int i=0; i<length/2; i++){
swap(str, i, length-i-1);
}
}
void reverse_words(char* str){
int l = strlen(str);
//Reverse string
reverse_string(str,strlen(str));
int p=0;
//Find word boundaries and reverse word by word
for(int i=0; i<l; i++){
if(str[i] == ' '){
reverse_string(&str[p], i-p);
p=i+1;
}
}
//Finally reverse the last word.
reverse_string(&str[p], l-p);
}
</code></pre>
<p>This should be O(n) in time and O(1) in space.</p>
<p>Edit: Cleaned it up a bit.</p>
<p>The first pass over the string is obviously O(n/2) = O(n). The second pass is O(n + combined length of all words / 2) = O(n + n/2) = O(n), which makes this an O(n) algorithm.</p>
|
<p>Push each word onto a stack. Pop all the words off the stack.</p>
| 6,963
|
<p>I have a web application that receives messages through an HTTP interface, e.g.:</p>
<pre><code>http://server/application?source=123&destination=234&text=hello
</code></pre>
<p>This request contains the ID of the sender, the ID of the recipient and the text of the message.</p>
<p>This message should be processed like:</p>
<ul>
<li>finding the matching User object for both the source and the destination from the database</li>
<li>creating a tree of objects: a Message that contains a field for the message text and two User objects for the source and the destination</li>
<li>persisting this tree to a database.</li>
</ul>
<p>The tree will be loaded by other applications that I can't touch.</p>
<p>I use Oracle as the backing database and JPA with Toplink for the database handling tasks. If possible, I'd stay with these.</p>
<p>Without much optimization I can achieve ~30 requests/sec throughput in my environment. That's not much, I'd require ~300 requests/sec. So I measured where the performance bottleneck is and found that the calls to <code>em.persist()</code> takes most of the time. If I simply comment out that line, the throughput go well over 1000 requests/sec.</p>
<p>I tried to write a small test application that used simple JDBC calls to persist 1 million messages to the same database. I used batching, meaning I did 100 inserts then a commit, and repeated until all the records was in the database. I measured ~500 requests/sec throughput in this scenario, that would meet my needs.</p>
<p>It is clear that I need to optimize insert performance here. However as I mentioned earlier I would like to keep using JPA and Toplink for this, not pure JDBC.</p>
<p>Do you know a way to create batch inserts with JPA and Toplink? Can you recommend any other technique for improving JPA persist performance?</p>
<p><strong>ADDITIONAL INFO:</strong></p>
<p>"requests/sec" means here: total number of requests / total time from beginning of test to last record written to database.</p>
<p>I tried to make the calls to <code>em.persist()</code> asynchronous by creating an in-memory queue between the servlet stuff and the persister. It helped the performance greatly. However the queue did grow really fast and as the application will receive ~200 requests/second continuously, It is not an acceptable solution for me.</p>
<p>In this decoupled approach I collected requests for 100 msec and called <code>em.persist()</code> on all collected items before commiting the transaction. The EntityManagerFactory is cached between each transaction.</p>
|
<p>You should decouple from the JPA interface and use the bare TopLink API. You can probably chuck the objects you're persisting into a UnitOfWork and commit the UnitOfWork on your schedule (sync or async). Note that one of the costs of em.persist() is the implicit clone that happens of the whole object graph. TopLink will work rather better if you uow.registerObject() your two user objects yourself, saving itself the identity tests it has to otherwise do. So you'll end up with:</p>
<pre><code>uow=sess.acquireUnitOfWork();
for (job in batch) {
thingyCl=uow.registerObject(new Thingy());
user1Cl=uow.registerObject(user1);
user2Cl=uow.registerObject(user2);
thingyCl.setUsers(user1Cl,user2Cl);
}
uow.commit();
</code></pre>
<p>This is very old school TopLink btw ;)</p>
<p>Note that the batch will help a lot, because batch writing and more especially batch writing with parameter binding will kick in which for this simple example will probably have a very large impact on your performance.</p>
<p>Other things to look for: your sequencing size. A lot of the time spent writing objects in TopLink is actually spent reading sequencing information from the database, especially with the small defaults (I would probably have several hundred or even more as my sequence size).</p>
|
<p>What is your measure of "requests/sec"? In other words, what happens for the 31st request? What resource is being blocked? If it is the front-end/servlet/web portion, can you run em.persist() in another thread and return immediately?</p>
<p>Also, are you creating transactions each time? Are you creating EntityManagerFactory objects with each request?</p>
| 9,037
|
<p>Why does Visual Studio declare new classes as private in C#? I almost always switch them over to public, am I the crazy one?</p>
|
<p>I am not sure WHY it does that, but here's what you do in order to get Visual Studio to create the class as Public by default:</p>
<p>Go over to “Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033″, you will find a file called Class.zip, inside the .zip file open the file called Class.cs, the content of the file looks like this:</p>
<pre><code>using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)using System.Linq;
$endif$using System.Text;
namespace $rootnamespace$
{
class $safeitemrootname$
{
}
}
</code></pre>
<p>All you need to do is add “Public” before the class name. The outcome should look like this:</p>
<pre><code>using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)using System.Linq;
$endif$using System.Text;
namespace $rootnamespace$
{
public class $safeitemrootname$
{
}
}
</code></pre>
<p>One last thing you need to do is flush all the Templates Visual Studio is using, and make him reload them. The command for that is ( it takes a while so hold on): </p>
<pre><code>devenv /installvstemplates
</code></pre>
<p>And that’s it, no more private classes by default. Of course you can also add internal or whatever you want.</p>
<p><a href="http://www.dev102.com/2008/03/14/how-to-get-visual-studio-to-create-new-classes-public-by-default/" rel="noreferrer">Source</a></p>
|
<p>C++, upon which C# is derived, specified that the default class access level is private. C# carries this forward for better or worse.</p>
| 6,106
|
<p>I have a little game written in C#. It uses a database as back-end. It's
a <a href="http://en.wikipedia.org/wiki/Collectible_card_game" rel="noreferrer">trading card game</a>, and I wanted to implement the function of the cards as a script.</p>
<p>What I mean is that I essentially have an interface, <code>ICard</code>, which a card class implements (<code>public class Card056: ICard</code>) and which contains a function that is called by the game.</p>
<p>Now, to make the thing maintainable/moddable, I would like to have the class for each card as source code in the database and essentially compile it on first use. So when I have to add/change a card, I'll just add it to the database and tell my application to refresh, without needing any assembly deployment (especially since we would be talking about 1 assembly per card which means hundreds of assemblies).</p>
<p>Is that possible? Register a class from a source file and then instantiate it, etc.</p>
<pre><code>ICard Cards[current] = new MyGame.CardLibrary.Card056();
Cards[current].OnEnterPlay(ref currentGameState);
</code></pre>
<p>The language is C# but extra bonus if it's possible to write the script in any .NET language.</p>
|
<p><a href="https://www.codeproject.com/Articles/8656/C-Script-The-Missing-Puzzle-Piece" rel="nofollow noreferrer">Oleg Shilo's C# Script solution (at The Code Project</a>) really is a great introduction to providing script abilities in your application.</p>
<p>A different approach would be to consider a language that is specifically built for scripting, such as <a href="https://en.wikipedia.org/wiki/IronRuby" rel="nofollow noreferrer">IronRuby</a>, <a href="https://en.wikipedia.org/wiki/IronPython" rel="nofollow noreferrer">IronPython</a>, or <a href="https://en.wikipedia.org/wiki/Lua_%28programming_language%29" rel="nofollow noreferrer">Lua</a>.</p>
<p>IronPython and IronRuby are both available today.</p>
<p>For a guide to embedding IronPython read
<a href="https://blogs.msdn.microsoft.com/jmstall/2005/09/01/how-to-embed-ironpython-script-support-in-your-existing-app-in-10-easy-steps/" rel="nofollow noreferrer">How to embed IronPython script support in your existing app in 10 easy steps</a>.</p>
<p>Lua is a scripting language commonly used in games. There is a Lua compiler for .NET, available from CodePlex -- <a href="http://www.codeplex.com/Nua" rel="nofollow noreferrer">http://www.codeplex.com/Nua</a></p>
<p>That codebase is a great read if you want to learn about building a compiler in .NET.</p>
<p>A different angle altogether is to try <a href="https://en.wikipedia.org/wiki/PowerShell" rel="nofollow noreferrer">PowerShell</a>. There are numerous examples of embedding PowerShell into an application -- here's a thorough project on the topic:
<a href="http://code.msdn.microsoft.com/PowerShellTunnel/Wiki/View.aspx?title=PowerShellTunnel%20Reference" rel="nofollow noreferrer" title="PowerShell Tunnel">Powershell Tunnel</a></p>
|
<p>Yes, I thought about that, but I soon figured out that another Domain-Specific-Language (DSL) would be a bit too much.</p>
<p>Essentially, they need to interact with my gamestate in possibly unpredictable ways. For example, a card could have a rule "When this cards enter play, all your undead minions gain +3 attack against flying enemies, except when the enemy is blessed". As trading card games are turn based, the GameState Manager will fire OnStageX events and let the cards modify other cards or the GameState in whatever way the card needs.</p>
<p>If I try to create a DSL, I have to implement a rather large feature set and possibly constantly update it, which shifts the maintenance work to another part without actually removing it.</p>
<p>That's why I wanted to stay with a "real" .NET language to essentially be able to just fire the event and let the card manipulate the gamestate in whatever way (within the limits of the code access security).</p>
| 2,275
|
<p>I've seen lots of descriptions how anonymous types work, but I'm not sure how they're really useful. What are some scenarios that anonymous types can be used to address in a well-designed program?</p>
|
<p>Anonymous types have nothing to do with the design of systems or even at the class level. They're a tool for developers to use when coding.</p>
<p>I don't even treat anonymous types as types per-se. I use them mainly as method-level anonymous tuples. If I query the database and then manipulate the results, I would rather create an anonymous type and use that rather than declare a whole new type that will never be used or known outside of the scope of my method.</p>
<p>For instance:</p>
<pre><code>var query = from item in database.Items
// ...
select new { Id = item.Id, Name = item.Name };
return query.ToDictionary(item => item.Id, item => item.Name);
</code></pre>
<p>Nobody cares about `a, the anonymous type. It's there so you don't have to declare another class.</p>
|
<p>@Wouter :</p>
<pre><code>var query = from item in database.Items
select new Person
{
ID =item.id,
NAME= item.Name
};
</code></pre>
<p>where ID and NAME are real property of your Person class.</p>
| 7,113
|
<p>I've seen a few print time-lapse videos lately which use gyroid infill: wavy lines, which deform across layers so that the waves end up alternating between the two axes. Other than making the time-lapse videos look much cooler, what are the benefits of this infill style compared to the more common hatching or cross-hatching?</p>
|
<p>From <a href="https://mattshub.com/2018/03/15/gyroid-infill/" rel="noreferrer">this reference</a> you can read that:</p>
<blockquote>
<p>A gyroid is a naturally occurring structure which be found in
butterfly wings and even within membranes inside cells. In 2017, MIT
researchers discovered that when graphene was shaped into a gyroid
structure, it had exceptional strength properties at low densities.
They then discovered however, that the crucial aspect of this was
actually the gyroid structure itself, and that other materials such as
plastic could benefit from this.</p>
</blockquote>
<p>It is assumed that this type of infill has better properties against failure than the normal types of infill we know.</p>
<p>A test conducted by an author named Martin is found <a href="https://www.cartesiancreations.com.au/gyroid-infill-tests/" rel="noreferrer">here</a>. He printed test specimen and subjected them to bending to test the resistance against shear stress.</p>
<p><a href="https://i.stack.imgur.com/jpMc8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jpMc8.png" alt="Test details"></a></p>
<p>From the figure can be concluded that the gyroid infill has a better resistance against bending for a lower weight. </p>
<p>The advantages of gyroid infill over the tested infill types are:</p>
<ul>
<li>high shear strength, and </li>
<li>low weight (so less filament needed).</li>
</ul>
<p>On top of these advantages Gyroid infill prints relatively fast with respect to some other infill types and is close to <a href="https://en.wikipedia.org/wiki/Isotropy" rel="noreferrer">isotropic</a> (i.e. uniform in all orientations), meaning that is very suitable for flexible prints.</p>
|
<p>This answer builds on to both 0scar and tedder42's answer:</p>
<p>Martin's experiment was about shear strength, where as Stefan of CNC Kitchen's experiment was about compressive strength on 2 directions.</p>
<p>From their experiments, it is reasonable to conclude that gyroid does well on sheer strength, and above mediocre on compressive strength.</p>
<p><strong>Why use gyroid?</strong></p>
<ol>
<li>If your print requires shear strength, use gyroid.</li>
<li>Else if your print requires compressive strength from transverse or both directions, use cubic.</li>
<li>Else if your print requires only perpendicular compressive strength, use triangle.</li>
<li>If your print infill naked, each pattern has its own beauty.</li>
</ol>
<p><strong>See also:</strong></p>
<p>Martin's experiment (Note how he used a bottle of water to test different structures for their shear strength):</p>
<p><a href="https://www.cartesiancreations.com.au/gyroid-infill-tests/" rel="noreferrer">https://www.cartesiancreations.com.au/gyroid-infill-tests/</a></p>
<p>Stefan of CNC Kitchen's experiment (Note how he used his self-made machine to compress different structures):</p>
<p><a href="https://www.youtube.com/channel/UCiczXOhGpvoQGhOL16EZiTg" rel="noreferrer">https://www.youtube.com/channel/UCiczXOhGpvoQGhOL16EZiTg</a></p>
<p>Examples of gyroid's aesthetics can be found in Matt's links:</p>
<p><a href="https://mattshub.com/2018/03/15/gyroid-infill/" rel="noreferrer">https://mattshub.com/2018/03/15/gyroid-infill/</a></p>
| 1,052
|
<h2>Update below</h2>
<p>Printed 650 of these tokens, no problem. Then all of a sudden I can't get them to stick and the first layer looks wavy and weird.</p>
<p><a href="https://i.stack.imgur.com/BYuDc.jpg" rel="nofollow noreferrer" title="Closeup"><img src="https://i.stack.imgur.com/BYuDc.jpg" alt="Closeup" title="Closeup" /></a></p>
<p>After a few tokens it knocks one loose and the whole print fails.</p>
<p>Did try to recalibrate the z-height. Should it be even closer? The test pattern for first layer height looks good.</p>
<p>Removed the nozzle to inspect if it's damaged but it looks fine to me...</p>
<p><a href="https://i.stack.imgur.com/jf49h.jpg" rel="nofollow noreferrer" title="Whole bed"><img src="https://i.stack.imgur.com/jf49h.jpg" alt="Whole bed" title="Whole bed" /></a></p>
<p>Any help is much appreciated.</p>
<h1>Update - Dec 29th 2019</h1>
<p>With the new nozzle and recalibration I managed to get one more print to stick as in my answer below. Then back to not sticking.</p>
<p>I did order a textured plate from Prusa. Recalibrated the XYZ. That did not help.<br />
I have played around with the first layer calibration.
In the video below the setting of -0.900 is fixed the whole time.
The lines look good and healthy but then lifts on the right side of the bed.<br />
<a href="https://www.youtube.com/watch?v=9xsC4sDvSuY" rel="nofollow noreferrer">Video of first layer calibration</a></p>
<p>I then moved the nozzle even closer and REALLY smash it into the bed @ -1.050<br />
It still lifts on the right side and a little bit in the corners. The first purge plastic that is output to the bottom left usually does not stick at all.<br />
<a href="https://www.youtube.com/watch?v=acMJT58IKgY" rel="nofollow noreferrer">Untouched with nozzle closer</a></p>
<p>Things I have done:</p>
<ul>
<li>Recalibrated the XY & Z axis from scratch.</li>
<li>Did two cold pulls of the filament (<a href="https://help.prusa3d.com/article/WWVRzOY1dX-clogged-nozzle" rel="nofollow noreferrer">link</a>) to make sure the extruder is not clogged. The pulled filament looked nice and clean.</li>
<li>Switched to new textured bed sheet</li>
<li>Switched to a new 0.4mm nozzle (E3D V6)</li>
<li>Tried different filaments (only PLA though)</li>
<li>Lubricated moving parts</li>
<li>Checked heat bed to make sure screws are tight and the bed sits snuggly</li>
</ul>
<p>Two ideas now:<br />
Can it be the mesh leveling that is acting up? How do I check that?<br />
The heat bed feels differently warm in different places. Is the heat bed constructed with different zones where one can fail and the rest keep working? Do not have access to a heat camera to check.</p>
<p>Any suggestions would be much appreciated!</p>
<h1>EDIT:</h1>
<p>Thanks @Paulster2! It's good to find this community!<br />
I've been using several different PLA filaments since this started happening. Before, they all stuck to the printing bed like champions, now none of them do. Pictured is som generic white, but getting the same result with Prusament PLA. Nozzle 215°C, Bed 60°C. As I wrote above, I did check the nozzle and it <em>LOOKS</em> fine. It's very small though and I have ordered new nozzles. If no one has any other suggestions I will post more when I have tried the new nozzle.<br />
Also thanks to @Greenonline for correcting spelling and layout. Cheers!</p>
|
<p>A new day, a new nozzle, an old result!</p>
<p><a href="https://i.stack.imgur.com/nGdyx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nGdyx.jpg" alt="Success"></a></p>
<h2>EDIT</h2>
<p>The success was a one off. The problem remains!<br>
Heat on the heated bed seems to differ a lot in different areas. Just using my hands to feel it since I have no IR-camera.</p>
|
<p>Okay so I am not an expert but I think I can help.</p>
<ul>
<li><p>First off, your <strong>nozzle is too close to your bed</strong>. Take it up, I guess, to like between -0.75 to -0.6 mm. Play around there.</p></li>
<li><p>For not sticking part, see whether it sticks with <strong>higher bed and nozzle temperature</strong>. Higher temperature like for Nozzle: 220-250 °C and for Bed: 65-80 °C. <em>(Yes its too extreme for PLA filaments but we are observing what happens)</em>.</p></li>
<li><p>And I couldn't make out from the video, is your <strong>print fan</strong> on? If so, switch it off.</p></li>
<li><p>I would advice to test print with a cube of dimension 200x200x0.2 mm. In your PrusaSlicer, set the <em>Bottom Fill Pattern</em> to be "Concentric" and your <em>First layer height</em> to be 0.2 mm. (I got this idea from a forum but I cannot recall its name)</p></li>
<li><p>And as mentioned by @KeithS, keeping your <strong>bed clean</strong> is important. With <strong>isopropyl alcohol and cotton balls</strong> wipe the surface. (Though don't this too many times. I have heard that the bed looses its adhesion if done so. After a couple of prints wipe with isopropyl alcohol and before every print wipe just with a kitchen towel).</p></li>
<li><p>If your bed is clean, then use <strong>glue sticks</strong> (note note all glue sticks work) on the print surface right before a print. Don't worry you can take it off after the print.</p></li>
</ul>
| 1,520
|
<p>First post here, so please forgive me for any silly mistakes.</p>
<p>Recently the y-axis (I think, forward-backward) has started skipping forward when printing the first layer of my print. It prints the raft with no issues at all, sticks the bed nice and flat and the raft is perfect every time. </p>
<p>Then it starts to print the actual item, but every time it starts to the print the back right corner the Y-Axis jumps or skips on the gears and makes a loud grinding noise. The amount it jumps varies on the print, but always jumps towards the front of the print. It doesn't matter on the size of the print or the position, it always jumps forward never back.</p>
<p>The printer is a Makerbot Replikator clone, from eBay. The X & Y moves the extruder. I have tried upgrading and downgrading the software (which uses Makerbot software) I am unsure if I can update the firmware.</p>
<p>Any help much appreciated.</p>
<p>UPDATE:
Image has been attached of the failed part, excuse the colour, I use it for my test prints. This is orientation it printed on the bed. First 3 blocks printed fine, 4th one jumped It printed in the following order 1. top-left, 2. bottom left, 3. bottom right, 4. top right.</p>
<p><a href="https://i.stack.imgur.com/bIkxe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bIkxe.jpg" alt="Failed 3D print part"></a></p>
|
<p>Layer shifting is a result of the use of open-loop control systems. This means that the printer just instructs the head to go to certain positions without checking that it actually did arrive at that position. If something happens along the path, like hitting some part of the print or the printer, the motors could loose steps or the belts may skip teeth without the printer knowing it, so it continues further without correcting this.</p>
<p>There are a couple of causes for the skipping to occur. Usually it is a mechanical issue, but it can also be related to an electrical problem or a print settings problem (if e.g. your print speed it too high, the steppers could miss steps).</p>
<p>Looking closely at the image, you will see that the infill of the first layer does not touch the outer lines. This could be a hint that your belts are not tight enough (mechanical issue). Too loose belts cause the stepper driving pulley to skip. Also check the pulley whether it is securely fastened so that the pulley is not slipping when subjected to an increased torque. The nozzle most probably hits the raft (ABS? as it curls up and detaches, you see some irregularities on the left of the bottom right product in your image). Do note that too tight belts are also not wanted as they stress the stepper by an increased torque load. If the issue is electronically related, you could thick of increasing the torque by increasing the current through the stepper (and driver). Too much current will overheat the stepper driver though, so make sure that these do not exceed their rated maximum and properly cool the stepper drivers.</p>
<p>To solve your issues it is recommended to first try printing at lower speeds (this can be skipped if you already have low print speeds), then check the mechanical system of the printer, and finally, if this does not fix the problem, you could look into the electronics.</p>
|
<p>I'm guessing that the bed in the offending corner is farther away and your raft is curling and lifting off the bed in that corner, and your nozzle it hitting it. Try releveling your bed, paying particular close attention to that corner. In addition, work on bed adhesion in general. Clean the bed, make sure fan is off on first layer, and go slow on first layer, and use proper bed temp for the material. You can also try glue stick.</p>
| 1,116
|
<p>I am an absolute beginner having issues with my Monoprice Maker select v2 printer.
The left half of my prints look fine but the right half always gets messed up. When I watch it print the right half of an object it seems that the PLA isn't sticking even though I level the bed thoroughly beforehand. I don't think the problem is that the right half of my board is not sticky enough, because when I move the print so that the whole thing prints on the left half of the bed the problem persists.</p>
<p>I have attatched a photo to show what I am talking about. Any help is appreciated</p>
<p>Edit: I'm using inland pla. The extruder is at 220° and the bed temp is 60°
<a href="https://i.stack.imgur.com/PpBtK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PpBtK.jpg" alt="enter image description here"></a></p>
|
<p>I found the problem. This model of printer Monoprice Select v2 has bed warping issues so when the bed heated up it would warp severely. I bought a glass bed and all my problems were solved. </p>
|
<ul>
<li>Try cleaning bed with isopropyl alcohol to remove grease from the bed. (increases stickyness)</li>
<li>Try increasing bed temp to 70°C (increases stickyness)</li>
<li>If this is not enough, do a fresh bed leveling.</li>
</ul>
| 1,566
|
<p>Despite primarily being a windows user, I am a huge fan of rsync. Now, I don't want to argue the virtues of rsync vs any other tool...this is not my point.</p>
<p>The only way I've ever found of running rsync on windows is via a version that is built to run on top of Cygwin, and as Cygwin has issues with Unicode, so does rsync.</p>
<p>Is anyone familiar enough with the workings of rsync to say if there are any real technical programming hurdles to porting rsync to a native Win32 binary? </p>
<p>Or is it maybe that there has just never been enough interest from windows users to care to port it over?</p>
<p>Partly I ask because I'm am considering trying to take on the task of starting a port, but I want to make sure there's not something I'm missing in terms of why it may not be possible.</p>
|
<p>The way that windows locks open files might cause an issue requiring you to hook into the Volume Shadowcopy Service. </p>
<p>About two years ago this fellow ported the algorithm to C#. I haven't taken a look at the code (or the provided binary), but it might be a place to start looking or someone to try contacting.<br>
<a href="http://www.russiantequila.com/wordpress/?p=8" rel="noreferrer">http://www.russiantequila.com/wordpress/?p=8</a></p>
|
<p>Have you seen this:</p>
<p><a href="http://www.itefix.no/i2/taxonomy/term/39" rel="nofollow noreferrer">http://www.itefix.no/i2/taxonomy/term/39</a></p>
<p>I have used cwrsync without any problem (and with the much of the usual cygwin misery), but I haven't had any need for unicode filenames, so I've not seen that problem.</p>
<p>I don't really know why there isn't a native Win32 port, but I did look at the source a while back because I implemented a similar delta-copy system in C#. As one would expect from the world of brilliant *nix hackers, the source is largely single-character variable names and a total absence of comments, which isn't terrible helpful and might be rather off-putting to would-be porters.</p>
| 5,469
|
<p>I am experimenting with using the FaultException and FaultException<T> to determine the best usage pattern in our applications. We need to support WCF as well as non-WCF service consumers/clients, including SOAP 1.1 and SOAP 1.2 clients.</p>
<p>FYI: using FaultExceptions with wsHttpBinding results in SOAP 1.2 semantics whereas using FaultExceptions with basicHttpBinding results in SOAP 1.1 semantics. </p>
<p>I am using the following code to throw a FaultException<FaultDetails>:</p>
<pre><code> throw new FaultException<FaultDetails>(
new FaultDetails("Throwing FaultException<FaultDetails>."),
new FaultReason("Testing fault exceptions."),
FaultCode.CreateSenderFaultCode(new FaultCode("MySubFaultCode"))
);
</code></pre>
<p>The FaultDetails class is just a simple test class that contains a string "Message" property as you can see below.</p>
<p>When using wsHttpBinding the response is:</p>
<pre><code><?xml version="1.0" encoding="utf-16"?>
<Fault xmlns="http://www.w3.org/2003/05/soap-envelope">
<Code>
<Value>Sender</Value>
<Subcode>
<Value>MySubFaultCode</Value>
</Subcode>
</Code>
<Reason>
<Text xml:lang="en-US">Testing fault exceptions.</Text>
</Reason>
<Detail>
<FaultDetails xmlns="http://schemas.datacontract.org/2004/07/ClassLibrary" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Message>Throwing FaultException&lt;FaultDetails&gt;.</Message>
</FaultDetails>
</Detail>
</code></pre>
<p></p>
<p>This looks right according to the SOAP 1.2 specs. The main/root “Code” is “Sender”, which has a “Subcode” of “MySubFaultCode”. If the service consumer/client is using WCF the FaultException on the client side also mimics the same structure, with the faultException.Code.Name being “Sender” and faultException.Code.SubCode.Name being “MySubFaultCode”.</p>
<p>When using basicHttpBinding the response is:</p>
<pre><code><?xml version="1.0" encoding="utf-16"?>
<s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>s:MySubFaultCode</faultcode>
<faultstring xml:lang="en-US">Testing fault exceptions.</faultstring>
<detail>
<FaultDetails xmlns="http://schemas.datacontract.org/2004/07/ClassLibrary" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Message>Throwing FaultException&lt;FaultDetails&gt;.</Message>
</FaultDetails>
</detail>
</s:Fault>
</code></pre>
<p>This does not look right. Looking at the SOAP 1.1 specs, I was expecting to see the “faultcode” to have a value of “s:Client.MySubFaultCode” when I use FaultCode.CreateSenderFaultCode(new FaultCode("MySubFaultCode")). Also a WCF client gets an incorrect structure. The faultException.Code.Name is “MySubFaultCode” instead of being “Sender”, and the faultException.Code.SubCode is null instead of faultException.Code.SubCode.Name being “MySubFaultCode”. Also, the faultException.Code.IsSenderFault is false.</p>
<p>Similar problem when using FaultCode.CreateReceiverFaultCode(new FaultCode("MySubFaultCode")):</p>
<ul>
<li>works as expected for SOAP 1.2</li>
<li>generates “s:MySubFaultCode” instead of “s:Server.MySubFaultCode” and the faultException.Code.IsReceiverFault is false for SOAP 1.1</li>
</ul>
<p>This item was also posted by someone else on <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=669420&SiteID=1" rel="nofollow noreferrer">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=669420&SiteID=1</a> in 2006 and no one has answered it. I find it very hard to believe that no one has run into this, yet. </p>
<p>Here is someone else having a similar problem: <a href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3883110&SiteID=1&mode=1" rel="nofollow noreferrer">http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3883110&SiteID=1&mode=1</a></p>
<p>Microsoft Connect bug: <a href="https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=367963" rel="nofollow noreferrer">https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=367963</a></p>
<p>Description of how faults should work: <a href="http://blogs.msdn.com/drnick/archive/2006/12/19/creating-faults-part-3.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/drnick/archive/2006/12/19/creating-faults-part-3.aspx</a></p>
<p>Am I doing something wrong or is this truly a bug in WCF?</p>
|
<p>This is my current workaround:</p>
<pre><code> /// <summary>
/// Replacement for the static methods on FaultCode to generate Sender and Receiver fault codes due
/// to what seems like bugs in the implementation for basicHttpBinding (SOAP 1.1). wsHttpBinding
/// (SOAP 1.2) seems to work just fine.
///
/// The subCode parameter for FaultCode.CreateReceiverFaultCode and FaultCode.CreateSenderFaultCode
/// seem to take over the main 'faultcode' value in the SOAP 1.1 response, whereas in SOAP 1.2 the
/// subCode is correctly put under the 'Code->SubCode->Value' value in the XML response.
///
/// This workaround is to create the FaultCode with Sender/Receiver (SOAP 1.2 terms, but gets
/// translated by WCF depending on the binding) and an agnostic namespace found by using reflector
/// on the FaultCode class. When that NS is passed in WCF seems to be able to generate the proper
/// response with SOAP 1.1 (Client/Server) and SOAP 1.2 (Sender/Receiver) fault codes automatically.
///
/// This means that it is not possible to create a FaultCode that works in both bindings with
/// subcodes.
/// </summary>
/// <remarks>
/// See http://stackoverflow.com/questions/65008/net-wcf-faults-generating-incorrect-soap-11-faultcode-values
/// for more details.
/// </remarks>
public static class FaultCodeFactory
{
private const string _ns = "http://schemas.microsoft.com/ws/2005/05/envelope/none";
/// <summary>
/// Creates a sender fault code.
/// </summary>
/// <returns>A FaultCode object.</returns>
/// <remarks>Does not support subcodes due to a WCF bug.</remarks>
public static FaultCode CreateSenderFaultCode()
{
return new FaultCode("Sender", _ns);
}
/// <summary>
/// Creates a receiver fault code.
/// </summary>
/// <returns>A FaultCode object.</returns>
/// <remarks>Does not support subcodes due to a WCF bug.</remarks>
public static FaultCode CreateReceiverFaultCode()
{
return new FaultCode("Receiver", _ns);
}
}
</code></pre>
<p>Sadly I don't see a way to use subcodes without breaking either SOAP 1.1 or 1.2 clients. </p>
<p>If you use the Code.SubCode syntax, you can create SOAP 1.1 compatible faultcode values but it breaks SOAP 1.2.</p>
<p>If you use the proper subcode support in .NET (either via the static FaultCode methods or one of the overloads) it breaks SOAP 1.1 but works in SOAP 1.2.</p>
|
<p>Response from Microsoft:</p>
<p>As discussed in <a href="http://msdn.microsoft.com/en-us/library/ms789039.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms789039.aspx</a>, there are two methods outlined in the Soap 1.1 specification for custom fault codes:</p>
<p>(1) Using the "dot" notation as you describe</p>
<p>(2) Defining entirely new fault codes</p>
<p>Unfortunately, the "dot" notation should be avoided, as it's use is discouraged in the WS-I Basic Profile specification. Essentially, this means that there is no real equivalent of the Soap 1.2 fault SubCode when using Soap 1.1.</p>
<p>So, when generating faults, you'll have to be cognizant of the MessageVersion defined in the binding, and generate faultcodes accordingly.</p>
<p>Since "sender" and "receiver" are not vaild fault codes for Soap 1.1, and there is no real equivalent of a fault subcode, you shouldn't use the CreateSenderFaultCode and CreateReceiverFaultCode methods when generating custom fault codes for Soap 1.1.</p>
<p>Instead, you'll need to define your own faultcode, using your own namespace and name:</p>
<p>FaultCode customFaultCode = new FaultCode(localName, faultNamespace);</p>
| 9,070
|
<p>I'm currently trying to get into the Java EE development with the Spring framework. As I'm new to Spring, it is hard to imaging how a good running project should start off.</p>
<p>Do you have any <em>best practices</em>, tipps or major <em>DO NOTs</em> for a starter? How did you start with Spring - big project or small tutorial-like applications? Which technology did you use right away: AOP, complex Hibernate...</p>
|
<p>Small tip - I've found it helpful to modularize and clearly label my Spring xml context files based on application concern. Here's an example for a web app I worked on:</p>
<ul>
<li><code>MyProject / src / main / resources / spring /</code>
<ul>
<li><em><strong>datasource.xml</strong></em> - My single data source bean.</li>
<li><em><strong>persistence.xml</strong></em> - My DAOs/Repositories. Depends on <code>datasource.xml</code> beans.</li>
<li><em><strong>services.xml</strong></em> - Service layer implementations. These are usually the beans to which I apply transactionality using AOP. Depends on <code>persistence.xml</code> beans.</li>
<li><em><strong>controllers.xml</strong></em> - My Spring MVC controllers. Depends on <code>services.xml</code> beans.</li>
<li><em><strong>views.xml</strong></em> - My view implementations.</li>
</ul></li>
</ul>
<p>This list is neither perfect nor exhaustive, but I hope it illustrates the point. Choose whatever naming strategy and granularity works best for you.</p>
<p>In my (limited) experience, I've seen this approach yeild the following benefits:</p>
<p><strong>Clearer architecture</strong></p>
<p>Clearly named context files gives those unfamiliar with your project structure a reasonable
place to start looking for bean definitions. Can make detecting circular/unwanted dependencies a little easier.</p>
<p><strong>Helps domain design</strong></p>
<p>If you want to add a bean definition, but it doesn't fit well in any of your context files, perhaps there's a new concept or concern emerging? Examples:</p>
<ul>
<li>Suppose you want to make your Service layer transactional with AOP. Do you add those bean definitions to <code>services.xml</code>, or put them in their own <code>transactionPolicy.xml</code>? Talk it over with your team. Should your transaction policy be pluggable?</li>
<li>Add Acegi/Spring Security beans to your <code>controllers.xml</code> file, or create a <code>security.xml</code> context file? Do you have different security requirements for different deployments/environments?</li>
</ul>
<p><strong>Integration testing</strong></p>
<p>You can wire up a subset of your application for integration testing (ex: given the above files, to test the database you need to create only <code>datasource.xml</code> and <code>persistence.xml</code> beans).</p>
<p>Specifically, you can annotate an integration test class as such:</p>
<pre><code>@ContextConfiguration(locations = { "/spring/datasource.xml" , "/spring/persistence.xml" })
</code></pre>
<p><strong>Works well with Spring IDE's Beans Graph</strong></p>
<p>Having lots of focused and well-named context files makes it easy to create custom BeansConfigSets to visualize the layers of your app using Spring IDE's <a href="http://springide.org/project/wiki/BeansGraph" rel="noreferrer">Beans Graph</a>. I've used this before to give new team members a high-level overview of our application's organization.</p>
|
<p>Spring is also very much about unit testing and therefore testability of your classes. That basically means thinking about modularization, separation of concerns, referencing a class through interfaces etc.</p>
| 3,002
|
<p>I'm looking for (arguably) the correct way to return data from a <code>XmlHttpRequest</code>. Options I see are:</p>
<ul>
<li><p><strong>Plain HTML</strong>. Let the request format the data and return it in a usable format.<br>
<em>Advantage</em>: easy to consume by the calling page.<br><em>Disadvantage</em>: Very rigid, stuck with a fixed layout.</p></li>
<li><p><strong>XML</strong>. Let the request return XML, format it using XSLT on the calling page.<br><em>Advantage</em>: the requested service is easily consumed by other sources.<br><em>Disadvantage</em>: Is browser support for XSLT good enough?</p></li>
<li><p><strong>JSON</strong>. Let the request return JSON, consume it using javascript, render HTML accordingly.<br><em>Advantage</em>: easier to 'OO-ify' the javascript making the request. <br><em>Disadvantage</em>: Probably not as easy to use as the previous two options.</p></li>
</ul>
<p>I've also thought about going for option one while abstracting the view logic in the called service in such a way that switching in and out different layouts would be trivial. Personally I think this option is the best out of three, for compatibility reasons.</p>
<p>While typing this, I got another insight. Would it be a good idea to allow all three response formats, based on a parameter added to the request?</p>
|
<p>If you're looking for a quick solution that should work with most available frameworks, I'd go for JSON. It's easy to start with and works.</p>
<p>If you're trying to build a larger application that you're going to extend (in terms of size or maybe your own API for 3rd party extensions) I'd go for XML. You could write a proxy to provide the information in JSON or HTML too, but having XML as the main source is definitly worth the time and effort while building the app.</p>
<p>Like <a href="https://stackoverflow.com/users/1450/john-topley">@John Topley</a> said: it depends.</p>
|
<p>I think this sort of depends on the level of "ajaxyness" your app is going to have. If your front end is a "rich client", al'a gmail, I'd go with the JSON solution, as you'd have to solve the problem of having client side view generation anyway. If you're using ajax sparingly, to provide simple messages to the user, update a few fields now and then, etc, then I'd go with option 1, since most of your view logic is already on the server.</p>
| 4,200
|
<p>What is the difference in ASP/VBScript between <code>Int()</code> and <code>CInt()</code>?</p>
|
<ul>
<li><a href="http://www.w3schools.com/Vbscript/func_int.asp" rel="noreferrer">Int()</a></li>
</ul>
<blockquote>
<p>The Int function returns the integer part of a specified number.</p>
</blockquote>
<ul>
<li><a href="http://www.w3schools.com/VBScript/func_cint.asp" rel="noreferrer">CInt()</a></li>
</ul>
<blockquote>
<p>The CInt function converts an expression to type Integer.</p>
</blockquote>
<p>And the best answer comes from <a href="http://msdn.microsoft.com/en-us/library/fctcwhw9(VS.85).aspx" rel="noreferrer">MSDN</a></p>
<blockquote>
<p>CInt differs from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. When the fractional part is exactly 0.5, the CInt function always rounds it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2.</p>
</blockquote>
|
<p>Here is another difference:</p>
<p>Script:</p>
<pre><code>wscript.echo 40.91 * 100
wscript.echo Int(40.91 * 100)
wscript.echo CInt(40.91 * 100)
</code></pre>
<p>result:</p>
<pre><code>4091
4090 (????)
4091
</code></pre>
<p>Any thoughts?</p>
| 4,100
|
<p>Is anyone using the Obout controls in C# .Net? How would you rate these controls, especially the Grid Control?</p>
|
<p>I was thoroughly impressed with them. Of all the other control sets out there (infragistics, telerik) this is the only (more than) respectable one I've worked with that was 1) free! and 2) lightweight!. The only caveat to Obout is I had trouble with merging some of these controls and some of the stock AJAX components. </p>
<p>Infragistics is by far my favorite (my comment about Obout being "lightweight" is in comparison with the heavy use of viewstate in some of the Infragistics controls) but it's around 1000-1500 a seat, so it can get expensive if you have a larger team.</p>
|
<p>I used their tree for a project. Not bad for free controls.</p>
| 8,158
|
<p>"Evidence-based scheduling" in FogBugz is interesting, but how do I use it w/ an Agile methodology?</p>
|
<p>As <a href="https://stackoverflow.com/questions/55693/how-do-you-use-fogbugz-with-an-agile-methodology#55702">eed3si9n</a> said, if you are consistent in your estimates for EBS, FogBugz will take care of this for you.</p>
<p>As to the more general, how does FogBugz fit with the Agile methodology, your best bet is to do sprints as mini-releases. Create a sprint and add the cases you want to achieve for that sprint to that release (or milestone). Give it an end date, say a week away, if you do week long sprints. Then EBS can track it and tell you if you are on schedule.</p>
<p>The graphs in the Reports section will also show you a burndown chart. The terminology is a bit different because FogBugz isn't Agile-only but the info is there.</p>
<p>You want to see if the expected time you are going to finish your sprint is staying steady or going forward. If it is steady you are on track and your burndown rate is on target. If it is creeping up, you are losing ground and your sprint is getting delayed. Time to move things to the next sprint or figure out why you messed up your estimates :)</p>
<p>Essentially I suppose this is a burn-up chart instead of a burndown chart, but it gives you the same answer to the same question. Am I going to finish on time? What do I have left to do?</p>
<p>Atalasoft's <a href="https://loufranco.com/blog/scrum-at-atalasoft-burndown-charts-from-fogbugz" rel="nofollow noreferrer">Lou Franco wrote an excellent post</a> on this as well. <a href="http://paltman.com/2006/09/05/sprint-burndown-from-fogbugz/" rel="nofollow noreferrer">Patrick Altman</a> also has an article.</p>
<p><strong>Update:</strong> fixed link to Altman's article</p>
|
<p>I asked the FogBugz guys the same thing because in XP for example you'd provide the estimate in IET (ideal engineering time). Their answer was to be consistent in the way you provide the estimate.</p>
| 7,951
|
<p>I've been using a lot of new .NET 3.5 features in the work that I've been doing, lately. The application that I'm building is intended for distribution among consumers who will probably not have the latest version (or perhaps <em>any version</em>) of the .NET framework on their machines.</p>
<p>I went to go <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=333325FD-AE52-4E35-B531-508D977D32A6&displaylang=en" rel="noreferrer">download the .NET 3.5 redistributable package</a> only to find out that it's almost <strong><em>200 MB!</em></strong> This is unacceptable for my application, because it's supposed to be a quick and painless consumer application that installs quickly and keeps a low profile on the user's machine. For users that have .NET 3.5 already installed, our binary downloads have been instantaneous, so far. This 200 MB gorilla will more than quadruple the size of the download. Is there any other option than this redistributable package that I can use to make sure the framework is on the machine that won't take the user out of our "quick and painless" workflow? Our target time from beginning of download to finalizing the install is less than two minutes. Is it just not possible for someone who doesn't already have .NET installed?</p>
|
<p>That's one of the sad reasons i'm still targeting .net 2.0 whenever possible :/</p>
<p>But people don't neccessarily need the full 200 MB Package. There is a 3 MB Bootstrapper which will only download the required components:</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&DisplayLang=en" rel="noreferrer">.net 3.5 SP1 Bootstrapper</a></p>
<p>However, the worst case scenario is still a pretty hefty download. Also, see <a href="http://blogs.msdn.com/astebner/archive/2008/01/10/7067719.aspx" rel="noreferrer">this article</a> for a more detailed explanation on the size and an alternative workaround to the size problem.</p>
<p>Addition: Since answering this question, Scott Hanselman created <a href="http://www.smallestdotnet.com" rel="noreferrer">SmallestDotNet.com</a>, which will determine the smallest required download. Doesn't change the worst case scenario, but is still useful to know.</p>
|
<p>Also, it is worth including (in some fashion) the Service Pack downloads as well. In fact, depending on how your executables are built, you might be forced to install the Framework and the Service Packs.</p>
| 2,818
|
<p>I am writing an application in Java for the desktop using the Eclipse SWT library for GUI rendering. I think SWT helps Java get over the biggest hurdle for acceptance on the desktop: namely providing a Java application with a consistent, responsive interface that looks like that belonging to any other app on your desktop. However, I feel that packaging an application is still an issue. </p>
<p>OS X natively provides an easy mechanism for wrapping Java apps in native application bundles, but producing an app for Windows/Linux that doesn't require the user to run an ugly batch file or click on a .jar is still a hassle. Possibly that's not such an issue on Linux, where the user is likely to be a little more tech-savvy, but on Windows I'd like to have a regular .exe for him/her to run.</p>
<p>Has anyone had any experience with any of the .exe generation tools for Java that are out there? I've tried JSmooth but had various issues with it. Is there a better solution before I crack out Visual Studio and roll my own?</p>
<p><strong>Edit:</strong> I should perhaps mention that I am unable to spend a lot of money on a commercial solution.</p>
|
<p>To follow up on pauxu's answer, I'm using launch4j and NSIS on a project of mine and thought it would be helpful to show just how I'm using them. Here's what I'm doing for Windows. BTW, I'm creating .app and .dmg for Mac, but haven't figured out what to do for Linux yet.</p>
<h2>Project Copies of launch4j and NSIS</h2>
<p>In my project I have a "vendor" directory and underneath it I have a directory for "launch4j" and "nsis". Within each is a copy of the install for each application. I find it easier to have a copy local to the project rather than forcing others to install both products and set up some kind of environment variable to point to each.</p>
<h2>Script Files</h2>
<p>I also have a "scripts" directory in my project that holds various configuration/script files for my project. First there is the launch4j.xml file:</p>
<pre><code><launch4jConfig>
<dontWrapJar>true</dontWrapJar>
<headerType>gui</headerType>
<jar>rpgam.jar</jar>
<outfile>rpgam.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://www.rpgaudiomixer.com/</downloadUrl>
<supportUrl></supportUrl>
<customProcName>false</customProcName>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon></icon>
<jre>
<path></path>
<minVersion>1.5.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<splash>
<file>..\images\splash.bmp</file>
<waitForWindow>true</waitForWindow>
<timeout>60</timeout>
<timeoutErr>true</timeoutErr>
</splash>
</launch4jConfig>
</code></pre>
<p>And then there's the NSIS script rpgam-setup.nsis. It can take a VERSION argument to help name the file.</p>
<pre><code>; The name of the installer
Name "RPG Audio Mixer"
!ifndef VERSION
!define VERSION A.B.C
!endif
; The file to write
outfile "..\dist\installers\windows\rpgam-${VERSION}.exe"
; The default installation directory
InstallDir "$PROGRAMFILES\RPG Audio Mixer"
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\RPG_Audio_Mixer" "Install_Dir"
# create a default section.
section "RPG Audio Mixer"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
File /r "..\dist\layout\windows\"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\RPG_Audio_Mixer "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "DisplayName" "RPG Audio Mixer"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "NoRepair" 1
WriteUninstaller "uninstall.exe"
; read the value from the registry into the $0 register
;readRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion
; print the results in a popup message box
;messageBox MB_OK "version: $0"
sectionEnd
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\RPG Audio Mixer"
CreateShortCut "$SMPROGRAMS\RPG Audio Mixer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\RPG AUdio Mixer\RPG Audio Mixer.lnk" "$INSTDIR\rpgam.exe" "" "$INSTDIR\rpgam.exe" 0
SectionEnd
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer"
DeleteRegKey HKLM SOFTWARE\RPG_Audio_Mixer
; Remove files and uninstaller
Delete $INSTDIR\rpgam.exe
Delete $INSTDIR\uninstall.exe
; Remove shortcuts, if any
Delete "$SMPROGRAMS\RPG Audio Mixer\*.*"
; Remove directories used
RMDir "$SMPROGRAMS\RPG Audio Mixer"
RMDir "$INSTDIR"
SectionEnd
</code></pre>
<h2>Ant Integration</h2>
<p>I have some targets in my Ant buildfile (build.xml) to handle the above. First I tel Ant to import launch4j's Ant tasks:</p>
<pre><code><property name="launch4j.dir" location="vendor/launch4j" />
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" />
</code></pre>
<p>I then have a simple target for creating the wrapper executable:</p>
<pre><code><target name="executable-windows" depends="jar" description="Create Windows executable (EXE)">
<launch4j configFile="scripts/launch4j.xml" outfile="${exeFile}" />
</target>
</code></pre>
<p>And another target for making the installer:</p>
<pre><code><target name="installer-windows" depends="executable-windows" description="Create the installer for Windows (EXE)">
<!-- Lay out files needed for building the installer -->
<mkdir dir="${windowsLayoutDirectory}" />
<copy file="${jarFile}" todir="${windowsLayoutDirectory}" />
<copy todir="${windowsLayoutDirectory}/lib">
<fileset dir="${libraryDirectory}" />
<fileset dir="${windowsLibraryDirectory}" />
</copy>
<copy todir="${windowsLayoutDirectory}/icons">
<fileset dir="${iconsDirectory}" />
</copy>
<copy todir="${windowsLayoutDirectory}" file="${exeFile}" />
<mkdir dir="${windowsInstallerDirectory}" />
<!-- Build the installer using NSIS -->
<exec executable="vendor/nsis/makensis.exe">
<arg value="/DVERSION=${version}" />
<arg value="scripts/rpgam-setup.nsi" />
</exec>
</target>
</code></pre>
<p>The top portion of that just copies the necessary files for the installer to a temporary location and the second half executes the script that uses all of it to make the installer.</p>
|
<p>I went through the same and found that all of the free options weren't very good. Looks like you'll be writing your own. I'd be interested to see if someone has a free/cheap option that works</p>
| 2,933
|
<p>I am trying to scrape an html table and save its data in a database. What strategies/solutions have you found to be helpful in approaching this program.</p>
<p>I'm most comfortable with Java and PHP but really a solution in any language would be helpful.</p>
<p>EDIT: For more detail, the UTA (Salt Lake's Bus system) provides bus schedules on its website. Each schedule appears in a table that has stations in the header and times of departure in the rows. I would like to go through the schedules and save the information in the table in a form that I can then query. </p>
<p>Here's the <a href="http://www.rideuta.com/ridingUTA/schedules/routeSchedules.aspx" rel="nofollow noreferrer">starting point</a> for the schedules </p>
|
<p>It all depends on how properly your HTML to scrape is? If it's valid XHTML, you can simply use some XPath queries on it to get whatever you want.</p>
<p>Example of xpath in php: <a href="http://blogoscoped.com/archive/2004_06_23_index.html#108802750834787821" rel="nofollow noreferrer">http://blogoscoped.com/archive/2004_06_23_index.html#108802750834787821</a></p>
<p>A helper class to scrape a table into an array: <a href="http://www.tgreer.com/class_http_php.html" rel="nofollow noreferrer">http://www.tgreer.com/class_http_php.html</a></p>
|
<p>I have tried screen-scraping before, but I found it to be very brittle, especially with dynamically-generated code.
I found a third-party DOM-parser and used it to navigate the source code with Regex-like matching patterns in order to find the data I needed.</p>
<p>I suggested trying to find out if the owners of the site have a published API (often Web Services) for retrieving data from their system. If not, then good luck to you.</p>
| 9,886
|
<p>I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this:</p>
<pre><code>import unittest
l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]]
class TestSequence(unittest.TestCase):
def testsample(self):
for name, a,b in l:
print "test", name
self.assertEqual(a,b)
if __name__ == '__main__':
unittest.main()
</code></pre>
<p>The downside of this is that it handles all data in one test. I would like to generate one test for each item on the fly. Any suggestions?</p>
|
<p>This is called "parametrization".</p>
<p>There are several tools that support this approach. E.g.:</p>
<ul>
<li><a href="https://docs.pytest.org/en/latest/parametrize.html" rel="noreferrer">pytest's decorator</a></li>
<li><a href="https://github.com/wolever/parameterized" rel="noreferrer">parameterized</a></li>
</ul>
<p>The resulting code looks like this:</p>
<pre><code>from parameterized import parameterized
class TestSequence(unittest.TestCase):
@parameterized.expand([
["foo", "a", "a",],
["bar", "a", "b"],
["lee", "b", "b"],
])
def test_sequence(self, name, a, b):
self.assertEqual(a,b)
</code></pre>
<p>Which will generate the tests:</p>
<pre class="lang-none prettyprint-override"><code>test_sequence_0_foo (__main__.TestSequence) ... ok
test_sequence_1_bar (__main__.TestSequence) ... FAIL
test_sequence_2_lee (__main__.TestSequence) ... ok
======================================================================
FAIL: test_sequence_1_bar (__main__.TestSequence)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/parameterized/parameterized.py", line 233, in <lambda>
standalone_func = lambda *a: func(*(a + p.args), **p.kwargs)
File "x.py", line 12, in test_sequence
self.assertEqual(a,b)
AssertionError: 'a' != 'b'
</code></pre>
<p>For historical reasons I'll leave the original answer circa 2008):</p>
<p>I use something like this:</p>
<pre><code>import unittest
l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]]
class TestSequense(unittest.TestCase):
pass
def test_generator(a, b):
def test(self):
self.assertEqual(a,b)
return test
if __name__ == '__main__':
for t in l:
test_name = 'test_%s' % t[0]
test = test_generator(t[1], t[2])
setattr(TestSequense, test_name, test)
unittest.main()
</code></pre>
|
<p>Besides using setattr, we can use <em>load_tests</em> with Python 3.2 and later.</p>
<pre><code>class Test(unittest.TestCase):
pass
def _test(self, file_name):
open(file_name, 'r') as f:
self.assertEqual('test result',f.read())
def _generate_test(file_name):
def test(self):
_test(self, file_name)
return test
def _generate_tests():
for file in files:
file_name = os.path.splitext(os.path.basename(file))[0]
setattr(Test, 'test_%s' % file_name, _generate_test(file))
test_cases = (Test,)
def load_tests(loader, tests, pattern):
_generate_tests()
suite = TestSuite()
for test_class in test_cases:
tests = loader.loadTestsFromTestCase(test_class)
suite.addTests(tests)
return suite
if __name__ == '__main__':
_generate_tests()
unittest.main()
</code></pre>
| 5,290
|
<p>Basically I would like to find a way to ddo something like:</p>
<pre><code><asp:Label ID="lID" runat="server" AssociatedControlID="txtId" Text="<%# MyProperty %>"></asp:Label>
</code></pre>
<p>I know I could set it from code behind (writing lId.Text = MyProperty), but I'd prefer doing it in the markup and I just can't seem to find the solution.
(MyProperty is a string property)
cheers</p>
|
<p>You can do </p>
<pre><code><asp:Label runat="server" Text='<%# MyProperty %>' />
</code></pre>
<p>And then a Page.DataBind() in the codebehind.</p>
|
<p>Call lID.Databind() from code-behind</p>
| 9,916
|
<p>What is the best method to parse multiple, discrete, custom XML documents with Java?</p>
|
<p>I would use <a href="http://jcp.org/en/jsr/detail?id=173" rel="noreferrer">Stax</a> to parse XML, it's fast and easy to use. I've been using it on my last project to parse XML files up to 24MB. There's a nice introduction on <a href="http://today.java.net/pub/a/today/2006/07/20/introduction-to-stax.html" rel="noreferrer">java.net</a>, which tells you everything you need to know to get started.</p>
|
<p>Below is the code of extracting some value value using <a href="http://vtd-xml.sf.net" rel="nofollow">vtd-xml</a>.</p>
<pre><code>import com.ximpleware.*;
public class extractValue{
public static void main(String s[]) throws VTDException, IOException{
VTDGen vg = new VTDGen();
if (!vg.parseFile("input.xml", false));
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("/aa/bb[name='k1']/value");
int i=0;
while ((i=ap.evalXPath())!=-1){
System.out.println(" value ===>"+vn.toString(i));
}
}
}
</code></pre>
| 4,311
|
<p>I'm having an issue where prints with narrow tolerance come out fused. This makes it pretty much impossible to print anything with narrow parts. It seems to be mostly (maybe only) an issue in the bottom skin layers. Once it gets through those, the rest of the print goes smoothly and tight tolerances are not a problem.</p>
<p>Here's an example where I've tried to print some hinges:</p>
<p><a href="https://i.stack.imgur.com/NrtaB.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/NrtaB.jpg" alt="First three layers" /></a></p>
<p>It's a test print where each hinge has a different tolerance, so the left and right are expected to look different. Below each real image is a preview layer from Cura showing how it's supposed to look.</p>
<p>The first layer appears OK. The second layer looks a little messy, and the gap between inner and outer circles has shrunk. By the third layer the hinge on the right is completely fused.</p>
<p>The printer is an Ender 3 Pro with a glass bed (flat glass, no special surface), BLTouch, and Marlin 1.1.9. The slicer is Cura 4.6.1, and for this test print I used the default for "Super Quality - 0.12 mm" at 200 °C and 60 °C bed with no changes. The filament is Mika3D PLA.</p>
<p>Some things I've tried to fix this:</p>
<ul>
<li>Calibrated e-steps (currently set at 95.88) - no noticeable difference</li>
<li>Calibrated flow rate (got 97.859 % but returned to 100 % for this test) - no noticeable difference</li>
<li>Varying temperatures from 190 to 230 °C by 5 °C increments - no improvement from 200 °C</li>
<li>Set "Initial Layer Horizontal Expansion" to -0.1 mm, -0.4 mm, and -1.0 mm in Cura. - no improvement.</li>
<li>Set "Initial Layer Flow" to 90 %. - no improvement.</li>
<li>Obsessively leveled and re-leveled the bed. - no improvement.</li>
<li>Moved the Z-offset up and down to get more or less squish on the first layer - no improvement.</li>
<li>Tried various brands and colors of PLA - problem is consistent.</li>
<li>Reduced build plate temperature to 45 °C after initial layer - no improvement.</li>
</ul>
<p>What else is there to check?</p>
<p><strong>Edit 2020-06-26:</strong></p>
<p>At <code>R.. GitHub STOP HELPING ICE</code>'s suggestion I returned the e-steps to default (93), re-leveled the bed, and adjusted the z-offset tighter. I made 10 attempts with varying z-offsets, and here's the best one:</p>
<p><a href="https://i.stack.imgur.com/bRrSW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/bRrSW.jpg" alt="First three layers with e-steps at 93" /></a></p>
<p>The first layer looks better! But the second and third layers are just as bad as before, in fact maybe worse. The circle on the right completely fused on only the second layer. And the top surface is just as ripple-ey and messed up as before.</p>
<p>Here's a closeup of the fourth layer to show how bad it is:
<a href="https://i.stack.imgur.com/Z7MvW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Z7MvW.jpg" alt="Fourth layer" /></a></p>
<p>So although the re-calibrated e-steps may have been <em>a</em> problem, that clearly wasn't the only problem. What else should I be looking at here?</p>
<p><strong>Edit 2020-06-27:</strong></p>
<p>At <code>Davo</code>'s suggestion I double-checked all my slicer settings. Flow is set to 100% everywhere, wall thickness is 0.8 mm for two walls (so 0.4 mm each), and nozzle diameter is correct at 0.4 mm.</p>
<p>At <code>R.. GitHub STOP HELPING ICE</code>s suggestion I double-checked my filament diameter. It is set to 1.75 mm. On the actual filament, my digital caliper measures 1.74 to 1.76, within the expected tolerance. So that doesn't appear to be the issue.</p>
<p>At <code>0scar♦</code>s suggestion I tried a print with 0.2 mm layer height. Here's the first layer:
<a href="https://i.stack.imgur.com/sFOUo.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/sFOUo.jpg" alt="0.2 mm layer height, first layer" /></a>
Looks like the same over-extrusion.</p>
<p>Then I tried reducing the flow multiplier to 90% (for both "flow" and "initial layer flow") and printing at 0.2 mm layer height:
<a href="https://i.stack.imgur.com/8oloh.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/8oloh.jpg" alt="90% flow with 0.2 mm layer height" /></a>
Better, but it <em>still</em> looks over-extruded!</p>
<p>I don't know what else to try.</p>
|
<p>I think this is resolved. After looking at every conceivable source of over-extrusion and coming up negative, <code>R.. GitHub STOP HELPING ICE</code> suggested that it might be a mechanical problem in Z axis movement, like in <a href="https://3dprinting.stackexchange.com/questions/8022/first-3-mm-prints-poorly-then-fine-after-that">this question</a>.</p>
<p>I checked by leveling the bed and zeroing the Z axis at 0.05 mm above the bed, using a feeler gauge. I gave it the instruction to move the Z axis up by 0.2 mm (to simulate a single layer), then checked it with a 0.25 mm feeler gauge. It did not fit. I raised it .01 mm at a time, and I was not able to insert the gauge until it hit 0.5 mm!</p>
<p>I printed a 20 mm test cube and measured the Z height:
<a href="https://i.stack.imgur.com/4Lvq2.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/4Lvq2.jpg" alt="Initial 20 mm test cube" /></a></p>
<p>At 19.58 mm, it was short. Only a little bit though, which is consistent with Z problems only occurring in the first few layers for some reason.</p>
<p>Based on the advice in the other question, I fiddled with the eccentric nuts on the left and right side of X axis gantry, adjusting them to be tight enough that turning the wheels moves the gantry up and down, but loose enough that I can still turn the wheels if I hold the gantry in place.</p>
<p>I checked again with the feeler gauge, and this time the 0.25 mm gauge fit just fine at 0.2 mm. Cool! I printed another test cube and measured:</p>
<p><a href="https://i.stack.imgur.com/Yq2zW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Yq2zW.jpg" alt="Revised 20 mm test cube" /></a></p>
<p>OK, at 20.06 mm it's not perfect, but it's a lot better. I printed the hinges again:</p>
<p><a href="https://i.stack.imgur.com/Q4MYZ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Q4MYZ.jpg" alt="Hinges" /></a></p>
<p>Again not perfect, but so much better. And the specific problem of uncontrollable expansion in the 2nd and 3rd layers is totally gone.</p>
|
<p>I had the same problem with my Ender-3 V2.</p>
<p>You need to check if the feeder bracket is square like explained in <a href="https://www.youtube.com/watch?v=xnzNd_FIMKY" rel="nofollow noreferrer">this YouTube</a></p>
<p>If that is not the problem maybe you need a custom bracket to change the spacing between the Z-motor and the frame like <a href="https://www.thingiverse.com/thing:2752080" rel="nofollow noreferrer">this</a>, <a href="https://www.thingiverse.com/thing:4699747" rel="nofollow noreferrer">this</a> or <a href="https://www.thingiverse.com/thing:4723087" rel="nofollow noreferrer">this</a></p>
<p>I have improved mine a lot using:</p>
<ul>
<li><a href="https://www.thingiverse.com/thing:2752080" rel="nofollow noreferrer">This Z-motor mount</a></li>
<li>Using <a href="https://www.amazon.com/s?k=Elmer%E2%80%99s+Disappearing+Purple+Glue+Stick" rel="nofollow noreferrer">glue stick</a> instead of squeezing the first layer</li>
<li><a href="https://www.youtube.com/watch?v=rDm9OziZ6dY" rel="nofollow noreferrer">Leveling the bed using a feeler gauge</a> instead of a piece of paper</li>
<li>Initial fan speed 100 %, all layers the same</li>
<li>Same flow rate, line width, line height on all layers</li>
<li>Build plate 40 °C, nozzle 205 °C</li>
<li>Seam Corner Preference: Hide or Expose Seam</li>
</ul>
| 1,694
|
<p>Is there a way to have TortoiseSVN (or any other tool) auto-add any new .cs files I create within a directory to my working copy so I don't have to remember which files I created at the end of the day?</p>
|
<p>If you just commit your working copy, you'll get a file list showing you your unversioned files, which you can tick to add as you commit. You don't have to add them explicitly before you commit.</p>
|
<p>Yes, you can add a bat file to svn (on the installed server) so that anytime you update a particular branch, that change get mimicked.. I believe its called hooks... </p>
<p>I hope this is what you meant. </p>
| 7,349
|
<p>This caught my attention last night.</p>
<p>On the latest <a href="http://altnetpodcast.com/episodes/10-oop-in-ruby" rel="nofollow noreferrer">ALT.NET Podcast</a> Scott Bellware discusses how as opposed to Ruby, languages like C#, Java et al. are not truly object oriented rather opting for the phrase "class-oriented". They talk about this distinction in very vague terms without going into much detail or discussing the pros and cons much.</p>
<p>What is the real difference here and how much does it matter? What are other languages then are "object-oriented"? It sounded pretty interesting but I don't want to have to learn Ruby just to know what if anything I am missing.</p>
<h2>Update</h2>
<p>After reading some of the answers below it seems like people generally agree that the reference is to duck-typing. What I'm not sure I understand still though is the claim that this ultimately changes all that much. Especially if you are already doing proper TDD with loose coupling etc. Can someone show me an example of a specific thing I could do with Ruby that I cannot do with C# and that exemplifies this different OOP approach?</p>
|
<p>The duck typing comments here are more attributing to the fact that Ruby and Python are more <em>dynamic</em> than C#. It doesn't really have anything to do with it's OO Nature.</p>
<p>What (I think) Bellware meant by that is that in Ruby, everything is an object. Even a class. A class definition is an instance of an object. As such, you can add/change/remove behavior to it at runtime.</p>
<p>Another good example is that NULL is an object as well. In ruby, everything is LITERALLY an object. Having such deep OO in it's entire being allows for some fun meta-programming techniques such as method_missing.</p>
|
<p>I'll take a stab at this.</p>
<p>Python and Ruby are duck-typed. To generate any maintainable code in these languages, you pretty much have to use test driven development. As such, it is very important for a developer to easily inject dependencies into their code without having to create a giant supporting framework. </p>
<p>Successful dependency-injection depends upon on having a pretty good object model. The two are sort of two sides of the same coin. If you really understand how to use OOP, then you should by default create designs where dependencies can be easily injected. </p>
<p>Because dependency injection is easier in dynamically typed languages, the Ruby/Python developers feel like their language understands the lessons of OO much better than other statically typed counterparts.</p>
| 7,533
|
<p>Marlin offers a bunch of different choices for auto-levelling and assisted manual levelling for bent build plates (mesh levelling), but for the moment I want to level things completely manually.</p>
<p>That is, I want to move Z to 0, disable steppers, and then move around the print head and adjust the distance between bed and nozzle at various points with a piece of paper.</p>
<p>With the old Repetier based firmware on my printer, selecting "home all axes" did not only home XYZ to endstops, but it also moved the head to position (0, 0, 0) afterwards. Then I could simply disable steppers via the menu and go on with my levelling. Note that in my case, the coordinates of the endstop positions are negative for all axes, so moving to the endstops alone isn't cutting it.</p>
<p>With Marlin, selecting the "auto home" option merely moves to the endstops and then to some positive Z position (+10). This means I have to use the menu to manually move Z back to 0, which is quite inconvenient, unless I have a PC nearby that allows me to enter G-code.</p>
<p>So, that leaves two related questions for me:</p>
<p>Is there some simple way to move to (0, 0, 0) with the menu?</p>
<p>Can I implement an assisted manual levelling (i.e. some procedure that simply moves the head between a number of different X/Y positions) easily? Does something like that already exist? If not, I wonder why.</p>
|
<p>Write a few pieces of gcode to do this. Place it on an SD-card (I assume you have a reader) and select the file you want to execute.</p>
<p>Home all:</p>
<pre><code>G28
G1 Z0
</code></pre>
<p>Do you really want to home it directly? I would say you want to take it down slowly and adjusting end-stops incrementally.</p>
<p>First:</p>
<pre><code>G28
G1 Z10
</code></pre>
<p>Then</p>
<pre><code>G28
G1 Z3
</code></pre>
<p>Then</p>
<pre><code>G28
G1 Z1
</code></pre>
<p>etc etc</p>
<p>You can also move it around in the X and Y plane:</p>
<pre><code>G28
G1 Z5 X50 Y30
</code></pre>
|
<p>The way I manually level my bed is by connecting a computer to the printer via USB. As far as I am aware, if you have a touchscreen this should be available on the printer options as well for marlin.</p>
<p>But if you connect a computer, simply run something like pronterface or any other manual control gui and:</p>
<p>1) home axes</p>
<p>2) disable motors</p>
<p>3) move printhead in x/y directions as necessary by hand</p>
<p>4) adjust z height manually with the GUI software. This should not affect your x/y positions or turn on their motors.</p>
| 532
|
<p>We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very conducive to continuous integration via Hudson.</p>
<p>We have OSGi bundles which depend on other OSGi bundles. I'd really hate to hardcode build order in a custom ANT build. We've done this is the past and it's pretty horrible. Is there any build tool that can EASILY manage OSGi dependencies, if not automatically resolve them? Are there any DECENT examples of how to this?</p>
<p>CLARIFICATION:</p>
<p>The generated build scripts are only usable via Eclipse. They require manually running pieces of Eclipse. We've also got some standard targets which the Eclipse build won't have, and I don't want to modify the generated file since I may regenerate (I know I can do includes, but I want to avoid the Eclipse gen file all together)</p>
<p>Here is my project layout:</p>
<pre><code>/
-PluginA
-PluginB
-PluginC
.
.
.
</code></pre>
<p>In using the Eclipse PDE, each plugin has a Manifest, but no build.xml as the PDE does that for me. Hard to automate a gui driven process w/ Hudson. I'd like to setup my own build.xml to build each, BUT there are dependencies and build order issues. These issues are driven by the Manifest files (which describe OSGi imports). For example, PluginC depends on PluginB which depends on PluginA. They must be built in the correct order. I realize that I can manually control the build order, I'm looking for a tool to help automate the build order dependency management.</p>
|
<p>Maven2 all the way; has an Eclipse plugin called <a href="http://m2eclipse.codehaus.org/" rel="nofollow noreferrer">m2eclipse</a> to help with managing it, solves exactly the dependency problem and then some. Has a <a href="http://www.sonatype.com/community/definitive_guide.html" rel="nofollow noreferrer">free online book as documentation</a>.</p>
<p>Specifically look at <a href="http://www.sonatype.com/book/reference/multimodule.html#" rel="nofollow noreferrer">multi-module projects</a> for bundling many components together and have Maven work out the build order and dependencies.</p>
<p>There is also a <a href="http://www.sonatype.com/book/reference/eclipse.html#" rel="nofollow noreferrer">chapter on the Eclipse integration</a>.</p>
<p>And that is just Eclipse and Maven, next you get some cool goodies for OSGi:</p>
<ul>
<li>The <a href="http://felix.apache.org/site/maven-bundle-plugin-bnd.html" rel="nofollow noreferrer">Apache Felix BND Maven plugin</a> will auto-generate your manifests or at the very least help you</li>
<li>The <a href="http://www.ops4j.org/projects/pax/maven/" rel="nofollow noreferrer">PAX OPS4J project</a> and their Maven plugins can be a great help in bootstrapping projects, providing launchers, etc</li>
</ul>
<p>And just fundamentally, the Maven module model fits perfectly with OSGi's bundle model. We've been building and managing multiple products with hundreds of bundles using Maven for more than 3 years now and it's great.</p>
|
<p>Can you please elaborate where the problem occurs? You mention OSGi bundle dependencies. Is this during runtime? Or during compile-time? In the first case you should consider Declarative Services (see OSGi Spec).</p>
| 4,747
|
<p>Question is pretty self explanitory. I want to do a simple find and replace, like you would in a text editor on the data in a column of my database (which is MsSQL on MS Windows server 2003)</p>
|
<p>The following query replace each and every <code>a</code> character with a <code>b</code> character.</p>
<pre><code>UPDATE
YourTable
SET
Column1 = REPLACE(Column1,'a','b')
WHERE
Column1 LIKE '%a%'
</code></pre>
<p>This will not work on SQL server 2003.</p>
|
<p>If you are working with SQL Server 2005 or later there is also a CLR library available at <a href="http://www.sqlsharp.com/" rel="nofollow noreferrer">http://www.sqlsharp.com/</a> that provides .NET implementations of string and RegEx functions which, depending on your volume and type of data may be easier to use and in some cases the .NET string manipulation functions can be more efficient than T-SQL ones.</p>
| 8,350
|
<p>How can I copy a line 10 times easily in Emacs? I can't find a copy-line shortcut or function. I can use C-aC-spcC-eM-w to laboriously copy the line but how can I then paste it more than once?</p>
<p>Any ideas before I go and write my own functions.</p>
|
<p>you can use a keyboard macro for that:-</p>
<p>C-a C-k C-x ( C-y C-j C-x ) C-u 9 C-x e</p>
<p><strong>Explanation:-</strong></p>
<ul>
<li>C-a : Go to start of line</li>
<li>C-k : Kill line</li>
<li>C-x ( : Start recording keyboard macro</li>
<li>C-y : Yank killed line</li>
<li>C-j : Move to next line</li>
<li>C-x ) : Stop recording keyboard macro</li>
<li>C-u 9 : Repeat 9 times</li>
<li>C-x e : Execute keyboard macro</li>
</ul>
|
<p>You get the line with C-k, you make the next command happen ten times with C-u 10, then you paste the line with C-y. Pretty simple.</p>
<p>If you always want C-k to do the whole line, you can set kill-whole-line to t. No more fiddling with C-a or C-e.</p>
<p>There's a lot you can do with fancy kill rings, registers, and macros, and I encourage you to learn them, but yanking a line ten times doesn't have to be tough or strange.</p>
| 9,755
|
<p><a href="http://hessian.caucho.com" rel="nofollow noreferrer">Hessian</a> is a custom binary serialization protocol, (which is open-source - I think), that forms the basis for a binary cross platform remoting framework. I'd like to know if anyone here has used it, and if so, what sort of performance can we expect from a solution that bridges a Java app on one side with a C# app on the other. (Let us consider that we are serializing simple classes, and may be arrays, lists, dictionaries of simple classes.)</p>
|
<p>Have you looked at the HessianC# project (<a href="http://www.hessiancsharp.org/" rel="nofollow noreferrer">http://www.hessiancsharp.org/</a>)?</p>
|
<p>This is the sort of problem that web services were designed to solve. Although no longer simple, the SOAP format allows you to serialize objects to an XML representation on a Java/C# application, transmit them across the wire and deserialize them in the corresponding Java/C# application (Java/C# may be replaced with virtually any language that can translate an XML document). Although "serialize" is used here, it is also common for this process to be referred as "marshalling".</p>
<p>However, moving away from SOAP for web services is currently being considered by many. Find out more about web services from Wikipedia: <a href="http://en.wikipedia.org/wiki/Web_services" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Web_services</a></p>
| 8,845
|
<p>Does Django have any template tags to generate common HTML markup? For example, I know that I can get a url using</p>
<pre><code>{% url mapper.views.foo %}
</code></pre>
<p>But that only gives me the URL and not the HTML code to create the link. Does Django have anything similar to Rails' link_to helper? I found <a href="http://code.google.com/p/django-helpers/" rel="noreferrer">django-helpers</a> but since this is a common thing I thought Django would have something built-in.</p>
|
<p>No it doesn't.</p>
<p><a href="http://www.b-list.org/" rel="noreferrer">James Bennett</a> answered a <a href="http://www.b-list.org/weblog/2006/jul/02/django-and-ajax/" rel="noreferrer">similar question</a> a while back, regarding Rails' built-in JavaScript helpers.</p>
<p>It's <em>really</em> unlikely that Django will ever have 'helper' functionality built-in. The reason, if I understand correctly, has to do with Django's core philosophy of keeping things <a href="http://docs.djangoproject.com/en/dev/misc/design-philosophies/#id1" rel="noreferrer">loosely coupled</a>. Having that kind of helper functionality built-in leads to coupling Django with a specific JavaScript library or (in your case) html document type. </p>
<p>EG. What happens if/when HTML 5 is finally implemented and Django is generating HTML 4 or XHTML markup?</p>
<p>Having said that, Django's template framework is really flexible, and it wouldn't be terribly difficult to <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/" rel="noreferrer">write your own tags/filters</a> that did what you wanted. I'm mostly a designer myself, and I've been able to put together a couple custom tags that worked like a charm.</p>
|
<p>This won't answer directly to the question, but why not using <code><a href="{% url mapper.views.foo %}">foo</a></code> in template then?</p>
| 8,670
|
<p>When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property value, and if you set "Sender" it only adds another header field in the DATA section. This results in "From X@Y.COM on behalf of A@B.COM", which is not what you want. Am I missing something?</p>
<p>The use case is controlling the NDR destination for newsletters, etc., that are sent on behalf of someone else.</p>
<p>I am currently using <a href="http://www.aspnetemail.com/" rel="noreferrer">aspNetEmail</a> instead of System.Net.Mail, since it allows me to do this properly (like most other SMTP libraries). With aspNetEmail, this is accomplished using the EmailMessage.ReversePath property.</p>
|
<p><code>MailMessage.Sender</code> will always insert a <code>Sender</code> header (interpreted as <em>on behalf of</em> in your e-mail client). </p>
<p>If you use the <code>Network</code> delivery method on the <code>SmtpClient</code>, <code>.Sender</code> will also change the sender in the envelope. Using the <code>PickupDirectoryFromIis</code> delivery method will leave it to IIS to determine the envelope sender, and IIS will use the <code>From</code> address, not the <code>Sender</code> address. </p>
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/ncl/thread/a26c273a-18eb-4143-8631-233088977b21/" rel="noreferrer">There's a similar question on MSDN here.</a> </p>
|
<p>Do you mean this?:</p>
<pre><code>//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@mycompany.com");
mail.To.Add("you@yourcompany.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>";
mail.IsBodyHtml = true;
//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
</code></pre>
<p>From <a href="http://www.systemnetmail.com/faq/3.1.2.aspx" rel="nofollow noreferrer">http://www.systemnetmail.com/faq/3.1.2.aspx</a></p>
| 7,501
|
<p>I have an Ender 5 with an auto bed leveling sensor (TRU-LEV 600).</p>
<p>It is working fine, however, as the sensor probes the bed, the nozzle and the bed cool down and are not staying heated as it is getting the points, even though they were heated up in the first place.</p>
<p>How do I stop the bed and hotend from cooling down while the bed is being probed?</p>
<p>Here is my start G-code:</p>
<pre><code>M75; Start Print Timer and Engage Fil Sensor if USB Printing
G92 E0; Reset Extruder distance to 0
G1 E-2; Retracts filament to prevent blobs during probing
M84 E; Disable E Motor for probe accuracy on direct drive systems
G28; home all axes
G28 Z; home Z to get more accurate Z position
G29; TRULEV mesh generation
G4 S10; wait for heaters to recover
M117 Purge extruder
G92 E0; reset extruder
G1 X0.1 Y20 Z0.3 F5000.0; move to start-line position
G1 Z1.0 F3000; move z up little
G1 X0.1 Y100.0 Z0.3 F750.0 E15; draw 1st line
G1 X0.4 Y100.0 Z0.3 F5000.0; move to side a little
G1 X0.4 Y20 Z0.3 F750.0 E30; draw 2nd line
G92 E0; reset extruder
G1 Z1.0 F3000; move z up little
M117 Printing.....
</code></pre>
|
<p>For Marlin firmware, you should <strong>check the setting <code>PROBING_HEATERS_OFF</code></strong> in <em>Configuration.h</em> file:</p>
<pre><code>//#define PROBING_HEATERS_OFF // Turn heaters off when probing
#if ENABLED(PROBING_HEATERS_OFF)
//#define WAIT_FOR_BED_HEATER // Wait for bed to heat back up between probes (to improve accuracy)
#endif
//#define PROBING_FANS_OFF // Turn fans off when probing
//#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing
//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors
</code></pre>
<p>It is probably enabled in your case. You may want to switch this off and reinstall firmware to maintain constant heating during probing.</p>
<p>However, you may want to take into account possibility of <strong>electrical or magnetic intereferences during probing</strong> from heaters and their circuits. Disabling them for a while may eliminate these influences and give more reliable measurements. Unless the bed ot hotend are unable to maintain stable temperature for a while and cool down too much (e.g. bed changing shape). So may want to experiment what works the best in your case, maybe including other settings listed in given section.</p>
|
<p>Eco mode under settings shuts off the bed after a 30 minutes ish maybe an hour. Either way it is probably the issue</p>
| 1,846
|
<p>How do I check if an object property in JavaScript is undefined?</p>
|
<p>The usual way to check if the value of a property is the special value <code>undefined</code>, is:</p>
<pre class="lang-js prettyprint-override"><code>if(o.myProperty === undefined) {
alert("myProperty value is the special value `undefined`");
}
</code></pre>
<p>To check if an object does not actually have such a property, and will therefore return <code>undefined</code> by default when you try to access it:</p>
<pre class="lang-js prettyprint-override"><code>if(!o.hasOwnProperty('myProperty')) {
alert("myProperty does not exist");
}
</code></pre>
<p>To check if the value associated with an identifier is the special value <code>undefined</code>, <em>or</em> if that identifier has not been declared:</p>
<pre class="lang-js prettyprint-override"><code>if(typeof myVariable === 'undefined') {
alert('myVariable is either the special value `undefined`, or it has not been declared');
}
</code></pre>
<p>Note: this last method is the only way to refer to an <strong>undeclared</strong> identifier without an early error, which is different from having a value of <code>undefined</code>.</p>
<p>In versions of JavaScript prior to ECMAScript 5, the property named "undefined" on the global object was writeable, and therefore a simple check <code>foo === undefined</code> might behave unexpectedly if it had accidentally been redefined. In modern JavaScript, the property is read-only.</p>
<p>However, in modern JavaScript, "undefined" is not a keyword, and so variables inside functions can be named "undefined" and shadow the global property.</p>
<p>If you are worried about this (unlikely) edge case, you can use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void" rel="noreferrer">the void operator</a> to get at the special <code>undefined</code> value itself:</p>
<pre class="lang-js prettyprint-override"><code>if(myVariable === void 0) {
alert("myVariable is the special value `undefined`");
}
</code></pre>
|
<pre><code>if (somevariable == undefined) {
alert('the variable is not defined!');
}
</code></pre>
<p>You can also make it into a function, as shown <a href="http://verens.com/archives/2005/07/25/isset-for-javascript/" rel="nofollow noreferrer">here</a>:</p>
<pre><code>function isset(varname){
return(typeof(window[varname]) != 'undefined');
}
</code></pre>
| 4,711
|
<p>I've written a stored proc that will do an update if a record exists, otherwise it will do an insert. It looks something like this:</p>
<pre><code>update myTable set Col1=@col1, Col2=@col2 where ID=@ID
if @@rowcount = 0
insert into myTable (Col1, Col2) values (@col1, @col2)
</code></pre>
<p>My logic behind writing it in this way is that the update will perform an implicit select using the where clause and if that returns 0 then the insert will take place.</p>
<p>The alternative to doing it this way would be to do a select and then based on the number of rows returned either do an update or insert. This I considered inefficient because if you are to do an update it will cause 2 selects (the first explicit select call and the second implicit in the where of the update). If the proc were to do an insert then there'd be no difference in efficiency.</p>
<p>Is my logic sound here?
Is this how you would combine an insert and update into a stored proc?</p>
|
<p>Your assumption is right, this is the optimal way to do it and it's called <a href="http://en.wikipedia.org/wiki/Upsert" rel="noreferrer">upsert/merge</a>.</p>
<p><a href="http://www.sqlservercentral.com/articles/T-SQL/61773/" rel="noreferrer">Importance of UPSERT - from sqlservercentral.com</a>: </p>
<blockquote>
<p>For every update in the case mentioned above we are removing one
additional read from the table if we
use the UPSERT instead of EXISTS.
Unfortunately for an Insert, both the
UPSERT and IF EXISTS methods use the
same number of reads on the table.
Therefore the check for existence
should only be done when there is a
very valid reason to justify the
additional I/O. The optimized way to
do things is to make sure that you
have little reads as possible on the
DB.</p>
<p>The best strategy is to attempt the
update. If no rows are affected by the
update then insert. In most
circumstances, the row will already
exist and only one I/O will be
required.</p>
</blockquote>
<p><strong>Edit</strong>:
Please check out <a href="https://stackoverflow.com/questions/13540/insert-update-stored-proc-on-sql-server/193876#193876">this answer</a> and the linked blog post to learn about the problems with this pattern and how to make it work safe.</p>
|
<p>Your logic seems sound, but you might want to consider adding some code to prevent the insert if you had passed in a specific primary key.</p>
<p>Otherwise, if you're always doing an insert if the update didn't affect any records, what happens when someone deletes the record before you "UPSERT" runs? Now the record you were trying to update doesn't exist, so it'll create a record instead. That probably isn't the behavior you were looking for.</p>
| 3,446
|
<p>I'm dynamically loading user controls adding them to the Controls collection of the web form.</p>
<p>I'd like to hide user controls if they cause a unhandled exception while rendering.</p>
<p>So, I tried hooking to the Error event of each UserControl but it seems that this event never fires for the UserControls as it does for Page class. </p>
<p>Did some googling around and it doesn't seem promising. Any ideas here?</p>
|
<p>mmilic, following on from <a href="https://stackoverflow.com/questions/10793/catching-unhandled-exceptions-in-aspnet-usercontrols#10910">your response</a> to my <a href="https://stackoverflow.com/questions/10793/catching-unhandled-exceptions-in-aspnet-usercontrols#10815">previous idea</a>..</p>
<p>No additional logic required! That's the point, your doing nothing to the classes in question, just wrapping them in some instantiation bubble-wrap! :)</p>
<p>OK, I was going to just bullet point but I wanted to see this work for myself, so I cobbled together some <em>very</em> rough code but the concept is there and it seems to work.</p>
<p><strong>APOLOGIES FOR THE LONG POST</strong></p>
<h2>The SafeLoader</h2>
<p>This will basically be the "bubble" I mentioned.. It will get the controls HTML, catching any errors that occur during Rendering.</p>
<pre><code>public class SafeLoader
{
public static string LoadControl(Control ctl)
{
// In terms of what we could do here, its down
// to you, I will just return some basic HTML saying
// I screwed up.
try
{
// Get the Controls HTML (which may throw)
// And store it in our own writer away from the
// actual Live page.
StringWriter writer = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
ctl.RenderControl(htmlWriter);
return writer.GetStringBuilder().ToString();
}
catch (Exception)
{
string ctlType = ctl.GetType().Name;
return "<span style=\"color: red; font-weight:bold; font-size: smaller;\">" +
"Rob + Controls = FAIL (" +
ctlType + " rendering failed) Sad face :(</span>";
}
}
}
</code></pre>
<h2>And Some Controls..</h2>
<p>Ok I just mocked together two controls here, one will throw the other will render junk. Point here, I don't give a crap. These will be replaced with your custom controls..</p>
<h3>BadControl</h3>
<pre><code>public class BadControl : WebControl
{
protected override void Render(HtmlTextWriter writer)
{
throw new ApplicationException("Rob can't program controls");
}
}
</code></pre>
<h3>GoodControl</h3>
<pre><code>public class GoodControl : WebControl
{
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<b>Holy crap this control works</b>");
}
}
</code></pre>
<h2>The Page</h2>
<p>OK, so lets look at the "test" page.. Here I simply instantiate the controls, grab their html and output it, I will follow with thoughts on designer support etc..</p>
<h3>Page Code-Behind</h3>
<pre><code> protected void Page_Load(object sender, EventArgs e)
{
// Create some controls (BadControl will throw)
string goodHtml = SafeLoader.LoadControl(new BadControl());
Response.Write(goodHtml);
string badHtml = SafeLoader.LoadControl(new GoodControl());
Response.Write(badHtml);
}
</code></pre>
<h3>Thoughts</h3>
<p>OK, I know what you are thinking, "these controls are instantiated programatically, what about designer support? I spent freaking hours getting these controls nice for the designer, now you're messing with my mojo".</p>
<p>OK, so I havent really tested this yet (probably will do in a min!) but the idea here is to override the CreateChildControls method for the page, and take the instance of each control added on the form and run it through the SafeLoader. If the code passes, you can add it to the Controls collection as normal, if not, then you can create erroneous literals or something, up to you my friend.</p>
<h2>Finally..</h2>
<p>Again, sorry for the long post, but I wanted to get the code here so we can discuss this :)
I hope this helps demonstrate my idea :)</p>
<h2>Update</h2>
<p>Tested by chucking a control in on the designer and overriding the CreateChildControls method with this, works fine, may need some clean up to make things better looking, but I'll leave that to you ;)</p>
<pre><code>protected override void CreateChildControls()
{
// Pass each control through the Loader to check
// its not lame
foreach (Control ctl in Controls)
{
string s = SafeLoader.LoadControl(ctl);
// If its bad, smack it downnnn!
if (s == string.Empty)
{
ctl.Visible = false; // Prevent Rendering
string ctlType = ctl.GetType().Name;
Response.Write("<b>Problem Occurred Rendering " +
ctlType + " '" + ctl.ID + "'.</b>");
}
}
}
</code></pre>
<p>Enjoy!</p>
|
<p>Global.asax and Application_Error?</p>
<p><a href="http://www.15seconds.com/issue/030102.htm" rel="nofollow noreferrer">http://www.15seconds.com/issue/030102.htm</a></p>
<p>Or the Page_Error Event on an individual Page only:</p>
<p><a href="http://support.microsoft.com/kb/306355" rel="nofollow noreferrer">http://support.microsoft.com/kb/306355</a></p>
<pre><code>void Page_Load(object sender, System.EventArgs e)
{
throw(new ArgumentNullException());
}
public void Page_Error(object sender,EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err = "<b>Error Caught in Page_Error event</b><hr><br>" +
"<br><b>Error in: </b>" + Request.Url.ToString() +
"<br><b>Error Message: </b>" + objErr.Message.ToString()+
"<br><b>Stack Trace:</b><br>" +
objErr.StackTrace.ToString();
Response.Write(err.ToString());
Server.ClearError();
}
</code></pre>
<p>Also, Karl Seguin (Hi Karl!) had a Post on using HttpHandler instead:</p>
<p><a href="http://codebetter.com/blogs/karlseguin/archive/2006/06/12/146356.aspx" rel="nofollow noreferrer">http://codebetter.com/blogs/karlseguin/archive/2006/06/12/146356.aspx</a></p>
<p>(Not sure what the permission to reproduce it, but if you want to write up an answer, you got my Upvote ☺)</p>
| 3,194
|
<p>I am working with a bunch of Makerbot Replicator+ printers and one Z18 in a classroom. I would like my students to be able to print cups and stuff to drink from if they want. I know I need a food-safe material AND a food safe nozzle if it can be managed.</p>
<p>So, I wanted to check the following:</p>
<ol>
<li><p>Is there a material data sheet for the PLA filament that Makerbots use? I am told you need to check for each color, so the general one doesn't seem to be what I need. If anyone knows where to find it, please let me know.</p>
</li>
<li><p>I am told stainless steel nozzles are best. I saw several sold on amazon and the like that will supposedly fit the Smart Extruders. Recs on which I should use (if any) are welcome. Especially as the nozzle width will differ, the stock nozzle I think is 0.4mm? I assume I will need to adjust the settings on the printer as well anyway if I swap out the stock nozzle.</p>
</li>
<li><p>Another procedure my research yielded was that I would probably want to coat the 3D prints in resin. It seems there are several food-safe brands. Would such resins stand up to acidic liquids like orange juice and the like? What about alcohol? I know they won't work with coffee or something because PLA melts as such a low temperature. Recommendations are welcome here, and whether I should paint on or dip the 3D print?</p>
</li>
</ol>
<p>3a. Even if the PLA isn't itself officially food safe would just coating it in resin solve that problem?</p>
<p>Any assistance here is much appreciated.</p>
|
<p>FDM itself is not particularly food-safe, coating the print may prevent bacteria to settle in crevices. Furthermore, the filament should be able to withstand high temperatures for extended periods of time in case you want to clean the printed cups to kill bacteria.</p>
<p>An overview of food-safe filaments is given by <a href="https://all3dp.com/2/food-safe-3d-printer-filament-best-brands/" rel="nofollow noreferrer">All3DP</a>. Without going into details, this overview recommends the use of certain TPU, nylon, high-temperature resistant co-polyester, PETG and ABS filaments. All these filaments are located at the higher-end temperature region of the filament pool.</p>
|
<p>A better alternative would be PETG, it's food safe on it's own and has more heat tolerance than PLA. It prints with much the same ease as PLA.</p>
<p>I'm not familiar with your particular printer, but nozzles are standard sizes. Swapping a brass nozzle for a stainless steel one doesn't need anything extra done. They both work the same, just the steel nozzle is harder wearing.</p>
| 2,200
|
<p>I am new to any scripting language. But, Still I worked on scripting a bit like tailoring other scripts to work for my purpose. For me, What is the best online resource to learn Python?</p>
<p>[Response Summary:] </p>
<p>Some Online Resources:</p>
<p><a href="http://docs.python.org/tut/tut.html" rel="nofollow noreferrer"> <a href="http://docs.python.org/tut/tut.html" rel="nofollow noreferrer">http://docs.python.org/tut/tut.html</a></a> - Beginners</p>
<p><a href="http://diveintopython3.ep.io/" rel="nofollow noreferrer"> <a href="http://diveintopython3.ep.io/" rel="nofollow noreferrer">http://diveintopython3.ep.io/</a></a> - Intermediate</p>
<p><a href="http://www.pythonchallenge.com/" rel="nofollow noreferrer"><a href="http://www.pythonchallenge.com/" rel="nofollow noreferrer">http://www.pythonchallenge.com/</a></a> - Expert Skills</p>
<p><a href="http://docs.python.org/" rel="nofollow noreferrer"><a href="http://docs.python.org/" rel="nofollow noreferrer">http://docs.python.org/</a></a> - collection of all knowledge</p>
<p>Some more:</p>
<p><a href="http://www.swaroopch.com/notes/Python" rel="nofollow noreferrer"> A Byte of Python. </a></p>
<p><a href="http://rgruet.free.fr/PQR25/PQR2.5.html" rel="nofollow noreferrer">Python 2.5 Quick Reference</a></p>
<p><a href="http://www.edgewall.org/python-sidebar/" rel="nofollow noreferrer">Python Side bar</a></p>
<p><a href="http://www.learningpython.com/" rel="nofollow noreferrer">A Nice blog for beginners</a></p>
<p><a href="http://www.greenteapress.com/thinkpython/thinkpython.html" rel="nofollow noreferrer">Think Python: An Introduction to Software Design</a></p>
|
<p>If you need to learn python from scratch - you can start here: <a href="http://docs.python.org/tut/tut.html" rel="nofollow noreferrer">http://docs.python.org/tut/tut.html</a> - good begginers guide</p>
<p>If you need to extend your knowledge - continue here <a href="http://diveintopython3.ep.io/" rel="nofollow noreferrer">http://diveintopython3.ep.io/</a> - good intermediate level book</p>
<p>If you need perfect skills - complete this <a href="http://www.pythonchallenge.com/" rel="nofollow noreferrer">http://www.pythonchallenge.com/</a> - outstanding and interesting challenge</p>
<p>And the perfect source of knowledge is <a href="http://docs.python.org/" rel="nofollow noreferrer">http://docs.python.org/</a> - collection of all knowledge</p>
|
<p>There are some screencasts on <a href="http://showmedo.com" rel="nofollow noreferrer">http://showmedo.com</a></p>
| 9,601
|
<p>There are so many different options coming out of microsoft for data access. Which one is the best for scalable apps?</p>
<p><strong>Linq</strong></p>
<p>Should we be using Linq? It certainly seems easy but if you know your SQL does it really help. Also I hear that you can't run Async queries in ASP.NET using Linq. Therefore I wonder if it is really scalable? Are there any really big sites using Linq (With the possible exception of stackoverflow).</p>
<p><strong>Entity Framework</strong></p>
<p>Don't hear so much razzmatazz about the Entity Framework. Seems closer to the Object model I'm familure with. </p>
<p><strong>Astoria/Dynamic Data</strong></p>
<p>Should we be exposing our data as a service?</p>
<p>I'm pretty confused and thats before I get into the other ORM products like NHibernate. Any ideas or wisdom on which is better?</p>
|
<p>I would recommend either NHibernate or Entity Framework. For large sites, I'd use ADO.NET Data Services. I wouldn't do anything large with LINQ to SQL. I think Stack Overflow might end up with some interesting scale problems being 2-tier rather than 3-tier, and they'll also have some trouble refactoring as the physical aspects of the database change and those changes ripple throughout the code. Just a thought.</p>
|
<p>This post is from 2008 before the cloud really took off. It seems like an update to the answer is required. I will just provide some links and an overview. I am sure that there are more up-to-date posts at this site on this topic, and if I find them, then I will add the links here.</p>
<p>When it comes to data scalability and transaction processing scalability, in 2017 we need to be talk about the Cloud and Cloud Service Providers. </p>
<p>I think the top three Cloud Providers these days are: </p>
<ul>
<li><a href="https://aws.amazon.com/pricing/" rel="nofollow noreferrer">Amazon Web Services (AWS)</a></li>
<li><a href="https://cloud.google.com/pricing/" rel="nofollow noreferrer">Google's Cloud Platform (GCP)</a></li>
<li><a href="https://azure.microsoft.com/en-us/pricing/" rel="nofollow noreferrer">Microsoft Azure</a></li>
</ul>
<p><strong>Cost</strong></p>
<p>One of the great thing about using cloud services is that there are no upfront costs, no termination fees, and you pay only for what you use. (Quoting Mr.Alba's 2016 article "<a href="https://www.sitepoint.com/a-side-by-side-comparison-of-aws-google-cloud-and-azure/" rel="nofollow noreferrer">A Side-by-Side Comparison of AWS, Google Cloud and Azure</a>")</p>
<p>We use AWS ourselves. We pay only while we have VMs installed and running, so it can be a cheap way to start up. Typically, service providers charge by the minute or by the hour but you are guaranteed to have it for that entire time. </p>
<p>A cheaper way to go is best-effort spot pricing. The Spot price represents the price above which you have to bid to guarantee that a single Spot request is fulfilled. When your bid price is above the Spot price, Amazon EC2 launches your Spot instance, and when the Spot price rises above your bid price, Amazon EC2 terminates your Spot instance. (Shamelessly quoting Amazon's User Guide <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances-history.html" rel="nofollow noreferrer">here</a>) </p>
<p><a href="https://www.sitepoint.com/a-side-by-side-comparison-of-aws-google-cloud-and-azure/" rel="nofollow noreferrer"><em>A Side-by-Side Comparison of AWS, Google Cloud and Azure</em></a> is a good article doing a side-by-side comparison of these three service providers available <a href="https://www.sitepoint.com/a-side-by-side-comparison-of-aws-google-cloud-and-azure/" rel="nofollow noreferrer">here</a>. </p>
<p>For a more academic look at cloud services, read the 2010 paper by Yu, Wang, Ren, and Lou "<a href="http://ieeexplore.ieee.org/document/5462174/" rel="nofollow noreferrer"><em>Achieving Secure, Scalable, and Fine-grained Data Access Control in Cloud Computing</em>"</a> in the INFOCOM 2010 Proceedings available <a href="http://ieeexplore.ieee.org/document/5462174/" rel="nofollow noreferrer">here</a>, but you may need to be an IEEE member to gain access to it. While it is somewhat dated, it is excellent and you can use it as a jumping off point. </p>
<p>Scaling in the cloud has been exploding, and until recently that scaling was done by starting up new Virtual Machines which tooks seconds, but with Containers one can spin up new instances in milliseconds. For more information on this, check out Docker and Docker Containers <a href="https://www.docker.com/what-docker" rel="nofollow noreferrer">here</a>.</p>
<p>I apologize for this answer being just a bunch of links for more information, but I thought the answer to this question should have an update. I hope this inspires someone to provide more first hand details. If you have already posted some related information, please consider providing links to your own posts. Thanks!</p>
| 9,339
|
<p>Do you have any strategies for retrofitting unit tests onto a code base that currently has no unit tests ?</p>
|
<p>Read <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code by Feathers</a>.</p>
<p>Jimmy Bogard has a <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/tags/Refactoring/default.aspx" rel="noreferrer">good blog series on SOC</a>.</p>
|
<p>Is it possible that we are in a panic and are getting confused between unit tests and performance tests? Is it that your application works fine with few users, but starts throwing errors when under heavier load? If so, unit tests are not the answer. Unit tests != Load tests.</p>
<p>If unit tests are in fact the answer, retrofitting unit tests is a good idea as it will help clean up the code. Just be prepared to refactor a lot. Code written with TDD turns out looking a lot different than code written without TDD. In my case, I had a method HandleDisposition() which took care of a lot of cases. This kind of method would not have existed if we had written the code with TDD. When retrofitting unit tests, we refactored that function and now have methods like XDisposition(), YDisposition(), ZDisposition(), which are a lot easier to write unit tests against.</p>
| 6,436
|
<p>Browsing through the git documentation, I can't see anything analogous to SVN's commit hooks or the "propset" features that can, say, update a version number or copyright notice within a file whenever it is committed to the repository.</p>
<p>Are git users expected to write external scripts for this sort of functionality (which doesn't seem out of the question) or have I just missed something obvious?</p>
<p><em>Edit</em> : Just to be clear, I'm more interested in, e.g.,</p>
<pre><code>svn propset svn:keywords "Author Date Id Revision" expl3.dtx
</code></pre>
<p>where a string like this:</p>
<pre><code>$Id: expl3.dtx 780 2008-08-30 12:32:34Z morten $
</code></pre>
<p>is kept up-to-date with the relevant info whenever a commit occurs.</p>
|
<p>Quoting from the <a href="https://git.wiki.kernel.org/index.php/GitFaq#Does_git_have_keyword_expansion.3F" rel="noreferrer">Git FAQ</a>:</p>
<blockquote>
<p>Does git have keyword expansion?</p>
<p>Not recommended. Keyword expansion causes all sorts of strange problems and
isn't really useful anyway, especially within the context of an SCM. Outside
git you may perform keyword expansion using a script. The Linux kernel export
script does this to set the EXTRA_VERSION variable in the Makefile.</p>
<p>See gitattributes(5) if you really want to do this. If your translation is not
reversible (eg SCCS keyword expansion) this may be problematic.</p>
</blockquote>
|
<p>Perhaps the most common SVN property, 'svn:ignore' is done through the .gitignore file, rather than metadata. I'm afraid I don't have anything more helpful for the other kinds of metadata.</p>
| 6,088
|
<p>I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this query on my Macbook Pro while Java and Python perform the same calculation in under 20 ms (350,000 rows):</p>
<pre><code>SELECT count(id), avg(a), avg(b), avg(c), avg(d) FROM tuples;
</code></pre>
<p>Is this normal behaviour when using a SQL database?</p>
<p>The schema (the table holds responses to a survey):</p>
<pre><code>CREATE TABLE tuples (id integer primary key, a integer, b integer, c integer, d integer);
\copy tuples from '350,000 responses.csv' delimiter as ','
</code></pre>
<p>I wrote some tests in Java and Python for context and they crush SQL (except for pure python):</p>
<pre><code>java 1.5 threads ~ 7 ms
java 1.5 ~ 10 ms
python 2.5 numpy ~ 18 ms
python 2.5 ~ 370 ms
</code></pre>
<p>Even sqlite3 is competitive with Postgres despite it assumping all columns are strings (for contrast: even using just switching to numeric columns instead of integers in Postgres results in 10x slowdown)</p>
<p>Tunings i've tried without success include (blindly following some web advice):</p>
<pre><code>increased the shared memory available to Postgres to 256MB
increased the working memory to 2MB
disabled connection and statement logging
used a stored procedure via CREATE FUNCTION ... LANGUAGE SQL
</code></pre>
<p>So my question is, is my experience here normal, and this is what I can expect when using a SQL database? I can understand that ACID must come with costs, but this is kind of crazy in my opinion. I'm not asking for realtime game speed, but since Java can process millions of doubles in under 20 ms, I feel a bit jealous. </p>
<p>Is there a better way to do simple OLAP on the cheap (both in terms of money and server complexity)? I've looked into Mondrian and Pig + Hadoop but not super excited about maintaining yet another server application and not sure if they would even help.</p>
<hr>
<p>No the Python code and Java code do all the work in house so to speak. I just generate 4 arrays with 350,000 random values each, then take the average. I don't include the generation in the timings, only the averaging step. The java threads timing uses 4 threads (one per array average), overkill but it's definitely the fastest.</p>
<p>The sqlite3 timing is driven by the Python program and is running from disk (not :memory:)</p>
<p>I realize Postgres is doing much more behind the scenes, but most of that work doesn't matter to me since this is read only data.</p>
<p>The Postgres query doesn't change timing on subsequent runs.</p>
<p>I've rerun the Python tests to include spooling it off the disk. The timing slows down considerably to nearly 4 secs. But I'm guessing that Python's file handling code is pretty much in C (though maybe not the csv lib?) so this indicates to me that Postgres isn't streaming from the disk either (or that you are correct and I should bow down before whoever wrote their storage layer!)</p>
|
<p>Postgres is doing a lot more than it looks like (maintaining data consistency for a start!)</p>
<p>If the values don't have to be 100% spot on, or if the table is updated rarely, but you are running this calculation often, you might want to look into Materialized Views to speed it up.</p>
<p>(Note, I have not used materialized views in Postgres, they look at little hacky, but might suite your situation).</p>
<p><a href="http://jonathangardner.net/tech/w/PostgreSQL/Materialized_Views" rel="noreferrer">Materialized Views</a></p>
<p>Also consider the overhead of actually connecting to the server and the round trip required to send the request to the server and back.</p>
<p>I'd consider 200ms for something like this to be pretty good, A quick test on my oracle server, the same table structure with about 500k rows and no indexes, takes about 1 - 1.5 seconds, which is almost all just oracle sucking the data off disk.</p>
<p>The real question is, is 200ms fast enough?</p>
<p>-------------- More --------------------</p>
<p>I was interested in solving this using materialized views, since I've never really played with them. This is in oracle.</p>
<p>First I created a MV which refreshes every minute.</p>
<pre><code>create materialized view mv_so_x
build immediate
refresh complete
START WITH SYSDATE NEXT SYSDATE + 1/24/60
as select count(*),avg(a),avg(b),avg(c),avg(d) from so_x;
</code></pre>
<p>While its refreshing, there is no rows returned</p>
<pre><code>SQL> select * from mv_so_x;
no rows selected
Elapsed: 00:00:00.00
</code></pre>
<p>Once it refreshes, its MUCH faster than doing the raw query</p>
<pre><code>SQL> select count(*),avg(a),avg(b),avg(c),avg(d) from so_x;
COUNT(*) AVG(A) AVG(B) AVG(C) AVG(D)
---------- ---------- ---------- ---------- ----------
1899459 7495.38839 22.2905454 5.00276131 2.13432836
Elapsed: 00:00:05.74
SQL> select * from mv_so_x;
COUNT(*) AVG(A) AVG(B) AVG(C) AVG(D)
---------- ---------- ---------- ---------- ----------
1899459 7495.38839 22.2905454 5.00276131 2.13432836
Elapsed: 00:00:00.00
SQL>
</code></pre>
<p>If we insert into the base table, the result is not immediately viewable view the MV.</p>
<pre><code>SQL> insert into so_x values (1,2,3,4,5);
1 row created.
Elapsed: 00:00:00.00
SQL> commit;
Commit complete.
Elapsed: 00:00:00.00
SQL> select * from mv_so_x;
COUNT(*) AVG(A) AVG(B) AVG(C) AVG(D)
---------- ---------- ---------- ---------- ----------
1899459 7495.38839 22.2905454 5.00276131 2.13432836
Elapsed: 00:00:00.00
SQL>
</code></pre>
<p>But wait a minute or so, and the MV will update behind the scenes, and the result is returned fast as you could want.</p>
<pre><code>SQL> /
COUNT(*) AVG(A) AVG(B) AVG(C) AVG(D)
---------- ---------- ---------- ---------- ----------
1899460 7495.35823 22.2905352 5.00276078 2.17647059
Elapsed: 00:00:00.00
SQL>
</code></pre>
<p>This isn't ideal. for a start, its not realtime, inserts/updates will not be immediately visible. Also, you've got a query running to update the MV whether you need it or not (this can be tune to whatever time frame, or on demand). But, this does show how much faster an MV can make it seem to the end user, if you can live with values which aren't quite upto the second accurate.</p>
|
<p>You need to increase postgres' caches to the point where the whole working set fits into memory before you can expect to see perfomance comparable to doing it in-memory with a program.</p>
| 7,466
|
<p>I've found <a href="http://blogs.msdn.com/priozersk/archive/2007/08/06/implementing-mvc-pattern-in-net-cf-applications-part-1.aspx" rel="noreferrer">an article</a> on this subject by a Microsoft employee, but has anyone implemented a more robust framework for this? Is there a lightweight framework for WinForms that could be ported easily? I'd like to get up to speed fairly quickly and avoid producing a framework/library of my own to handle this when someone smarter has already done this. </p>
<p>I haven't looked at the <a href="http://msdn.microsoft.com/en-us/library/aa480471.aspx" rel="noreferrer">Mobile Software Factory</a> from the P&P group, but I suspect it's kind of heavy. Is it worth a look?</p>
<p><strong>Edit: I'm not looking for information on the ASP.NET MVC project. I'm asking about the compact framework 'WinForms' implementation, and how to implement MVC with that.</strong></p>
|
<p>I personally think that the Mobile Software Factory doesn't hold much joy for CF.
We still use one part of it (EventBroker) at work and I'd like to even remove that part if possible (as it doesn't support generic events and you have to cast the arguments into their strong types from EventArgs). A sister project at work used it for part of their UI but had to rip it out due to performance issues (another big project, although that has additional performance issues of it's own as well).</p>
<p>The issue I find with the MVP framework that the P&P lib offers is that Forms and Controls OWN presenters instead of Presenters/Controllers owning Forms (who didn't read "It's just a view" : Pragmatic Programmer?).
This fits beautifully with MS's "Form First" rapid application development mantra but it sucks when you consider how expensive windows handles can be in CE (if you have a lot of them).
We run a very large CF application at work and we've rolled our own MVC framework. It's not hard to roll your own, just make sure you separate everything out into Controllers, Views, Business Objects and Services and have a UIController that controls the interactions between the controllers. </p>
<p>We actually go one step further and re-use forms/controls by using a Controller->View->Layout pattern.
The controller is the same as usual, the view is the object that customises a layout into a particular view and the layout is the actual UserControl. We then swap these in and out of a single Form. This reduces the amount of Windows Controls we use dramatically.
This + initialising all of the forms on start-up means that we eradicate the noticable pause that you get when creating new Windows Controls "on-demand".</p>
<p>Obviously it only really pays to do this kind of thing if you are rolling a large application. We have roughly 20 + different types of View which use in total about 7 different layouts. This hurts our initialisation routine (as we load the forms at start up) by a magnitude of about 10 seconds but psychologically most users are willing to accept such a hit at start up as opposed to noticeable pauses during run-time.</p>
<p>The main issue with the P&P library in my books is that it is a FF -> CF port and due to certain incompatability and performance differences between the two platforms you lose a lot of useful functionality.</p>
<p>Btw, <a href="http://ctrl-shift-b.blogspot.com/2007/08/interactive-application-architecture.html" rel="nofollow noreferrer">this</a> is by far and away the most comprehensive article i've ever read on MVC/MVP.
For Windows application (desktop or CE) I'd recommend using the Taligent Model-View-Presenter version without the interactions, commands and selections (e.g the controller/presenter performs all the work).</p>
|
<p><strong>Edit: The above posters are correct. I saw MVC and immediately thought of web forms. My apologies. Feel free to disregard this. I'll leave my original message in place just in case anyone who <em>is</em> interested in web forms MVC needs the links. :-)</strong></p>
<p>There are a couple MVC frameworks out there, neither of which are very "lightweight", but MVC is a pretty big shift away from web forms so that is expected:</p>
<ul>
<li><a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC</a> - This is Microsoft's attempt at an MVC framework. It is still in preview mode so use it at your own discretion, but several people are already using it in their production applications. You will find ample documentation on this with a simple Google search as it is becoming very popular amongst the .NET crowd.</li>
<li><a href="http://www.castleproject.org/MonoRail/" rel="nofollow noreferrer">Castle MonoRail</a> - The MonoRail framework is an open-source MVC framework that has been around for quite some time and is in use on several production applications. It is definitely more flushed out than the ASP.NET MVC framework, but considering the amount of effort Microsoft is throwing at their MVC offering, I think will change relatively soon.</li>
</ul>
| 4,591
|
<p>In C++, what alternatives do I have for exposing a collection, from the point of view of performance and data integrity?</p>
<p>My problem is that I want to return an internal list of data to the caller, but I don't want to generate a copy. Thant leaves me with either returning a reference to the list, or a pointer to the list. However, I'm not crazy about letting the caller change the data, I just want to let it read the data. </p>
<ul>
<li>Do I have to choose between performance and data integrity? </li>
<li>If so, is in general better to go one way or is it particular to the case? </li>
<li>Are there other alternatives?</li>
</ul>
|
<p><a href="https://stackoverflow.com/questions/44693/in-c-what-alternatives-do-i-have-for-exposing-a-collection-from-the-point-of-vi#44734">RichQ's answer</a> is a reasonable technique, if you're using an array, vector, etc. </p>
<p>If you're using a collection that isn't indexed by ordinal values... or think you <em>might need to</em> at some point in the near future... then you might want to consider exposing your own iterator type(s), and associated <code>begin()</code>/<code>end()</code> methods:</p>
<pre><code>class Blah
{
public:
typedef std::vector<mydata> mydata_collection;
typedef myDataCollection::const_iterator mydata_const_iterator;
// ...
mydata_const_iterator data_begin() const
{ return myPreciousData.begin(); }
mydata_const_iterator data_end() const
{ return myPreciousData.end(); }
private:
mydata_collection myPreciousData;
};
</code></pre>
<p>...which you can then use in the normal fashion:</p>
<pre><code>Blah blah;
for (Blah::mydata_const_iterator itr = blah.data_begin();
itr != blah.data_end();
++itr)
{
// ...
}
</code></pre>
|
<p>Using const is a reasonable choice.
You may also wish to check out the boost C++ library for their shared pointer implementation. It provides the advantages of pointers i.e. you may have the requirement to return a shared pointer to "null" which a reference would not allow.</p>
<p><a href="http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm</a></p>
<p>In your case you would make the shared pointer's type const to prohibit writes.</p>
| 6,644
|
<p>I want to format my existing comments as 'RDoc comments' so they can be viewed using <code>ri</code>.</p>
<p>What are some recommended resources for starting out using RDoc?</p>
|
<p>A few things that have bitten me:</p>
<ul>
<li><code>:main:</code> -- RDoc uses only the last one evaluated; best to make sure there's only one in your project and you don't also use the <code>--main</code> command-line argument.</li>
<li>same as previous, but for <code>:title:</code></li>
<li><code>:section:</code> doesn't work very well</li>
</ul>
|
<p>RDoc uses SimpleMarkup so it's fairly simple to create lists, etc. using *, - or a number. It also treats lines that are indented at the same column number as part of the same paragraph until there is an empty line which signifies a new paragraph. Do you have a few examples of comments you want RDoc'ed so we could show you how to do them and then you could extrapolate that for the rest of your comments?</p>
| 2,248
|
<p>If I have an issue with my FLSUN printer how can I contact customer support?</p>
|
<p>They have a webpage by now <a href="http://www.flsun3d.com" rel="noreferrer">www.flsun3d.com</a></p>
|
<p>I have had good luck contacting them via AliExpress <a href="https://flsun.aliexpress.com/store/2383013" rel="nofollow noreferrer">https://flsun.aliexpress.com/store/2383013</a> even though I bought my printer on Amazon. </p>
| 1,681
|
<p>I'm writing a little desktop app that should be able to encrypt a data file and protect it with a password (i.e. one must enter the correct password to decrypt). I want the encrypted data file to be self-contained and portable, so the authentication has to be embedded in the file (or so I assume).</p>
<p>I have a strategy that appears workable and seems logical based on what I know (which is probably just enough to be dangerous), but I have no idea if it's actually a good design or not. So tell me: is this crazy? Is there a better/best way to do it?</p>
<ul>
<li>Step 1: User enters plain-text password, e.g. "MyDifficultPassword" </li>
<li>Step 2: App hashes the user-password and uses that value as the symmetric key to encrypt/decrypt the data file. e.g. "MyDifficultPassword" --> "HashedUserPwdAndKey". </li>
<li>Step 3: App hashes the hashed value from step 2 and saves the new value in the data file header (i.e. the unencrypted part of the data file) and uses that value to validate the user's password. e.g. "HashedUserPwdAndKey" --> "HashedValueForAuthentication"</li>
</ul>
<p>Basically I'm extrapolating from the common way to implement web-site passwords (when you're not using OpenID, that is), which is to store the (salted) hash of the user's password in your DB and never save the actual password. But since I use the hashed user password for the symmetric encryption key, I can't use the same value for authentication. So I hash it again, basically treating it just like another password, and save the doubly-hashed value in the data file. That way, I can take the file to another PC and decrypt it by simply entering my password.</p>
<p>So is this design reasonably secure, or hopelessly naive, or somewhere in between? Thanks!</p>
<p>EDIT: clarification and follow-up question re: Salt.<br>
I thought the salt had to be kept secret to be useful, but your answers and links imply this is not the case. For example, <a href="ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-5v2/pkcs5v2-0.pdf" rel="noreferrer">this spec</a> linked by erickson (below) says: </p>
<blockquote>
<p>Thus, password-based key derivation as defined here is a function of a password, a salt, and an iteration count, where the latter two quantities need not be kept secret.</p>
</blockquote>
<p>Does this mean that I could store the salt value in the same place/file as the hashed key and still be more secure than if I used no salt at all when hashing? How does that work?</p>
<p>A little more context: the encrypted file isn't meant to be shared with or decrypted by others, it's really single-user data. But I'd like to deploy it in a shared environment on computers I don't fully control (e.g. at work) and be able to migrate/move the data by simply copying the file (so I can use it at home, on different workstations, etc.).</p>
|
<h3>Key Generation</h3>
<p>I would recommend using a recognized algorithm such as PBKDF2 defined in <a href="ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-5v2/pkcs5v2-0.pdf" rel="nofollow noreferrer">PKCS #5 version 2.0</a> to generate a key from your password. It's similar to the algorithm you outline, but is capable of generating longer symmetric keys for use with AES. You should be able to find an open-source library that implements PBE key generators for different algorithms.</p>
<h3>File Format</h3>
<p>You might also consider using the <a href="http://www.ietf.org/rfc/rfc3852.txt" rel="nofollow noreferrer">Cryptographic Message Syntax</a> as a format for your file. This will require some study on your part, but again there are existing libraries to use, and it opens up the possibility of inter-operating more smoothly with other software, like S/MIME-enabled mail clients.</p>
<h3>Password Validation</h3>
<p>Regarding your desire to store a hash of the password, if you use PBKDF2 to generate the key, you could use a standard password hashing algorithm (big salt, a thousand rounds of hashing) for that, and get different values. </p>
<p>Alternatively, you could compute a MAC on the content. A hash collision on a password is more likely to be useful to an attacker; a hash collision on the content is likely to be worthless. But it would serve to let a legitimate recipient know that the wrong password was used for decryption.</p>
<h3>Cryptographic Salt</h3>
<p><a href="http://en.wikipedia.org/wiki/Cryptographic_salt" rel="nofollow noreferrer">Salt</a> helps to thwart pre-computed dictionary attacks. </p>
<p>Suppose an attacker has a list of likely passwords. He can hash each and compare it to the hash of his victim's password, and see if it matches. If the list is large, this could take a long time. He doesn't want spend that much time on his next target, so he records the result in a "dictionary" where a hash points to its corresponding input. If the list of passwords is very, very long, he can use techniques like a <a href="http://lasecwww.epfl.ch/~oechslin/projects/ophcrack/" rel="nofollow noreferrer">Rainbow Table</a> to save some space.</p>
<p>However, suppose his next target salted their password. <em>Even if the attacker knows what the salt is, his precomputed table is worthless</em>—the salt changes the hash resulting from each password. He has to re-hash all of the passwords in his list, affixing the target's salt to the input. Every different salt requires a different dictionary, and if enough salts are used, the attacker won't have room to store dictionaries for them all. Trading space to save time is no longer an option; the attacker must fall back to hashing each password in his list for each target he wants to attack.</p>
<p>So, it's not necessary to keep the salt secret. Ensuring that the attacker doesn't have a pre-computed dictionary corresponding to that particular salt is sufficient.</p>
|
<p>Is there really need to save the hashed password into the file. Can't you just use the password (or hashed password) with some salt and then encrypt the file with it. When decrypting just try to decrypt the file with the password + salt. If user gives wrong password the decrypted file isn't correct.</p>
<p>Only drawbacks I can think is if the user accidentally enters wrong password and the decryption is slow, he has to wait to try again. And of course if password is forgotten there's no way to decrypt the file.</p>
| 7,971
|
<p>This is in reference to my other question <a href="https://stackoverflow.com/questions/16110/c-auto-clearing-winform-textbox">Auto Clearing Textbox</a>.<br>
If I choose to derive a new TextBox control from TextBox instead of implement a user control just containing my Textbox, how would I include that in the toolbox.</p>
|
<blockquote>
<p>Right-click the toolbox, click "Choose
Items" from the context menu, browse
to your DLL, and select it.</p>
</blockquote>
<p>To extend on Greg's answer...
Just to clarify, you cannot add a user control to the tool box if the code for it is in the same project that you want to use it in. For some reason MS has never added this ability, which would make sense since we don't want to always have to create a User Control Library DLL everytime we want to use a user control. So, to get it in your tool box, you have to first create a separate "User Control Library" project (which <em>can</em> be in the same solution!) and then do what Greg said.</p>
|
<p>Right-click the toolbox, click "Choose Items" from the context menu, browse to your DLL, and select it.</p>
| 3,685
|
<p>Admittedly this might not be a problem on larger screens, but my employer is abit tight and refuses to buy monitors larger than 19inch, this means that I dont have much screen real estate to view all the Visual Studio windows and my code at the same time, or two pieces of code at once. Is there anything that allows me to detach the code panels so that I can view two different classes at once on each of my screens? </p>
|
<p>You can right click on the tab strip and insert a new vertical (or horizontal) tab group.</p>
<p>This allows you to view multiple tabs at the same time.</p>
|
<p>Hmm.. I don't think there is a way from within Visual Studio. For maximizing real estate and working on simultaneous files, I use that method plus viewing the files on Full Screen mode.</p>
<p>Do you multiple monitors?</p>
| 3,764
|
<p>I'm looking for a python library that will help me to create an authentication method for a desktop app I'm writing.
I have found several method in web framework such as django or turbogears.</p>
<p>I just want a kind of username-password association stored into a local file.
I can write it by myself, but I'm really it already exists and will be a better solution (I'm not very fluent with encryption).</p>
|
<p>dbr said:</p>
<blockquote>
<pre><code>def hash_password(password):
"""Returns the hashed version of a string
"""
return hasher.new( str(password) ).hexdigest()
</code></pre>
</blockquote>
<p>This is a really insecure way to hash passwords. You <em>don't</em> want to do this. If you want to know why read the <a href="http://www.openbsd.org/papers/bcrypt-paper.pdf" rel="noreferrer" title=""B-Crypt Paper">Bycrypt Paper</a> by the guys who did the password hashing system for OpenBSD. Additionally if want a good discussion on how passwords are broken check out <a href="http://www.securityfocus.com/columnists/388" rel="noreferrer">this interview</a> with the author of Jack the Ripper (the popular unix password cracker).</p>
<p>Now B-Crypt is great but I have to admit I don't use this system because I didn't have the EKS-Blowfish algorithm available and did not want to implement it my self. I use a slightly updated version of the FreeBSD system which I will post below. The gist is this. Don't just hash the password. Salt the password then hash the password and repeat 10,000 or so times.</p>
<p>If that didn't make sense here is the code: </p>
<pre><code>#note I am using the Python Cryptography Toolkit
from Crypto.Hash import SHA256
HASH_REPS = 50000
def __saltedhash(string, salt):
sha256 = SHA256.new()
sha256.update(string)
sha256.update(salt)
for x in xrange(HASH_REPS):
sha256.update(sha256.digest())
if x % 10: sha256.update(salt)
return sha256
def saltedhash_bin(string, salt):
"""returns the hash in binary format"""
return __saltedhash(string, salt).digest()
def saltedhash_hex(string, salt):
"""returns the hash in hex format"""
return __saltedhash(string, salt).hexdigest()
</code></pre>
<p>For deploying a system like this the key thing to consider is the HASH_REPS constant. This is the scalable cost factor in this system. You will need to do testing to determine what is the exceptable amount of time you want to wait for each hash to be computed versus the risk of an offline dictionary based attack on your password file. </p>
<p>Security is hard, and the method I present is not the best way to do this, but it is significantly better than a simple hash. Additionally it is dead simple to implement. So even you don't choose a more complex solution this isn't the worst out there.</p>
<p>hope this helps,
Tim</p>
|
<p>Use " md5 " it's much better than base64</p>
<pre><code>>>> import md5
>>> hh = md5.new()
>>> hh.update('anoop')
>>> hh.digest
<built-in method digest of _hashlib.HASH object at 0x01FE1E40>
</code></pre>
| 9,607
|
<p>I'm giving a presentation to a Java User's Group on Groovy and I'm going to be doing some coding during the presentation to show some side-by-side Java/Groovy. I really like the GroovyConsole as it's simple and I can resize the text easily. </p>
<p>I'm wondering if there is anything similar for Java? I know I could just use Eclipse but I'd rather have a smaller app to use without having to customize a view. What's the community got?</p>
<p>Screen shot of GroovyConsole:</p>
<p><img src="https://i.stack.imgur.com/GiR7b.jpg" alt="enter image description here"></p>
|
<p><a href="http://www.drjava.org/" rel="nofollow noreferrer">DrJava</a> is your best bet. It also has an <a href="http://www.drjava.org/eclipse.shtml" rel="nofollow noreferrer">Eclipse plugin</a> to use the interactions pane like GroovyConsole.</p>
|
<p>Why not use the GroovyConsole ? Groovy accepts the vast majority of Java syntax</p>
| 5,003
|
<p>The situation: We're out of beta and version 1.0 has been released to several customer sites. Team A is already busy working on version 1.1 that will have incremental bugfixes and usability tweaks, while another team works on version 2.0 with large-scale changes, where the core of the product may have been completely redesigned. Now, most of the changes made for 1.1 will have to make their way into 2.0 at some point, and some of the bug fixes made in the 2.0 branch might in fact need to be scheduled for an earlier release. The problem is that since 2.0 has fundamental differences, no changes from 1.1 can be merged in without manual conversion, nor vice versa.</p>
<p>My question: What are the best revision control practises to minimise merge conflicts and duplicate work in this kind of situation? How can I ensure that my teams spend as little time and effort as possible on revision control issues, while still providing regular patches to customers?</p>
|
<p>One good way is to fix each bug in the stable branch and merge the stable branch into the development branch. This is the <a href="http://www.cmcrossroads.com/bradapp/acme/branching/branch-structs.html#ParallelMaintDev" rel="nofollow noreferrer">Parallel Maintenance/Development Lines</a> pattern, and the key is to merge early and often. Merging infrequently and late means that the development branch is unrecognisable compared to the stable one, or the bug cannot be repeated in the same way.</p>
<p><a href="http://subversion.tigris.org/" rel="nofollow noreferrer">Subversion</a> includes merge tracking since version 1.5 so you ensure that the same change set is not merged twice, causing silly conflicts. Other systems exist (e.g. <a href="http://git-scm.com/" rel="nofollow noreferrer">Git</a>, <a href="http://mercurial.selenic.com/" rel="nofollow noreferrer">Mercurial</a>, <a href="http://www.accurev.com" rel="nofollow noreferrer">Accurev</a>, <a href="http://www.perforce.com/" rel="nofollow noreferrer">Perforce</a>) that let you make queries of the type "what changes on branch A have not been merged into branch B?" and cherry-pick the fixes you need across to the dev branch.</p>
|
<p>Merge early, merge often, and make sure that QA on the mainline knows and regresses/verifies the defects fixed in each patch of the maintenance releases. </p>
<p>It's really easy to let something slip out and "unfix" a bug in a subsequent release, and let me tell you, customers don't care about how complicated it can get to manage multiple branches -- that's your job.</p>
<p>Make sure you're using a source control system that supports branching and merging (I've had experience with Perforce and SVN, and while Perforce is better, SVN is free).</p>
<p>I also believe that having a single person responsible for performing the merges in a consistent manner helps ensure that they happen regularly. It's generally been me or one of the senior people on our team.</p>
| 6,634
|
<p>I know two approaches to Exception handling, lets have a look at them.</p>
<ol>
<li><p>Contract approach.</p>
<p>When a method does not do what it says it will do in the method header, it will throw an exception. Thus the method "promises" that it will do the operation, and if it fails for some reason, it will throw an exception.</p>
</li>
<li><p>Exceptional approach.</p>
<p>Only throw exceptions when something truly weird happens. You should not use exceptions when you can resolve the situation with normal control flow (If statements). You don't use Exceptions for control flow, as you might in the contract approach.</p>
</li>
</ol>
<p>Lets use both approaches in different cases:</p>
<p>We have a Customer class that has a method called OrderProduct.</p>
<p>contract approach:</p>
<pre><code>class Customer
{
public void OrderProduct(Product product)
{
if((m_credit - product.Price) < 0)
throw new NoCreditException("Not enough credit!");
// do stuff
}
}
</code></pre>
<p>exceptional approach:</p>
<pre><code>class Customer
{
public bool OrderProduct(Product product)
{
if((m_credit - product.Price) < 0)
return false;
// do stuff
return true;
}
}
if !(customer.OrderProduct(product))
Console.WriteLine("Not enough credit!");
else
// go on with your life
</code></pre>
<p>Here I prefer the exceptional approach, as it is not truly Exceptional that a customer has no money assuming he did not win the lottery.</p>
<p>But here is a situation I err on the contract style.</p>
<p>Exceptional:</p>
<pre><code>class CarController
{
// returns null if car creation failed.
public Car CreateCar(string model)
{
// something went wrong, wrong model
return null;
}
}
</code></pre>
<p>When I call a method called CreateCar, I damn wel expect a Car instance instead of some lousy null pointer, which can ravage my running code a dozen lines later. Thus I prefer contract to this one:</p>
<pre><code>class CarController
{
public Car CreateCar(string model)
{
// something went wrong, wrong model
throw new CarModelNotKnownException("Model unkown");
return new Car();
}
}
</code></pre>
<p>Which do style do you use? What do you think is best general approach to Exceptions?</p>
|
<p>I favor what you call the "contract" approach. Returning nulls or other special values to indicate errors isn't necessary in a language that supports exceptions. I find it much easier to understand code when it doesn't have a bunch of "if (result == NULL)" or "if (result == -1)" clauses mixed in with what could be very simple, straightforward logic.</p>
|
<p>I believe that if you are building a class which will be used by an external program (or will be reused by other programs) then you should use the contract approach. A good example of this is an API of any kind.</p>
| 4,595
|
<p>I want to create dynamic content based on this. I know it's somewhere, as web analytics engines can get this data to determine how people got to your site (referrer, search terms used, etc.), but I don't know how to get at it myself.</p>
|
<p>You can use the "referer" part of the request that the user sent to figure out what he searched for. Example from Google:</p>
<blockquote>
<p><a href="http://www.google.no/search?q=stack%20overflow" rel="nofollow noreferrer">http://www.google.no/search?q=stack%20overflow</a></p>
</blockquote>
<p>So you must search the string (in ASP(.NET) this can be found be looking in <code>Request.Referer</code>) for "q=" and then URLDecode the contents.</p>
<p>Also, you should take a look at this article that talks more about referrers and also other methods to track your visitors:</p>
<p><a href="http://www.15seconds.com/issue/021119.htm" rel="nofollow noreferrer">http://www.15seconds.com/issue/021119.htm</a></p>
|
<p>This is some code to backup the idea of using a querystring method and if that's not available using the UrlReferrer property of the Request object. This can then be stashed in a session object (or somewhere else if that works better for you) so that you can track the source between pages. (Page_Load doesn't seem to be formatted correctly inside the code sample here)</p>
<pre><code>public void Page_Load(Object Sender, EventArgs E) {
if (null == Session["source"] || Session["source"].ToString().Equals(string.Empty)) {
if (Request.QueryString["src"] != null) {
Session["source"] = Server.UrlDecode(Request.QueryString["src"].ToString());
} else {
if (Request.UrlReferrer != null) {
Session["source"] = Request.UrlReferrer.ToString();
} else {
Session["source"] = string.Empty;
}
}
}}
</code></pre>
| 8,120
|
<p>I'm looking to create <code>favicon.ico</code> files programatically from Python, but PIL only has support for reading <code>ico</code> files.</p>
|
<p>You can use <a href="http://pillow.readthedocs.org" rel="noreferrer">Pillow</a>:</p>
<pre><code>from PIL import Image
filename = r'logo.png'
img = Image.open(filename)
img.save('logo.ico')
</code></pre>
<p>Optionally, you may specify the icon sizes you want:</p>
<pre><code>icon_sizes = [(16,16), (32, 32), (48, 48), (64,64)]
img.save('logo.ico', sizes=icon_sizes)
</code></pre>
<p>The <a href="http://pillow.readthedocs.org/en/3.1.x/handbook/image-file-formats.html" rel="noreferrer">Pillow docs</a> say that by default it will generate sizes
<code>[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (255, 255)]</code> and any size bigger than the original size or 255 will be ignored.</p>
<p>Yes, it is in the <strong>Read-only</strong> section of the docs, but it works to some extent.</p>
|
<p>I don't know if this applies for all cases, but on WinXP an .ico can be a bmp of size 16x16, 32x32 or 64x64. Just change the extension to ico from bmp and you're ready to go.</p>
| 6,740
|
<p>Here is my code, which takes two version identifiers in the form "1, 5, 0, 4" or "1.5.0.4" and determines which is the newer version.</p>
<p>Suggestions or improvements, please!</p>
<pre><code> /// <summary>
/// Compares two specified version strings and returns an integer that
/// indicates their relationship to one another in the sort order.
/// </summary>
/// <param name="strA">the first version</param>
/// <param name="strB">the second version</param>
/// <returns>less than zero if strA is less than strB, equal to zero if
/// strA equals strB, and greater than zero if strA is greater than strB</returns>
public static int CompareVersions(string strA, string strB)
{
char[] splitTokens = new char[] {'.', ','};
string[] strAsplit = strA.Split(splitTokens, StringSplitOptions.RemoveEmptyEntries);
string[] strBsplit = strB.Split(splitTokens, StringSplitOptions.RemoveEmptyEntries);
int[] versionA = new int[4];
int[] versionB = new int[4];
for (int i = 0; i < 4; i++)
{
versionA[i] = Convert.ToInt32(strAsplit[i]);
versionB[i] = Convert.ToInt32(strBsplit[i]);
}
// now that we have parsed the input strings, compare them
return RecursiveCompareArrays(versionA, versionB, 0);
}
/// <summary>
/// Recursive function for comparing arrays, 0-index is highest priority
/// </summary>
private static int RecursiveCompareArrays(int[] versionA, int[] versionB, int idx)
{
if (versionA[idx] < versionB[idx])
return -1;
else if (versionA[idx] > versionB[idx])
return 1;
else
{
Debug.Assert(versionA[idx] == versionB[idx]);
if (idx == versionA.Length - 1)
return 0;
else
return RecursiveCompareArrays(versionA, versionB, idx + 1);
}
}
</code></pre>
<hr>
<p>@ <a href="https://stackoverflow.com/questions/30494/compare-version-identifiers#30510">Darren Kopp</a>:</p>
<p>The version class does not handle versions of the format 1.0.0.5.</p>
|
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.version.aspx" rel="nofollow noreferrer">System.Version</a> class does not support versions with commas in it, so the solution presented by <a href="https://stackoverflow.com/questions/30494#30510">Darren Kopp</a> is not sufficient.</p>
<p>Here is a version that is as simple as possible (but no simpler).</p>
<p>It uses <a href="http://msdn.microsoft.com/en-us/library/system.version.aspx" rel="nofollow noreferrer">System.Version</a> but achieves compatibility with version numbers like "1, 2, 3, 4" by doing a search-replace before comparing.</p>
<pre><code> /// <summary>
/// Compare versions of form "1,2,3,4" or "1.2.3.4". Throws FormatException
/// in case of invalid version.
/// </summary>
/// <param name="strA">the first version</param>
/// <param name="strB">the second version</param>
/// <returns>less than zero if strA is less than strB, equal to zero if
/// strA equals strB, and greater than zero if strA is greater than strB</returns>
public static int CompareVersions(String strA, String strB)
{
Version vA = new Version(strA.Replace(",", "."));
Version vB = new Version(strB.Replace(",", "."));
return vA.CompareTo(vB);
}
</code></pre>
<p>The code has been tested with:</p>
<pre><code> static void Main(string[] args)
{
Test("1.0.0.0", "1.0.0.1", -1);
Test("1.0.0.1", "1.0.0.0", 1);
Test("1.0.0.0", "1.0.0.0", 0);
Test("1, 0.0.0", "1.0.0.0", 0);
Test("9, 5, 1, 44", "3.4.5.6", 1);
Test("1, 5, 1, 44", "3.4.5.6", -1);
Test("6,5,4,3", "6.5.4.3", 0);
try
{
CompareVersions("2, 3, 4 - 4", "1,2,3,4");
Console.WriteLine("Exception should have been thrown");
}
catch (FormatException e)
{
Console.WriteLine("Got exception as expected.");
}
Console.ReadLine();
}
private static void Test(string lhs, string rhs, int expected)
{
int result = CompareVersions(lhs, rhs);
Console.WriteLine("Test(\"" + lhs + "\", \"" + rhs + "\", " + expected +
(result.Equals(expected) ? " succeeded." : " failed."));
}
</code></pre>
|
<p>If you can assume that each place in the version string will only be one number (or at least the last 3, you can just remove the commas or periods and compare...which would be a lot faster...not as robust, but you don't always need that.</p>
<pre><code>public static int CompareVersions(string strA, string strB)
{
char[] splitTokens = new char[] {'.', ','};
string[] strAsplit = strA.Split(splitTokens, StringSplitOptions.RemoveEmptyEntries);
string[] strBsplit = strB.Split(splitTokens, StringSplitOptions.RemoveEmptyEntries);
int versionA = 0;
int versionB = 0;
string vA = string.Empty;
string vB = string.Empty;
for (int i = 0; i < 4; i++)
{
vA += strAsplit[i];
vB += strBsplit[i];
versionA[i] = Convert.ToInt32(strAsplit[i]);
versionB[i] = Convert.ToInt32(strBsplit[i]);
}
versionA = Convert.ToInt32(vA);
versionB = Convert.ToInt32(vB);
if(vA > vB)
return 1;
else if(vA < vB)
return -1;
else
return 0; //they are equal
}
</code></pre>
<p>And yes, I'm also assuming 4 version places here...</p>
| 5,036
|
<p>Is there a way to access Visual Studio's built-in ASP.NET Development Server over HTTPS?</p>
|
<p>As of now we can use IIS Express to develop and test in SSL. Here is a complete article explaning how to use IIS Express and Visual Studion 2010 to develop websites in SSL.</p>
<p><img src="https://i.stack.imgur.com/jvqeG.png" alt="enter image description here"></p>
<p><strong>Next</strong></p>
<p><img src="https://i.stack.imgur.com/3didG.png" alt="enter image description here"></p>
<p><strong>Then you will get this</strong> </p>
<p><img src="https://i.stack.imgur.com/Oh154.png" alt="enter image description here"></p>
<p><a href="http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx" rel="noreferrer">Working with SSL at Development Time is easier with IISExpress</a></p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx" rel="noreferrer">Introducing IIS Express </a></p>
|
<p><strong>Select the project-file in the Solution Explorer:</strong> for example: "WebApplication1". </p>
<p>With pressing <strong>ALT+ENTER</strong> you enter the project-properties. </p>
<p>Select <strong>"DEBUG"</strong> on the <strong>left side</strong>.</p>
<p>Here you can select <strong>"Enable SSL"</strong>.</p>
<p><em>Then you can start your project with IIS Express normally and it will start using SSL, the new Port will be 44301</em> </p>
| 8,493
|
<p>This is a follow-on question to the <a href="https://stackoverflow.com/questions/29061/how-do-you-use-ssh-in-a-shell-script">How do you use ssh in a shell script?</a> question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this:</p>
<pre><code>ssh user@target "cd /some/directory; program-to-execute &"
</code></pre>
<p>Any ideas? One thing to note is that logins to the target machine always produce a text banner and I have <strong>SSH</strong> keys set up so no password is required.</p>
|
<p>I had this problem in a program I wrote a year ago -- turns out the answer is rather complicated. You'll need to use nohup as well as output redirection, as explained in the wikipedia artcle on <a href="http://en.wikipedia.org/wiki/Nohup" rel="noreferrer">nohup</a>, copied here for your convenience. </p>
<blockquote>
<p>Nohuping backgrounded jobs is for
example useful when logged in via SSH,
since backgrounded jobs can cause the
shell to hang on logout due to a race
condition [2]. This problem can also
be overcome by redirecting all three
I/O streams:</p>
<pre><code>nohup myprogram > foo.out 2> foo.err < /dev/null &
</code></pre>
</blockquote>
|
<p>First follow this procedure: </p>
<p>Log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:</p>
<pre><code>a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
</code></pre>
<p>Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):</p>
<pre><code>a@A:~> ssh b@B mkdir -p .ssh
b@B's password:
</code></pre>
<p>Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:</p>
<pre><code>a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
</code></pre>
<p>From now on you can log into B as b from A as a without password:</p>
<pre><code>a@A:~> ssh b@B
</code></pre>
<p>then this will work without entering a password </p>
<p>ssh b@B "cd /some/directory; program-to-execute &"</p>
| 4,881
|
<p>Here is an example of what I've got going on:</p>
<pre><code>CREATE TABLE Parent (id BIGINT NOT NULL,
PRIMARY KEY (id)) ENGINE=InnoDB;
CREATE TABLE Child (id BIGINT NOT NULL,
parentid BIGINT NOT NULL,
PRIMARY KEY (id),
KEY (parentid),
CONSTRAINT fk_parent FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE) ENGINE=InnoDB;
CREATE TABLE Uncle (id BIGINT NOT NULL,
parentid BIGINT NOT NULL,
childid BIGINT NOT NULL,
PRIMARY KEY (id),
KEY (parentid),
KEY (childid),
CONSTRAINT fk_parent_u FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE,
CONSTRAINT fk_child FOREIGN KEY (childid) REFERENCES Child (id)) ENGINE=InnoDB;
</code></pre>
<p>Notice there is no ON DELETE CASCADE for the Uncle-Child relationship; i.e. deleting a Child does not delete its Uncle(s) and vice-versa.</p>
<p>When I have a Parent and an Uncle with the same Child, and I delete the Parent, it <em>seems</em> like InnoDB should be able to just "figure it out" and let the cascade ripple through the whole family (i.e. deleting the Parent deletes the Uncle and the Child as well). However, instead, I get the following:</p>
<pre><code> ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`cascade_test/uncle`, CONSTRAINT `fk_child` FOREIGN KEY (`childid`) REFERENCES `child` (`id`))
</code></pre>
<p>InnoDB is trying to cascade-delete the Child before the Uncle(s) that refer to it.</p>
<p>Am I missing something? Is this <em>supposed</em> to fail for some reason I don't understand? Or is there some trick to making it work (or is it a bug in MySQL)?</p>
|
<p>In the simpler case, what happens if a record is deleted from Child and it has a referencing Uncle? That's unspecified, so the constraints fail for that anyway.</p>
<p>If deleting a Child does not delete its Uncles, then what happens instead? Uncle.childid cannot be null.</p>
<p>What you want is one of these three things:</p>
<ol>
<li>Uncle.childid can be null, and you want ON DELETE SET NULL for childid.</li>
<li>Uncle.childid cannot be null, and you want ON DELETE CASCADE for childid.</li>
<li>Childid does not belong on Uncle, and you want a ChildsUncle relation with ON DELETE CASCADE foreign key constraints to both Child and Uncle. Uncleid would be a candidate key for that relation (i.e. it should be unique).</li>
</ol>
|
<p>the design is all wrong. You should have single table, with parent child relationship (literrally).
Then you can figure out uncles (and aunts) with a query</p>
<p><code>
select id from persons where -find all children of the grandparents<br>
parent id in (<br>
select parentid from persons --find the grandparents<br>
where id in (<br>
select parentid from persons --find the parents<br>
where id=THECHILD)
)<br>
minus --and take out the child's parents<br>
select parentid from persons<br>
where id=THECHILD<br>
</code> </p>
| 8,500
|
<p>I'm wondering what is the quickest and most reliable way to forward mail from an IMAP account.</p>
<p>My university does not allow our student-mailbox to forward to a private e-mail account (everybody uses either Gmail or Hotmail here). It's a political thing, not technical. We do have IMAP access to the mailbox. I would like to have a service which downloads the mail through IMAP, and forwards. And it would be nice to scale it, so thousands of students can use it. Eventually, I want to build a public signup page, and have it processed automatically from there. </p>
<p>So far, I've made a decent PHP script which connects, downloads headers and body parts, and ties it all together. I have two problems with that. </p>
<p>1) I'm downloading all kind of parts, and sticking them back together. I hope that every exotic attached file, weird encoded piece of text and every type of header survives this. I'm not even sure I have the complete header.</p>
<p>2) The to: e-mail address becomes the private e-mail address, not the original student e-mail address. I think this is lame, and inconvenient in searching and archiving.</p>
<p>Is the PHP script the way to go? Is there a trick using a particular linux mail service/daemon? Does IMAP have a 'forward' command, I'm missing? </p>
|
<p>You might want to look at <A HREF="http://www.fetchmail.info//" rel="nofollow noreferrer">Fetchmail</A>, as this sounds like the problem it was designed to solve. Fetchmail retrieves mail from POP/IMAP/etc servers and forwards it to SMTP/LMTP/etc servers. Fetchmail has the advantage of a few years and lots of users ironing out problems with various IMAP servers.</p>
|
<p>If using Gmail you can configure GMAIL to pick up mail from other accounts.</p>
| 8,184
|
<p>I have a tomcat instance setup but the database connection I have configured in <code>context.xml</code> keeps dying after periods of inactivity.</p>
<p>When I check the logs I get the following error:</p>
<p>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received from the server was68051 seconds
ago. The last packet sent successfully to the server was 68051 seconds
ago, which is longer than the server configured value of
'wait_timeout'. You should consider either expiring and/or testing
connection validity before use in your application, increasing the
server configured values for client timeouts, or using the Connector/J
connection property 'autoReconnect=true' to avoid this problem.</p>
<p>Here is the configuration in context.xml:</p>
<pre><code><Resource name="dataSourceName"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="username"
password="********"
removeAbandoned = "true"
logAbandoned = "true"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/databasename?autoReconnect=true&amp;useEncoding=true&amp;characterEncoding=UTF-8" />
</code></pre>
<p>I am using <code>autoReconnect=true</code> like the error says to do, but the connection keeps dying. I have never seen this happen before.</p>
<p>I have also verified that all database connections are being closed properly.</p>
|
<p><a href="http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html" rel="noreferrer">Tomcat Documentation</a></p>
<p>DBCP uses the Jakarta-Commons Database Connection Pool. It relies on number of Jakarta-Commons components:</p>
<pre><code>* Jakarta-Commons DBCP
* Jakarta-Commons Collections
* Jakarta-Commons Pool
</code></pre>
<p>This attribute may help you out.</p>
<pre><code>removeAbandonedTimeout="60"
</code></pre>
<p>I'm using the same connection pooling stuff and I'm setting these properties to prevent the same thing it's just not configured through tomcat.
But if the first thing doesn't work try these.</p>
<pre><code>testWhileIdle=true
timeBetweenEvictionRunsMillis=300000
</code></pre>
|
<p>I do not know whether the above answer does basically the same thing, but some of our systems use the DB connection about once a week and I've seen that we provide a -Otimeout flag or something of that sort to mysql to set the connection timeout.</p>
| 3,672
|
<p>Is there a way when executing a stored procedure in Management Studio to get the data types of the result sets coming back? I'm looking for something like functionality of when you pass a table name to sp_help</p>
|
<p>You do get to look at the types though, if you call the stored procedure via ADO, ADO.NET, ODBC or the likes: The resulting recordsets have the type information you are looking for. Are you really restricted to Management Studio?</p>
|
<p>You could always use an actual table that is garrenteed to be unique. It's a kludge, but it's an option. This will not work inside a stored proc though.</p>
<pre><code>if exists (select * from sys.tables where name = 'tmp_TableName')
drop table tmp_TableName
go
select * into tmp_TableName from MyTable
--do some stuff
go
if exists (select * from sys.tables where name = 'tmp_TableName')
drop table tmp_TableName
go
</code></pre>
| 5,317
|
<p>So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause:</p>
<pre><code>CREATE PROCEDURE getSomething @keyList varchar(4096)
AS
SELECT * FROM mytbl WHERE name IN (@keyList)
</code></pre>
<p>How do I call my stored proc with more than 1 value in the list?
So far I've tried </p>
<pre><code>exec getSomething 'John' -- works but only 1 value
exec getSomething 'John','Tom' -- doesn't work - expects two variables
exec getSomething "'John','Tom'" -- doesn't work - doesn't find anything
exec getSomething '"John","Tom"' -- doesn't work - doesn't find anything
exec getSomething '\'John\',\'Tom\'' -- doesn't work - syntax error
</code></pre>
<p><strong>EDIT:</strong> I actually found this <a href="http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm" rel="noreferrer">page</a> that has a great reference of the various ways to pas an array to a sproc</p>
|
<p>If you're using Sybase 12.5 or earlier then you can't use functions. A workaround might be to populate a temporary table with the values and read them from there.</p>
|
<p>Do you need to use a comma separated list? The last couple of years, I've been taking this type of idea and passing in an XML file. The openxml "function" takes a string and makes it like xml and then if you create a temp table with the data, it is queryable.</p>
<pre><code>DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
<ROOT>
<Customer CustomerID="VINET" ContactName="Paul Henriot">
<Order CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
<OrderDetail OrderID="10248" ProductID="11" Quantity="12"/>
<OrderDetail OrderID="10248" ProductID="42" Quantity="10"/>
</Order>
</Customer>
<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">
<Order CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00">
<OrderDetail OrderID="10283" ProductID="72" Quantity="3"/>
</Order>
</Customer>
</ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/ROOT/Customer',1)
WITH (CustomerID varchar(10),
ContactName varchar(20))
</code></pre>
| 2,810
|
<p>Using ASP.NET MVC there are situations (such as form submission) that may require a <code>RedirectToAction</code>. </p>
<p>One such situation is when you encounter validation errors after a form submission and need to redirect back to the form, but would like the URL to reflect the URL of the form, not the action page it submits to.</p>
<p>As I require the form to contain the originally <code>POST</code>ed data, for user convenience, as well as validation purposes, how can I pass the data through the <code>RedirectToAction()</code>? If I use the viewData parameter, my <code>POST</code> parameters will be changed to <code>GET</code> parameters.</p>
|
<p>The solution is to use the TempData property to store the desired Request components.</p>
<p>For instance:</p>
<pre><code>public ActionResult Send()
{
TempData["form"] = Request.Form;
return this.RedirectToAction(a => a.Form());
}
</code></pre>
<p>Then in your "Form" action you can go:</p>
<pre><code>public ActionResult Form()
{
/* Declare viewData etc. */
if (TempData["form"] != null)
{
/* Cast TempData["form"] to
System.Collections.Specialized.NameValueCollection
and use it */
}
return View("Form", viewData);
}
</code></pre>
|
<p>TempData is the solution which keeps the data from action to action.</p>
<pre><code>Employee employee = new Employee
{
EmpID = "121",
EmpFirstName = "Imran",
EmpLastName = "Ghani"
};
TempData["Employee"] = employee;
</code></pre>
| 2,416
|
<p>A tutorial I have on Regex in python explains how to use the re module in python, I wanted to grab the URL out of an A tag so knowing Regex I wrote the correct expression and tested it in my regex testing app of choice and ensured it worked. When placed into python it failed:</p>
<pre><code>result = re.match("a_regex_of_pure_awesomeness", "a string containing the awesomeness")
# result is None`
</code></pre>
<p>After much head scratching I found out the issue, it automatically expects your pattern to be at the start of the string. I have found a fix but I would like to know how to change:</p>
<pre><code>regex = ".*(a_regex_of_pure_awesomeness)"
</code></pre>
<p>into</p>
<pre><code>regex = "a_regex_of_pure_awesomeness"
</code></pre>
<p>Okay, it's a standard URL regex but I wanted to avoid any potential confusion about what I wanted to get rid of and possibly pretend to be funny.</p>
|
<p>In Python, there's a distinction between "match" and "search"; match only looks for the pattern at the start of the string, and search looks for the pattern starting at any location within the string.</p>
<p><a href="http://docs.python.org/lib/module-re.html" rel="noreferrer">Python regex docs</a><br>
<a href="http://docs.python.org/lib/matching-searching.html" rel="noreferrer">Matching vs searching</a></p>
|
<p>Are you using the <code>re.match()</code> or <code>re.search()</code> method? My understanding is that <code>re.match()</code> assumes a "<code>^</code>" at the beginning of your expression and will only search at the beginning of the text, while <code>re.search()</code> acts more like the Perl regular expressions and will only match the beginning of the text if you include a "<code>^</code>" at the beginning of your expression. Hope that helps.</p>
| 9,801
|
<p>I'm storing a Word document in a SQL Server 2005 database in a varbinary(max) column. Is there a way to open this document from a VB.NET Windows Forms application without serialising to a file first (i.e. directly from the byte array I've read from the database)?</p>
|
<p>Depends on what's reading it. If it's Word, you'll probably have to serialize to a file, but if it's a function or library that can take an IO.Stream then you could wrap a new MemoryStream around the byte array and pass that.</p>
|
<p>Not really. You need to treat it like an e-mail attachment, where the file is generally copied to a temp folder that is cleaned out periodically.</p>
| 8,103
|
<p>I am wondering if anyone here knows of any 3D printers that work by assembling models from parts instead of extruding or setting material.</p>
<p>The closest I have found is the <a href="https://www.youtube.com/channel/UCtoqCrwr91bNH_hbPtBrprw" rel="nofollow noreferrer">pixelstone</a> but it appears to only be a prototype and I haven't seen or heard of any progress on it in over a year.</p>
<p>There is a similar house printer <a href="http://fbr.com.au/" rel="nofollow noreferrer">fastbrick</a> but it is also just a prototype.</p>
<p>There is research papers on rapid prototyping with lego blocks and software for this (<a href="https://all3dp.com/brickify-rapid-prototyping-lego/" rel="nofollow noreferrer">brickify</a>), but these don't have machine assembly.</p>
<p>And there are 3D printers that can do conductive filament in the model but none of these seem to do pick and place as well and they still need a human to add the electronics or to change the tool head. (<a href="http://delta.firepick.org/" rel="nofollow noreferrer">firepick</a>)</p>
<p>So are there any 3D printers that work like pick and place machines and just stick blocks together?</p>
|
<h2>Yes and no</h2>
<p><strong>Yes</strong>, there are machines, that assemble things from parts. For example, <a href="https://en.wikipedia.org/wiki/SMT_placement_equipment" rel="nofollow noreferrer">SMT placement equipment & pick-and-place-machines</a>. Almost all electronics are made this way. In fact, a lot of items are made by using Pick-and-Place machines in the final assembly.</p>
<p>On the other hand: <strong>No</strong>, there is no <em>3D-printer</em>, that works by <em>just</em> being a P&P machine: it simply is not inside the specifications of additive manufacturing to be <em>just</em> an assembly machine. That is an <em>assembly</em> or <em>pick and place</em> machine, no matter if they call it <em>printing</em>. It is not.</p>
<h4>combo machines?</h4>
<p>However, I have seen a recent (<strong>2018</strong>) <a href="https://youtu.be/jfopGYO0r-M?t=488" rel="nofollow noreferrer">makerfaire video</a> and <a href="https://www.youtube.com/watch?v=DRkF-D0fEbQ" rel="nofollow noreferrer">a talk</a> that was showing a prototype of an E3D toolhead swapper, which - in its idea - would allow to <em>combine</em> a 3D printer with a P&P machine. Their idea is to fully automate the manufacturing process, including adding non-printed parts with grabbers or the like.</p>
<h2>2022 update</h2>
<p>Multi-Tool 3D printers based on the E3D-Toolchanger including a pick-and-place are in <a href="https://youtu.be/pBztvEJJGwA?list=TLPQMTIxMTIwMjKbAChud1cdqg" rel="nofollow noreferrer">small-scale</a> use in at least one fabrication shop in their prototyping stage. They also use conductive filaments in conjunction with their setup - but need to compensate for the considerable resistance of conductive filaments.</p>
|
<p>I've prototyped a design that used beads similar to these <a href="http://www.infostir.com/images/plastic-beads-350.jpg" rel="nofollow noreferrer">http://www.infostir.com/images/plastic-beads-350.jpg</a> on a rod with a heated tip and then you just press them off into the design. But it wasn't too strong and had some pretty specific requirements of the model. Labelled it a failure. </p>
| 542
|
<p>I've been given a job of 'translating' one language into another. The source is too flexible (complex) for a simple line by line approach with regex. Where can I go to learn more about lexical analysis and parsers?</p>
|
<p>If you want to get "emotional" about the subject, pick up a copy of "<a href="http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools" rel="noreferrer">The Dragon Book</a>." It is <em>usually</em> the text in a compiler design course. It will definitely meet your need "learn more about lexical analysis and parsers" as well as a bunch of other <strong>fun</strong> stuff! </p>
<p>IMH(umble)O, save yourself an arm and/or leg and buy an older edition - it will fill your information desires.</p>
|
<p>If you prefer Java based tools, the Java Compiler Compiler, JavaCC, is a nice parser/scanner. It's config file driven, and will generate java code that you can include in your program. I haven't used it a couple years though, so I'm not sure how the current version is. You can find out more here: <a href="https://javacc.dev.java.net/" rel="nofollow noreferrer">https://javacc.dev.java.net/</a></p>
| 5,424
|
<p>Is there any IL level debugger in form of a VS plugin or standalone application?</p>
<p>Visual studio’s debugger is great, but it allows you to debug on either HLL code level or assembly language, you can’t debug IL.
It seems that in some situations it would be useful to have an opportunity to debug at IL level. </p>
<p>In particular it might be helpful when debugging a problem in the code that you don't have the source of.</p>
<p>It is arguable if it is actually useful to debug IL when you don't have the source, but anyway.</p>
|
<p>The best way to do this is to use ILDASM to disassemble the managed binary, which will generate the IL instructions. Then recompile that IL source code in debug mode using ILASM, when you fire up the Visual Studio debugger you will be able to step through the raw IL.</p>
<ol>
<li><code>ildasm foo.exe /OUT=foo.exe.il /SOURCE</code></li>
<li><code>ilasm foo.exe.il /DEBUG</code></li>
</ol>
<p>I've written a blog post about this topic at:
<a href="http://blogs.msdn.com/chrsmith/archive/2008/03/13/how-to-debug-compiler-generated-code.aspx" rel="noreferrer">How to debug Compiler Generated code</a>.</p>
|
<p>ISTR there's a debugger plug-in for Reflector. </p>
<p>Not used it myself, though I have used TestDriven.net to debug a 3rd-party assembly with the aid of Reflector:</p>
<p><a href="http://weblogs.asp.net/nunitaddin/archive/2006/11/05/Debug-With-Reflector.aspx" rel="nofollow noreferrer">weblogs.asp.net/nunitaddin</a></p>
| 3,062
|
<p>Is there a good yacc/bison type LALR parser generator for .NET ?</p>
|
<p><a href="http://antlr.org/" rel="noreferrer">Antlr</a> supports C# code generation, though it is LL(k) not technically LALR. Its tree rewriting rules are an interesting feature though.</p>
|
<p>Check out <a href="http://goldparser.org/grammars/index.htm" rel="nofollow">Gold</a>. It is LALR compliant and supports lots of languages, if not the most. Gold can convert YACC and Bison type grammars. </p>
<p>If it does not suit your needs then check out <a href="http://en.wikipedia.org/wiki/Comparison_of_parser_generators" rel="nofollow">this page</a>.</p>
<p>Spirit is another LALR parser.</p>
<p>Also note that <a href="http://www.mono-project.com/Main_Page" rel="nofollow">Mono</a> created a variant of the Jay parser for their c# and .NET framework. Their c# compiler is, from what I can tell, production quality.</p>
| 5,732
|
<p>I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux).</p>
<p>I have implemented <code>QueryPerformanceCounter</code> by giving the uSeconds since the process start up: </p>
<pre><code>BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount)
{
gettimeofday(&currentTimeVal, NULL);
performanceCount->QuadPart = (currentTimeVal.tv_sec - startTimeVal.tv_sec);
performanceCount->QuadPart *= (1000 * 1000);
performanceCount->QuadPart += (currentTimeVal.tv_usec - startTimeVal.tv_usec);
return true;
}
</code></pre>
<p>This, coupled with <code>QueryPerformanceFrequency()</code> giving a constant 1000000 as the frequency, works well <b>on my machine</b>, giving me a 64-bit variable that contains <code>uSeconds</code> since the program's start-up.</p>
<p>So <em>is this portable?</em> I don't want to discover it works differently if the kernel was compiled in a certain way or anything like that. I am fine with it being non-portable to something other than Linux, however.</p>
|
<p>Maybe. But you have bigger problems. <code>gettimeofday()</code> can result in incorrect timings if there are processes on your system that change the timer (ie, ntpd). On a "normal" linux, though, I believe the resolution of <code>gettimeofday()</code> is 10us. It can jump forward and backward and time, consequently, based on the processes running on your system. This effectively makes the answer to your question no.</p>
<p>You should look into <code>clock_gettime(CLOCK_MONOTONIC)</code> for timing intervals. It suffers from several less issues due to things like multi-core systems and external clock settings.</p>
<p>Also, look into the <code>clock_getres()</code> function.</p>
|
<p>From my experience, and from what I've read across the internet, the answer is "No," it is not guaranteed. It depends on CPU speed, operating system, flavor of Linux, etc.</p>
| 2,252
|
<p>In my C++ program I want to parse a small piece of XML, insert some nodes, then extract the new XML (preferably as a <code>std::string</code>).<br>
<a href="http://rapidxml.sourceforge.net/" rel="nofollow noreferrer">RapidXml</a> has been recommended to me, but I can't see how to retrieve the XML back as a text string.<br>
(I could iterate over the nodes and attributes and build it myself, but surely there's a build in function that I am missing.)<br>
Thank you.</p>
|
<p>Althoug the documentation is poor on this topic, I managed to get some working code by looking at the source. Although it is missing the xml header which normally contains important information. Here is a small example program that does what you are looking for using rapidxml:</p>
<pre><code>#include <iostream>
#include <sstream>
#include "rapidxml/rapidxml.hpp"
#include "rapidxml/rapidxml_print.hpp"
int main(int argc, char* argv[]) {
char xml[] = "<?xml version=\"1.0\" encoding=\"latin-1\"?>"
"<book>"
"</book>";
//Parse the original document
rapidxml::xml_document<> doc;
doc.parse<0>(xml);
std::cout << "Name of my first node is: " << doc.first_node()->name() << "\n";
//Insert something
rapidxml::xml_node<> *node = doc.allocate_node(rapidxml::node_element, "author", "John Doe");
doc.first_node()->append_node(node);
std::stringstream ss;
ss <<*doc.first_node();
std::string result_xml = ss.str();
std::cout <<result_xml<<std::endl;
return 0;
}
</code></pre>
|
<p>If you aren't yet committed to Rapid XML, I can recommend some alternative libraries:</p>
<ul>
<li><p>Xerces - This is probably the defacto C++ implementation.</p></li>
<li><p>XMLite - I've had some luck with this minimal XML implementation. See the article at <a href="http://www.codeproject.com/KB/recipes/xmlite.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/recipes/xmlite.aspx</a></p></li>
</ul>
| 5,896
|
<p>Ok, so there has to be a way to do this... no? If not I'd love some ideas. </p>
<p>I have two repeaters and an image inside an update panel along with some AJAX dropdowns with link buttons to the left. I want to update the data inside the update panel as fast as possible as values are selected from the dropdowns. </p>
<p>What do you think would be the best way to update the data? The repeaters are populated by objects, so if I could just filter the objects by some properties I could end up with the correct data. No new data from the server is needed. </p>
<p>Anyone have some ideas?</p>
|
<p>As far as I know, it is not easy to get just Data and data-bind the repeater on the client side. But, you might want to <a href="http://dotnetslackers.com/articles/ajax/ASPNETRepeater.aspx" rel="nofollow noreferrer">check this out</a>.</p>
|
<p>Wrap only the repeater you want to rebind with an update panel of its own. The only viewstate transferred when doing this is the portion inside the update panel. You may have to play around with the triggers and update mode of the panels to get everything to play nicely. </p>
<p>Another option is instead of using repeaters, serialize your objects into XML and then write a page method that returns an html string of your transformed data using xsl. Then client side call your path method and update the DOM as appropriate. </p>
<p>A third option is to use use a service reference/page method to return JSON objects and update the DOM manually.</p>
<p><a href="http://www.asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXWebServicesTutorials.aspx" rel="nofollow noreferrer">http://www.asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXWebServicesTutorials.aspx</a></p>
<p>Good luck! I have done all 3,</p>
| 8,715
|
<p>For my Frankenstein's printer I am at a loss with the hotend mount. I cannot drill holes of 16 (upper diameter) and 12 mm (clamping diameter, 6mm high) which i would need to mount the E3D V6 clone I have.</p>
<p>What I am looking for: a hotend mount plate that tightly fixes the hotend while having some holes for screws to mount it to the horizontally moving x-y drives. As I cannot print yet, it needs to be manufacturable at home. I thought of something like this:<br>
<a href="http://www.thingiverse.com/thing:285405" rel="nofollow">http://www.thingiverse.com/thing:285405</a><br>
I could get a piece of wood thin enough to fit the 6mm gap for the hotend, would not really be able to put any screws through it along the flat axis. also I would have to glue the layer with a 16mm hole on top. Not to say that I don't own a drillbit of 16mm diameter...</p>
<p>Are there some completely different ideas around which I didn't think of yet?</p>
<p>Additional info: the x-y axes are made from a scanner bed and an underneath mounted dvd drive laser positioner. Ideally, I'd want to mount the hotend directly to the DVD drive but a) there is almost no space for that, and b) I'm pretty sure I will burn the DVD drive's motor somewhere along the way, so I don't want to put too much work in the individual DVD drive.</p>
|
<p>If you do not have the tools to fabricate this component yourself, but have a 3D model available, I would suggest getting someone else to 3D print it for you.</p>
<p>There are multiple options for getting your model printed, such as:</p>
<ul>
<li>Friends</li>
<li>Your local makerspace, library or similar</li>
<li><a href="https://www.3dhubs.com/" rel="nofollow">3D Hubs</a> </li>
<li><a href="https://www.makexyz.com/" rel="nofollow">MakeXYZ</a></li>
<li><a href="http://www.shapeways.com/" rel="nofollow">Shapeways</a></li>
<li><a href="http://www.sculpteo.com/en/" rel="nofollow">Sculpteo</a></li>
<li>and so on..</li>
</ul>
<p>Good luck!</p>
|
<p>If you do not have the tools to fabricate this component yourself, but have a 3D model available, I would suggest getting someone else to 3D print it for you.</p>
<p>There are multiple options for getting your model printed, such as:</p>
<ul>
<li>Friends</li>
<li>Your local makerspace, library or similar</li>
<li><a href="https://www.3dhubs.com/" rel="nofollow">3D Hubs</a> </li>
<li><a href="https://www.makexyz.com/" rel="nofollow">MakeXYZ</a></li>
<li><a href="http://www.shapeways.com/" rel="nofollow">Shapeways</a></li>
<li><a href="http://www.sculpteo.com/en/" rel="nofollow">Sculpteo</a></li>
<li>and so on..</li>
</ul>
<p>Good luck!</p>
| 227
|
<p>I found some wild remarks that ASP.NET MVC is 30x faster than ASP.NET WebForms. What real performance difference is there, has this been measured and what are the performance benefits.</p>
<p>This is to help me consider moving from ASP.NET WebForms to ASP.NET MVC.</p>
|
<p>We haven't performed the type of scalability and perf tests necessary to come up with any conclusions. I think ScottGu may have been discussing potential perf targets. As we move towards Beta and RTM, we will internally be doing more perf testing. However, I'm not sure what our policy is on publishing results of perf tests.</p>
<p>In any case, any such tests really need to consider real world applications...</p>
|
<p><img src="https://i.stack.imgur.com/I7eXy.png" alt="enter image description here"></p>
<p>I did a small VSTS load test experiment with some basic code and found ASP.NET MVC response time to be twice faster as compared to ASP.NET Webforms. Above is the attached graph with the plot. </p>
<p>You can read this load test experiment in details from this CP article <a href="https://www.codeproject.com/Articles/864950/ASP-NET-MVC-vs-ASP-NET-WebForm-performance-compari" rel="nofollow noreferrer">https://www.codeproject.com/Articles/864950/ASP-NET-MVC-vs-ASP-NET-WebForm-performance-compari</a></p>
<p>Test was conducted with the below specifications using VSTS and telerik load test software:-</p>
<p>User load 25 users.</p>
<p>Run duration of test was 10 minutes.</p>
<p>Machine config DELL 8 GB Ram, Core i3</p>
<p>Project was hosted in IIS 8.</p>
<p>Project was created using MVC 5.</p>
<p>Network LAN connection was assumed. So this test does not account for network lag for now.</p>
<p>Browser in the test selected Chrome and Internet explorer.</p>
<p>Multiple reading where taken during the test to average unknown events. 7 readings where taken and all readings are published in this article as reading 1 , 2 and so on.</p>
| 6,531
|
<p>I've just introduced a friend to <strong>GNU Screen</strong> and they're having a hard time getting used to it. That makes me think about the essential things he needs to know about the excellent <strong>Screen</strong> utility, the same things that you'd think worthwhile to teach someone, a beginner, from the ground up. What are some analogies and handy tips for remembering binds, etc.?</p>
<p>It would be awesome.</p>
|
<p>I've been using <code>Screen</code> for over 10 years and probably use less than half the features. So it's definitely not necessary to learn all its features right away (and I wouldn't recommend trying). My day-to-day commands are:</p>
<pre><code>^A ^W - window list, where am I
^A ^C - create new window
^A space - next window
^A p - previous window
^A ^A - switch to previous screen (toggle)
^A [0-9] - go to window [0-9]
^A esc - copy mode, which I use for scrollback
</code></pre>
<p>I think that's it. I sometimes use the split screen features, but certainly not daily. The other tip is if screen seems to have locked up because you hit some random key combination by accident, do both <code>^Q</code> and <code>^A ^Q</code> to try to unlock it.</p>
|
<p>^A A switches back to the screen you just came from.</p>
| 9,605
|
<p>I start to write a client - server application using .net (C#) for both client and server side.</p>
<p>Unfortunately, my company refuse to pay for Windows licence on server box meaning that I need to rewrite my code in Java, or go to the Mono way.</p>
<p>Is there any good way to translate C# code in Java ? The server application used no .net specific feature, only cross language tools like Spring.net, Hibernate.net and log4net.</p>
<p>Thanks.</p>
|
<p>I'd suggest building for Mono. You'll run into some gray area, but overall it's great. However, if you want to build for Java, you might check out <a href="http://dev.mainsoft.com/Default.aspx?tabid=130" rel="noreferrer">Grasshopper</a>. It's a commercial product, but it claims to be able to translate CIL (the output of the C# compiler) to Java bytecodes.</p>
|
<p>I only know the other way. <a href="http://www.db4o.com/" rel="nofollow noreferrer">Dbo4</a> is developed in java and the c# version is generated from the java sources automaticaly.</p>
| 9,077
|
<p>Is there a good library for extracting text from a PDF? I'm willing to pay for it if I have to.</p>
<p>Something that works with C# or classic ASP (VBScript) would be ideal and I also need to be able to separate the pages from the PDF.</p>
<p><a href="https://stackoverflow.com/questions/25665/python-module-for-converting-pdf-to-text">This question</a> had some interesting stuff, especially <a href="http://en.wikipedia.org/wiki/Pdftotext" rel="nofollow noreferrer">pdftotext</a> but I'd like to avoid calling to an external command-line app if I can.</p>
|
<p>You can use the IFilter interface built into Windows to extract text and properties (author, title, etc.) from any supported file type. It's a COM interface so you would have use the .NET interop facilities.</p>
<p>You'd also have to download the free PDF IFilter driver from Adobe.</p>
|
<p>Here is a good list:
<a href="http://csharp-source.net/open-source/pdf-libraries" rel="nofollow noreferrer">Open Source Libs for PDF/C#</a></p>
<p>Most of these are geared toward creating PDFs, but they should have read capability as well.</p>
<p>There is this one as well: <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">iText</a></p>
<p>I have only played with iText before. Nothing major.</p>
| 6,904
|
<p>I have installed and setup RubyCAS-Server and RubyCAS-Client on my machine. Login works perfectly but when I try to logout I get this error message from the RubyCAS-Server:</p>
<pre><code>Camping Problem!
CASServer::Controllers::Logout.GET
ActiveRecord::StatementInvalid Mysql::Error: Unknown column 'username' in 'where clause': SELECT * FROM `casserver_pgt` WHERE (username = 'lgs') :
</code></pre>
<p>I am using version 0.6 of the gem. Looking at the migrations in the RubyCAS-Server it looks like there shouldn't be a username column in that table at all.</p>
<p>Does anyone know why this is happening and what I can do about it?</p>
|
<p>Do you need something more than what can be provided by MsgBox?</p>
<pre><code>MsgBox("Do you want to see this message?", MsgBoxStyle.OkCancel + MsgBoxStyle.Information, "Respond")
</code></pre>
|
<p>Are you unable to use the <a href="http://msdn.microsoft.com/en-us/library/aa335422(VS.71).aspx" rel="nofollow noreferrer">MessageBox class</a>?</p>
| 8,840
|
<p>I am looking for either a FireFox extension, or a similar program, that allows you to craft GET and POST requests. The user would put in a form action, and as many form key/value pairs as desired. It would also send any cookie information (or send the current cookies from any domain the user chooses.) The Web Developer add-on is almost what I'm looking for; It let's you quickly see the form keys, but it doesn't let you change them or add new ones (which leads to a lot of painful JavaScript in the address bar...)</p>
|
<p>If you're a windows user, use <a href="http://www.fiddler2.com/fiddler2/version.asp" rel="nofollow noreferrer">Fiddler</a>. It is invaluable for looking at the raw Http requests and responses. It also has the ability to create requests with the request builder and it has an auto responder also, so you can intercept requests. It even lets you inspect HTTPS traffic and it has a built in event scripting engine, where you can create your own rules.</p>
|
<p>If you've got Greasemonkey installed you might want to try the XSS Assistant user script: <a href="http://www.whiteacid.org/greasemonkey/#xss_assistant" rel="nofollow noreferrer">http://www.whiteacid.org/greasemonkey/#xss_assistant</a></p>
| 3,655
|
<p>I'm currently designing a very large and complicated model, because it's large and should be strong enough completely hollow I want to print it with no infill to save material.</p>
<p>However, there are some points in the model where there are indentations in the top shell.</p>
<p>The bottom of those indentations are lower then the surrounding shell (pretty mush the dictionary definition of indentation) and so they are printed earlier with nothing to connect to.</p>
<p>For example, in the image below from Cura's layer view you can see two round surfaces just hanging in mid air</p>
<p><a href="https://i.stack.imgur.com/d4Rrm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d4Rrm.png" alt="Surface in mid air"></a></p>
<p>Obviously this can't be printed.</p>
<p>What I'm currently doing is designing internal spaces inside the model where the internal space shell is holding the "detached" surfaces.</p>
<p>What I want is a mostly automatic process that will generate a support structure inside where needed or that will generate infill but only between the floating surface and the nearest solid shell below it.</p>
<p>Reorienting the model is not an option because a. it wouldn't fit on the build plate and b. even if it did it has a lot of internal parts with different orientations so it would just move the problem from one part of the model to another. </p>
<p>I usually use SketchUp for designing and Cura for slicing so I prefer something I can do in Cura - but since I strongly suspect this can't be done in Cura I'll accept answers that work with other tools</p>
|
<p>I'm not really sure if i get you right but it seems like you gotta switch on support material. That's all. Correct me if I'm wrong but it sounds like very common situation where some parts are hanging like your yellow disks.</p>
<p>Otherwise if your model is going to be closed at the bottom and at the top you can mock support on your own to have better control of it. How? Just add hollow cylinders under your disk so in fact cylinder will stay on the bottom layer then its walls will be support and finally your yellow disk will be a top cover of the cylinder. I hopw you can imagine that properly.</p>
<p>Another way is to design support elements wich would grow out of walls and this way support your disks</p>
<p><a href="https://i.stack.imgur.com/p9Z7F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p9Z7F.png" alt="enter image description here"></a></p>
<p>Maybe if you would explain a bit more, what the model is then I could support you more.</p>
<p><strong>[edit]</strong></p>
<p>To make it more automatic, you could try to use parametric CAD apps. I would say, Autodesk Inventor is one which I can suggest. You can use for example its Ribs functionality as support (varsion C).</p>
<p><strong>[edit2]</strong></p>
<p>After Tormod Haugene's and tbm0115's comments I decided to fill some gaps in my answer. Here go pros and cons of options A, B and C.</p>
<ul>
<li><strong>option A</strong></li>
</ul>
<p>The simplest one and more or less automatic one. Which means when user add support then this option will be a result of it. Of course if user needs to have support only for the disk but over the disk there will be... a "ceiling" then option A cannot use regular support as it will generate a support also for the ceiling. For such situation user needs to add a cylinder manually (filled one) or</p>
<ul>
<li><strong>option B</strong></li>
</ul>
<p>User can add hollow cyliner (just its walls). This option can give similar or higher stiffness as regular support because solid walls increase endurance tahn thin support grid.</p>
<ul>
<li><strong>option C</strong></li>
</ul>
<p>This option (my personal choose) has some advantages unavailable in A or B option. First - support doesn't have to have "ground" base. It means the yellow disk can really hang even if there is no bottom layer at all. Second - it joins walls with disk and walls together so the stiffness concerns other surfaces.</p>
<p>Depending on needs the cylinder (option A or B) can be transformed into a cross or pillar (thinner than cylinder itself). It can be more taper expandint to the top or to the bottom.</p>
<p>There could be even option where the above one would be joined with option C. So these (3) ribs would raise from the bottom but not from the walls.</p>
|
<p>In Cura 2 you can do several things:</p>
<ol>
<li><p>Design internal support pillars, and make them an Infill Mesh via the Per-object settings. I suggest you also reduce the top/bottom thickness and Wall thickness of the infill mesh.</p></li>
<li><p>Enable Hollow Out Objects and enable support.</p></li>
<li><p>Enable gradual infill: increase the Gradual Infill Steps. Although this will still make infill everywhere it will drastically reduce the infill where it's less needed.</p></li>
</ol>
| 340
|
<p>In trying to understand 3D printers, I have watched some YouTube videos where the crafters make items with hinges. That in itself blows my mind. It is hard to grasp how something with moving parts can be printed. But specifically I am wondering if the concept can be extended to food printers to make, for example, a sugar or chocolate telescoping lollipop (sucker)?</p>
|
<p>No, M108 does not do that. You are looking for <strong>T#</strong>, where # is the tool position you want:</p>
<pre><code>T1 ; switch to tool position 1
T3 ; switch to tool position 3
</code></pre>
<p>This tells the processor to send all heating, cooling and flow commands to this tool until another tool change is specified, and invokes the X/Y(/Z) offset for the new tool position.</p>
<p>See <a href="http://reprap.org/wiki/G-code#T:_Select_Tool" rel="nofollow noreferrer">http://reprap.org/wiki/G-code#T:_Select_Tool</a></p>
|
<p>As @tbm0115 has mentioned - it differs. Your <code>M108 T{index of tool}</code> command is perfectly fine on some FlashForge printers, a company known for its different sorts of proprietary code. It is indeed used for tool changing here.</p>
<p>While on the common Marlin firmware (e.g. used on the popular Creality Ender printers), <code>M108</code> does a completely different thing-namely acting as a break sequence if the G-code parser is in a closed-loop-condition (after certain commands like <code>M109</code> that wait until a certain action takes place).</p>
| 539
|
<p>Currently my workflow with Emacs when I am coding in C or C++ involves three windows. The largest on the right contains the file I am working with. The left is split into two, the bottom being a shell which I use to type in compile or make commands, and the top is often some sort of documentation or README file that I want to consult while I am working. Now I know there are some pretty expert Emacs users out there, and I am curious what other Emacs functionally is useful if the intention is to use it as a complete IDE. Specifically, most IDEs usually fulfill these functions is some form or another:</p>
<ul>
<li>Source code editor</li>
<li>Compiler</li>
<li>Debugging</li>
<li>Documentation Lookup</li>
<li>Version Control</li>
<li>OO features like class lookup and object inspector </li>
</ul>
<p>For a few of these, it's pretty obvious how Emacs can fit these functions, but what about the rest? Also, if a specific language must be focused on, I'd say it should be C++. </p>
<p><strong>Edit:</strong> One user pointed out that I should have been more specific when I said 'what about the rest'. Mostly I was curious about efficient version control, as well as documentation lookup. For example, in SLIME it is fairly easy to do a quick hyperspec lookup on a Lisp function. Is there a quick way to look up something in C++ STL documentation (if I forgot the exact syntax of <a href="http://www.sgi.com/tech/stl/hash_map.html" rel="noreferrer">hash_map</a>, for example)?</p>
|
<p>You'll have to be specific as to what you mean by "the rest". Except for the object inspector (that I"m aware of), emacs does all the above quite easily:</p>
<ul>
<li>editor (obvious)</li>
<li>compiler - just run <code>M-x compile</code> and enter your compile command. From there on, you can just <code>M-x compile</code> and use the default. Emacs will capture C/C++ compiler errors (works best with GCC) and help you navigate to lines with warnings or errors.</li>
<li>Debugging - similarly, when you want to debug, type <code>M-x gdb</code> and it will create a gdb buffer with special bindings</li>
<li>Documentation Lookup - emacs has excellent CScope bindings for code navigation. For other documentation: Emacs also has a manpage reader, and for everything else, there's the web and books.</li>
<li>version control - there are lots of Emacs bindings for various VCS backends (CVS, SCCS, RCS, SVN, GIT all come to mind)</li>
</ul>
<p>Edit: I realize my answer about documentation lookup really pertained to code navigation. Here's some more to-the-point info: </p>
<ul>
<li><a href="http://www.delorie.com/gnu/docs/emacs/emacs_289.html" rel="noreferrer">Looking up manpages, info manuals, and Elisp documentation from within emacs</a></li>
<li><a href="https://bitbucket.org/jonwaltman/pydoc-info" rel="noreferrer">Looking up Python documentation from within Emacs</a>. </li>
</ul>
<p>Google searching will no doubt reveal further examples.</p>
<p>As the second link shows, looking up functions (and whatever) in other documentation can be done, even if not supported out of the box.</p>
|
<p>In the Unix or X windows style, I don't know that there is an integrated IDE that works for everything. </p>
<p>For interacting with debuggers, just one component of an IDE, consider <a href="https://github.com/realgud" rel="nofollow noreferrer">realgud</a>. The other thing it has that I find useful are parsers for location messages, so that if you have a call stack trace and want to edit at a particular place in the callstack, this front-end interface will can do that. </p>
<p>By far this program could use improvement. But then it could also use people working on it to improve it. </p>
<p>Disclaimer: I work on realgud</p>
| 8,889
|
<p>I'm looking for a GPS with a good API. I would like to be able to send an address to it, and tell it to navigate to that address. I also need to pull the current location from the GPS. I'd like to be able to do this with the GPS hooked up to a laptop by bluetooth or even just a USB cable.</p>
<p>I've looked at the Dash a little, but the monthly subscription is a downside. Also, I would like to keep the location and addresses on our private network.</p>
<p>I'm a .NET programmer, so a .NET friendly API is best for me.</p>
<p>Bonus points if you can show me some examples of using an API to push and pull data to and from the GPS. </p>
|
<p>If you want to talk to a Garmin GPS, you can check out their <a href="http://developer.garmin.com" rel="nofollow noreferrer">developer website</a>. They've got resources ranging from talking to Web Services all the way to doing low-level Serial & USB I/O to interface directly with the devices.</p>
|
<p>I presume that by GPS you mean Satellite Navigation? Most GPS units don't offer the turn-by-turn capability required to navigate effectively on roads, or the underlying road map data for that matter.</p>
<p><strong><em>updated:</em></strong> OK, since Garmin are by far the biggest dog in the yard, I'd recommend taking a look at Garmin's <a href="http://developer.garmin.com/lbs/lbs-toolkit/" rel="nofollow noreferrer">Location Based Services Toolkit</a>, <a href="http://developer.garmin.com/lbs/fleet-management/" rel="nofollow noreferrer">Fleet Management Toolkit</a> and their <a href="http://developer.garmin.com/web-device/garmin-communicator-plugin/" rel="nofollow noreferrer">Communicator API</a> (specifically the <a href="http://developer.garmin.com/web-device/garmin-communicator-plugin/devicecontrol/" rel="nofollow noreferrer">DeviceControl</a> module).</p>
| 3,133
|
<p>I have a winforms application where users will be creating stock items, and a time of creation there are a number of different things that need to happen.</p>
<p>I think the UI for this should probably be a wizard of some kind, but I'm unsure as to the best way to achieve this. I have seen a couple of 3rd party Wizard controls, and I have also seen manual implementations of making panel visible/invisible.</p>
<p>What are the best ways that people have used in the past, that are easy to implement, and also make it easy to add "pages" to the wizard later on if needed?</p>
|
<p>Here are a few more resources you should check out:</p>
<ol>
<li><p>This DevExpress WinForms control: <a href="http://www.devexpress.com/Products/NET/Controls/WinForms/Wizard/" rel="nofollow noreferrer">http://www.devexpress.com/Products/NET/Controls/WinForms/Wizard/</a></p></li>
<li><p>A home-grown wizards framework: <a href="http://weblogs.asp.net/justin_rogers/articles/60155.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/justin_rogers/articles/60155.aspx</a></p></li>
<li><p>A wizard framework by Shawn Wildermut part of the Chris Sells's Genghis framework: <a href="http://www.sellsbrothers.com/tools/genghis/" rel="nofollow noreferrer">http://www.sellsbrothers.com/tools/genghis/</a></p></li>
</ol>
|
<p>The easiest way to create a wizard dialog is to use one of the third-party versions available that handle all of the "hard stuff" (the page navigation, UI framework, etc.) for you. The one I like the most is from <a href="http://www.divelements.co.uk/net/" rel="nofollow noreferrer">Divelements</a>; they have both a WinForms and a WPF version.</p>
| 5,966
|
<p>I'd like to execute JavaScript code from within a C# assembly and have the results of the JavaScript code returned to the calling C# code.</p>
<p>It's easier to define things that I'm not trying to do:</p>
<ul>
<li><p>I'm not trying to call a JavaScript function on a web page from my code behind.</p></li>
<li><p>I'm not trying to load a WebBrowser control.</p></li>
<li><p>I don't want to have the JavaScript perform an AJAX call to a server.</p></li>
</ul>
<p>What I want to do is write unit tests in JavaScript and have then unit tests output JSON, even plain text would be fine. Then I want to have a generic C# class/executible that can load the file containing the JS, run the JS unit tests, scrap/load the results, and return a pass/fail with details during a post-build task.</p>
<p>I think it's possible using the old ActiveX ScriptControl, but it seems like there ought to be a .NET way to do this without using SilverLight, the DLR, or anything else that hasn't shipped yet. Anyone have any ideas?</p>
<p>update: <a href="http://blogs.msdn.com/brada/articles/239857.aspx" rel="nofollow noreferrer">From Brad Abrams blog</a></p>
<pre><code>namespace Microsoft.JScript.Vsa
{
[Obsolete("There is no replacement for this feature. " +
"Please see the ICodeCompiler documentation for additional help. " +
"http://go.microsoft.com/fwlink/?linkid=14202")]
</code></pre>
<p>Clarification:
We have unit tests for our JavaScript functions that are written in JavaScript using the JSUnit framework. Right now during our build process, we have to manually load a web page and click a button to ensure that all of the JavaScript unit tests pass. I'd like to be able to execute the tests during the post-build process when our automated C# unit tests are run and report the success/failure alongside of out C# unit tests and use them as an indicator as to whether or not the build is broken.</p>
|
<p>The code should be pretty self explanitory, so I'll just post that.</p>
<pre><code><add assembly="Microsoft.Vsa, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</code></pre>
<hr>
<pre><code>using Microsoft.JScript;
public class MyClass {
public static Microsoft.JScript.Vsa.VsaEngine Engine = Microsoft.JScript.Vsa.VsaEngine.CreateEngine();
public static object EvaluateScript(string script)
{
object Result = null;
try
{
Result = Microsoft.JScript.Eval.JScriptEvaluate(JScript, Engine);
}
catch (Exception ex)
{
return ex.Message;
}
return Result;
}
public void MyMethod() {
string myscript = ...;
object myresult = EvaluateScript(myscript);
}
}
</code></pre>
|
<p>Could it be simpler to use <a href="https://github.com/pivotal/jsunit" rel="nofollow noreferrer">JSUnit</a> to write your tests, and then use a <a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a>
test wrapper to run them through C#, passing or failing based on the JSUnit results?</p>
<p>It is indeed an extra step though.</p>
<p>I believe I read somewhere that an upcoming version of either MBUnit or WatiN will have the functionality built in to process JSUnit test fixtures. If only I could remember where I read that...</p>
| 9,329
|
<p>Sorry, I'm new in 3D printing and modeling and I need help.</p>
<p>I bought a 3D model with a hollow part of the body that doesn't print on my printer normally (with very high resolution (layer is 0.12 mm, the nozzle is 0.4 mm) because the walls are very thin). I tried to make it as a solid in MeshMixer or ZBrush, but I can't. Can you help me, how I can fix this defect?</p>
<p>I use Cura for slicing.</p>
<p>I know, that I can take a thinner nozzle (0.2 mm) and Cura will slice it better, but I want to make this model solid so I could print it with nozzle 0.4 mm.</p>
<p><a href="https://i.stack.imgur.com/QqOdU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QqOdU.png" alt="Hollow part of body" /></a></p>
<p><a href="https://i.stack.imgur.com/VZNwk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VZNwk.jpg" alt="How Cura have sliced that" /></a></p>
|
<p>The model clearly contains an enclosed surface, which is directed to the inside - in other words, it was modeled to contain a volume of air.</p>
<p>Those surfaces need to be removed to print the body solid. To do this, you could check if those surfaces constitute a separate shell for meshmixer. If yes, you can just go, run separate shells, remove those internal items, and then re-merge all other shells. Slicing that should result in the voids being filled.</p>
<p>If however the shell is meant to exist, then it should instead simply get its normals inverted. This is best done with modeling software such as blender. Some steps you need can be seen <a href="https://3dprinting.stackexchange.com/a/15881/8884">here</a></p>
|
<p>This is a problem with the model, you need to make sure that the model isn't hollow. You might be able to get around this though if you use scaffolding, it might recognize the overhand hand build supports for your print inside of your print, you just might have to mess around with the scaffolding settings a bit.</p>
| 1,938
|
<p>This seems to be an overlooked area that could really use some insight. What are your best practices for:</p>
<ul>
<li>making an upgrade procedure</li>
<li>backing out in case of errors</li>
<li>syncing code and database changes</li>
<li>testing prior to deployment</li>
<li>mechanics of modifying the table</li>
</ul>
<p>etc...</p>
|
<p>That's a great question. ( There is a high chance this is going to end up a normalised versus denormalised database debate..which I am not going to start... okay now for some input.)</p>
<p>some off the top of my head things I have done (will add more when I have some more time or need a break)</p>
<p>client design - this is where the VB method of inline sql (even with prepared statements) gets you into trouble. You can spend AGES just finding those statements. If you use something like Hibernate and put as much SQL into named queries you have a single place for most of the sql (nothing worse than trying to test sql that is inside of some IF statement and you just don't hit the "trigger" criteria in your testing for that IF statement). Prior to using hibernate (or other orms') when I would do SQL directly in JDBC or ODBC I would put all the sql statements as either public fields of an object (with a naming convention) or in a property file (also with a naming convention for the values say PREP_STMT_xxxx. And use either reflection or iterate over the values at startup in a) test cases b) startup of the application (some rdbms allow you to pre-compile with prepared statements before execution, so on startup post login I would pre-compile the prep-stmts at startup to make the application self testing. Even for 100's of statements on a good rdbms thats only a few seconds. and only once. And it has saved my butt a lot. On one project the DBA's wouldn't communicate (a different team, in a different country) and the schema seemed to change NIGHTLY, for no reason. And each morning we got a list of exactly where it broke the application, on startup.</p>
<p>If you need adhoc functionality , put it in a well named class (ie. again a naming convention helps with auto mated testing) that acts as some sort of factory for you query (ie. it builds the query). You are going to have to write the equivalent code anyway right, just put in a place you can test it. You can even write some basic test methods on the same object or in a separate class.</p>
<p>If you can , also try to use stored procedures. They are a bit harder to test as above. Some db's also don't pre-validate the sql in stored procs against the schema at compile time only at run time. It usually involves say taking a copy of the schema structure (no data) and then creating all stored procs against this copy (in case the db team making the changes DIDn't validate correctly). Thus the structure can be checked. but as a point of change management stored procs are great. On change all get it. Especially when the db changes are a result of business process changes. And all languages (java, vb, etc get the change )</p>
<p>I usually also setup a table I use called system_setting etc. In this table we keep a VERSION identifier. This is so that client libraries can connection and validate if they are valid for this version of the schema. Depending on the changes to your schema, you don't want to allow clients to connect if they can corrupt your schema (ie. you don't have a lot of referential rules in the db, but on the client). It depends if you are also going to have multiple client versions (which does happen in NON - web apps, ie. they are running the wrong binary). You could also have batch tools etc. Another approach which I have also done is define a set of schema to operation versions in some sort of property file or again in a system_info table. This table is loaded on login, and then used by each "manager" (I usually have some sort of client side api to do most db stuff) to validate for that operation if it is the right version. Thus most operations can succeed, but you can also fail (throw some exception) on out of date methods and tells you WHY.</p>
<p>managing the change to schema -> do you update the table or add 1-1 relationships to new tables ? I have seen a lot of shops which always access data via a view for this reason. This allows table names to change , columns etc. I have played with the idea of actually treating views like interfaces in COM. ie. you add a new VIEW for new functionality / versions. Often, what gets you here is that you can have a lot of reports (especially end user custom reports) that assume table formats. The views allow you to deploy a new table format but support existing client apps (remember all those pesky adhoc reports).</p>
<p>Also, need to write update and rollback scripts. and again TEST, TEST, TEST...</p>
<p>------------ OKAY - THIS IS A BIT RANDOM DISCUSSION TIME --------------</p>
<p>Actually had a large commercial project (ie. software shop) where we had the same problem. The architecture was a 2 tier and they were using a product a bit like PHP but pre-php. Same thing. different name. anyway i came in in version 2....</p>
<p>It was costing A LOT OF MONEY to do upgrades. A lot. ie. give away weeks of free consulting time on site. </p>
<p>And it was getting to the point of wanting to either add new features or optimize the code. Some of the existing code used stored procedures , so we had common points where we could manage code. but other areas were this embedded sql markup in html. Which was great for getting to market quickly but with each interaction of new features the cost at least doubled to test and maintain. So when we were looking at pulling out the php type code out, putting in data layers (this was 2001-2002, pre any ORM's etc) and adding a lot of new features (customer feedback) looked at this issue of how to engineer UPGRADES into the system. Which is a big deal, as upgrades cost a lot of money to do correctly. Now, most patterns and all the other stuff people discuss with a degree of energy deals with OO code that is running, but what about the fact that your data has to a) integrate to this logic, b) the meaning and also the structure of the data can change over time, and often due to the way data works you end up with a lot of sub process / applications in your clients organisation that needs that data -> ad hoc reporting or any complex custom reporting, as well as batch jobs that have been done for custom data feeds etc.</p>
<p>With this in mind i started playing with something a bit left of field. It also has a few assumptions. a) data is heavily read more than write. b) updates do happen, but not at bank levels ie. one or 2 a second say.</p>
<p>The idea was to apply a COM / Interface view to how data was accessed by clients over a set of CONCRETE tables (which varied with schema changes). You could create a seperate view for each type operation - update, delete, insert and read. This is important. The views would either map directly to a table , or allow you to trigger of a dummy table that does the real updates or inserts etc. What i actually wanted was some sort of trappable level indirection that could still be used by crystal reports etc. NOTE - For inserts , update and deletes you could also use stored procs. And you had a version for each version of the product. That way your version 1.0 had its version of the schema, and if the tables changed, you would still have the version 1.0 VIEWS but with NEW backend logic to map to the new tables as needed, but you also had version 2.0 views that would support new fields etc. This was really just to support ad hoc reporting, which if your a BUSINESS person and not a coder is probably the whole point of why you have the product. (your product can be crap but if you have the best reporting in the world you can still win, the reverse is true - your product can be the best feature wise, but if its the worse on reporting you can very easily loose).</p>
<p>okay, hope some of those ideas help.</p>
|
<p>As Pat said, use liquibase. Especially when you have several developers with their own dev databases
making changes that will become part of the production database.</p>
<p>If there's only one dev, as on one project I'm on now(ha), I just commit the schema changes as SQL text files into a CVS repo, which I check out in batches on the production server when the code changes go in.</p>
<p>But liquibase is better organized than that!</p>
| 4,950
|
<p>I'm looking for a library/method to parse an html file with more html specific features than generic xml parsing libraries.</p>
|
<p><a href="https://html-agility-pack.net" rel="nofollow noreferrer">Html Agility Pack</a></p>
<blockquote>
<p>This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).</p>
</blockquote>
|
<p>You could use a HTML DTD, and the generic XML parsing libraries.</p>
| 8,000
|
<p>I try to print a stamp with flexible filaments. The problem I encounter is that the filament is flexible, but not soft. This leads to small differences in height to parts of the stamp not working.</p>
<p>One solution would be to add a small 'cushion' to add some squishyness to the stamp. I designed the stamp and the 'cushion' but now the question arises:
"Which infill will provide the best uniform squishyness (in one axis)?"</p>
<p>I did a test with cubic infill of Cura, and although it becomes quite squishy, some parts are squishier than other parts of the block.</p>
<p>TLDR; Trying to print a squishy cube, where in one axis all areas of the cube have the same squishyness.</p>
|
<p>As the rubber stamp needs to be soft in one axis for the whole area, you could use an infill that causes the same softness in all directions, but is sliced as such that the stamp experiences the same softness. Alternatively you can use the specific infill types for flexibility, but beware of the orientation:</p>
<ul>
<li>Concentric</li>
<li>Cross</li>
<li>Cross 3D </li>
</ul>
<p><strong>First</strong>, to get the same softness in each direction you need to use an infill pattern that has similar/uniform properties (<a href="https://en.wikipedia.org/wiki/Isotropy" rel="nofollow noreferrer">isotropic</a>) in all dimensions. </p>
<p>It is suggested to look into the infill type called "<em>gyroid</em>" (see question <a href="/q/7037/">What are the advantages of gyroid infill?</a>). </p>
<p><a href="https://ultimaker.com/en/products/52762-ultimaker-cura-36" rel="nofollow noreferrer">This type of infill</a> is described as:</p>
<blockquote>
<p>Gyroid infill is one of the strongest infill types for a given weight, has isotropic properties, and prints relatively fast with reduced material use and a fully connected part interior. </p>
</blockquote>
<p><strong>Second</strong>, since the stamp has relief, slicing the part may cause different infill height. You could look into <a href="/q/6522/">Different infill in the same part</a> to e.g. get a solid infill for under the relief to get a uniform infill for the "cushion".</p>
|
<p>Sinusoidal infill provides great squishiness in the infill direction, but you'll still have the problem that where the infill meets the perimeter wall, it'll be less squishy than where the perimeter wall isn't touching any infill. You can reduce this effect by using a stiffer filament for that wall (if you can print with multiple filaments), by adding more perimeters, and by reducing the gap between infills (i.e. increasing the infill density). You can even explicitly design an extra-thick wall on the face that takes the pressure (the engraved face of the stamp), and then a section behind that with the squishy infill.</p>
<p>TBH, I'm not sure that flexible filament is really what you need for a stamp. Soft materials are commonly used for traditional stamp-making more because they're easy to etch than because the stamping works better that way. Print-making uses wooden or metal plates (the equivalent to the stamp) and produces better, more repeatable images than rubber stamps. When you're printing a stamp, you don't need to etch it, so the softness of rubber isn't an advantage for you. My outsider recommendation would be to try using a normal, rigid filament, and sand the surface to the smoothness you need. If you print with the stamp face on the bed, and your first-layer quality is really good on a smooth build plate, you can probably get better results without sanding.</p>
| 1,303
|
<p>Having been a PHP developer on LAMP servers for quite a while, is there anything that I will need to take into consideration while preparing an application for <em>IIS</em> on windows.</p>
|
<p>Make sure you get the FastCGI extension for IIS 6.0 or IIS 7.0. It is the single most important thing you can have when running PHP under IIS. Also this article should get you setup:</p>
<p><a href="http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/" rel="noreferrer">http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/</a></p>
<p>Everything beyond this is simple, MySQL and what not.</p>
|
<p>One of the major sticking points I've had with IIS is the lack of Apache's mod_rewrite. There are other work-arounds and work-alikes depending on what you're doing, but just keep in mind that you'll need to change things up a bit to work with IIS if you're using mod rewrite extensively.</p>
| 3,171
|
<p>In Python one can get a dictionary of all local and global variables in the current scope with the built-in functions <code>locals()</code> and <code>globals()</code>. Is there some equivalent way of doing this in Javascript? For instance, I would like to do something like the following:</p>
<pre><code>var foo = function(){ alert('foo'); };
var bar = function(){ alert('bar'); };
var s = 'foo';
locals()[s](); // alerts 'foo'
</code></pre>
<p>Is this at all possible, or should I just be using a local object for the lookup?</p>
|
<ul>
<li><p>locals() - No. </p></li>
<li><p>globals() - Yes.</p></li>
</ul>
<p><code>window</code> is a reference to the global scope, like <code>globals()</code> in python.</p>
<pre><code>globals()["foo"]
</code></pre>
<p>is the same as:</p>
<pre><code>window["foo"]
</code></pre>
|
<p>AFAIK, no. If you just want to check the existence of a given variable, you can do it by testing for it, something like this:</p>
<pre><code>if (foo) foo();
</code></pre>
| 6,115
|
<p>I have just received a 3D printer for Christmas (Robo R2). I am confused by the sheer amount of settings that I can tweak and I'm hesitant to do so until I know more about them. I was wondering if anybody has any recommendations for literature on:</p>
<ul>
<li>3D printing in general (geared towards beginners);</li>
<li>Designing parts specifically.</li>
</ul>
<p>Books are preferred but websites are acceptable as well.</p>
|
<p>Welcome to the fantastic, sometimes frustrating but most often glorious world of 3D printing David! :)</p>
<p>Your question is really very very broad, but here's my contribution to make your first steps a success. First of all: I don't have experience with the Robo R2, but judging from the specs available online, I would say that you got a machine that take care of most of the troubles beginners encounter when starting out (e.g.: levelling the bed) and has a few features that allow you to print more reliably/with better quality (heated bed, enclosure, possibility for a second extruder).</p>
<p>Give a hug to whoever made the gift to you! ;)</p>
<p>I like to think to 3D printing as a process that involves 4 phases (well, normally several iteration of them as <em>prototyping</em> is a thing):</p>
<ul>
<li>Designing (creating the mesh, i.e. the shape of the object you want to print)</li>
<li>Slicing (creating GCODE, i.e. the file with the step-by-step instructions for moving your printer nozzle in space, extruding the plastic, controlling temperatures and cooling, etc...)</li>
<li>Printing (the actual process of having your printer running that GCODE)</li>
<li>Post-processing (finishing the piece, by for example removing support material, sanding, vapor-smoothing the surface, painting, etc...)</li>
</ul>
<p>Technology in the 3D printing world is moving so fast that printed information tends to get outdated quickly, and the Internet is often the best source of information. So in the following bits I will mention the the source of information that I use[d] for myself, of which many are online rather than in print.</p>
<p><strong>DESIGN</strong></p>
<p>Broadly speaking, there are two kind of designs one can do: <strong>decorative</strong> or <strong>functional</strong>. Decorative designs are those in which the final object will essentially sit still on a shelf or be handled very gently (e.g.: a model of the Tour Eiffel, a miniature for RPG gaming), functional designs are those in which the final part will have to bear a load or perform some sort of mechanical work (e.g.: a drone, a shelf bracket, a pipe adapter...).</p>
<p>Both designs need to take into consideration the physical limitations of FDM printers such as the fact that the nozzle is round and with a fixed diameter, or the fact that molten plastic needs to rest onto something, thus the need for support.</p>
<p>Additionally, functional design requires an understanding of the physical properties of 3D MFD printed parts (hint: they are anisotropic, so their properties differs along their axis). If you are interested in functional designing a book that I can highly recommend is <a href="https://www.amazon.co.uk/Functional-Design-3D-Printing-Designing/dp/0692883215/" rel="noreferrer">Functional Design for 3D Printing by Cliff Smyth</a>. It is concise, accessible and full of information you'll be using from your very first design.</p>
<p>In terms of tools, for decorative, organic forms, you will probably want to use a program like <a href="https://www.blender.org/" rel="noreferrer">Blender</a>, that manipulate meshes directly, while for functional designs will probably turn to CAD software, like for examaple <a href="https://www.freecadweb.org/" rel="noreferrer">FreeCAD</a> that operate on a "model" and let you export the finished part as a mesh at the very end.</p>
<p>Both Blender and FreeCAD are free software (like in: "free speech") but commercial versions do exist as well (most notably from Autodesk).</p>
<p>Blender is professional grade software with a very steep learning curve and I would suggest to take an structured online course like <a href="https://www.udemy.com/blendertutorial/learn/v4/overview" rel="noreferrer">this one</a> about it, rather than trying to learn it the DIY way.</p>
<p>FreeCAD belongs to a category of CAD programmes that operate on a well defined, well understood, set of principles (so it works similarly to OnShape and Fusion360 for example) and it is much easier to learn. In my experience CAD modelling is best learnt by understanding the very basic, and then just researching further information as you go, according to the needs of your project as CAD design is full of small specific operations that is useful to know only if you actually need them (e.g.: how to draw a screw thread, or to perform a loft). I started out with <a href="https://www.youtube.com/watch?v=_HEvhclR4-o&list=PL6fZ68Cq3L8k0JhxnIVjZQN26cn9idJrj" rel="noreferrer">this series of video tutorials</a> by the late Roland Frank (a celebrated contributor to the FreeCAD community), but there are tons of other tutorial should you choose to go with a commercial product.</p>
<p><strong>SLICING</strong></p>
<p>Slicing is as much an art as it is science. While the actual work of generating the GCODE is automated and requires just the click of a button, there are a myriad of settings that are mutually interdependent in their effect. For example: filament temperature, movement speed, cooling fan, retraction and coasting all affect oozing, but each of them also affect other things (bridging, layer adhesion, curling, nominal overextrusion, etc...).</p>
<p>Also: settings differs for each filament material, each brand, and sometimes even different spools from the same material/brand. Moreover, you may wish to tune them depending to what you are printing (maybe you are printing a finely detailed miniature and want to go slower to reduce vibration, or maybe you are printing a torsion bar and want to increase the temperature for increasing layer adhesion, for example...).</p>
<p>IMO the best way to understand how settings affect your print is playing around with calibration towers (<a href="https://www.thingiverse.com/thing:1956512" rel="noreferrer">example</a>) and torture tests (<a href="https://www.thingiverse.com/thing:1363023" rel="noreferrer">example</a>).</p>
<p>Calibration towers work by printing the same thing on top of each other but changing at each repetition a specific setting (like filament temperature, or extrusion multiplier). You will then visually inspect the final piece and evaluate how the print quality changed relative to that parameter.</p>
<p>Torture tests work by putting in the same piece a number of features that are hard for the printer to print correctly (thin walls, bridges, overhangs, to name a few).</p>
<p>A specific model that is sort of gold standard as a basic test is the <a href="http://www.3dbenchy.com/" rel="noreferrer">3D benchy</a>. The good thing about it is that it comes with a full website that also tell you how you can evaluate the print. However, the benchy - differently than torture tests - is not designed to let you discover the limits of your printer, it is more of a quality-control test. If you can print a 3D benchy, you should be good to go for printing "regular" objects.</p>
<p>Also, at least in the two most common free-as-in-freedom slicers (<a href="https://ultimaker.com/en/products/ultimaker-cura-software" rel="noreferrer">Cura</a> and <a href="https://github.com/prusa3d/Slic3r/releases" rel="noreferrer">slic3r Prusa Edition</a>) each setting comes with some explanatory text while hovering on it, that helps a lot understanding what that setting does).</p>
<p><strong>PRINTING</strong></p>
<p>How much you can affect the actual printing process depends from how "open source" is your printer, and if it uses standard components or not. Consumer-grade printers get often upgraded/modded to improve print quality or tweak them for a specific job/material. Typical upgrades are extruder upgrades, stepper motor upgrades, vibration dampeners, different sensors, etc...</p>
<p>Each printer is unique, but normally you can find abundant information wherever the community of owners of a specific model gathers.</p>
<p>I would also advise to subscribe to some good youtube channel about 3D printing like <a href="https://www.youtube.com/user/ThomasSanladerer" rel="noreferrer">Tom's</a> or <a href="https://www.youtube.com/user/TheMakersMuse" rel="noreferrer">Makers Muse</a> or <a href="https://www.youtube.com/channel/UC_7aK9PpYTqt08ERh1MewlQ" rel="noreferrer">Joel's</a>, and to visit sites like <a href="https://all3dp.com/" rel="noreferrer">All3dp</a> regularly. As I mentioned, 3D printing tech changes constantly, and it is good to keep tabs on new materials, new software, new components, etc...</p>
<p><strong>POST-PROCESSING</strong></p>
<p>This is entirely dependent from the material you used for the print, its size, and its intended use, but I wanted to mention this nonetheless as there are amazing things you can do with <a href="https://www.youtube.com/watch?v=Xj53P2YzYGM" rel="noreferrer">acetone on ABS</a>, lot of <a href="https://www.youtube.com/watch?v=0vgynnYzo08" rel="noreferrer">elbow grease on PLA</a> or the <a href="https://www.youtube.com/watch?v=oj1kgFHo3sU" rel="noreferrer">use of an airbrush</a>... so you know 3D printing does not end with the print! ;)</p>
<p>Hope this helps you at least a bit. Again: welcome to the the 3D printing world! :)</p>
|
<p>I have found that "Troubleshooting and Maintaining your 3d Printer" by Charles Bell has a good overview of:</p>
<ul>
<li><p>3d Printer Assembly and parts</p></li>
<li><p>3d Printer Calibration</p></li>
<li><p>3d Printer Software</p></li>
<li><p>Filament materials</p></li>
<li><p>3d Printer Maintenance (both preventative and corrective)</p></li>
<li><p>3d Hardware Troubleshooting</p></li>
<li><p>3d Print Troubleshooting</p></li>
</ul>
| 779
|
<p>I specifically want to add the style of <code>background-color</code> to the <code><body></code> tag of a master page, from the code behind (C#) of a content page that uses that master page. </p>
<p>I have different content pages that need to make the master page has different colors depending on which content page is loaded, so that the master page matches the content page's theme.</p>
<p>I have a solution below:</p>
<hr>
<p>I'm looking for something more like:</p>
<pre><code>Master.Attributes.Add("style", "background-color: 2e6095");
</code></pre>
<p>Inside of the page load function of the content page. But I can't get the above line to work. I only need to change the <code>background-color</code> for the <code><body></code> tag of the page.</p>
|
<p>What I would do for the particular case is:</p>
<p>i. Define the body as a server side control</p>
<pre><code><body runat="server" id="masterpageBody">
</code></pre>
<p>ii. In your content aspx page, register the MasterPage with the register:</p>
<pre><code><% MasterPageFile="..." %>
</code></pre>
<p>iii. In the Content Page, you can now simply use </p>
<pre><code>Master.FindControl("masterpageBody")
</code></pre>
<p>and have access to the control. Now, you can change whatever properties/style that you like!</p>
|
<p>I believe you are talking about a content management system. The way I have delt with this situation in the past is to either:</p>
<ol>
<li>Allow a page/content to define an extra custom stylesheet or</li>
<li>Allow a page/content to define inline style tags</li>
</ol>
| 2,438
|
<p>Where I work, the design and development departments are totally separated, however we (the design department) are responsible for managing the CSS for our sites. Typically, new CSS needs to be released to the production server far more often than new website code. Because of this, we are deploying the CSS separately, and it lives outside source control.</p>
<p>However, lately, we've run into a few problems with new CSS not being synched for up site releases, and in general the process is a huge headache. I've been pushing to get the CSS under some kind of source control, but having trouble finding a good deployment method that makes everyone happy. Our biggest problem is managing changes that affect current portions of the site, where the CSS changes need to go live before the site changes, but not break anything on the exisiting site.</p>
<p>I won't go into the finer details of the weird culture between designers and devs here, but I was wondering what experience others have had in managing large amounts of CSS (50+ files, thousands and thousands of lines) that needs to be constantly updated and released independent of site releases.</p>
|
<p>I'll advocate the use of source control here. Especially if the development team uses branching to deal with structured releases. That way, whatever CSS is checked into the production branch is what should be deployed ... and if it is updated mid-stream, it's the responsibility of the person (designer?) that updates it to promote that code using whatever system your company uses to promote changes to production.</p>
|
<p>The fancy name is "Content Delivery Network" <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network" rel="nofollow noreferrer">(Wikipedia)</a>.</p>
<p>We store our CSS files in a database, and then have a separate website that does nothing but serve CSS resources. We implemented this in May 2007 for 1000+ websites in 30+ countries. It has worked flawlessly for the last 15 months. </p>
<p>Static images and even JavaScript files are handled the same way.</p>
| 7,625
|
<p>I've been trying to understand how to read the memory of other processes on Mac OS X, but I'm not having much luck. I've seen many examples online using <code>ptrace</code> with <code>PEEKDATA</code> and such, however it doesn't have that option on BSD <sup>[<a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/ptrace.2.html" rel="noreferrer"><code>man ptrace</code></a>]</sup>.</p>
<pre><code>int pid = fork();
if (pid > 0) {
// mess around with child-process's memory
}
</code></pre>
<p>How is it possible to read from and write to the memory of another process on Mac OS X?</p>
|
<p>Matasano Chargen had a good post a while back on porting some debugging code to OS X, which included learning how to read and write memory in another process (among other things).</p>
<p><a href="http://replay.web.archive.org/20090627062246/http://www.matasano.com/log/1100/what-ive-been-doing-on-my-summer-vacation-or-it-has-to-work-otherwise-gdb-wouldnt/" rel="nofollow noreferrer">It has to work, otherwise GDB wouldn't</a>:</p>
<blockquote>
<p>It turns out Apple, in their infinite wisdom, had gutted <code>ptrace()</code>. The OS X man page lists the following request codes:</p>
<ul>
<li><code>PT_ATTACH</code> — to pick a process to debug</li>
<li><code>PT_DENY_ATTACH</code> — so processes can stop themselves from being debugged<br>
[...]</li>
</ul>
<p>No mention of reading or writing memory or registers. Which would have been discouraging if the man page had not also mentioned <code>PT_GETREGS</code>, <code>PT_SETREGS</code>, <code>PT_GETFPREGS</code>, and <code>PT_SETFPREGS</code> in the error codes section. So, I checked <code>ptrace.h</code>. There I found:</p>
<ul>
<li><code>PT_READ_I</code> — to read instruction words</li>
<li><code>PT_READ_D</code> — to read data words</li>
<li><code>PT_READ_U</code> — to read U area data if you’re old enough to remember what the U area is<br>
[...]</li>
</ul>
<p>There’s one problem solved. I can read and write memory for breakpoints. But I still can’t get access to registers, and I need to be able to mess with EIP.</p>
</blockquote>
|
<p>Manipulating a process's memory behind its back is a Bad Thing and is fraught with peril. That's why Mac OS X (like any Unix system) has protected memory, and keeps processes isolated from one another.</p>
<p>Of course it can be done: There are facilities for shared memory between processes that explicitly cooperate. There are also ways to manipulate other processes' address spaces as long as the process doing so has explicit right to do so (as granted by the security framework). But that's there for people who are writing debugging tools to use. It's not something that should be a normal — or even rare — occurrence for the vast majority of development on Mac OS X.</p>
| 3,188
|
<p>How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP?</p>
<p>This is somewhat easy in .NET if you know your way around. But how do you do it in Java?</p>
|
<p>Java doesn't make this as pleasant as other languages, unfortunately. Here's what I did:</p>
<pre><code>import java.io.*;
import java.util.*;
public class ExecTest {
public static void main(String[] args) throws IOException {
Process result = Runtime.getRuntime().exec("traceroute -m 1 www.amazon.com");
BufferedReader output = new BufferedReader(new InputStreamReader(result.getInputStream()));
String thisLine = output.readLine();
StringTokenizer st = new StringTokenizer(thisLine);
st.nextToken();
String gateway = st.nextToken();
System.out.printf("The gateway is %s\n", gateway);
}
}
</code></pre>
<p>This presumes that the gateway is the second token and not the third. If it is, you need to add an extra <code>st.nextToken();</code> to advance the tokenizer one more spot.</p>
|
<p>I'm not sure if it works on every system but at least here I found this:</p>
<pre><code>import java.net.InetAddress;
import java.net.UnknownHostException;
public class Main
{
public static void main(String[] args)
{
try
{
//Variables to find out the Default Gateway IP(s)
String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName();
String hostName = InetAddress.getLocalHost().getHostName();
//"subtract" the hostName from the canonicalHostName, +1 due to the "." in there
String defaultGatewayLeftover = canonicalHostName.substring(hostName.length() + 1);
//Info printouts
System.out.println("Info:\nCanonical Host Name: " + canonicalHostName + "\nHost Name: " + hostName + "\nDefault Gateway Leftover: " + defaultGatewayLeftover + "\n");
System.out.println("Default Gateway Addresses:\n" + printAddresses(InetAddress.getAllByName(defaultGatewayLeftover)));
} catch (UnknownHostException e)
{
e.printStackTrace();
}
}
//simple combined string out of the address array
private static String printAddresses(InetAddress[] allByName)
{
if (allByName.length == 0)
{
return "";
} else
{
String str = "";
int i = 0;
while (i < allByName.length - 1)
{
str += allByName[i] + "\n";
i++;
}
return str + allByName[i];
}
}
}
</code></pre>
<p>For me this produces:</p>
<pre><code>Info:
Canonical Host Name: PCK4D-PC.speedport.ip
Host Name: PCK4D-PC
Default Gateway Leftover: speedport.ip
Default Gateway Addresses:
speedport.ip/192.168.2.1
speedport.ip/fe80:0:0:0:0:0:0:1%12
</code></pre>
<p>I'd require more tests on other Systems/Configurations/PC-Gateway-Setups to confirm if it works everywhere. Kind of doubt it but this was the first I found.</p>
| 3,305
|
<p>This print failed a couple of hours in. I was wondering if the nature of the print surface, with lots of retracts (similarly the previous print which was OK) might have contributed to the clog, or if it's just bad luck? To be clear, the surface has lots of short dead-end, not just a wiggly perimeter.
<a href="https://i.stack.imgur.com/iymMN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iymMN.jpg" alt="enter image description here"></a>
The filament seemed to have stopped moving, and was cut through by the drive gear.</p>
<p>This was a genuine Titan Aero extruder, 0.4mm nozzle, 215C (on an Anet a8 printer)</p>
|
<p>Reading your question it's not clear to me if you are referring to <em>filament retraction</em> (which is a configurable setting) or <em>surface recesses</em> which seems what you are referring to when writing:</p>
<blockquote>
<p>the nature of the print surface, with lots of retracts</p>
</blockquote>
<p>If it is the latter, then the answer is "no". The amount of complexity of the surface of the model does not correlate <em>directly</em> to the possibility of the printer head clogging.</p>
<p>If it is the former, then the answer is "possibly". <strong>It is in fact not so much the amount of retracts that affects the likelihood of a clog but rather their speed and lenght</strong>. If you retract <em>too quickly</em> and <em>too much</em> filament, you risk to have molten plastic being "sucked" into the cold end, solidify, and act as a glue, blocking the filament in place.</p>
<p><strong>This is especially true for all-metal print heads</strong> like titan aero, as plastic sticks a lot better to metal than to PTFE.</p>
<p>However, <strong>with a <em>properly calibrated</em> retraction, you shouldn't experience problems</strong> regardless of how many times / how often you retract the filament.</p>
<p>In general, it is a common misconception that retraction should work as a plunger, actively sucking in plastic that would otherwise ooze out of the nozzle. However <strong>all you need is to just release the pressure within the melting chamber, and in a direct drive (i.e.: non-bowden) extruder, this requires a very minimal retraction</strong>.</p>
<p>Finally: what material are you printing in? The picture shows a lot of oozing for being PLA. If you are using a flexible material like nylon or ninjaflex, you should probably just let retraction alone: the hysteresis in such materials is very high, and retraction often does not work predictably. If it is PLA, I would try to increase the movement and retraction speed, and probably lower the temperature 10 or 15 degrees. As for the retraction lenght, I don't own a titan, but I would expect the correct amount to be somewhere between 0.5mm and 2mm.</p>
|
<p>In addition to the retraction distance, in the case of this model, I was seeing some places where there were a lot of very close retractions. I think these were increasing the risk of damaged filament, so I reduced the 'maximum retraction count' which at 50 over a 5mm length seemed fairly high.</p>
| 837
|
<p>I've read the book <a href="http://oreilly.com/catalog/9780596529321/" rel="noreferrer" title="Programming Collective Intelligence">Programming Collective Intelligence</a> and found it fascinating. I'd recently heard about a challenge amazon had posted to the world to come up with a better recommendation engine for their system.</p>
<p>The winner apparently produced the best algorithm by limiting the amount of information that was being fed to it.</p>
<p>As a first rule of thumb I guess... "<strong>More information is not necessarily better when it comes to fuzzy algorithms."</strong></p>
<p>I know's it's subjective, but ultimately it's a measurable thing (clicks in response to recommendations).</p>
<p>Since most of us are dealing with the web these days and search can be considered a form of recommendation... I suspect I'm not the only one who'd appreciate other peoples ideas on this. </p>
<p>In a nutshell, <strong>"What is the best way to build a recommendation ?"</strong></p>
|
<p>You don't want to use "overall popularity" unless you have no information about the user. Instead, you want to align this user with similar users and weight accordingly.</p>
<p>This is exactly what <a href="http://en.wikipedia.org/wiki/Bayesian_inference" rel="noreferrer">Bayesian Inference</a> does. In English, it means adjusting the overall probability you'll like something (the average rating) with ratings from other people <em>who generally vote your way as well</em>.</p>
<p>Another piece of advice, but this time ad hoc: I find that there are people where if they like something I will almost assuredly <em>not</em> like it. I don't know if this effect is real or imagined, but it might be fun to build in a kind of "negative effect" instead of just clumping people by similarity.</p>
<p>Finally there's a company specializing in exactly this called <a href="http://sensearray.com/" rel="noreferrer">SenseArray</a>. The owner (<a href="http://en.wikipedia.org/wiki/Ian_Clarke_(computer_scientist)" rel="noreferrer">Ian Clarke</a> of <a href="http://freenetproject.org/" rel="noreferrer">freenet fame</a>) is very approachable. You can use my name if you call him up.</p>
|
<p>@Lao Tzu, I agree with you.</p>
<p>According to me, recommendation engines are made up of: </p>
<blockquote>
<ul>
<li>Context Input fed from context aware systems (logging all your data)</li>
<li>Logical reasoning to filter the most obvious</li>
<li>Expert systems that improve your subjective data over the period of time based on context inputs, and </li>
<li>Probabilistic reasoning to do decision-making close-to-proximity based on weighted sum of previous actions(beliefs, desires, & intentions).</li>
</ul>
</blockquote>
<p>P.S.
I made such recommendation engine.</p>
| 7,778
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.