instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<h2>Summary</h2>
<p>Hi All,<br />
OK, further into my adventures with custom controls...</p>
<p>In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong!</p>
<ol>
<li><strong>UserControls</strong> - Which inherit from <em>UserControl</em> and are contained within an <em>ASCX</em> file. These are pretty limited in what they can do, but are a quick and light way to get some UI commonality with designer support.</li>
<li><strong>Custom Composite Controls</strong> - These are controls that inherit from <em>WebControl</em> where you add pre-existing controls to the control within the <em>CreateChildControls</em> method. This provides great flexibility, but lack of designer support without additional coding. They are highly portable though since they can be compiled into a DLL.</li>
<li><strong>Custom Rendered Controls</strong> - Similar to Custom Composite Controls, these are added to a Web Control Library project. The rendering of the control is completely controlled by the programmer by overriding the <em>Render</em> method.</li>
</ol>
<h2>My Thoughts..</h2>
<p>OK, so while playing with custom composites, I found the following:</p>
<ul>
<li>You have little/no control over the HTML output making it difficult to "debug".</li>
<li>The <em>CreateChildControls</em> (and subsequent methods) can get real busy with <em>Controls.Add(myControl)</em> everywhere.</li>
<li>I found rendering tables (be it for layout or content) to be considerably awkward.</li>
</ul>
<h2>The Question(s)..</h2>
<p>So, I admit, I am new to this so I could be way off-base with some of my points noted above..</p>
<ul>
<li>Do you use Composites?</li>
<li>Do you have any neat tricks to control the HTML output?</li>
<li>Do you just say "to hell with it" and go ahead and create a custom rendered control?</li>
</ul>
<p><strong>Its something I am keen to get really firm in my mind since I know how much <em>good</em> control development can cut overall development time.</strong></p>
<p>I look forward to your answers ^_^</p>
|
<p>I say go ahead with the custom rendered control. I find that in most cases the composite can be easier done and used in a UserControl, but anything beyond that and you'd need to have a finer degree of control (pun unintended) to merit your own rendering strategy.</p>
<p>There maybe controls that are simple enough to merit a composite (e.g., a textbox combined with a javascript/dhtml based datepicker, for example) but beyond that one example, it looks like custom rendered controls are the way to go.</p>
|
<p>You might be able to make use of this technique to make design-time easier:</p>
<p><a href="http://aspadvice.com/blogs/ssmith/archive/2007/10/19/Render-User-Control-as-String-Template.aspx" rel="nofollow noreferrer">http://aspadvice.com/blogs/ssmith/archive/2007/10/19/Render-User-Control-as-String-Template.aspx</a></p>
<p>Basically you create an instance of a user control at runtime using the LoadControl method, then hand it a statebag of some kind, then attach it to the control tree. So your composite control would actually function like more of a controller, and the .ascx file would be like a view.</p>
<p>This would save you the trouble of having to instantiate the entire control tree and style the control in C#!</p>
| 3,815
|
<p>When you add a raft in Slic3r, the first layer of the raft prints at the first layer speed. After the raft is finished, the first layer of the print prints at the standard speed. How can I make the first layer of the actual print slow down to the first layer speed?</p>
|
<p>This is still work in progress, and here is what I have so far, but first:</p>
<p><strong>A useful alternative for similar problems:</strong></p>
<p>A problem very similar to this would be to use different settings for different parts of a model in Slic3r. For most settings, this can be achieved through <a href="http://slic3r.org/blog/modifier-meshes" rel="nofollow">modifier meshes</a>.</p>
<h1>Post processing scripts:</h1>
<p>As far as I know, Slic3r does not give you the option of setting the speed of the first layer after a raft directly, but they do allow you to run <a href="http://manual.slic3r.org/advanced/post-processing" rel="nofollow">post processing scripts</a>; that is, to automatically run a set of operations - programmed by you - on the g-code output.</p>
<p>Although far from trivial, you can in theory make a program that runs through the output g-code, adjusts the settings to your preference, and then saves it again at the target destination.</p>
<h3>Tuning overall printer speed through g-code:</h3>
<p>As it turns out, there is a <a href="http://reprap.org/wiki/G-code#M220:_Set_speed_factor_override_percentage" rel="nofollow">simple g-code command</a> that sets the overall speed of your printer's operation:</p>
<pre><code>M220 S[some number] ; see the link above for compatible firmware
</code></pre>
<p>A <a href="http://reprapworld.com/newletters/newsletter_4_201438.pdf" rel="nofollow">newsletter</a> from Reprapwold explains that:</p>
<blockquote>
<p>For example M220 S50 will reduce the speed to 50%
of the original sliced G-code. If you want to hurry your print to the finish in time
for dinner, use M220 S200, to print twice as fast (200%)</p>
</blockquote>
<p>In other words, just like some printers allow you the change speed mid-print, you can use the M220 command to override the current speed used, either through a user interface such as PrintRun, or by fiddling with the original g-code itself.</p>
<h3>Manipulating the g-code output to adjust speed settings:</h3>
<p>The easiest way to achieve our goal would be to manually manipulate the output g-code file through a text editor, and insert our M220 command in appropriate places:</p>
<ul>
<li>Set M220 S50 just before the first <em>perimeter</em> layer (after the raft's <em>interface layer</em>), to slow down the first layer of the actual model.</li>
<li>Set M220 S100 sometime after the first perimeter layer, to resume the normal speed settings.</li>
</ul>
<p>In order to do this, though, we need to be able to distinguish these two points in the g-code output.</p>
<h3>Distinguishing insertion points:</h3>
<p>Slic3r offers a setting under <code>Print Settings -> Output options -> Verbose G-code</code> that - when enabled - inserts written comments all throughout the g-code files generated. </p>
<p>If one inspects a g-code file outputted for a model with raft, one will find the comment:</p>
<pre><code>; move to first perimeter point <- lets call this A
</code></pre>
<p>and </p>
<pre><code>; move to next layer (x) <- lets call this B
</code></pre>
<p>littered several places throughout the gcode. </p>
<p>It is under my <em>impression</em> that the <em>first</em> occurrence of comment <strong>A</strong> happens right after the raft is finished, and before the actual model is being printed, while the first occurrence of comment <strong>B</strong> succeeding comment <strong>A</strong> can be used to set the speed back to normal.</p>
<p>It should be noted, however, that <strong>the comments in the output g-code does not seem fully consistent</strong>, and I would therefore not recommend anyone to automate this logic into a script without possibly finding other, more reliable breakpoints, and thoroughly verify these through several different models. </p>
<p>I have not looked into the details of writing an automatic script for this task as of yet.</p>
|
<p>You shouldn't need to. The purpose of a slower first layer is to help with need adhesion. With a raft the first layer of the model is printing on the raft so it can go at regular speeds.</p>
| 111
|
<p>Is it possible to use a standard color inkjet cartridge to color filament for full color 3D printing?</p>
<p>It seems like a natural next step to me, but I haven't seen much of anything on this. (Just a few ancient experiments on reprap wiki.)</p>
<p>I've learned that some inkjet printers have the heads built into the cartridge whereas others it's part of the printer. I think the former would be more appropriate.</p>
<p>Unfortunately I haven't seen anything on actually how to drive the cartridges. I'm guessing the mfgr's treat this as a trade secret (?) Still, there's got to be some overseas reverse-engineer... something... on this, right?</p>
<p>Anybody have resources/notes they'd like to share?</p>
|
<p>I don't think it makes a lot of sense - you don't need that kind of resolution, and getting a sufficient amount of ink that way to coat the filament would be hard. If you're going to be switching colors rapidly, you'd need a long purge between colors anyway. I also doubt the type of ink is suitable for sticking to filament materials.</p>
<p>If you really want an automated filament coloring system, I would do it with Sharpies and actuators to move individual ones on/off of the filament as it passes through. Coloring PLA with Sharpies prior to printing is a known-working technique, and there are even models available on Thingiverse for holders to keep them in place while the filament runs through. Designing the actuators to switch individual ones on/off, and the firmware controls for them, would be the natural next step.</p>
<p>Here are some examples I did with manual coloring of natural translucent PLA (from left to right: uncolored, silver Sharpie, and red Sharpie):</p>
<p><img src="https://i.stack.imgur.com/4BE8K.jpg" alt="3 printed nuts, colored as described in text" /></p>
<p>I didn't color a long enough segment of filament or properly purge for any of them, which is why the coloring is inconsistent/incomplete. But the technique definitely works.</p>
|
<p>AS an FYI, this is becoming available commercially:
<a href="https://www.xyzprinting.com/en-US/product-level/PROFESSIONAL/color-series" rel="nofollow noreferrer">https://www.xyzprinting.com/en-US/product-level/PROFESSIONAL/color-series</a></p>
| 1,734
|
<p>Usually when I'm creating indexes on tables, I generally guess what the <code>Fill Factor</code> should be based on an educated guess of how the table will be used (many reads or many writes).</p>
<p>Is there a more scientific way to determine a more accurate <code>Fill Factor</code> value?</p>
|
<p>You could try running a big list of realistic operations and looking at IO queues for the different actions.</p>
<p>There are a lot of variables that govern it, such as the size of each row and the number of writes vs reads.</p>
<p>Basically: high fill factor = quicker read, low = quicker write.</p>
<p>However it's not quite that simple, as almost all writes will be to a subset of rows that need to be looked up first.</p>
<p>For instance: set a fill factor to 10% and each single-row update will take 10 times as long to find the row it's changing, even though a page split would then be very unlikely.</p>
<p>Generally you see fill factors 70% (very high write) to 95% (very high read).</p>
<p>It's a bit of an art form.</p>
<p>I find that a good way of thinking of fill factors is as pages in an address book - the more tightly you pack the addresses the harder it is to change them, but the slimmer the book. I think I explained it better on <a href="http://bizvprog.blogspot.com/2008/02/expensive-database-server-1980s-filofax.html" rel="nofollow noreferrer">my blog</a>. </p>
|
<p>I would tend to be of the opinion that if you're after performance improvements, your time is much better spent elsewhere, tweaking your schema, optimising your queries and ensuring good index coverage. Fill factor is one of those things that you only need to worry about when you <em>know</em> that everything else in your system is optimal. I don't know anyone that can say that.</p>
| 3,212
|
<p>I just assembled a Prusa i3 MK3 and went through the calibration process, but when I print the first layer doesn't look good and my prints come unstuck from the bed. I think it might be Z height but this was as high as I could put the probe without the paper moving on the calibration test. The layers after the first few look good but then the print either warps or comes unstuck and moves.</p>
<p><a href="https://i.stack.imgur.com/EdidQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EdidQ.jpg" alt="Bottom view of a hexagon print"></a>
<a href="https://i.stack.imgur.com/4voqC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4voqC.jpg" alt="Detail of the bottom of another print"></a></p>
|
<p>Judging by the images you posted in your question, the first layer distance is too far away from the bed for the current filament flow.</p>
<p>This could either be related to:</p>
<ul>
<li>having an offset on the first layer like a height correction in the slicer,</li>
<li>an incorrectly levelled (read height adjusted) bed, (you did the paper test correctly, so this is probably not your problem, it is mentioned for completeness)</li>
<li>under-extrusion
<ul>
<li>slicer setting not correct, e.g. filament diameter or flow modifier not 100 %</li>
<li>incorrectly calibrated extruder</li>
</ul></li>
</ul>
<p>Your most likely problem is under-extrusion. It would be advised to calibrate the extruder: <a href="https://3dprinting.stackexchange.com/questions/6483/how-do-i-calibrate-the-extruder-of-my-printer">How do I calibrate the extruder of my printer?</a> and check the slicer settings.</p>
|
<p>I used the live-z adjustment feature and set it to +0.150 and now my prints look much better.</p>
| 1,068
|
<p>I've recently discovered that it's possible to place .net assemblies on SQL Server >=2005 servers so that .net functions can be called in T/SQL statements.</p>
<p>I wondered what uses people found for these and how they perform?</p>
|
<p>The first general purpose use for the CLR in SQL 2005 I created was a SQL 2005 assembly that has a variety of functions that perform string operations and pattern matches using regular expressions. The native string functions in SQL 2005 can be augmented so that you can validate common formats like phone numbers or credit card numbers or perform ad-hoc regular expressions within stored procedures.</p>
<p>For deterministic user defined functions, I have found the SQL CLR support to be very performant.</p>
|
<p>I found it to be very useful. </p>
<p>I used this possibility to extend MSSQL2005 XML related functions. </p>
<p>If I remember correctly you can even introduce your own data types.</p>
| 6,076
|
<p>The code</p>
<pre><code>private SomeClass<Integer> someClass;
someClass = EasyMock.createMock(SomeClass.class);
</code></pre>
<p>gives me a warning "Type safety: The expression of type SomeClass needs unchecked conversion to conform to SomeClass<Integer>".</p>
|
<p>AFAIK, you can't avoid the unchecked warning when a class name literal is involved, and the <code>SuppressWarnings</code> annotation is the only way to handle this.</p>
<p>Note that it is good form to narrow the scope of the <code>SuppressWarnings</code> annotation as much as possible. You can apply this annotation to a single local variable assignment:</p>
<pre><code>public void testSomething() {
@SuppressWarnings("unchecked")
Foo<Integer> foo = EasyMock.createMock(Foo.class);
// Rest of test method may still expose other warnings
}
</code></pre>
<p>or use a helper method:</p>
<pre><code>@SuppressWarnings("unchecked")
private static <T> Foo<T> createFooMock() {
return (Foo<T>)EasyMock.createMock(Foo.class);
}
public void testSomething() {
Foo<String> foo = createFooMock();
// Rest of test method may still expose other warnings
}
</code></pre>
|
<p>I know this goes against the question, but why not create a List rather than a Mock List?</p>
<p>It's less code and easier to work with, for instance if you want to add items to the list.</p>
<pre><code>MyItem myItem = createMock(myItem.class);
List<MyItem> myItemList = new ArrayList<MyItem>();
myItemList.add(myItem);
</code></pre>
<p>Instead of </p>
<pre><code>MyItem myItem = createMock(myItem.class);
@SuppressWarnings("unchecked")
List<MyItem> myItemList = createMock(ArrayList.class);
expect(myItemList.get(0)).andReturn(myItem);
replay(myItemList);
</code></pre>
| 8,114
|
<p>Erasing programs such as Eraser recommend overwriting data maybe 36 times.</p>
<p>As I understand it all data is stored on a hard drive as 1s or 0s.</p>
<p>If an overwrite of random 1s and 0s is carried out once over the whole file then why isn't that enough to remove all traces of the original file?</p>
|
<p>A hard drive bit which used to be a 0, and is then changed to a '1', has a slightly weaker magnetic field than one which used to be a 1 and was then written to 1 again. With sensitive equipment the previous contents of each bit can be discerned with a reasonable degree of accuracy, by measuring the slight variances in strength. The result won't be exactly correct and there will be errors, but a good portion of the previous contents can be retrieved.</p>
<p>By the time you've scribbled over the bits 35 times, it is effectively impossible to discern what used to be there.</p>
<p><b>Edit:</b> <a href="http://www.h-online.com/news/Secure-deletion-a-single-overwrite-will-do-it--/112432" rel="noreferrer">A modern analysis</a> shows that a single overwritten bit can be recovered with only 56% accuracy. Trying to recover an entire byte is only accurate 0.97% of the time. So I was just repeating an urban legend. Overwriting multiple times might have been necessary when working with floppy disks or some other medium, but hard disks do not need it.</p>
|
<p>There are "disk repair" type applications and services that can still read data off a hard drive even after it's been formatted, so simply overwriting with random 1s and 0s one time isn't sufficient if you really need to securely erase something.</p>
<p>I would say that for the average user, this is more than sufficient, but if you are in a high-security environment (government, military, etc.) then you need a much higher level of "delete" that can pretty effectively guarantee that no data will be recoverable from the drive.</p>
| 8,432
|
<p>Is there a way of mapping data collected on a stream or array to a data structure or vice-versa?
In C++ this would simply be a matter of casting a pointer to the stream as a data type I want to use (or vice-versa for the reverse)
eg: in C++</p>
<pre><code>Mystruct * pMyStrct = (Mystruct*)&SomeDataStream;
pMyStrct->Item1 = 25;
int iReadData = pMyStrct->Item2;
</code></pre>
<p>obviously the C++ way is pretty unsafe unless you are sure of the quality of the stream data when reading incoming data, but for outgoing data is super quick and easy.</p>
|
<p>Most people use .NET serialization (there is faster binary and slower XML formatter, they both depend on reflection and are version tolerant to certain degree)</p>
<p>However, if you want the fastest (unsafe) way - why not:</p>
<p>Writing:</p>
<pre><code>YourStruct o = new YourStruct();
byte[] buffer = new byte[Marshal.SizeOf(typeof(YourStruct))];
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
Marshal.StructureToPtr(o, handle.AddrOfPinnedObject(), false);
handle.Free();
</code></pre>
<p>Reading:</p>
<pre><code>handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
o = (YourStruct)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(YourStruct));
handle.Free();
</code></pre>
|
<p>if its .net on both sides:</p>
<p>think you should use binary serialization and send the byte[] result.</p>
<p>trusting your struct to be fully blittable can be trouble.</p>
<p>you will pay in some overhead (both cpu and network) but will be safe.</p>
| 2,443
|
<p>How are people unit testing code that uses Linq to SQL? </p>
|
<p>Update:</p>
<p>Fredrik has put an example solution on how to do unit test linq2sql applications over at his blog. You can download it at:</p>
<p><a href="http://web.archive.org/web/20120415022448/http://iridescence.no/post/DataContext-Repository-Pattern-Example-Code.aspx" rel="nofollow noreferrer">http://web.archive.org/web/20120415022448/http://iridescence.no/post/DataContext-Repository-Pattern-Example-Code.aspx</a></p>
<p>Not only do I think its great that he posted an example solution, he also managed to extract interfaces for all classes, which makes the design more decoupled.</p>
<p>My old post:</p>
<p>*I found these blogs that I think are a good start for making the DataContext wrapper:
<a href="http://web.archive.org/web/20120414060200/http://iridescence.no/post/Linq-to-Sql-Programming-Against-an-Interface-and-the-Repository-Pattern.aspx" rel="nofollow noreferrer">Link1</a>
<a href="http://nixusg.com/post/2008/08/05/The-Automated-Testing-Continuum-Part-2-(Unit-Testing-LinQ).aspx" rel="nofollow noreferrer">Link2</a></p>
<p>They cover almost the same topic except that the first one implements means for extracting interfaces for the tables as well. The second one is more extensive though, so I included it as well.*</p>
|
<p>LINQ to SQL is actually really nice to unit test as it has the ability to create databases on the fly from what is defined in your DBML.</p>
<p>It makes it really nice to test a ORM layer by creating the DB through the DataContext and having it empty to begin with.</p>
<p>I cover it on my blog here: <a href="http://web.archive.org/web/20090526231317/http://www.aaron-powell.com/blog/may-2008/unit-testing-linq-to-sql.aspx" rel="nofollow noreferrer">http://web.archive.org/web/20090526231317/http://www.aaron-powell.com/blog/may-2008/unit-testing-linq-to-sql.aspx</a></p>
| 7,590
|
<p>HI All,</p>
<p>We have a .Net 2.0 application which has a MySQL backend. We want to be able to deploy MySQl and the DB when we install the application and im trying to find the best solution. The current setup is to copy the required files to a folder on the local machine and then perform a "NET START" commands to install and start the mysql service. Then we restore a backup of the DB to this newly created mysql instance using bat files. Its not an ideal solution at all and im trying to come up with something more robust. </p>
<p>The issues are User rights on Vista, and all sorts of small things around installing and starting the service. Its far too fragile to be reliable or at least it appears that way when i am testing it. This is a Client/Server type setup so we only need to install one Server per office but i want to make sure its as hassle free as possible and with as few screens as possible.</p>
<p>How would you do it?</p>
|
<p>Not sure where you're at in the project, but if it's a simple and small database you might consider converting it to <a href="http://www.sqlite.org/" rel="noreferrer">SQLite</a>. It's not ideal for Client/Server operations, but if it's low volume/transactions it might work.</p>
|
<p>With a Client/Sever setup, you're allowed to require that whoever installs the server install it as an admin. That should solve most of your problems.</p>
<p>Again- that's the server. The clients might be another story.</p>
| 7,190
|
<p>I didn't get the answer to this anywhere. What is the runtime complexity of a Regex match and substitution?</p>
<p>Edit: I work in python. But would like to know in general about most popular languages/tools (java, perl, sed).</p>
|
<p>From a purely theoretical stance:</p>
<p>The implementation I am familiar with would be to build a Deterministic Finite Automaton to recognize the regex. This is done in O(2^m), m being the size of the regex, using a standard algorithm. Once this is built, running a string through it is linear in the length of the string - O(n), n being string length. A replacement on a match found in the string should be constant time.</p>
<p>So overall, I suppose O(2^m + n).</p>
|
<p>You can trade space for speed by building a nondeterministic finite automaton instead of a DFA. This can be traversed in linear time. Of course, in the worst case this could need O(2^m) space. I'd expect the tradeoff to be worth it.</p>
| 4,180
|
<p>Say I have the following C++:</p>
<pre><code>char *p = new char[cb];
SOME_STRUCT *pSS = (SOME_STRUCT *) p;
delete pSS;
</code></pre>
<p>Is this safe according to the C++ standard? Do I need to cast back to a <code>char*</code> and then use <code>delete[]</code>? I know it'll work in most C++ compilers, because it's plain-ordinary-data, with no destructors. Is it guaranteed to be safe?</p>
|
<p>It's not guaranteed to be safe. Here's a relevant link in the C++ FAQ lite:</p>
<p>[16.13] Can I drop the <code>[]</code> when deleting array of some built-in type (<code>char</code>, <code>int</code>, etc.)?</p>
<p><a href="https://isocpp.org/wiki/faq/freestore-mgmt#delete-array-built-ins" rel="nofollow noreferrer">http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.13</a></p>
|
<p>While this <em>should</em> work, I don't think you can guarantee it to be safe because the SOME_STRUCT is not a char* (unless it's merely a typedef).</p>
<p>Additionally, since you're using different types of references, if you continue to use the *p access, and the memory has been deleted, you will get a runtime error.</p>
| 9,635
|
<p>My team is moving from Visual SourceSafe to Subversion soon, while developing/supporting a legacy project in Visual Basic 6.0, so I have a couple of questions:</p>
<ul>
<li>What's the best tool for Subversion IDE integration in Visual Studio 6? (or is it not worth the trouble...)</li>
<li>Are there any best practices for using Subversion with Visual Basic 6.0? (file types to ignore, etc.)</li>
</ul>
|
<p>I would agree that Tortoise SVN in Windows Explorer would be the best way to use SVN with VB6.</p>
<p>The biggest change you will find migrating to SVN is the idea of "Check out" and "Check in" aren't exactly the same as "Update" and "Commit". . . thus, any IDE integration with VB6 is limited because VB6 supports MSSCCI, a check-out/check-in mechanism. I once used TamTam SVN (<a href="http://www.daveswebsite.com/software/tamtamsvn/index.shtml" rel="noreferrer">http://www.daveswebsite.com/software/tamtamsvn/index.shtml</a>) with Visual Studio 2003, but stopped since I found it limiting. Merging/branching/blaming, etc. are very powerful features Tortoise SVN provides that weren't in TamTam. Tigris also has <a href="http://svnvb6.tigris.org/" rel="noreferrer">http://svnvb6.tigris.org/</a>, but I have not tried it.</p>
<p>Again, while you quite possibly get an IDE to work with VB6, I would not recommend it since the greatest strength of migrating to SVN is to break the Source Safe philosophy of check-in/check-out.</p>
|
<p>For the server side, VisualSVN Server, is a super simple solution, we are running it in a vmware virtual, and its humming along.</p>
<p>If you are a command line guy, I really like the command line interface for svn, I find it less confusing to get to certain actions than tortoise, such as status of the folder. But if you are an explorer fan, tortoise is more than adequate, coming from a source safe world.</p>
<p>The main things to ignore are:</p>
<ul>
<li>Reproducable artifacts (dll, pdb, exe)</li>
<li>Environment specific settings (i.e. the settings file for vs, csproj.user file, .suo files)</li>
</ul>
| 4,434
|
<p>From a <a href="http://www.joelonsoftware.com/items/2007/01/26.html" rel="nofollow noreferrer">Joel's post on Copilot</a>:</p>
<blockquote>
<p>Direct Connect! We’ve always done
everything we can to make sure that
Fog Creek Copilot can connect in any
networking situation, no matter what
firewalls or NATs are in place. To
make this happen, both parties make
outbound connections to our server,
which relays traffic on their behalf.
Well, in many cases, this isn’t
necessary. So version 2.0 does
something rather clever: it sets up
the initial connection through our
servers, so you get connected right
away with 100% reliability. But then
once you’re all connected, it quietly,
in the background, looks for a way to
make a direct connection. If it can’t,
no big deal: you just keep relaying
through our server. If you can make a
direct peer-to-peer connection, it
silently shifts your data onto the
direct connection. You won’t notice
anything except, probably, much faster
communication.</p>
</blockquote>
<p>How do they change the server connection to a P2P connection?</p>
|
<p>It's pretty tricky and interesting. I'm sure I have some details wrong, but the overview is this:</p>
<p>The programs can already talk to each other through Joel's server, so they can exchange information with each other and Joel's server. Further, Joel has their external IP addresses, and they give joel information about their internal IP addresses.</p>
<p>They decide to try this hole punch technique. Computer A initiates a TCP connection with Computer B using B's external IP address. It won't go through, but what it does is tell's A's router that it needs to allow incoming packets from B on a given port.</p>
<p>Computer B does the same thing, but its message gets through to A since A's router opened a port/ip combination that matches what B sent (there's some port magic that happens here - this is non trivial, but doable).</p>
<p>B's router remembers that B initiated a connection with A on a given port and IP, and so A's packets now flow into B past their router correctly as well.</p>
<p>So it's actually pretty straight forward, but the implementation has details, especially regarding how ports are given to new TCP connections, and how NAT routers <em>typically</em> deal with TCP requests and how they map to external ports. These details are the interesting, and difficult, bit.</p>
<p>-Adam</p>
|
<p>There is a technique called "<a href="https://en.wikipedia.org/wiki/Hole_punching_(networking)" rel="nofollow noreferrer">Hole Punching</a>" that works well with "Cone" NAT (Cone is a technical familly of router). That's not an 100% sure technique, today, it works well with UDP on about 80% of the router.</p>
<p>There is some implementations of library to realize Hole Punching: <a href="http://sourceforge.net/projects/stun/" rel="nofollow noreferrer">STUN</a> (<a href="http://en.wikipedia.org/wiki/STUN" rel="nofollow noreferrer">wikipedia</a>)</p>
| 6,591
|
<p>I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious?</p>
|
<p>Converting from timestamp to format:</p>
<pre><code>date('Y-m-d', $timestamp);
</code></pre>
<p>Converting from formatted to timestamp:</p>
<pre><code>mktime(0, 0, 0, $month, $day, $year, $is_dst);
</code></pre>
<p>See <a href="http://www.php.net/manual/en/function.date.php" rel="noreferrer">date</a> and <a href="http://www.php.net/manual/en/function.mktime.php" rel="noreferrer">mktime</a> for further documentation.</p>
<p>When it comes to storing it's up to you whether to use the MySQL DATE format for stroing as a formatted date; as an integer for storing as a UNIX timestamp; or you can use MySQL's TIMESTAMP format which converts a numeric timestamp into a readable format. <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html" rel="noreferrer">Check the MySQL Doc</a> for TIMESTAMP info.</p>
|
<p><a href="http://ca.php.net/manual/en/function.strtotime.php" rel="nofollow noreferrer">strtotime()</a> and <a href="http://ca.php.net/manual/en/function.getdate.php" rel="nofollow noreferrer">getdate()</a> are two functions that can be used to get dates from strings and timestamps. There isn't a standard library function that converts between MySQL and PHP timestamps though.</p>
| 4,094
|
<p>As part of a project with my university, I have developed a new extruder to attach to a Prusa i3 MK2. My problem is that both the nozzle and PINDA probe have moved 17mm forward and 0.5mm to the right. As a result when I try and calibrate the printer it moves to the home position and the PINDA probe is too far out over the heatbed so it doesn't detect the printing surface. What is the simplest method of moving the home position so that the printer can be properly calibrated?</p>
<p>UPDATE:
I am planning on removing the heatbed and placing spacers that will move the printing surface 17mm forward. This should then prevent the printer losing any printing area and hopefully prevents me having to edit any code. Can anyone see any problems with this I'm overlooking?</p>
<p>The simplest thing to do would be to move extruder 17mm closer to be the same as the original printer but my deadline is fast approaching and I haven't time for a redesign that large.</p>
|
<p>Consider the original installation with the orientation of the Pinda probe to the nozzle. Let's say for argument's sake that the Pinda probe is 3 mm to the right and directly in line with the nozzle on the y axis.</p>
<p>If you examine your new nozzle, I would expect that the relationship of the nozzle to the Pinda probe no longer matches the original spacing.</p>
<p>If possible, re-design the mount to place the Pinda probe in such a way as to match the original design.</p>
<p>Thanks for pointing out my oversight, Mac. If the relative position of the nozzle and pinda probe are as the original, the solution is then in changing the appropriate parameters in the firmware.</p>
<p>I found a <a href="https://shop.prusa3d.com/forum/original-prusa-i3-mk2-f23/prusa-i3-mk2-homing-offset-t5256.html" rel="nofollow noreferrer">reference</a> for someone who had a bit smaller error in home position, but the concept is the same.</p>
<p>The link above points to information reading thus:</p>
<blockquote>
<p>In Configuration_Prusa.h:</p>
<p>Code: Select all // Home position</p>
<h1>define MANUAL_X_HOME_POS 0</h1>
<h1>define MANUAL_Y_HOME_POS -2.2</h1>
<h1>define MANUAL_Z_HOME_POS 0.15</h1>
<p>// Travel limits after homing</p>
<h1>define X_MAX_POS 250</h1>
<h1>define X_MIN_POS 0</h1>
<h1>define Y_MAX_POS 210</h1>
<h1>define Y_MIN_POS -2.2</h1>
<h1>define Z_MAX_POS 210</h1>
<h1>define Z_MIN_POS 0.15</h1>
</blockquote>
<p>it will be necessary to connect the printer via USB to a computer running an Arduino IDE and to load the Prusa specific files for that printer. Edit the noted location, save/write the configuration and test.</p>
<p>I would suggest small adjustments in only one or two parameters at a time, to avoid ambiguity in the cause/result sequence.</p>
|
<blockquote>
<p>What is the simplest method of moving the home position...</p>
</blockquote>
<p>I think the solution outline by @fred_dot_u is very elegant, so I would go with it.</p>
<blockquote>
<p>...so that the printer can be properly calibrated?</p>
</blockquote>
<p>I'm not sure that will be possible.</p>
<p>Because the physical lenght of the axis hasn't changed, by moving the nozzle/probe, you have actually reduced their reach in the opposite direction, so the probe may be unable to travel on top of the intended calibration points (the usable printing area has also shrunk, but that's less of a problem).</p>
<p>If that is the case, I can't think of an easy solution (bar not using the auto-calibration feature altogether).</p>
| 827
|
<p>I need to copy hundreds of gigs of random files around on my computer and am pretty leery of using the vanilla file copy built into Windows.</p>
<p>I don't want it to hang on a "Are you sure?", "Are you really sure?", "Even zip files?", "Surely not read-only files too!" loop as soon as I step away.</p>
<p>I don't want it to work for hours and then stop unexpectedly: "Someone once opened this file and so I won't copy it!" and then cancel the whole copy or just quit with no indication of what was done and what work remains.</p>
<p>What file management programs do you have experience with? Which do you recommend?</p>
<p>This question is related to my other question: <a href="https://stackoverflow.com/questions/225/how-can-i-use-an-old-pata-hard-disk-drive-on-my-newer-sata-only-computer">How can I use an old PATA hard disk drive on my newer SATA-only computer?</a></p>
|
<p>Use <a href="http://en.wikipedia.org/wiki/Robocopy" rel="noreferrer">Robocopy (Robust File Copy)</a>.</p>
<p>NOTE:</p>
<p>In Windows Vista and Server 2008 when you type:</p>
<pre><code>xcopy /?
</code></pre>
<p>you get:</p>
<blockquote>
<p>NOTE: Xcopy is now deprecated, please use Robocopy.</p>
</blockquote>
<p>So start getting used to robocopy :)</p>
|
<p>Reboot into Linux, mount the drive, and use GNU <code>cp</code>.</p>
| 2,375
|
<p>So, the wife got me a Creality Ender-3 Pro 3d Printer for Christmas.</p>
<p>Assembly was easy, axis movements are all solid... when I go to print the <a href="https://www.thingiverse.com/thing:2879047" rel="nofollow noreferrer">test-dog.gcode</a> file provided with the machine, it comes out looking... flat.</p>
<p>Not kind of flat. TOTALLY flat.</p>
<p>The Z-Axis motor works - I can move it with the machine's control panel - and it moves on it's own for repositioning of the head for printing purposes, but it doesn't seem to be moving 'up' for each new layer. Layer height is set for 0.1 mm, nozzle is .4 mm. No settings changed in the G-code, or on the machine (and I did a "reset to failsafe" before attempting to print anything).</p>
<p>I'm relatively new to additive manufacturing, can someone help out here?</p>
<p><a href="https://i.stack.imgur.com/CQRlC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CQRlC.png" alt="Photo of the test print"></a></p>
|
<p>It turned out that there's something wrong with the G-code file that came with my printer.</p>
<p>I downloaded a calibration cube from Thingiverse and printed it - while it wasn't 100%, it did print viable. Now I need to get into details as to quality, and I suspect that too will be a factor for the G-code used in the printer. I'm looking at "Ultimaker Cura" to figure out the changes in G-code based on option changes.</p>
|
<p>I had the same problem on an Ender 3. Totally bewildering, because G-code commands <code>G0</code> & <code>G1</code> moved Z as expected, as did Pronterface commands, but Z did not advance during printing.</p>
<p>It turned out to be binding in the Z-axis lead screw caused by installing a BondTech style extruder. Previously, it had caused no problems but reinstallation saw it interfering with the screw. A quick workout on the Dremel created sufficient clearance.</p>
<p>The clear conclusion is that during printing power to the Z-motor decreases for whatever reason.</p>
<p>Check your machine's alignment. The Z screw should turn easily by hand, the nylon wheels of the X gantry the same. The bracket mounting the extruder and lead screw is well known to be non-square. Check by releasing the lead screw from motor coupling and seeing where its 'natural' position is vs the coupling. If it won't fall close to the coupling naturally that could be the cause.</p>
<p>Then RTFM or punish yourself with 1000 YouTube instructionals.</p>
| 1,155
|
<h1>Outline</h1>
<p>OK, I have Google'd this and already expecting a big fat <strong>NO!!</strong> But I thought I should ask since I know sometimes there can be the odd little gem of knowledge lurking around in peoples heads ^_^</p>
<p>I am working my way through some excercises in a book for study, and this particular exercise is User Controls. I have cobbled together a control and would like to set the DefaultEvent for it (having done this for previous controls) so when I double-click it, the default event created is whatever I specify it to be. </p>
<p><strong>NOTE:</strong> This is a standard User Control (.ascx), <em>NOT</em> a custom rendered control.</p>
<h2>Current Code</h2>
<p>Here is the class & event definition:</p>
<pre><code>[System.ComponentModel.DefaultEvent("OKClicked")]
public partial class AddressBox : System.Web.UI.UserControl
{
public event EventHandler OKClicked;
</code></pre>
<h2>Current Result</h2>
<p>Now, when I double click the the control when it is on a ASPX page, the following is created:</p>
<pre><code> protected void AddressBox1_Load(object sender, EventArgs e)
{
}
</code></pre>
<p>Not quite what I was expecting! So, my question:</p>
<h2>Is it possible to define a DefaultEvent for a UserControl? Is it a hack? If it's [not] supported, is there a reason?</h2>
<hr>
<p><strong>Side Note</strong>: How do we put underscores in code? I cant seem to put and escape char in?</p>
|
<p>I think to be honest you a better just boning up on your standard design patterns and applying them to the individual problems that you face in developing your UI.</p>
<p>While there are common UI "themes" (such as dealing with modifier keys) the actual implementation may vary widely.</p>
<p>I have O'Reilly's <a href="http://www.amazon.co.uk/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.co.uk%2FHead-First-Design-Patterns%2Fdp%2F0596007124%2Fref%3Dpd_bbs_sr_1%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1218730650%26sr%3D1-1&tag=robcthegeek-21&linkCode=ur2&camp=1634&creative=6738" rel="nofollow noreferrer">Head First Design Patterns</a> and <a href="http://www.amazon.co.uk/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.co.uk%2FHead-First-Design-Patterns-Poster%2Fdp%2F0596102143%2Fref%3Dpd_bbs_sr_3%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1218730650%26sr%3D1-3&tag=robcthegeek-21&linkCode=ur2&camp=1634&creative=6738" rel="nofollow noreferrer">The Poster</a>, which I have found invaluable!</p>
<h3>Shameless Plug : These links are using my associates ID.</h3>
|
<p>I don't think the that benefit of design patterns come from trying to find a design pattern to fit a problem. You can however use some heuristics to help clean up your design in this quite a bit, like keeping the UI as decoupled as possible from the rest of the objects in your system.</p>
<p>There is a pattern that might help out in this case, the <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">Observer Pattern</a>.</p>
| 3,240
|
<p>I have an Access database in which I drop the table and then create the table afresh. However, I need to be able to test for the table in case the table gets dropped but not created (i.e. when someone stops the DTS package just after it starts -roll-eyes- ). If I were doing this in the SQL database I would just do:</p>
<pre><code>IF (EXISTS (SELECT * FROM sysobjects WHERE name = 'Table-Name-to-look-for'))
BEGIN
drop table 'Table-Name-to-look-for'
END
</code></pre>
<p>But how do I do that for an Access database?</p>
<p>Optional answer: is there a way to have the DTS package ignore the error and just go to the next step rather than checking to see if it exists?</p>
<p>SQL Server 2000</p>
|
<blockquote>
<p>I would reccomend sticking to what you know - PHP is more than capable.</p>
</blockquote>
<p>That's true of course, but:</p>
<blockquote>
<p>I don't mind, and I would even like to use this as an excuse, learning some new thing like Python or Ruby.</p>
</blockquote>
<p>Then writing a browser game is an excellent opportunity to do this. Learning something new is never wrong and learning an alternative to PHP can never hurt (<a href="http://www.codinghorror.com/blog/archives/001119.html" rel="nofollow noreferrer">eh, Jeff?</a>). While neither Ruby on Rails nor Django are especially useful for writing games, they're still great. We had to write a small browser game in a matter of weeks for a project once and Rails worked charms. On the other hand, all successful browser games have enormous work loads and if you want to scale well you either have to get good hardware and load balancing or you need a non-interpreted framework (sorry, guys!).</p>
|
<p>I would reccomend sticking to what you know - PHP is more than capable.</p>
<p>I used to play a game called <a href="http://www.hyperiums.com/" rel="nofollow noreferrer">Hyperiums</a> - a text based browser game like yours - which is created using Java (it's web-based quivalent is JSP?) and servlets. It works fairly well (it has had downtime issues but those were more related to it's running on a pretty crap server).</p>
<p>As for which framework to use - why not create your own? Spend a good amount of time pre-coding deciding how you're going to handle various things - such as langauge support: you could use a phrase system or seperate langauge-specific templates. Third party frameworks are probably better tested than one you make but they're not created for a specific purpose, they're created for a wide range of purposes.</p>
| 4,564
|
<p>I broke 2 keys (i.e. left ctrl, enter) on my Asus UX31A laptop and it seems that this model is too old to find replacement keys.</p>
<p>Is there any way I can find a 3D model of the needed keys to have them 3D printed?</p>
<p>I do not have a printer nor I have any experience in this field.
What I need is either someone that has models for these or that can point me where I can find such models.</p>
|
<p>This is more off-topic as an answer, but serves as a possible solution.</p>
<p>Replacementlaptopkeys.com is a resource that appears to have keycaps for the model you've noted.</p>
<p><a href="https://www.replacementlaptopkeys.com/asus-zenbook-ux31a-db71-laptop-keys-replacement-dark-brown-black/" rel="nofollow noreferrer">https://www.replacementlaptopkeys.com/asus-zenbook-ux31a-db71-laptop-keys-replacement-dark-brown-black/</a></p>
<p>At seven dollars a key, it's going to be less expensive than 3D printing to accomplish your objective.</p>
<p>If you owned a 3D printer, it would not be less expensive to purchase, but the work involved would increase your cost to have such keys commissioned. As a 3D printed object, the strength is going to be less than a keycap purchased from the linked site.</p>
|
<p>You're better off if you can get the key from Fred's link. I was impressed by the detail of a 3D-printed battery cover for electronic calipers, but I'm sure it took much work to get it right. Also, ebay has keyboards for your model.</p>
| 1,943
|
<p>Test Driven Development has been the rage in the .NET community for the last few years. Recently, I have heard grumblings in the ALT.NET community about BDD. What is it? What makes it different from TDD?</p>
|
<p>I understand BDD to be more about <strong>specification</strong> than <strong>testing</strong>. It is linked to Domain Driven Design (don't you love these *DD acronyms?). </p>
<p>It is linked with a certain way to write user stories, including high-level tests. An example by <a href="http://tomtenthij.nl/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app" rel="noreferrer">Tom ten Thij</a>:</p>
<pre><code>Story: User logging in
As a user
I want to login with my details
So that I can get access to the site
Scenario: User uses wrong password
Given a username 'jdoe'
And a password 'letmein'
When the user logs in with username and password
Then the login form should be shown again
</code></pre>
<p>(In his article, Tom goes on to directly execute this test specification in Ruby.)</p>
<p>The pope of BDD is <a href="http://dannorth.net/" rel="noreferrer">Dan North</a>. You'll find a great introduction in his <a href="http://dannorth.net/introducing-bdd" rel="noreferrer">Introducing BDD</a> article.</p>
<p>You will find a comparison of BDD and TDD in this <a href="http://video.google.com/videoplay?docid=8135690990081075324" rel="noreferrer">video</a>. Also an opinion about BDD as "TDD done right" by <a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/09/06/bdd-tdd-and-the-other-double-d-s.aspx" rel="noreferrer">Jeremy D. Miller</a></p>
<p><strong>March 25, 2013 update</strong></p>
<p>The video above has been missing for a while. Here is a recent one by Llewellyn Falco, <a href="https://www.youtube.com/watch?v=mT8QDNNhExg" rel="noreferrer">BDD vs TDD (explained)</a>. I find his explanation clear and to the point.</p>
|
<p>Here's the quick snapshot:</p>
<blockquote>
<ul>
<li><p>TDD is just the process of testing code before writing it!</p></li>
<li><p>DDD is the process of being informed about the Domain before each cycle of touching code!</p></li>
<li><p>BDD is an implementation of TDD which brings in some aspects of DDD!</p></li>
</ul>
</blockquote>
| 2,461
|
<p>What are the advantages/disadvantages between MS VS C++ 6.0 and MSVS C++ 2008? </p>
<p>The main reason for asking such a question is that there are still many decent programmers that prefer using the older version instead of the newest version.</p>
<p>Is there any reason the might prefer the older over the new?</p>
|
<p>Advantages of Visual Studio 2008 over Visual C++ 6.0:</p>
<ul>
<li>Much more standards compliant C++ compiler, with better template handling</li>
<li>Support for x64 / mobile / XBOX targets </li>
<li>Improved STL implementation</li>
<li>Support for C++0x TR1 (smart pointers, regular expressions, etc)</li>
<li>Secure C runtime library</li>
<li>Improved code navigation</li>
<li>Improved debugger; possibility to run remote debug sessions</li>
<li>Better compiler optimizations</li>
<li>Many bug fixes</li>
<li>Faster builds on multi-core/multi-CPU systems</li>
<li>Improved IDE user interface, with many nice features</li>
<li>Improved macro support in the IDE; DTE allows access to more IDE methods and variables</li>
<li>Updated MFC library (in VS2008 Service Pack 1)</li>
<li>support for OPENMP (easy multithreading)(only in VS2008 pro.)</li>
</ul>
<p>Disadvantages of moving to Visual Studio 2008:</p>
<ul>
<li>The IDE is a lot slower than VS6</li>
<li>Intellisense still has performance issues (replacing it with VisualAssistX can help)</li>
<li>Side-by-side assemblies make app deployment much more problematic</li>
<li>The local (offline) MSDN library is extremely slow</li>
<li>As mentioned <a href="https://stackoverflow.com/questions/61669/profiling-in-visual-studio-2008-pro">here</a>, there's no profiler in the Professional version</li>
</ul>
<hr>
<p>In the spirit of Joel's recent <a href="http://www.joelonsoftware.com/items/2008/09/15.html" rel="nofollow noreferrer">blog post</a>, I've combined some of the other answers posted into a single answer (and made this a community-owned post, so I won't gain rep from it). I hope you don't mind. Many thanks to Laur, NeARAZ, 17 of 26, me.yahoo.com, and everyone else who answered. -- ChrisN</p>
|
<p>Visual C++ 2008 is much more standards compliant (Visual Studio 6 doesn't support the C++ standard set in 1998).</p>
| 8,778
|
<p>Are we supposed to find workarounds in our web applications so that they will work in every situation? Is it time to do away with IE6 programming?</p>
|
<p>This depends so much on the context of the application, and of its users. There are two key aspects: what browsers are your users using; and how important is it that they can access/interact with your site.</p>
<p>The first part is generally easily establish, <strong>if</strong> you have an existing version with stats (Google Analytics or similar is simple and great) or you have access to such data from a similar app / product.</p>
<p>The later is a little harder to decide. If you're developing a publically availalbe, ad-sponsored site for exmple, it's just a numbers game - work out how much of your audience you lose and factor what that's worth against the additional development time. If, however you're doing something specifically at the request of a group of users - like an enterprise web app for example - you may be stuck with what those users are browsing with.</p>
<p>In my experience those two things can change significantly for different apps. We've got web apps still (stats from last week) with close to 70% IE6 usage (20% IE7, the rest split between IE5.5 and FF2) and others with close to 0% IE6. For relatively ovbivous reasons, the latter are the kind of apps where losing a few users isn't so important.</p>
<p>Having said all that, we generally find it easy to support IE6 (and IE5.5 as others point out) simply because we've been doing so for a while. Yes, it's a pain and yes, it takes more time, but often not too much. There are very few situations where having to support IE6 drastically changes what kind development you do - it just means a little more work. The other nice benefit of supporting it (and testing for it) is that you generally end up doing better all-round browser and quirks testing as a result of the polarity of IE6's behaviours.</p>
<p>You need to decide whether or not you're supposed to find workarounds, based on the requirements of your app/product. That's it's IE6 isn't really that relevant - this kind of problem happens all the time in other situations, it just so happens that IE6 is a great example of the costs and implications of mixed standards, versioning and legacy support.</p>
|
<p>I'm all for pushing users to upgrade to the newest available version of IE (since problems improve with every release), however I'm also against telling people to upgrade or change their browsers.</p>
<p>I still support IE6 on my website. I even support as far back as IE5.5 pretty well I think. </p>
<p>Generally it is a good practice to never force your users to upgrade their system just to view your website. Unless, of course, you're developing an internal application, then I'd say everyone should upgrade to the newest available version.</p>
| 3,473
|
<p>Some e-Marketing tools claim to choose which web page to display based on where you were before. That is, if you've been browsing truck sites and then go to Ford.com, your first page would be of the Ford Explorer.</p>
<p>I know you can get the immediate preceding page with HTTP_REFERRER, but how do you know where they were 6 sites ago? </p>
|
<p>Javascript this should get you started: <a href="http://www.dicabrio.com/javascript/steal-history.php" rel="noreferrer">http://www.dicabrio.com/javascript/steal-history.php</a><br />
There are more nefarius means to: <a href="http://ha.ckers.org/blog/20070228/steal-browser-history-without-javascript/" rel="noreferrer">http://ha.ckers.org/blog/20070228/steal-browser-history-without-javascript/</a> <br />
Edit:I wanted to add that although this works it is a sleazy marketing teqnique and an invasion of privacy.</p>
|
<p>The browser history can't be directly accessed, but you can compare a list of sites with the user's history. This can be done because the browser attributes a different CSS style to a link that hasn't been visited and one that has.</p>
<p>Using this style difference you can change the content of you pages using pure CSS, but in general javascript is used. There is a good article here about using this trick to improve the user experience by displaying only the RSS aggregator or social bookmarking links that the user actually uses: <a href="http://www.niallkennedy.com/blog/2008/02/browser-history-sniff.html" rel="nofollow noreferrer">http://www.niallkennedy.com/blog/2008/02/browser-history-sniff.html</a></p>
| 7,126
|
<p>I have just ordered some filament samples (each sample is 10m x 1.75mm). How should I test the samples, given that there is only 10 metres of each to play with? Just printing a benchy will use about 4 metres. I would probably want to print a benchy, so that leaves 6 metres to play with. I am mostly interested in producing functional (not decorative) pieces. I do not have a heated bed.</p>
|
<p>Select an STL that exhibits characteristics you want to test (bridging, resistance to various pressures) and print it with each material. Preferably, run the <strong>same exact gcode</strong>, only changing temperatures, so that you get an apples-to-apples comparison.</p>
|
<p>Select an STL that exhibits characteristics you want to test (bridging, resistance to various pressures) and print it with each material. Preferably, run the <strong>same exact gcode</strong>, only changing temperatures, so that you get an apples-to-apples comparison.</p>
| 648
|
<p>How can I set the background color of an HTML element using css in JavaScript?</p>
|
<p>In general, CSS properties are converted to JavaScript by making them camelCase without any dashes. So <code>background-color</code> becomes <code>backgroundColor</code>.</p>
<pre><code>function setColor(element, color)
{
element.style.backgroundColor = color;
}
// where el is the concerned element
var el = document.getElementById('elementId');
setColor(el, 'green');
</code></pre>
|
<pre><code>$(".class")[0].style.background = "blue";
</code></pre>
| 2,549
|
<p>Using win forms with an <a href="http://en.wikipedia.org/wiki/Model-view-controller" rel="noreferrer">MVC</a>/<a href="http://msdn.microsoft.com/en-us/magazine/cc188690.aspx" rel="noreferrer">MVP</a> architecture, I would normally use a class to wrap a view to test the UI while using mocks for the model and controller/presenter. The wrapper class would make most everything in the UI an observable property for the test runner through properties and events.</p>
<p>Would this be a viable approach to testing a WPF app? Is there a better way? Are there any gotchas to watch out for?</p>
|
<p>As for the testing itself, you're probably best off using the <a href="https://msdn.microsoft.com/library/ms747327.aspx" rel="noreferrer">UI Automation</a> framework. Or if you want a more fluent and wpf/winforms/win32/swt-independent way of using the framework, you could download <a href="http://www.codeplex.com/white" rel="noreferrer">White</a> from Codeplex (provided that you're in a position to use open source code in your environment).</p>
<p>For the gotchas; If you're trying to test your views, you will probably run in to some threading issues. For instance, if you're running NUnit the default testrunner will run in MTA (Multi-Threaded Appartment), while as WPF needs to run as STA (Single-threaded Appartment). <a href="http://miketwo.blogspot.com/2007/03/unit-testing-wpf-controls-with.html" rel="noreferrer">Mike Two</a> has a real easy getting-started on unit testing WPF, but without considering the threading issue. Josh Smith has some thoughts on the threading issue in <a href="http://joshsmithonwpf.wordpress.com/2007/07/09/using-nunit-with-wpf/" rel="noreferrer">this post</a>, and he also points to <a href="http://www.hedgate.net/articles/2007/01/08/instantiating-a-wpf-control-from-an-nunit-test/" rel="noreferrer">this article</a> by Chris Hedgate. Chris uses a modified version of Peter Provost's <a href="http://www.peterprovost.org/blog/post/NUnit-and-Multithreaded-Tests-CrossThreadTestRunner.aspx" rel="noreferrer">CrossThreadTestRunner</a> to wrap the MTA/STA issues in a bit more friendly way. </p>
|
<p>Definitely look at TestAutomationFX.com. One can invest (OK, I did) a lot of time trying to capture / record events with White. (At the start of my quest I ignored the post or two in other places referring to it).</p>
<p>I of course second the other points about the best type of testing not being UI testing.</p>
<p>But if someone is going to do something automatable in the UI to get around shortcomings in other types of testing coverage, TAFX seems the quickest route there.</p>
| 8,270
|
<p>I do some minor programming and web work for a local community college. Work that includes maintaining a very large and soul destroying website that consists of a hodge podge of VBScript, javascript, Dreamweaver generated cruft and a collection of add-ons that various conmen have convinced them to buy over the years. </p>
<p>A few days ago I got a call "The website is locking up for people using Safari!" Okay, step one download Safari(v3.1.2), step two surf to the site. Everything appears to work fine.</p>
<p>Long story short I finally isolated the problem and it relates to Safari's back button. The website uses a fancy-pants javascript menu that works in every browser I've tried including Safari, the first time around. But in Safari if you follow a link off the page and then hit the back button the menu no longer works.</p>
<p>I made a pared down webpage to illustrate the principle.</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>Safari Back Button Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload="alert('Hello');">
<a href="http://www.codinghorror.com">Coding Horror</a>
</body>
</html>
</code></pre>
<p>Load the page and you see the alert box. Then follow the link off the page and hit the back button. In IE and Firefox you see the alert box again, in Safari you do not.</p>
<p>After a vigorous googling I've discovered others with similar problems but no really satisfactory answers. So my question is how can I make my pages work the same way in Safari after the user hits the back button as they do in other browsers?</p>
<p>If this is a stupid question please be gentle, javascript is somewhat new to me.</p>
|
<p>Stefan's iframe solution works, but if that's not elegant enough, I find the following JavaScript also solves it:</p>
<pre><code>window.onunload = function(){};
</code></pre>
<p>That is, if your menu is JavaScript, then you might prefer to solve this issue with JavaScript too.</p>
<p>The unload event handler definition idea came from this Firefox 1.5 article: <a href="https://developer.mozilla.org/en/Using_Firefox_1.5_caching" rel="noreferrer">https://developer.mozilla.org/en/Using_Firefox_1.5_caching</a>.</p>
|
<p>Had the same problem on iPad.</p>
<p>Not that beautiful but it works :). How it works.</p>
<p>I realised that on iPad Safari, the page was not reloaded when the back button was pressed. I put a counter every second on the page and I save the current timestamp.</p>
<p>When the page is loaded the counter and time are synchronized. On back button, counter continue where it stopped and there is a gap between timestamp and counter. If the gap is grater than 500ms, force reload the page.</p>
<p>In the file action.js</p>
<pre><code>var showLoadingBoxSetIntervalVar;
var showLoadingBoxCount = 0;
var showLoadingBoxLoadedTimestamp = 0
function showLoadingBox(text) {
var showLoadingBoxSetIntervalVar=self.setInterval(function(){showLoadingBoxIpadRelaod()},1000);
showLoadingBoxCount = 0
showLoadingBoxLoadedTimestamp = new Date().getTime();
//Here load the spinner
}
function showLoadingBoxIpadRelaod()
{
//Calculate difference between now and page loaded time minus threshold 500ms
var diffTime = ( (new Date().getTime()) - showLoadingBoxLoadedTimestamp - 500)/1000;
showLoadingBoxCount = showLoadingBoxCount + 1;
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if(diffTime > showLoadingBoxCount && isiPad){
location.reload();
}
}
</code></pre>
| 4,384
|
<p>What does it mean if a task is declared with the automatic keyword in Verilog?</p>
<pre><code>task automatic do_things;
input [31:0] number_of_things;
reg [31:0] tmp_thing;
begin
// ...
end
endtask;
</code></pre>
<p>Note: This question is mostly because I'm curious if there are any hardware programmers on the site. :)</p>
|
<p>It means that the task is re-entrant - items declared within the task are dynamically allocated rather than shared between different invocations of the task.</p>
<p>You see - some of us do Verilog... (ugh)</p>
|
<p>In computing, a computer program or subroutine is called re-entrant if multiple invocations can safely run concurrently (Wikipedia).
In simple words, the keyword automatic makes it safe, when multiple instances of a task run at a same time.
:D</p>
| 5,559
|
<p>What would be the easiest way to separate the directory name from the file name when dealing with <code>SaveFileDialog.FileName</code> in C#?</p>
|
<p>Use:</p>
<pre><code>System.IO.Path.GetDirectoryName(saveDialog.FileName)
</code></pre>
<p>(and the corresponding <code>System.IO.Path.GetFileName</code>). The Path class is really rather useful.</p>
|
<p>Since the forward slash is not allowed in the filename, one simple way is to divide the SaveFileDialog.Filename using String.LastIndexOf; for example:</p>
<pre><code>string filename = dialog.Filename;
string path = filename.Substring(0, filename.LastIndexOf("\"));
string file = filename.Substring(filename.LastIndexOf("\") + 1);
</code></pre>
| 3,700
|
<p>For my Ender 3 Pro I bought this touch sensor set <a href="https://tr.aliexpress.com/item/4001209045993.html?spm=a2g0s.9042311.0.0.68ea4c4d3CjwfW" rel="nofollow noreferrer">Chinese clone BLTouch set</a> and changed the printer's firmware to the latest TH3D firmware (first I tried with Creality's original BLTouch firmware but after 4 hours, I never managed to set a correct Z offset, I believe there is a bug or this BLTouch clone isn't compatible with Creality firmware).</p>
<p>After installing TH3D, found the right Z offset, when I print items like <a href="https://www.thingiverse.com/thing:3476490" rel="nofollow noreferrer">this one</a> which stays at the center everything just perfect it sticks well, no strings, strong lines.</p>
<p>But if I try to print something <a href="https://www.thingiverse.com/thing:2973856" rel="nofollow noreferrer">like this</a> which is using almost all the printing table from corner to corner (I need to rotate the print 45° to fit onto the build platform), it's good on center or near to center but not sticking on the corners and first lines are sticking to nozzle (because at the far corners, the nozzle is too far or too close) and makes a mess.</p>
<p>I powered off the printer and adjusted the good old way (with a paper) and re-setted the Z offset accordingly but the result is the same.</p>
<p>According to my research some peoples advised you need to add <code>G29</code> after <code>G28</code> to your G-code to get proper solution, I added the code in Cura. When I try adding <code>G29</code>, the printer starts leveling after starting printing, but the "not sticking problem at the corners" still continues.</p>
<p>I tried with both magnetic bed & glass bed, but nothing helped. I was using 200 °C for the nozzle and 60nbsp;°C for the bed, printing speed is 50nbsp;mm/s with Standart quality 0.2nbsp;mm, retraction enabled, mostly using 10nbsp;% infill on my models.</p>
<p>I thougt maybe filament causes this problem, changed filament to another roll but not helped, I also have an Ender 3 V2 (no BLTouch) and tried same model, same filament, same settings on V2 printed perfectly.</p>
<p>This is how my bed looks like according to OctoPrint bed visualizer plugin;</p>
<p><a href="https://i.stack.imgur.com/u8YQH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u8YQH.png" alt="enter image description here" /></a></p>
<p>I've watched many tutorial videos and some said you need to adjust your bed with spirit level to make sure it's flat, I even did that and it is just perfectly flat.</p>
<p>I've installed the BLTouch clone 1 week ago and I'm struggling with this problem since then, I believe I'm missing something very obvious or making a realy simple mistake because many people use touch sensors and they are all happy with auto bed leveling.</p>
|
<p>Following <a href="https://3dprinting.stackexchange.com/a/14765/5740">Nathan's</a> answer, I've solved my problem with Nathan's suggestions and the method in <a href="https://www.youtube.com/watch?v=W8ouBPnRV4s&ab_channel=cheule" rel="nofollow noreferrer">this video</a>.</p>
<p>What I did?</p>
<ol>
<li>Flashed Creality's original BLTouch firmware to printer</li>
<li>Heated up bed to 60 °C</li>
<li>Leveled bed the old fashion way first, but with slight resistance (you don't have to level perfectly)</li>
<li>Followed the youtube method to find proper Z offset</li>
<li>Opened Cura, Settings->Printer->Manage Printers: and added <code>G29; ABL</code> after <code>G28</code>
<a href="https://i.stack.imgur.com/dpOtR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dpOtR.png" alt="enter image description here" /></a></li>
</ol>
<p>Voilâ, now your printer prints perfectly! Enjoying the relieving after 1 week of struggling.</p>
|
<p>I would suggest you read <a href="https://www.reddit.com/r/ender3/comments/jdd2nf/for_some_reason_my_bltouch_isnt_working_quite_as/g9amvfn/?context=3" rel="nofollow noreferrer">this</a>, even tho it's a different mainboard it may help.</p>
<p>Next to that you should level the bed the old fashion way first with a paper on the 4 outer corners, it is essential that you do this because ABL can only compensate so much when printing. After that set the Z-offset using a paper and run some bed adhesion test prints and use babysteps.</p>
<p>Level and probe your bed with it being heated up to 60 °C for PLA and 80 °C for PETG, the thermal expansion of the bed can easily mess up the probe data you already have!</p>
<p>Also make sure your ABL functions as Z-endstop; it solved all the issues for me.</p>
<hr />
<p><em>If you ever want to upgrade your mainboard for some reason I can highly recommend the SKR mini E3 V2 it has great support for additional sensors.</em></p>
| 1,773
|
<p>I am wondering if anyone has any experience using a JQuery plugin that converts a html </p>
<pre><code><select>
<option> Blah </option>
</select>
</code></pre>
<p>combo box into something (probably a div) where selecting an item acts the same as clicking a link.</p>
<p>I guess you could probably use javascript to handle a selection event (my javascript knowledge is a little in disrepair at the moment) and 'switch' on the value of the combo box but this seems like more of a hack.</p>
<p>Your advice, experience and recommendations are appreciated.</p>
|
<p>The simple solution is to use</p>
<pre><code>$("#mySelect").change(function() {
document.location = this.value;
});
</code></pre>
<p>This creates an onchange event on the select box that redirects you to the url stored in the value field of the selected option.</p>
|
<p>This bit of javascript in the 'select':</p>
<pre><code>onchange="if(this.options[this.selectedIndex].value!=''){this.form.submit()}"
</code></pre>
<p>It's not ideal (because form submissions in ASP.NET MVC which I'm using don't appear to use the routing engine for URLs) but it does its job.</p>
| 7,141
|
<p>I have a big string (let's call it a CSV file, though it isn't actually one, it'll just be easier for now) that I have to parse in C# code.<br>
The first step of the parsing process splits the file into individual lines by just using a <code>StreamReader</code> object and calling <code>ReadLine</code> until it's through the file. However, any given line might contain a quoted (in single quotes) literal with embedded newlines. I need to find those newlines and convert them temporarily into some other kind of token or escape sequence until I've split the file into an array of lines..then I can change them back. </p>
<p>Example input data: </p>
<pre><code>1,2,10,99,'Some text without a newline', true, false, 90
2,1,11,98,'This text has an embedded newline
and continues here', true, true, 90
</code></pre>
<p>I could write all of the C# code needed to do this by using <code>string.IndexOf</code> to find the quoted sections and look within them for newlines, but I'm thinking a Regex might be a better choice (i.e. <a href="http://regex.info/blog/2006-09-15/247" rel="nofollow noreferrer">now I have two problems</a>)</p>
|
<p>Since this isn't a true CSV file, does it have any sort of schema?</p>
<p>From your example, it looks like you have:
int, int, int, int, string , bool, bool, int</p>
<p>With that making up your record / object.</p>
<p>Assuming that your data is well formed (I don't know enough about your source to know how valid this assumption is); you could:</p>
<ol>
<li>Read your line.</li>
<li>Use a state machine to parse your data.</li>
<li>If your line ends, and you're parsing a string, read the next line..and keep parsing.</li>
</ol>
<p>I'd avoid using a regex if possible.</p>
|
<p><strong>EDIT:</strong> Sorry, I've misinterpreted your post. If you're looking for a regex, then here is one:</p>
<pre><code>content = Regex.Replace(content, "'([^']*)\n([^']*)'", "'\1TOKEN\2'");
</code></pre>
<p>There might be edge cases and that two problems but I think it should be ok most of the time. What the Regex does is that it first finds any pair of single quotes that has \n between it and replace that \n with TOKEN preserving any text in-between.</p>
<p>But still, I'd go state machine like what @bryansh explained below.</p>
| 5,303
|
<p>There are lots of widgets provided by sites that are effectively bits of JavaScript that generate HTML through <em>DOM</em> manipulation or <code>document.write()</code>. Rather than slow the browser down even more with additional requests and trust yet another provider to be fast, reliable and not change the widget output, I want to execute* the JavaScript to generate the rendered HTML, and then save that HTML source.</p>
<p>Things I've looked into that seem unworkable or way too difficult:</p>
<ol>
<li>The Links Browser (<em>not lynx!</em>)</li>
<li>Headless use of Xvfb plus Firefox plus Greasemonkey (<em>yikes</em>)</li>
<li>The all-Java browser toolkit Cobra (<em>the best bet!</em>) </li>
</ol>
<p>Any ideas? </p>
<p>** Obviously you can't really execute the JavaScript completely, as it doesn't necessarily have an exit path, but you get the idea.</p>
|
<p>Wikipedia's <a href="http://en.wikipedia.org/wiki/Server-side_JavaScript" rel="nofollow noreferrer">"Server-side JavaScript"</a> article lists numerous implementations, many of which are based on Mozilla's <strong>Rhino</strong> JavaScript-to-Java converter, or its cousin <strong>SpiderMonkey</strong> (the same engine as found in Firefox and other Gecko-based browsers). In particular, something simple like <a href="http://www.modjs.org/" rel="nofollow noreferrer"><strong>mod_js</strong></a> for Apache may suit your needs.</p>
|
<p>If you're just using plain JS, <a href="http://www.mozilla.org/rhino/" rel="nofollow noreferrer">Rhino</a> should do the trick. But if the JS code is actually calling DOM methods and so on, you're going to need a full-blown browser. <a href="http://simile.mit.edu/wiki/Crowbar" rel="nofollow noreferrer">Crowbar</a> might help you.</p>
<p>Is this really going to make things faster for users without causing compatibility issues?</p>
| 3,576
|
<p>As I learn more and more about OOP, and start to implement various design patterns, I keep coming back to cases where people are hating on <a href="http://en.wikipedia.org/wiki/Active_record_pattern" rel="noreferrer">Active Record</a>.</p>
<p>Often, people say that it doesn't scale well (citing Twitter as their prime example) -- but nobody actually explains <strong><em>why</em></strong> it doesn't scale well; and / or how to achieve the pros of AR without the cons (via a similar but different pattern?)</p>
<p>Hopefully this won't turn into a holy war about design patterns -- all I want to know is ****specifically**** what's wrong with Active Record.</p>
<p>If it doesn't scale well, why not?</p>
<p>What other problems does it have?</p>
|
<p>There's <a href="http://en.wikipedia.org/wiki/Active_record_pattern" rel="noreferrer">ActiveRecord the Design Pattern</a> and <a href="http://api.rubyonrails.com/classes/ActiveRecord/Base.html" rel="noreferrer">ActiveRecord the Rails ORM Library</a>, and there's also a ton of knock-offs for .NET, and other languages.</p>
<p>These are all different things. They mostly follow that design pattern, but extend and modify it in many different ways, so before anyone says "ActiveRecord Sucks" it needs to be qualified by saying "which ActiveRecord, there's heaps?"</p>
<p>I'm only familiar with Rails' ActiveRecord, I'll try address all the complaints which have been raised in context of using it.</p>
<blockquote>
<p>@BlaM</p>
<p>The problem that I see with Active Records is, that it's always just about one table</p>
</blockquote>
<p>Code:</p>
<pre><code>class Person
belongs_to :company
end
people = Person.find(:all, :include => :company )
</code></pre>
<p>This generates SQL with <code>LEFT JOIN companies on companies.id = person.company_id</code>, and automatically generates associated Company objects so you can do <code>people.first.company</code> and it doesn't need to hit the database because the data is already present.</p>
<blockquote>
<p>@pix0r</p>
<p>The inherent problem with Active Record is that database queries are automatically generated and executed to populate objects and modify database records</p>
</blockquote>
<p>Code:</p>
<pre><code>person = Person.find_by_sql("giant complicated sql query")
</code></pre>
<p>This is discouraged as it's ugly, but for the cases where you just plain and simply need to write raw SQL, it's easily done.</p>
<blockquote>
<p>@Tim Sullivan</p>
<p>...and you select several instances of the model, you're basically doing a "select * from ..."</p>
</blockquote>
<p>Code:</p>
<pre><code>people = Person.find(:all, :select=>'name, id')
</code></pre>
<p>This will only select the name and ID columns from the database, all the other 'attributes' in the mapped objects will just be nil, unless you manually reload that object, and so on.</p>
|
<p>The problem that I see with Active Records is, that it's always just about <strong>one</strong> table. That's okay, as long as you really work with just that one table, but when you work with data in most cases you'll have some kind of join somewhere.</p>
<p>Yes, <strong>join</strong> usually is worse than <strong>no join at all</strong> when it comes to performance, but <strong>join</strong> <em>usually</em> is better than <strong>"fake" join</strong> by first reading the whole table A and then using the gained information to read and filter table B.</p>
| 2,941
|
<p>I have a problem with a little .Net web application which uses the Amazon webservice. With the integrated Visual Studio web server everything works fine. But after deploying it to the IIS on the same computer i get the following error message:</p>
<pre><code>Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach
einer bestimmten Zeitspanne nicht ordnungsgemäß reagiert hat, oder
die hergestellte Verbindung war fehlerhaft, da der verbundene Host
nicht reagiert hat 192.168.123.254:8080
</code></pre>
<p>Which roughly translates to "cant connect to 192.168.123.254:8080"</p>
<p>The computer is part of an Active Directory. The AD-Server was installed on a network which uses 192.168.123.254 as a proxy. Now it is not reachable and should not be used.</p>
<p><strong>How do I prevent the IIS from using a proxy?</strong></p>
<p>I think it has something to do with policy settings for the Internet Explorer. An "old" AD user has this setting, but a newly created user does not. I checked all the group policy settings and nowhere is a proxy defined.</p>
<p>The web server is running in the context of the anonymous internet user account on the local computer. Do local users get settings from the AD? If so how can I change that setting, if I cant login as this user?</p>
<p>What can I do, where else i could check?</p>
|
<p>Proxy use can be configured in the web.config.
The system.net/defaultProxy element will let you specify whether a proxy is used by default or provide a bypass list.</p>
<p>For more info see: <a href="http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx" rel="noreferrer"><a href="http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx</a></a></p>
|
<p>IIS is a destination. The configuration issue is in whatever is doing the call (acting like a client). If you are using the built-in .Net communication methods you will need to make the adjustment inside of ... Wait for it ... Internet Explorer. </p>
<p>Yep! That little bugger has bitten me more times than I care to remember. I used to have to switch the proxy server settings in IE 5 or 6 times a day as I switched between internal and external servers. Newer versions of IE have a much better "don't use proxy server" set of rules.</p>
<p>-- Clarification --
As it seems that the user ID used by IIS is using this setting, you'll probably need to search the registry for where the proxy information is stored for each user ID and/or the default.</p>
| 8,642
|
<p>The following code works great in IE, but not in FF or Safari. I can't for the life of me work out why. The code is <em>supposed</em> to disable radio buttons if you select the "Disable 2 radio buttons" option. It should enable the radio buttons if you select the "Enable both radio buttons" option. These both work...</p>
<p>However, if you don't use your mouse to move between the 2 options ("Enable..." and "Disable...") then the radio buttons do not appear to be disabled or enabled correctly, until you click anywhere else on the page (not on the radio buttons themselves).</p>
<p>If anyone has time/is curious/feeling helpful, please paste the code below into an html page and load it up in a browser. It works great in IE, but the problem manifests itself in FF (3 in my case) and Safari, all on Windows XP.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function SetLocationOptions() {
var frmTemp = document.frm;
var selTemp = frmTemp.user;
if (selTemp.selectedIndex >= 0) {
var myOpt = selTemp.options[selTemp.selectedIndex];
if (myOpt.attributes[0].nodeValue == '1') {
frmTemp.transfer_to[0].disabled = true;
frmTemp.transfer_to[1].disabled = true;
frmTemp.transfer_to[2].checked = true;
} else {
frmTemp.transfer_to[0].disabled = false;
frmTemp.transfer_to[1].disabled = false;
}
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><form name="frm" action="coopfunds_transfer_request.asp" method="post">
<select name="user" onchange="javascript: SetLocationOptions()">
<option value="" />Choose One
<option value="58" user_is_tsm="0" />Enable both radio buttons
<option value="157" user_is_tsm="1" />Disable 2 radio buttons
</select>
<br /><br />
<input type="radio" name="transfer_to" value="fund_amount1" />Premium&nbsp;&nbsp;&nbsp;
<input type="radio" name="transfer_to" value="fund_amount2" />Other&nbsp;&nbsp;&nbsp;
<input type="radio" name="transfer_to" value="both" CHECKED />Both
<br /><br />
<input type="button" class="buttonStyle" value="Submit Request" />
</form></code></pre>
</div>
</div>
</p>
|
<p>To get FF to mimic IE's behavior when using the keyboard, you can use the keyup event on the select box. In your example (I am not a fan of attaching event handlers this way, but that's another topic), it would be like this:</p>
<pre><code><select name="user" id="selUser" onchange="javascript:SetLocationOptions()" onkeyup="javascript:SetLocationOptions()">
</code></pre>
|
<p>Why not grab one of the AJAX scripting libraries, they abstract away a lot of the cross browser DOM scripting black magic and make life a hell of a lot easier.</p>
| 2,819
|
<p>I'm designing a mount for a cylindrical speaker to attach to my bicycle. It will mount on the bottle cages. I've printed a few iterations with various infill settings (using PLA) and the weak point is always the bolts holding the entire mount to the bike. They can't handle the compression needed to secure it properly. I had thought about using an imbedded metal part to distribute the load, but it's not easily replicable and I want to make the design public and fairly accessible to others with the same speaker. I currently have PETG and ABS, would one of those perform better or should I order a specialty high strength polymer? </p>
|
<ol>
<li><p>Infill has minimal effect on the strength of printed parts, so I would expect the part to break in the same spot regardless of what infill percentage you used. </p></li>
<li><p>PLA is especially poor in this exact application, and it undergoes significant creep/cold flow under mechanical compression over time, so even if achieved the necessary strength by changing settings (which you can), it would require that you periodically tighten the bolts more and more, as the PLA would slowly deform under the mounting pressure.</p></li>
</ol>
<p>Perimeter width and number of perimeters are what primarily influence the strength of a printed object, infill has very little impact on strength in comparison, and unless you're using an exotic pattern like gyroid, what impact it does have is not even close to isotropic (will add strength in some directions while doing nothing in others). But even then, infill only really has an effect when we are talking about forces that are spread evenly over the entire object, not concentrated strength of a specific spot of the part. And that effect is always much weaker than what perimeter count or width will have.</p>
<p>Just <strong>bump up your perimeters to 4</strong> or even more and that should make a huge difference. </p>
<p>And also, don't use PLA. <strong>I think PETG is a much better choice in this situation.</strong> It is more ductile only slightly less rigid than PLA, making it much more durable overall than PLA, and less prone to cracking under compressive forces. PLA theoretically has higher tensile strength, but that often doesn't mean much. </p>
<p>I would not recommend ABS, it tends to have similar issues with brittleness and is one of the weaker materials one can 3D print. </p>
<p>It terms of ordering a special high strength polymer.... unless printer and hotend is rated for in excess of 400°C, no such 'high strength polymer' exists, at least not that you can print. PLA and PETG are close to the best you can get, with Polycarbonate inching out ahead but not by a huge amount (~20%). Despite what filament companies would like you to believe, carbon fiber <strong><em>reduces</em></strong> the strength of PLA, ABS, PETG, PC, and probably nylon, and instead simply makes those polymers more rigid and increases dimensional stability. The only filaments that would actually be made stronger with added fibers short enough for filament manufacturing processes are ones with glass fiber. But you don't want to print those filaments, trust me. They will dull the teeth on your hobbed gear(s), even if made from steel, and will just ruin all but ruby nozzles very very quickly. And they <strong>still wear out ruby nozzles</strong> even then. </p>
<p>There are exotic polymers, but none of them print at less than ~350°C, and are generally exceedingly expensive. All the polymers that can be used at normal printing temperatures are all fairly similar to each other in terms of tensile strength at least. </p>
|
<p>Try heating op your PLA while mounting it. The PLA wil temporarily weaken and will become a bit moldable. PETG is a bit more brittle than PLA is my experience so I'd say stick to PLA. Otherwise you might try Arnitel ECO. I can try to find an amazon purchase link for you if you want. Anyway, it is more rubber like and stays flexible, it will never crack but depending on your design it might become a bit more wobbly. If you share a picture of your design or an STL i might be able to help you a bit better.</p>
| 1,526
|
<p>Does anyone know how to debug <code>JSP</code> in <strong>IntelliJ</strong> IDEA?</p>
<p>When I set breakpoint in my <code>JSP</code> files, those breakpoints never seem to take effect. The debugger never hits them. IDEA seems to think that the breakpoints are valid. I do see a red dot placed to the left of the line where I place my breakpoint.</p>
<p>I read in IntelliJ forum <a href="http://intellij.net/forums/thread.jspa;jsessionid=2B86A25AECC06A4BE3447388882AA79F?messageID=5218405&#5218405" rel="noreferrer">in this post</a> that <code>JSP</code> files need to be under web-inf for debugging to work. </p>
<p>But then I also read that <code>JSP</code> files placed under web-inf won't be directly accessible by the user.</p>
<p>I am not sure who's really right. </p>
|
<p>For JSP debugging in Intellij there are some configurations that must be in order. The fact that Intellij always allows you to add a breakpoint on a JSP line does not necessarily imply that you’ve configured JSP debugging. In the following I refer to Intellij 8 configuration, w.r.t. previous versions you will need to do similar operations as the concepts are the same.</p>
<p>In order to enable JSP debugging you must do two steps: set a web application configuration in your project and add a web application server configuration.</p>
<p><em>Web application Configuration</em>: in order to have JSP debugging, you must have a “web” facet in your project structure, pointing to the correct web.xml file. Depending on the kind of web application structure you are using, the facet may be detected automatically by Intellij (go anyway to check what it has done) or you may have to add it manually. Remember in the “Java EE build settings” tab to set as anable “Create web facet exploded directory”; if you don’t want duplications, a trick is just to enable it and point to your already existing directory.</p>
<p><em>(Web) Application server</em>: Go to “edit configurations”, there you have to add to configurations an application server, not launch the web server as an application like any other. In this way Intellij will be able to intercept JSP calls. In the list of application servers, you should have the default one, Tomcat. Be sure to have a local Tomcat installation before you do this, and point to that when adding the web application server. The last trick is going to the “Deployment” tab and selecting as “Deployment source” the same facet that you configured in the previous step.</p>
<p>The same configuration works if you want to use another web application server, I tested it with the latest Caucho Resin releases and debugging works fine (it didn’t with the previous Intellij and Resin combinations).</p>
<p>If you don’t see Tomcat in the list of available application servers to add, check the plugins in the general Intellij settings pane: in the latest releases, more and more functionality has become “pluggable”, and even very basic functions may be disabled; this plugin is called “Tomcat integration”.</p>
<p>Finally, it is surely not true that JSP files need to be under WEB-INF to be under debugging.</p>
|
<p>For the second part of your question ("jsp files placed under web-inf won't be directly accessible by user") that is correct. To allow users to access JSP files in the WEB-INF folder servlet and servlet-mapping entries need to be made in the web.xml file for each JSP page. </p>
| 5,381
|
<p>I am currently developing a Drupal webpage using PDT. When running without XDebug, the site works fine.</p>
<p>When I enable XDebug, the site works fine but opens up tons of Javascript errors that I need to click through.</p>
<p>Example:</p>
<p>A Runtime Error has occurred.
Do you wish to Debug?</p>
<p>Line: 1
Error: Syntax error</p>
<p>--</p>
<p>It seems to only be a problem when XDebug/PDT uses Firefox as its browser, this problem does not occur when using IE. Could it be some incompatability with Firebug?</p>
|
<p>here is how to solve this problem:</p>
<p>Turn off XDebug output capture:</p>
<p>Window -> Preferences, expand PHP, expand Debug, select "Installed Debuggers", choose "XDebug", click "Configure" on the right to bring up the configure dialog. In the middle "Output Capture Settings", set "Capture stdout" to "Off".</p>
|
<p>This is a bit of a guess, but try
Windows => Preferences => JavaScript => Include Path</p>
| 9,131
|
<p>We have some input data that sometimes appears with &nbsp characters on the end.</p>
<p>The data comes in from the source system as varchar() and our attempts to cast as decimal fail b/c of these characters.</p>
<p>Ltrim and Rtrim don't remove the characters, so we're forced to do something like:</p>
<pre><code>UPDATE myTable
SET myColumn = replace(myColumn,char(160),'')
WHERE charindex(char(160),myColumn) > 0
</code></pre>
<p>This works for the &nbsp, but is there a good way to do this for any non-alphanumeric (or in this case numeric) characters?</p>
|
<p><a href="http://www.lazydba.com/sql/1__4390.html" rel="noreferrer">This page</a> has a sample of how you can remove non-alphanumeric chars:</p>
<pre><code>-- Put something like this into a user function:
DECLARE @cString VARCHAR(32)
DECLARE @nPos INTEGER
SELECT @cString = '90$%45623 *6%}~:@'
SELECT @nPos = PATINDEX('%[^0-9]%', @cString)
WHILE @nPos > 0
BEGIN
SELECT @cString = STUFF(@cString, @nPos, 1, '')
SELECT @nPos = PATINDEX('%[^0-9]%', @cString)
END
SELECT @cString
</code></pre>
|
<p>For large datasets I have had better luck with this function that checks the ASCII value. I have added options to keep only alpha, numeric or alphanumeric based on the parameters.</p>
<pre><code>--CleanType 1 - Remove all non alpanumeric
-- 2 - Remove only alpha
-- 3 - Remove only numeric
CREATE FUNCTION [dbo].[fnCleanString] (
@InputString varchar(8000)
, @CleanType int
, @LeaveSpaces bit
) RETURNS varchar(8000)
AS
BEGIN
-- // Declare variables
-- ===========================================================
DECLARE @Length int
, @CurLength int = 1
, @ReturnString varchar(8000)=''
SELECT @Length = len(@InputString)
-- // Begin looping through each char checking ASCII value
-- ===========================================================
WHILE (@CurLength <= (@Length+1))
BEGIN
IF (ASCII(SUBSTRING(@InputString,@CurLength,1)) between 48 and 57 AND @CleanType in (1,3) )
or (ASCII(SUBSTRING(@InputString,@CurLength,1)) between 65 and 90 AND @CleanType in (1,2) )
or (ASCII(SUBSTRING(@InputString,@CurLength,1)) between 97 and 122 AND @CleanType in (1,2) )
or (ASCII(SUBSTRING(@InputString,@CurLength,1)) = 32 AND @LeaveSpaces = 1 )
BEGIN
SET @ReturnString = @ReturnString + SUBSTRING(@InputString,@CurLength,1)
END
SET @CurLength = @CurLength + 1
END
RETURN @ReturnString
END
</code></pre>
| 7,555
|
<p>There are many options for editing and writing Stored Procedures in Oracle; what is the best tool for you and why? (one tool per answer.)</p>
|
<p><a href="http://www.toadsoft.com/lic_agree.html" rel="nofollow noreferrer"><strong>T</strong>ool for <strong>O</strong>racle <strong>A</strong>pplication <strong>D</strong>evelopers (TOAD)</a>, from <a href="http://www.quest.com/" rel="nofollow noreferrer">Quest Software</a> (formerly <a href="http://www.toadsoft.com/" rel="nofollow noreferrer">TOADSoft</a>) has an excellent Stored Procedure editor with syntax highlighting, some autocomplete support (e.g. type in '<code>TABLE.</code>' and the columns will appear), a nice Execute Procedure option that will show the results in a Grid or show DBMS output, and will also focus on syntax errors when you hit compile.</p>
<p><em>Note:</em> The Freeware edition only allows 2 concurrent connections to the same Database Instance (even though the website says 5) - that means only 2 developers or DBA's can use it at the same time on the same Database. It also expires every 3 months but they're good at releasing updates.</p>
|
<p>I just used a standard editor (vim which then gave me syntax highlighting).</p>
<p>/Allan</p>
| 9,516
|
<p>Given a latitude and longitude, what is the easiest way to find the name of the city and the US zip code of that location.</p>
<p>(This is similar to <a href="https://stackoverflow.com/questions/23572/latitude-longitude-database">https://stackoverflow.com/questions/23572/latitude-longitude-database</a>, except I want to convert in the opposite direction.)</p>
<hr>
<p>Related question: <a href="https://stackoverflow.com/questions/158557/get-street-address-at-latlong-pair">Get street address at lat/long pair</a></p>
|
<p>This is the web service to call.
<a href="http://developer.yahoo.com/search/local/V2/localSearch.html" rel="nofollow noreferrer">http://developer.yahoo.com/search/local/V2/localSearch.html</a></p>
<p>This site has ok web services, but not exactly what you're asking for here.
<a href="http://www.usps.com/webtools/" rel="nofollow noreferrer">http://www.usps.com/webtools/</a></p>
|
<p>geonames has an extensive set of ws that can handle this (among others):
<br><br>
<a href="http://www.geonames.org/export/web-services.html#findNearbyPostalCodes" rel="nofollow noreferrer">http://www.geonames.org/export/web-services.html#findNearbyPostalCodes</a><br>
<a href="http://www.geonames.org/export/web-services.html#findNearbyPlaceName" rel="nofollow noreferrer">http://www.geonames.org/export/web-services.html#findNearbyPlaceName</a></p>
| 5,081
|
<p>I am currently building in Version 3.5 of the .Net framework and I have a resource (.resx) file that I am trying to access in a web application. I have exposed the .resx properties as public access modifiers and am able to access these properties in the controller files or other .cs files in the web app. My question is this: Is it possible to access the name/value pairs within my view page? I'd like to do something like this...</p>
<pre><code>text="<%$ Resources: Namespace.ResourceFileName, NAME %>"
</code></pre>
<p>or some other similar method in the view page.</p>
|
<pre class="lang-cs prettyprint-override"><code><%= Resources.<ResourceName>.<Property> %>
</code></pre>
|
<p>If you are using ASP.NET 2.0 or higher, after you compile with the resource file, you can reference it through the Resources namespace:</p>
<pre><code>text = Resources.YourResourceFilename.YourProperty;
</code></pre>
<p>You even get Intellisense on the filenames and properties.</p>
| 8,852
|
<p><a href="http://www.devexpress.com/Products/NET/ORM/" rel="noreferrer">XPO</a> is the object relational mapper of choice at my company. Any thoughts on the pros and cons?</p>
<hr>
<p>I was just looking for general feeling and anecdotes about the product. We are not switching to XPO. We are just getting rid of hard coded sql strings living in the app and moving completely to ORM for all data access.</p>
|
<p>Others will probably pitch in with technical answers (e.g. the query syntax, use of caching, ease or otherwise of mapping to an existing database structure) -- but if you have an established ORM layer the answer is probably </p>
<p>"Why change"?</p>
<p>I've used XPO successfully for years in an established commercial product with several hundred users. I find that it's fast, flexible and does the job. I don't see any need to change at the moment, as our data volumes aren't particularly large and the foibles (caching, mostly) are things we can work around. </p>
<p>If I were starting afresh I'd definitely look at both NHibernate and the ADO.NET Entity Framework. In practice, though, all are good; I'd most likely look at the commercial situation for the project ahead of the technical questions. </p>
<p>For instance, NHibernate is open-source -- is there a viable community there to support the tool and to provide (if necessary) commercial support? </p>
<p>XPO comes from a tools vendor, are they likely to remain in business for the lifetime of the product? </p>
<p>ADO.NET Entity Framework comes from Microsoft, who are notorious for changing database technologies more often then Larry fills his fighter with jet fuel -- will this, too, fade away?</p>
|
<p>The pros and cons compared to what? There are a lot of alternatives out there, the most popular being nHibernate, with the new kid 'ADO.NET Entity Framework' on the block.</p>
<p>Anyways, there are hundreds of answers depending on your situation and requirements.</p>
| 5,150
|
<p>Is it really viable to use GCJ to publish server-side applications? Webapps? </p>
<p>My boss is convinced that compiling our (<strong><em>my</em></strong>) webapp into a binary executable is a brilliant idea. (Then again, he likes nice, small simple things with blinky lights that he can understand.) He instinctively sees no issues with this, while I only see an endless series of problems and degradations. Once I start talking to him about the complexity of our platform, and more in depth specifics of byte code, JVMs, libraries, differences between operating systems, processor architectures, etc...well...his eyes glaze over, he smiles and he has made it clear he thinks I'm being childishly resistive.</p>
<p>Why does he want a single magic executable? He sees a couple of "benefits":</p>
<ul>
<li>If it is a binary executable, then it is hard to reverse engineer and circumvent any licensing. Management lives in constant fear that this is happening, even though we sell into larger corporates who generally do not do cheat with server software. </li>
<li>There is that vision of downloading this magic executable, running it, and everything works. (No more sending me out to do customer installations, which is not that frequent.)</li>
</ul>
<p>So, I've done my obligatory 20 minutes of googling, and now I am here. </p>
<p>A bit of background on my application: </p>
<p><strong>What it is made from:</strong></p>
<ul>
<li>Java 6 (Sun's JVM)</li>
<li>AspectJ 1.6</li>
<li>Tomcat 6</li>
<li>Hibernate 3</li>
<li>Spring 2</li>
<li>another two dozen supporting jar files</li>
</ul>
<p><strong>What it does</strong></p>
<ul>
<li>A streaming media CMS</li>
<li>Performance sensitive</li>
<li>Deployed on Linux, Solaris, Windows (and developed on a Mac)</li>
</ul>
<p>As you can probably gather, I'm highly skeptical of this <em>"compiling Java to native code"</em> thing. It sound like where Mono (VB on Linux) was back in 2000. But am I being overly pessimistic? Is it viable? Should I actually spend the time (days if not weeks) to try this out?</p>
<p>There is one other similar thread (<a href="https://stackoverflow.com/questions/53845/java-compiler-options-to-produce-exe-files">Java Compiler Options to produce .exe files</a>) but it is a bit too simple, the links dated, and not really geared towards a server-side question.</p>
<p>Your informed opinions will be highly cherished, my dear SOpedians! TIA!</p>
|
<p>FWIW: I have never had good luck with GCJ, I have had a lot of problems using it and have had some obscure issues pop up that took forever to diagnose to GCJ rather than me (I am always very very reluctant to blame things on external libraries). I will openly admit this happened several years ago and I have never wanted to go near GCJ again. To give that more substance this was while I was in school and was working on a mostly trivial program so on an <em>"enterprise level"</em> I have had a healthy fear of GCJ.</p>
|
<p>I don't think that a large application like yours will compile to machine code. Remember that java is not only java syntax (might compile to machine code) but also a virtual machine which is more like an application / process environment. I would suggest making an <a href="http://classworlds.codehaus.org/uberjar.html" rel="nofollow noreferrer">uberjar</a> or like that instead.</p>
| 9,071
|
<p>I'm not talking about tools that let one view a page in combinations of operating systems and browsers like crossbrowsertesting.com but in creating or figuring out the actual CSS.</p>
|
<p>If you guys are still coding for IE6, you're making a mistake. </p>
<p>I use <strong>IE7.js</strong> to get IE6 to render pages like IE7. IE7 is not perfect, but at least it has some semblance of standards. Since I only have to code for IE7 and FF it makes me 33% more efficient in terms of testing against browsers, something I think makes good business sense.</p>
<p>Link: <a href="http://code.google.com/p/ie7-js/" rel="nofollow noreferrer">IE7.js</a></p>
|
<p>I write to the standards and both Firefox and IE7 follow a pretty good set in common. </p>
<p>IE6 is dead as far as I am concerned but if I get back into professional web dev I'll probably have to revise that ;)</p>
| 4,570
|
<p>I'm thinking of recycling some filament from a couple of recently failed prints. I can reuse them in the future for basic prototypes, so I'm not concerned with whatever weird mixture of colors come out (they are of a few different colors).</p>
<p>The thing is, I have both PLA and ABS, in small quantities. I originally intended to simply use each one separately, but it occurred to me that they could be mixed.</p>
<p>If I recycle PLA and ABS together into one strand of filament, will there be any negative side effects (e.g. reduced strength)?</p>
|
<p>This is not a good idea. Both filaments have different melting points, that of ABS being much higher than that of PLA. To melt the ABS you have to heat the plastic to the point where the PLA starts to degrade.</p>
|
<p>yes but you would have to experiment with the settings to see were it afectivly melts.</p>
| 140
|
<p>How can I change the title of the command prompt window every time I execute a dos-based program by double clicking it, in c language. Should I use the Windows API?</p>
|
<p>Try <a href="http://msdn.microsoft.com/en-us/library/ms686050.aspx" rel="nofollow noreferrer">SetConsoleTitle</a>.</p>
|
<p>you can do </p>
<p>%comspec% /c start "testtest" %comspec%</p>
<p>at application launcher of Windows+R </p>
| 6,715
|
<p>Grails scaffolding defaults to 10 rows per page. I would like to increase that number without generating the views and changing the 10 in every file. Where do I change the default?</p>
|
<p>You have to install scaffold templates with:</p>
<p>grails install-templates</p>
<p>Now, edit in src/templates/scaffolding Controller.groovy and increase the value params.max as you want</p>
|
<p>Add to the uri:</p>
<pre><code>?max=<num_rows_desired>
</code></pre>
<p>For instance:</p>
<pre><code>http://projecthost:8080/Library/Books/list?max=20
</code></pre>
| 8,234
|
<p>I'd like some sorthand for this:</p>
<pre><code>Map rowToMap(row) {
def rowMap = [:];
row.columns.each{ rowMap[it.name] = it.val }
return rowMap;
}
</code></pre>
<p>given the way the GDK stuff is, I'd expect to be able to do something like:</p>
<pre><code>Map rowToMap(row) {
row.columns.collectMap{ [it.name,it.val] }
}
</code></pre>
<p>but I haven't seen anything in the docs... am I missing something? or am I just way too lazy?</p>
|
<p>I've recently came across the need to do exactly that: converting a list into a map. This question was posted before Groovy version 1.7.9 came out, so the method <a href="http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html#collectEntries(java.lang.Iterable,%20groovy.lang.Closure)" rel="noreferrer"><code>collectEntries</code></a> didn't exist yet. It works exactly as the <code>collectMap</code> method <a href="https://stackoverflow.com/questions/18538/shortcut-for-creating-a-map-from-a-list-in-groovy/19077#19077">that was proposed</a>:</p>
<pre><code>Map rowToMap(row) {
row.columns.collectEntries{[it.name, it.val]}
}
</code></pre>
<p>If for some reason you are stuck with an older Groovy version, the <a href="http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html#inject(java.lang.Object,%20groovy.lang.Closure)" rel="noreferrer"><code>inject</code></a> method can also be used (as proposed <a href="https://stackoverflow.com/questions/18538/shortcut-for-creating-a-map-from-a-list-in-groovy/198614#198614">here</a>). This is a slightly modified version that takes only one expression inside the closure (just for the sake of character saving!):</p>
<pre><code>Map rowToMap(row) {
row.columns.inject([:]) {map, col -> map << [(col.name): col.val]}
}
</code></pre>
<p>The <code>+</code> operator can also be used instead of the <code><<</code>.</p>
|
<p>What about something like this?</p>
<pre><code>// setup
class Pair {
String k;
String v;
public Pair(def k, def v) { this.k = k ; this.v = v; }
}
def list = [ new Pair('a', 'b'), new Pair('c', 'd') ]
// the idea
def map = [:]
list.each{ it -> map.putAt(it.k, it.v) }
// verify
println map['c']
</code></pre>
| 3,910
|
<p>How do I write the results from a mysql query to file? I just need something quick. Output can be CSV, XML, HTML, etc.</p>
|
<pre><code>SELECT a,b,a+b
FROM test_table
INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
</code></pre>
<p>(the docs show INTO OUTFILE up in the SELECT .. portion which may work as well, but I've never tried it that way)
<a href="http://dev.mysql.com/doc/refman/5.0/en/select.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/select.html</a></p>
<p>INTO OUTFILE creates a file on the server; if you are on a client and want it there, do:</p>
<pre><code>mysql -u you -p -e "SELECT ..." > file_name
</code></pre>
|
<p>if you have phpMyAdmin installed, it is a nobrainer: Run the query (haven't got a copy loaded, so I can't tell you the details, but it really is easy) and check neer bottom for export options. CSV will be listed, but I think you can also have SQL if you like :)</p>
<p>phpMyAdmin will give CSV in Excels dialect, which is probably what you want...</p>
| 5,071
|
<p>I'm working on a project were we need more performance. Over time we've continued to evolve the design to work more in parallel(both threaded and distributed). Then latest step has been to move part of it onto a new machine with 16 cores. I'm finding that we need to rethink how we do things to scale to that many cores in a shared memory model. For example the standard memory allocator isn't good enough.</p>
<p>What resources would people recommend? </p>
<p>So far I've found Sutter's column Dr. Dobbs to be a good start.
I just got The Art of Multiprocessor Programming and The O'Reilly book on Intel Threading Building Blocks</p>
|
<p>A couple of other books that are going to be helpful are:</p>
<ul>
<li><a href="https://rads.stackoverflow.com/amzn/click/com/0131972596" rel="noreferrer" rel="nofollow noreferrer" title="Synchronization Algorithms and Concurrent Programming">Synchronization Algorithms and Concurrent Programming</a></li>
<li><a href="https://rads.stackoverflow.com/amzn/click/com/0321228111" rel="noreferrer" rel="nofollow noreferrer" title="Patterns for Parallel Programming">Patterns for Parallel Programming</a></li>
<li><a href="http://www.usingcsp.com/" rel="noreferrer" title="Communicating Sequential Processes">Communicating Sequential Processes</a> by C. A. R. Hoare (a classic, free PDF at that link)</li>
</ul>
<p>Also, consider relying less on sharing state between concurrent processes. You'll scale much, much better if you can avoid it because you'll be able to parcel out independent units of work without having to do as much synchronization between them.</p>
<p>Even if you need to share some state, see if you can partition the shared state from the actual processing. That will let you do as much of the processing in parallel, independently from the integration of the completed units of work back into the shared state. Obviously this doesn't work if you have dependencies among units of work, but it's worth investigating instead of just assuming that the state is always going to be shared.</p>
|
<p>Take a look at <a href="http://www.hoard.org/" rel="nofollow noreferrer">Hoard</a> if you are doing a lot of memory allocation.</p>
<p>Roll your own <a href="http://www.boyet.com/Articles/LockfreeFreeList.html" rel="nofollow noreferrer">Lock Free List</a>. A good resource is here - it's in C# but the ideas are portable. Once you get used to how they work you start seeing other places where they can be used and not just in lists.</p>
| 2,853
|
<p>Some have suggested that filament costs are asymptotically approaching a baseline cost - others that costs are linearly decreasing. Does anyone know where to find the trending costs on a single class of filament over the past decade or more?</p>
<p>Part of the reason we are asking is to get enough longitudinal data to begin projecting costs for printing objects in the future. You might think of it like the "Moore's Law" of filament costs.</p>
|
<p>I'm not clear as to the intent of your question, but I would like to provide some insight. Typically, the biggest differentiating factor between a mediocre data scientist, and a good one, is based on the hypothesis they put forth. Therefore, understanding where the cost of filament is derived from is much more important than analyzing the market price equilibrium over a period of time (Even if done with consideration to various filament types).</p>
<p>Here are some basic costs:</p>
<ul>
<li>Raw material (the cost based on region, and grade)</li>
<li>Manufacturing scale (Mixers, extruders, cooling, spooling, packaging, etc.)</li>
<li>Shipping (Often 50% of cost for small quantities)</li>
<li>Supply chain (Number of middle men)</li>
</ul>
<p>Without going into detail of every preceding point, I was able to break down costs to a theoretical $10/kg for ABS, if starting with virgin pellets, and shipping flat rate USPS within the US. </p>
<p>The point that I am trying to make is, fundamentals over technical analysis in this case.</p>
|
<p>You could have a look though the various price trackers for Amazon (like <a href="http://uk.camelcamelcamel.com/Kg-Yellow-MakerGear-Ultimaker-THING-O-MATIC-Universal/product/B00MVKOSM8?context=browse" rel="nofollow">ccc</a> and <a href="https://thetracktor.com/detail/B010P3EE6W/" rel="nofollow">thetractor</a>), for some basic trends. Most of them does not seem to have sufficient data to give any valuable insight, but that could change.</p>
<p>In general, I would refer to the yearly and monthly <a href="https://www.3dhubs.com/trends" rel="nofollow">trend reports found on 3D Hubs</a>. They usually include the average filament order costs per filament type from the previous 30 days, although they do not display it as a continuous graph at this time.</p>
| 265
|
<p>Is it possible to design a heat block without cartridge heater?</p>
<p>My idea is to build a very small heat block to increase/decrease the heat as fast as possible. The resistance of the heat block will be used. The current to this block is 500mA and is set constant with a circuit. The voltage will be set with pwm. Is this possible with 500mA and 5V (2,5W)?</p>
|
<p>I have a Kill-A-Watt meter so I got a pretty good measurement for you with my Anet A6. Like Petar said each model is different but this should give you a idea. When heating both the nozzle and heat bed the printer consumes 160 W of power, once to temp it backs down to 9 W (it also uses 9 W when just "sitting doing nothing and is on"). When the nozzle and bed get down in temp it hits back up to 160 W. Basically it is never a consistent heating, it is on and off. Like a refrigerator. </p>
<p>When it comes to heating only the nozzle the printer uses 60 W (so 51 W is going to the nozzle for heating).</p>
<p>When it comes to heating only the bed the printer uses 142 W (133 W to the bed).</p>
<p>This is interesting because it would make sense the printer needs more than 160 W when 51 W is going for the nozzle and 142 W going to the bed, that makes 193 W. I make mention of this because that may suggest my power supply is not big enough and the printer could really use around 200 W. </p>
<p>As a little bonus when the printer is moving around (stepper motors are active) I find it using 35-40 W (or 26-31 W) to power the steppers. </p>
<p>So with all the said, is it possible to use a battery? Yes, you could. And to give a example a car battery should have 80 Amp-hours (or something like that, but we will go with it). With that battery you can get 960 Wh (Watt-hours) from the battery before it dies. Going with my printer using 160 W I will get 6 hours of printing time. But keep in mind as the battery is used the voltage will drop, so in the end the printer will be getting something like 10 V which I am sure will affect heating and overall performance. </p>
<p>Last thing I feel that needs to be said. If using a inverter to convert the 12 V battery to 110 V (or whatever voltage you use) a cheap one will not be healthy for the printer. Cheap inverters put out square waves instead of sines waves. Basically it will hurt the printer. You can learn more at this <a href="http://www.zelect.in/inverter/square-wave-inverter-vs-sine-wave-inverter" rel="nofollow noreferrer">WEBSITE</a></p>
<p>"Update" on March 4
I read a comment that mentioned running right off the battery without a battery and then I thought of something that I did not think of before. And that would be protecting the battery itself</p>
<p>So I said you can run the printer off the battery. There was one issue that I had not thought of. And that was the voltage drop and the battery discharged. A battery usually does not have voltage-cut off to keep the battery from being overly discharged, and a printer does not have anything to measure voltage (why should it). So a simple hook up of a 3D printer to a battery is prone to drain the battery much lower than 10 V, which will greatly shorten a battery life-span. This can be prevented two ways. </p>
<p>A circuit between battery and 3D printer. There is plenty of circuits that can be bought as long as they cut power to printer at 10 V or something (for lead acid anyway) and can handle the amperage draw. </p>
<p>An inverter can also be used because this voltage cut off is already in them. But remember that square waves are bad for the printer. </p>
|
<p>To answer the underlying (X-Y) question, yes it is possible to power a small 3D printer from a battery pack. <a href="https://www.3ders.org/articles/20171005-naomi-sexycyborg-wu-3d-prints-on-the-go-with-awesome-wearable-3d-printer.html" rel="nofollow noreferrer">This Article</a> describes a printer built by Naomi Wu, mounted on a frame to carry around whilst printing, as a 'novel' style of sponsored video. The printer here is a BIQU Delta printer, and the power supply is 2x 3Ah batteries (guessing this is @12V, but it's not clear). Presumably there is no heated bed, but still the run-time will be quite limited.</p>
<p>The important part for working out battery life is the duty cycle of the hot-end, not the load required to get it up to temperature. This probably comes to something like 15-30 watts on average, provided you can live without a heated bed.</p>
<p>Of course, if you have 10-15v batteries, the printer will probably run off these directly, no need to waste energy converting up to 110/220V and back again.</p>
| 832
|
<p>I am maintaining an app for a client that is used in two locations. One in England and one in Poland.</p>
<p>The database is stored in England and uses the format £1000.00 for currency, but the information is being gathered locally in Poland where 1000,00 is the format.</p>
<p>My question is, in VB6 is there a function that takes a currency string in a local format and converts to another, or will I just have to parse the string and replace , or . ?</p>
<p>BTW I have looked at CCur, but not sure if that will do what I want. </p>
|
<p>The data is not actually stored as the string <code>"£1000.00"</code>; it's stored in some numeric format.</p>
<blockquote>
<p><strong>Sidebar:</strong> Usually databases are set up to store money amounts using either the <strong>decimal</strong> data type (also called <strong>money</strong> in some DBs), or as a floating point number (also called <strong>double</strong>).</p>
<p>The difference is that when it's stored as <strong>decimal</strong> certain numbers like 0.01 are represented exactly whereas in <strong>double</strong> those numbers can only be stored approximately, causing rounding errors.</p>
</blockquote>
<p>The database <em>appears</em> to be storing the number as <code>"£1000.00"</code> because something is formatting it for display. In VB6, there's a function <code>FormatCurrency</code> which would take a number like 1000 and return a string like <code>"£1000.00"</code>.</p>
<p>You'll notice that the <code>FormatCurrency</code> function does not take an argument specifying what type of currency to use. That's because it, along with all the other locale-specific functions in VB, figures out the currency from the current locale of the system (from the Windows Control Panel).</p>
<p>That means that on my system,</p>
<pre><code>Debug.Print FormatCurrency(1000)
</code></pre>
<p>will print <code>$1,000.00</code>, but if I run that same program on a Windows computer set to the UK locale, it will probably print <code>£1,000.00</code>, which, of course, is something completely different.</p>
<p>Similarly, you've got some code, somewhere, I can't tell where, in Poland, it seems, that is responsible for parsing the user's string and converting it to a number. And if that code is in Visual Basic, again, it's relying on the control panel to decide whether "." or "," is the thousands separator and whether "," or "." is the decimal point.</p>
<p>The function <code>CDbl</code> converts its argument to a number. So for example on my system in the US</p>
<pre><code>Debug.Print CDbl("1.200")
</code></pre>
<p>produces the number one point two, on a system with the Control Panel set to European formatting, it would produce the number one thousand, two hundred.</p>
<p>It's possible that the problem is that you have someone sitting a computer with the regional control panel set to use "." as the decimal separator, but they're typing "," as the decimal separator.</p>
|
<p>What database are you using? And what data type is the amount stored in?</p>
<p>As long as you are always converting from one format to another, you do not need to do any parsing, just replace "." with "," or the other way around. You may need to remove the "£"-sign as well if that is stored in your string.</p>
| 4,017
|
<p>When should I use an interface and when should I use a base class? </p>
<p>Should it always be an interface if I don't want to actually define a base implementation of the methods?</p>
<p>If I have a Dog and Cat class. Why would I want to implement IPet instead of PetBase? I can understand having interfaces for ISheds or IBarks (IMakesNoise?), because those can be placed on a pet by pet basis, but I don't understand which to use for a generic Pet.</p>
|
<p>
Let's take your example of a Dog and a Cat class, and let's illustrate using C#:</p>
<p>Both a dog and a cat are animals, specifically, quadruped mammals (animals are waaay too general). Let us assume that you have an abstract class Mammal, for both of them:</p>
<pre class="lang-cs prettyprint-override"><code>public abstract class Mammal
</code></pre>
<p>This base class will probably have default methods such as:</p>
<ul>
<li>Feed</li>
<li>Mate</li>
</ul>
<p>All of which are behavior that have more or less the same implementation between either species. To define this you will have:</p>
<pre class="lang-cs prettyprint-override"><code>public class Dog : Mammal
public class Cat : Mammal
</code></pre>
<p>Now let's suppose there are other mammals, which we will usually see in a zoo:</p>
<pre class="lang-cs prettyprint-override"><code>public class Giraffe : Mammal
public class Rhinoceros : Mammal
public class Hippopotamus : Mammal
</code></pre>
<p>This will still be valid because at the core of the functionality <code>Feed()</code> and <code>Mate()</code> will still be the same.</p>
<p>However, giraffes, rhinoceros, and hippos are not exactly animals that you can make pets out of. That's where an interface will be useful:</p>
<pre class="lang-cs prettyprint-override"><code>public interface IPettable
{
IList<Trick> Tricks{get; set;}
void Bathe();
void Train(Trick t);
}
</code></pre>
<p>The implementation for the above contract will not be the same between a cat and dog; putting their implementations in an abstract class to inherit will be a bad idea. </p>
<p>Your Dog and Cat definitions should now look like:</p>
<pre class="lang-cs prettyprint-override"><code>public class Dog : Mammal, IPettable
public class Cat : Mammal, IPettable
</code></pre>
<p>Theoretically you can override them from a higher base class, but essentially an interface allows you to add on only the things you need into a class without the need for inheritance.</p>
<p>Consequently, because you can usually only inherit from one abstract class (in most statically typed OO languages that is... exceptions include C++) but be able to implement multiple interfaces, it allows you to construct objects in a strictly <em>as required</em> basis.</p>
|
<p>In addition to those comments that mention the IPet/PetBase implementation, there are also cases where providing an accessor helper class can be very valuable.</p>
<p>The IPet/PetBase style assumes that you have multiple implementations thus increasing the value of PetBase since it simplifies implementation. However, if you have the reverse or a blend of the two where you have multiple clients, providing a class help assist in the usage of the interface can reduce cost by making it easier to use an interface.</p>
| 8,099
|
<p>I have a bunch of classes I want to rename. Some of them have names that are small and that name is reused in other class names, where I don't want that name changed. Most of this lives in Python code, but we also have some XML code that references class names.</p>
<p>Simple search and replace only gets me so far. In my case, I want to rename AdminAction to AdminActionPlug and AdminActionLogger to AdminActionLoggerPlug, so the first one's search-and-replace would also hit the second, wrongly.</p>
<p>Does anyone have experience with Python refactoring tools ? Bonus points if they can fix class names in the XML documents too.</p>
|
<p>In the meantime, I've tried it two tools that have some sort of integration with vim.</p>
<p>The first is <a href="https://github.com/python-rope/rope" rel="noreferrer">Rope</a>, a python refactoring library that comes with a Vim (and emacs) plug-in. I tried it for a few renames, and that definitely worked as expected. It allowed me to preview the refactoring as a diff, which is nice. It is a bit text-driven, but that's alright for me, just takes longer to learn.</p>
<p>The second is <a href="http://bicyclerepair.sourceforge.net/" rel="noreferrer">Bicycle Repair Man</a> which I guess wins points on name. Also plugs into vim and emacs. Haven't played much with it yet, but I remember trying it a long time ago.</p>
<p>Haven't played with both enough yet, or tried more types of refactoring, but I will do some more hacking with them.</p>
|
<p>You can use sed to perform this. The trick is to recall that regular expressions can recognize word boundaries. This works on all platforms provided you get the tools, which on Windows is Cygwin, Mac OS may require installing the dev tools, I'm not sure, and Linux has this out of the box. So grep, xargs, and sed should do the trick, after 12 hours of reading man pages and trial and error ;)</p>
| 4,842
|
<p>I have an HBot 3D 1.1 printer (it's a CoreXY style printer, newer versions are produced by ZMorph). I think that a filament guide tube inside the hotend got damaged, resulting in decreased diameter, which means I can't push the filament through it. It stops halfway through the heatsink (black marker in the attached photo).</p>
<p>I need some help, I'm not sure how to disassemble this type of hotend. With my Ender 3 which I have at home, I can just unscrew the nozzle since it's simply a hexagonal nut, but here it seems that the nozzle and heat block are one part and I don't think I can unscrew the heat block and the heatsink. I'm not sure what to do.</p>
<p>I'm sure the nozzle itself isn't clogged. I've done some cold-pulling on one end, inserted a thin wire from the other, and examined the insides with a flashlight.</p>
<p><a href="https://i.stack.imgur.com/Pkoj3.jpg" rel="nofollow noreferrer" title="Photo of the heat block and nozzle of the HBot 3D printer"><img src="https://i.stack.imgur.com/Pkoj3.jpg" alt="Photo of the heat block and nozzle of the HBot 3D printer" title="Photo of the heat block and nozzle of the HBot 3D printer" /></a></p>
|
<p>This is an old hotend type, it is called a <a href="https://www.google.com/search?q=j+head+nozzle" rel="noreferrer">J-Head</a> (see e.g. the <a href="https://reprap.org/wiki/J_Head_Nozzle#Mk_V" rel="noreferrer">J-Head Nozzle Mk V</a>, I'm unsure which exact version you have). The hotend is serviceable, you can buy separate "nozzles" (with integrated heater block) for it in <a href="https://www.123-3d.nl/3D-printer-onderdelen/Extruder/J-Head-p388.html" rel="noreferrer">some e-shops</a>. You should be able to unscrew the "nozzle" from the PEEK nozzle holder. The milled flat surfaces indicate that you can use a 13 mm or 1/2" open-end wrench to disassemble the PEEK nozzle holder.</p>
<p>The "nozzle":</p>
<p><a href="https://i.stack.imgur.com/a3MXz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/a3MXz.png" alt="enter image description here" /></a></p>
<p>The instruction to assemble such a hotend are:</p>
<blockquote>
<p><strong>Mk V</strong></p>
<ol>
<li>Secure the brass nozzle in a vise by the heater section.</li>
<li>Wrap a couple of turns of PTFE tape (plumbing tape) around the brass threads.</li>
<li>Screw the nozzle holder down onto the nozzle. If no flats are milled, use a pair of pliers to tighten the nozzle. The nozzle holder can be protected from the pliers by first wrapping it with a rag or paper towel. If there are flats milled, a 13 mm (1/2") open-end wrench can be used to tighten the nozzle.</li>
<li>Remove the brass nozzle from the vise.</li>
<li>Slide the PTFE liner down into the nozzle holder. The PTFE liner needs to be inserted such that the flat end is making contact with the brass and the internally tapered end is towards the top.
Install the washer.</li>
<li>Screw in the hollow-lock socket set screw. Ensure that the washer stays centered while tightening this set screw. Use a piece of filament to ensure that the set screw is not too tight as the liner can become compressed and obstruct the passage. If this happens, slightly loosen the set screw.</li>
</ol>
</blockquote>
<p>To disassemble you need to reverse the order.</p>
<p>You need to ask yourself it you want to change to a newer type of hotend, but generally, these are higher, e.g. compared to a V6:</p>
<p><a href="https://i.stack.imgur.com/2XnBm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2XnBm.png" alt="enter image description here" /></a></p>
|
<p>Not exactly the type of answer you probably want, but this hotend does not look servicable. The nozzle is usually considered a consumable part unless it's made of something like tungsten carbide, or at least steel. The nozzle is almost surely long past its useful life unless the printer was barely used, and the entire hotend has lots of design flaws like very small thermal mass and heat sink butting up against the heater block, which defeats the purpose of having a heat sink.</p>
<p>The right solution here is to figure out what kind of attachment it's supposed to use (dimensions of that groove mount) and buy or put together a replacement hotend.</p>
| 2,209
|
<p>I am using VMWare tools for Ubuntu Hardy, but for some reason <code>vmware-install.pl</code> finds fault with my LINUX headers. The error message says that the "address space size" doesn't match.</p>
<p>To try and remediate, I have resorted to <code>vmware-any-any-update117</code>, and am now getting the following error instead:</p>
<pre><code>In file included from include/asm/page.h:3,
from /tmp/vmware-config0/vmmon-only/common/hostKernel.h:56,
from /tmp/vmware-config0/vmmon-only/common/task.c:30:
include/asm/page_32.h: In function ‘pte_t native_make_pte(long unsigned int)’:
include/asm/page_32.h:112: error: expected primary-expression before ‘)’ token
include/asm/page_32.h:112: error: expected ‘;’ before ‘{’ token
include/asm/page_32.h:112: error: expected primary-expression before ‘.’ token
include/asm/page_32.h:112: error: expected `;' before ‘}’ token
</code></pre>
<p>Can anyone help me make some sense of this, please?</p>
|
<p>This error ofter occurs because incompatibility of VMWare Tools Version and recent Kernels (You can test it using older Kernels). Sometimes you can fix some thing with patches all over the internet, but I prefer to downgrade my kernel or don't using latest distribution's version in VMWare. It can be really annoying. Another problem you may have is with your mouse pointer in X Windows, like if it was a inch to left or below than it really shows.</p>
<p>About vmware-any-any-update117, it's a patch to VMWare running under linux, usually Workstation version. It won't have effect in Tools. </p>
|
<p>I've heard a lot of good things about VirtualBox from Sun. If you get fed up with VMWare, it's worth a look.</p>
| 5,118
|
<p>I have a requirement to make a large amount of code MISRA compliant.<br>
First question: Can somebody to give an <strong>estimation</strong> for passing well written code for embedded system based on experience. I understand that "well written" is poorly defined and vague so i ask for raw estimation.<br>
Second question: Any recommendation for tool that can be customizable (i.e allowing suppress specific warnings) and used in automatic build environment (i.e command line interface)<br>
Any other useful suggestions that can help with this task.<br>
Thanks Ilya. </p>
|
<p>I also highly recommend PC-Lint. If you happen to be compiling your code with Visual Studio I recommend a plug-in 'Visual Lint' from Riverblade. If you cannot compile the code in Visual Studio, you can still run PC-Lint from the command line to good effect.</p>
<p>Some embedded system compilers provide MISRA compliance testing as compiler warnings. I use the IAR compiler for Arm7/Arm9 development. It provides an easy to configure MISRA compliance checklist right in the compiler setup.</p>
<p>It is difficult to come up with a rule of thumb for estimating the time it would take you to make some well written code MISRA compliant. A lot depends on the existing coding habits of the programmers and how closely they follow the MISRA rules in the first place.</p>
<p>Rough estimates:<br>
2 - 3 days to become adept at PC-Lint usage.<br>
Initial pass at making existing code MISRA compliant: 10 to 25 percent of the time spent writing the code in the first place.<br>
Keeping code MISRA compliant: 5 to 10 percent added to code development. Half of this cost is changing the habits of your coders to follow the 'MISRA way' of doing things. The other half is the extra cost of code testing and inspection to ensure MISRA compliance.</p>
|
<p>I appreciate that this is an old question, but for the benefit of any other Archaeologists (or searchers), it is important to remember that MISRA provides <strong>guidelines</strong> that should not always be blindly followed.</p>
<p>I commend writing new code with MISRA in mind; therefore it will be a lot easier to stay compliant.</p>
<p>However, this is not always possible - and in particular, when trying to reverse engineer code to meet the guidelines. In this case I suggest that you focus on the Required rules, and treat the Advisories as a bonus... cost v benefit applies here too!</p>
<p>Also, bear in mind that there is a deviation process - it is better to keep clean and maintainable code with a deviation, than to contrive some compliant but illegible spaghetti.</p>
| 8,848
|
<p>I'm not really sure where to ask this question as I think it is a design question, but also a printing question. So if there is a better place to post, I'd be happy to harass someone else.<br>
I'm (re)designing a sprinkler manifold for a dripper system because the stupid pegs for this <a href="https://rads.stackoverflow.com/amzn/click/com/B00M0UG9SK" rel="nofollow noreferrer" rel="nofollow noreferrer">stupid manifold</a> are on top of the manifold, which is a prime spot for any old postal person/dog/raindrop to break off. Of course the pegs aren't sold separately so you have to buy a whole new manifold. Seems like a great use for a 3D printer. </p>
<p><a href="https://i.stack.imgur.com/t5VuH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t5VuH.jpg" alt="sprinkler pegs"></a></p>
<p>I designed a new manifold and decided the pegs were useful in case they broke off. I was thinking having them screw in would be a better design, but for the life of me I can't get them to actually screw in after I print.
<a href="https://www.dropbox.com/s/9cy2vbtc8r8j47g/MushroomManifold%20FO%20real-%20i2%20v4.f3d?dl=0" rel="nofollow noreferrer">Here</a> is the fusion 360 file.
This is generally what it looks like:
<a href="https://i.stack.imgur.com/gam5D.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gam5D.jpg" alt="MushroomManifold"></a>
And <a href="https://www.dropbox.com/s/e1edw8pbpw64j20/MushroomManifold.stl?dl=0" rel="nofollow noreferrer">here</a> is the resulting stl file. </p>
<p>After several prints, the pegs won't screw into the manifold base. I push and I turn and turn but the threads just won't bite. The 3/4" pipe threads fit just fine, so I know threads can be printed, but these pegs are stubborn. </p>
<p>I guess my question is, what's a good design for a peg thingy that needs to attach into a manifold, but also pass water? Should I try to replicate the cantilever thing they have going on, or is a screw better? Any ideas why my pegs won't screw into the base of my mushroom? This is my first attempt at 3d modeling so I'm not totally familiar with all the terminology, so any pointers there would be helpful.
Thanks!</p>
|
<p>I examined and sliced your STL file, and the profile of your threads looks very strange.</p>
<p>It's definitely possible to do very strong, perfectly-fitting threads down to small sizes (at least down to M4 or slightly smaller) using modern inexpensive 3D printers, and contrary to widespread belief (there's a well-known YouTube comparison with a major test fallacy claiming otherwise) they should usually be stronger than threaded inserts against being pulled out. But you need to get the thread profile exactly right.</p>
<p>Most real thread profiles are trapezoidal, but yours peak at points and have round bases. This is unlikely to match the external thread on the part you're trying to fit to it, and it's going to have major dimensional accuracy issues because of the sharp point which can't necessarily be represented in the layer resolution.</p>
<p>I'm not familiar with Fusion 360 so I don't know how to tell you exactly, but most CAD software has libraries for generating threads conforming to standard thread profiles. If you want to do 3D printed threads, you should look at those and figure out which one you're trying to match. Or, if you want to replace the pegs with your own design anyway, just pick a reasonable one for both.</p>
<p>Generally, most modern threads use the basic <a href="https://en.wikipedia.org/wiki/ISO_metric_screw_thread" rel="nofollow noreferrer">ISO metric thread profile</a>, even if they're not standard metric diameter or pitch:</p>
<p><a href="https://i.stack.imgur.com/5TTOQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5TTOQ.png" alt="ISO Metric Thread Profile diagram"></a></p>
<p>Your cross-sections should look roughly like the "internal thread" side of that.</p>
|
<p>If I may suggest a slight alternative: don't try to make the threads part of the 3Dprint. Instead, thicken the walls where the threads would have been, increasing the ID (inner diameter) of the hole, maybe even "thread" to match the outside of : metal <a href="https://www.homedepot.com/p/Everbilt-1-4-in-20-tpi-x-20-mm-Zinc-Plated-Screw-in-Type-E-Insert-Nut-4-Pack-817798/204804833" rel="nofollow noreferrer">threaded inserts</a>. Those can be screwed in, .<br>
Perhaps a small "<a href="https://www.homedepot.com/p/Everbilt-6-32-Coarse-Zinc-Plated-Steel-Tee-Nut-4-per-Pack-802261/204274190" rel="nofollow noreferrer">T-nut</a>" (pick the size you need) would be sufficient, and you could create holes in your printed part for the penetration tips. </p>
| 1,327
|
<p>I'd like to display 100 floating cubes using <code>DirectX</code> or <code>OpenGL</code>.</p>
<p>I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly.</p>
<p>I've combed the net for a good series of tutorials and although they talk about how to do <code>3D</code> primitives, what I can't find is information on how to do large numbers of <code>3D</code> primitives - <code>cubes</code>, <code>spheres</code>, <code>pyramids</code>, and so forth.</p>
|
<p>You say you have enough trouble getting one cube to display... so I am not sure if you have got one to display or not.</p>
<p>Basically... put your code for writing a cube in one function, then just call that function 100 times.</p>
<pre><code>void DrawCube()
{
//code to draw the cube
}
void DisplayCubes()
{
for(int i = 0; i < 10; ++i)
{
for(int j = 0; j < 10; ++j)
{
glPushMatrix();
//alter these values depending on the size of your cubes.
//This call makes sure that your cubes aren't drawn overtop of each other
glTranslatef(i*5.0, j*5.0, 0);
DrawCube();
glPopMatrix();
}
}
}
</code></pre>
<p>That is the basic outline for how you could go about doing this. If you want something more efficient take a look into Display Lists sometime once you have the basics figured out :)</p>
|
<p>This answer isn't just for OP's question. It also answers a more general question - displaying many cubes <em>in general</em>.</p>
<h3>Drawing many cube meshes</h3>
<p>This is probably the most naive way of doing things. We draw the same cube mesh with many different transformation matrices:</p>
<pre class="lang-cpp prettyprint-override"><code>prepare();
for (int i = 0; i < numCubes; i++) {
setTransformation(matrices[i]);
drawCube();
}
/* and so on... */
</code></pre>
<p>The nice thing is that this is SUPER easy to implement, and it's not <em>too</em> slow (at least for 100 cubes). I'd recommend this as a starter.</p>
<h3>The problem</h3>
Ok, but let's say you want to make a Minecraft clone, or at least some sort of project that requires thousands, if not tens of thousands of cubes to be rendered. That's where the performance starts to go down. The problem is that each drawCube() sends a draw call to the GPU, and the time in each draw call adds up, so that eventually, it's unbearable.
<p>However, we can fix this. The solution is <em>batching</em>, a way to do only <em>one</em> draw call for all of the cubes.</p>
<h3>Batching</h3>
<p>We join all the (transformed) cubes into one single mesh. This means that we will have to deal with only one draw call, instead of thousands. Here is some pseudocode for doing so:</p>
<pre class="lang-cpp prettyprint-override"><code>vector<float> transformedVerts;
for (int i = 0; i < numCubes; i++) {
cubeData = cubes[i];
for (int j = 0; j < numVertsPerCube; j++) {
vert = verts[j];
/* We transform the position by the transformation matrix. */
vec3 vposition = matrices[i] * verts.position;
transformedVerts.push(vposition);
/* We don't need to transform the colors, so we just directly push them. */
transformedVerts.push(vert.color);
}
}
...
sendDataToBuffer(transformedVerts);
</code></pre>
<p>If the cubes are moving, or one of the cubes is added or deleted, you'll have to recalculate <code>transformedVerts</code> and then resend it to the buffer - but this is minor.</p>
<p>Then at the end we draw the entire lumped-together mesh in one draw call, instead of many.</p>
| 2,349
|
<p>I am creating a program that will be installed using the .net installer project. The program writes to settings files to its directory in the Program Files dir. It believe there are some active directory settings that will prevent the application from righting to that directory if a limited user is running the program. Is there away to change the settings for the application folder through the install so this will not be a problem?</p>
|
<p>Writing to the Program Files folder is a really bad idea, you should assume that this location is "read only" once installed. </p>
<p>Saving user settings in Program Files causes problems if more than two people use the computer at once (eg. Terminal Services) who's settings should be saved, do you want other users to know 'your' settings? What happens if your program writes settings to the file as user A, but user B can't edit the file? User B may have access to the directory, but not read/delete the preference file as this is owned by user A. </p>
<p>Legacy win9x programs often write to the program files folder, Windows Vista actually does some neat trickery to let these programs work. When your program writes a file, vista actually puts it someplace else that is only accessible to that user. The same is done for registry writes to HKLM (or so I discovered after hours of debugging...) and Server 2008 does the same thing.</p>
<p>If you're needing to save user settings the best alternative would be to save the settings to the Application Data folder (Environment Variable %APPDATA%)</p>
<p>If the settings are system wide, then the administrative user should set these after install or on first run and they should not be able to be overwritten by limited users.</p>
<p>So to answer your question - YES there is a way to do what you've asked. But it's a bad idea, it's insecure and will probably cause problems in the long run.</p>
|
<p>You can write a custom installer class which can change the security permissions of the folder. This would assume the installation is done by a user who has permission to change file/directory security.</p>
<p>The best option is to not write to directories under Program Files at all.</p>
| 3,921
|
<p>I often have to sort a dictionary (consisting of keys & values) by value. For example, I have a hash of words and respective frequencies that I want to order by frequency.</p>
<p>There is a <code>SortedList</code> which is good for a single value (say frequency), that I want to map back to the word.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/f7fta44c.aspx" rel="noreferrer">SortedDictionary</a> orders by key, not value. Some resort to a <a href="http://www.codeproject.com/KB/recipes/lookupcollection.aspx" rel="noreferrer">custom class</a>, but is there a cleaner way?</p>
|
<p>Use:</p>
<pre><code>using System.Linq.Enumerable;
...
List<KeyValuePair<string, string>> myList = aDictionary.ToList();
myList.Sort(
delegate(KeyValuePair<string, string> pair1,
KeyValuePair<string, string> pair2)
{
return pair1.Value.CompareTo(pair2.Value);
}
);
</code></pre>
<p>Since you're targeting .NET 2.0 or above, you can simplify this into lambda syntax -- it's equivalent, but shorter. If you're targeting .NET 2.0 you can only use this syntax if you're using the compiler from Visual Studio 2008 (or above).</p>
<pre><code>var myList = aDictionary.ToList();
myList.Sort((pair1,pair2) => pair1.Value.CompareTo(pair2.Value));
</code></pre>
|
<p>You can sort the Dictionary by value and get the result in dictionary using the code below:</p>
<pre><code>Dictionary <<string, string>> ShareUserNewCopy =
ShareUserCopy.OrderBy(x => x.Value).ToDictionary(pair => pair.Key,
pair => pair.Value);
</code></pre>
| 2,279
|
<p>I'm writing a mobile phone game using j2me. In this game, I am using multiple Canvas objects.
For example, the game menu is a Canvas object, and the actual game is a Canvas object too.
I've noticed that, on some devices, when I switch from one Canvas to another, e.g from the main menu to the game, the screen momentarily "flickers". I'm using my own double buffered Canvas.</p>
<p>Is there anyway to avoid this?</p>
|
<p>I would say, that using multiple canvases is generally bad design. On some phones it will even crash. The best way would really be using one canvas with tracking state of the application. And then in paint method you would have</p>
<pre><code>protected void paint(final Graphics g) {
if(menu) {
paintMenu(g);
} else if (game) {
paintGame(g);
}
}
</code></pre>
<p>There are better ways to handle application state with screen objects, that would make the design cleaner, but I think you got the idea :)</p>
<p>/JaanusSiim </p>
|
<p>Do you use double buffering? If the device itself does not support double buffering you should define a off screen buffer (Image) and paint to it first and then paint the end result to the real screen. Do this for each of your canvases. Here is an example:</p>
<pre><code>public class MyScreen extends Canvas {
private Image osb;
private Graphics osg;
//...
public MyScreen()
{
// if device is not double buffered
// use image as a offscreen buffer
if (!isDoubleBuffered())
{
osb = Image.createImage(screenWidth, screenHeight);
osg = osb.getGraphics();
osg.setFont(defaultFont);
}
}
protected void paint(Graphics graphics)
{
if (!isDoubleBuffered())
{
// do your painting on off screen buffer first
renderWorld(osg);
// once done paint it at image on the real screen
graphics.drawImage(osb, 0, 0, Tools.GRAPHICS_TOP_LEFT);
}
else
{
osg = graphics;
renderWorld(graphics);
}
}
}
</code></pre>
| 9,195
|
<p>I have a reprap printer with 0.3mm nozzle. It prints quite well, I am really surprised with quality of all the surfaces and the general precision of the parts printed. BUT I HAVE a problem: when making (for example) a 10mm x 10mm x 10mm cube with a 2.8mm diameter hole from top to bottom (to fit a screw) after I print it gets a size of 3mm diameter.</p>
<p>I know this is related to extrusion width but cant the slicer software (I am using s3d) know that it is using a specific extrusion width and compensate for that in order to get the diamter right?</p>
<p>OBS: this printer is supposed to get 0.05mm precision.</p>
|
<p>It's a generally accepted fact that FDM/FFF printers will have <a href="https://innovationstation.utexas.edu/tip-design/" rel="nofollow noreferrer">deviations when it comes to holes and perimeters</a>. Typically, holes print smaller than designed and external surfaces end up larger than designed.</p>
<p>In your case, it seems to be the opposite: the hole is too big. It could be that you're just printing too big overall. You might want to make sure that your printer is printing the 10mm X/Y dimension in you example correctly. If it's too big, part of it may be just the typical oversized perimeter, but some of it might be due to incorrect firmware X/Y 'steps/mm' or extrusion like you mentioned.</p>
<p>See also: <a href="https://www.deltarap.org/printing-undersized-holes/" rel="nofollow noreferrer">"Are you printing undersized holes?"</a></p>
|
<p>For one thing, the entire part generally shrinks, as it's printed (at whatever precision of nozzle location) as molten plastic, and then cools and solidifies.</p>
<p>Given that you are getting a bigger hole in the finished part, I'd start by measuring the part's actual overall outside size, as printed (is that 10mm, or might it be 10.5 or 11mm?), and suspect some calibration tweaks are needed.</p>
<p>If the outside of the cube is actually 10mm, then you may simply need to find the right fudge-factor for hole sizing - if 2.8 is becoming 3, you might need 2.65 to get 2.8 as printed - or 2.63, or...</p>
<p>Alternatively, plan for drilling when a precision hole is needed, and print a deliberately undersized hole with a thick shell so it can be drilled out precisely.</p>
| 568
|
<p>I wondered whether anybody knows how to obtain membership of local groups on a remote server programmatically via C#. Would this require administrator permissions? And if so is there any way to confirm the currently logged in user's membership (or not) of these groups?</p>
|
<p><a href="http://www.codeproject.com/KB/system/everythingInAD.aspx" rel="nofollow noreferrer">Howto: (Almost) Everything In Active Directory via C#</a> is very helpfull and also includes instructions on how to iterate AD members in a group.</p>
<pre><code>public ArrayList Groups(string userDn, bool recursive)
{
ArrayList groupMemberships = new ArrayList();
return AttributeValuesMultiString("memberOf", userDn,
groupMemberships, recursive);
}
</code></pre>
<p>You will also need this function:</p>
<pre><code>public ArrayList AttributeValuesMultiString(string attributeName,
string objectDn, ArrayList valuesCollection, bool recursive)
{
DirectoryEntry ent = new DirectoryEntry(objectDn);
PropertyValueCollection ValueCollection = ent.Properties[attributeName];
IEnumerator en = ValueCollection.GetEnumerator();
while (en.MoveNext())
{
if (en.Current != null)
{
if (!valuesCollection.Contains(en.Current.ToString()))
{
valuesCollection.Add(en.Current.ToString());
if (recursive)
{
AttributeValuesMultiString(attributeName, "LDAP://" +
en.Current.ToString(), valuesCollection, true);
}
}
}
}
ent.Close();
ent.Dispose();
return valuesCollection;
}
</code></pre>
<p>If you do now want to use this AD-method, you could use the info in this article, but it uses unmanaged code:</p>
<p><a href="http://www.codeproject.com/KB/cs/groupandmembers.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/groupandmembers.aspx</a></p>
<p>The sample application that they made:</p>
<p><img src="https://i.stack.imgur.com/9Vt9Z.jpg" alt="alt text"></p>
|
<p>Perhaps this is something that can be done via WMI?</p>
| 6,732
|
<p>How can I write G-code for a triangle without sharp tips?</p>
<p><a href="https://i.stack.imgur.com/T0hpu.jpg" rel="nofollow noreferrer" title="Example of required triangle"><img src="https://i.stack.imgur.com/T0hpu.jpg" alt="Example of required triangle" title="Example of required triangle"></a></p>
<p>I want to generate the corners manually, rather than using a slicer to generate them, just to know how it is done.</p>
|
<p>First, convert the given measurements into a sketch...</p>
<p><a href="https://i.stack.imgur.com/ivxIW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ivxIW.png" alt="Sketched out dimensions" /></a></p>
<h2>G-code shenanigans</h2>
<p>we actually have the printer do circles.. let's plot that out...</p>
<p><a href="https://i.stack.imgur.com/hGFSc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hGFSc.png" alt="Plotted all start-ends and centers" /></a></p>
<p>Using that, it's easy to write the G-code using the Documentation for <a href="http://marlinfw.org/docs/gcode/G000-G001.html" rel="nofollow noreferrer">G1</a> and <a href="http://marlinfw.org/docs/gcode/G002-G003.html" rel="nofollow noreferrer">G2</a>. You'll have to add the E values to extrude something along the paths, but your sketch would turn into this path:</p>
<pre><code>G92 X0 Y0 ; the current position is now (0,0) on the XY
G90 ;Abolute mode for everything...
M83 ;...but for the E-argument, so you can just put the length into the extrusions that are to be done
G0 X10.66 Y2
G2 R5 X6.33 Y9.5 ; Alternate: G3 I0 J5 X6.33 Y9.5
G1 X45.66 Y77.638
G2 R5 X54.33 Y77.638 ; Alternate: G3 I4.33 Y-2.5 X54.33 Y77.638
G1 93.67 Y9.5
G2 R5 X89.33 Y2 ; Alternate: G3 I-4.33 Y-2.5 X89.33 Y2
G1 X10.66 Y2
G0 X0 Y0
G91 ; return to relative coordinates
</code></pre>
<p><strong>This code has to be prefixed by a move to where you want to start the pattern</strong> and will <strong>not</strong> know if you move it off the build plate, so keep 100 mm X and 87 mm in Y of the allowable build plate. It will end exactly where you started it.</p>
<h2>Iterative approach</h2>
<p>In many uses of g-code, <em>rounded</em> corners are actually n-gons with a very high number n. then we only need <code>G1</code> and can easily calculate the length of the stretches and fill in the G1. We need to iterate down to somewhat circular...</p>
<p>Let's start iterating with n=3 aka a triangle, which gives a direct line over the corner gives this:</p>
<p><a href="https://i.stack.imgur.com/ANEnx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ANEnx.png" alt="Iteration 1" /></a></p>
<p>going to n=6 (hexagon) follows the curve a lot better...</p>
<p><a href="https://i.stack.imgur.com/JRSMV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JRSMV.png" alt="Iteration 2" /></a></p>
<p>going to n=12 looks almost round on a larger scale...</p>
<p><a href="https://i.stack.imgur.com/STTXL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/STTXL.png" alt="Iteration 3" /></a></p>
<p>and when we reach n=24, we are pretty close to the circle..</p>
<p><a href="https://i.stack.imgur.com/rO7dr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rO7dr.png" alt="iteration 4" /></a></p>
<p>And as we go above n=6, we also get easier math for the corners, as we always get the same lengths of movement along X and Y just swapped around due to symmetry.</p>
<p>With all these stretches defined, we could start to work in <em>relative</em> coordinates easily, again without E, and only for the bottom left corner:</p>
<pre><code>G0 X10.66 Y2
G1 X-1.294 Y0.17
G1 X-1.206 Y0.5
G1 X-1.036 Y0.795
G1 X-0.795 X1.036
G1 X-0.5 Y1.206
G1 X-0.17 Y1.294
G1 X0.17 Y1.294
G1 X0.5 Y1.036
...
</code></pre>
|
<p>Marlin has <code>G2</code> (clockwise arc) and <code>G3</code> (counterclockwise arc) commands that could be used to do this. <a href="http://marlinfw.org/docs/gcode/G002-G003.html" rel="nofollow noreferrer">You can find detailed documentation for the command here.</a></p>
<p>Basically, you can use</p>
<blockquote>
<p>G2 R1 X5 Y5</p>
</blockquote>
<p>to draw a (clockwise) arc from the current position to <span class="math-container">$(X,Y)=(5,5)$</span> with a radius of <span class="math-container">$1$</span>.</p>
<p>So, your rounded triangle could be drawn with 3 straight line moves and 3 arc moves. Figuring out the exact coordinates for each move would be a quite challenging geometry exercise, as you'd need to know where the straight line portion of each side ends and the rounded portion starts.</p>
| 1,393
|
<p>I am looking for a way to delete all files older than 7 days in a batch file. I've searched around the web, and found some examples with hundreds of lines of code, and others that required installing extra command line utilities to accomplish the task.</p>
<p>Similar things can be <a href="https://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash">done in BASH</a> in just a couple lines of code. It seems that something at least remotely easy could be done for batch files in Windows. I'm looking for a solution that works in a standard Windows command prompt, without any extra utilities. Please no PowerShell or Cygwin either.</p>
|
<p>Enjoy:</p>
<pre><code>forfiles -p "C:\what\ever" -s -m *.* -d <number of days> -c "cmd /c del @path"
</code></pre>
<p>See <a href="http://ss64.com/nt/forfiles.html" rel="noreferrer"><code>forfiles</code> documentation</a> for more details.</p>
<p>For more goodies, refer to <em><a href="http://www.ss64.com/nt/" rel="noreferrer">An A-Z Index of the Windows XP command line</a></em>.</p>
<p>If you don't have <code>forfiles</code> installed on your machine, copy it from any <a href="http://en.wikipedia.org/wiki/Windows_Server_2003" rel="noreferrer">Windows Server 2003</a> to your Windows XP machine at <code>%WinDir%\system32\</code>. This is possible since the EXE is fully compatible between Windows Server 2003 and Windows XP.</p>
<p>Later versions of Windows and Windows Server have it installed by default.</p>
<p>For Windows 7 and newer (including Windows 10):</p>
<p>The syntax has changed a little. Therefore the updated command is:</p>
<pre><code>forfiles /p "C:\what\ever" /s /m *.* /D -<number of days> /C "cmd /c del @path"
</code></pre>
|
<p>More flexible way is to use <a href="https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/FileTimeFilterJS.bat" rel="nofollow noreferrer"><code>FileTimeFilterJS.bat</code></a>:</p>
<pre><code>@echo off
::::::::::::::::::::::
set "_DIR=C:\Users\npocmaka\Downloads"
set "_DAYS=-5"
::::::::::::::::::::::
for /f "tokens=* delims=" %%# in ('FileTimeFilterJS.bat "%_DIR%" -dd %_DAYS%') do (
echo deleting "%%~f#"
echo del /q /f "%%~f#"
)
</code></pre>
<p>The script will allow you to use measurements like days, minutes ,seconds or hours.
To choose weather to filter the files by time of creation, access or modification
To list files before or after a certain date (or between two dates)
To choose if to show files or dirs (or both)
To be recursive or not</p>
| 7,393
|
<p>Is it possible to write a <code>doctest</code> unit test that will check that an exception is raised?<br />
For example, if I have a function <code>foo(x)</code> that is supposed to raise an exception if <code>x < 0</code>, how would I write the <code>doctest</code> for that?</p>
|
<p>Yes. You can do it. The <a href="https://docs.python.org/3/library/doctest.html" rel="noreferrer">doctest module documentation</a> and Wikipedia has an <a href="http://en.wikipedia.org/wiki/Doctest#Example_2:_doctests_embedded_in_a_README.txt_file" rel="noreferrer">example</a> of it.</p>
<pre><code> >>> x
Traceback (most recent call last):
...
NameError: name 'x' is not defined
</code></pre>
|
<pre><code>>>> import math
>>> math.log(-2)
Traceback (most recent call last):
...
ValueError: math domain error
</code></pre>
<p>ellipsis flag <em># doctest: +ELLIPSIS</em> is not required to use ... in Traceback doctest </p>
| 3,363
|
<h2>Backstory</h2>
<p>I've had issues in the past with my drive gear "eating" my filament. It seemed that the filament quit extruding for one reason or another and the drive gear would slowly eat away at the side of the filament.</p>
<p>I eventually assumed it was the plastic filament guides causing unnecessary tension that the drive gear couldn't compete with, ultimately keeping the filament from moving forward. Thusly, allowing the drive gear to continue "trying".</p>
<p>My solution was to hang my spools above the machine to avoid using the filament guides feeding from the back of the machine up through the top.</p>
<h2>Question</h2>
<p>Can the plastic filament guides really cause that much drag? What other variables can I expect to look out for?</p>
<p><em>Machine:</em> <strong>MakerBot Replicator Dual (1st Generation)</strong></p>
|
<p>For an easy test, try manually pulling the filament through the U-loop of guide tube. How hard is it to pull through? It should only take 1-2 lbs of tension at most. </p>
<p>Then do a "tug test" on the extruder. Start it loading and grab the filament by hand to try to stop it from extruding. The Replicator 1/2/2x extruder style can typically pull ~8-10 lbs of tension and it should be fairly difficult to stop the filament. When you do stop the filament, you should hear clicking/thumping from the stepper stalling, NOT quiet grinding as the drive gear chews through the filament. If the grip slips rather than stalls, your extruder hardware needs to be tuned or replaced. </p>
<p>There are three common causes of excessive feed tube drag:</p>
<ul>
<li>Use of polyethylene tubing instead of PTFE -- this makes a shockingly large difference in drag friction. You can use a heat gun or torch (outside!!) to tell the difference between PE and PTFE. PE will soften quickly and then melt fairly easily, whereas PTFE will simply go clear and eventually char without melting. Nylon is also sometimes used for feed tubes with acceptable results, but if you have any suspicion about the tube material, just buy new PTFE tubes from a reputable vendor like McMaster. </li>
<li>Too many loops/curves in the tube. Total drag friction is an exponential function of the total amount of curvature in the tube. You should have one good U-loop, no spirals or floppy zig-zags. </li>
<li>Excessive friction on the spool rotation. Any spool back-tension gets greatly magnified through the feed tube per the <a href="https://en.wikipedia.org/wiki/Capstan_equation" rel="nofollow">capstan equation</a>. This can be caused by a bad spool holder, or if the filament is knotted on the spool due to letting the end of the spool loose during handling. </li>
</ul>
|
<p>The friction inside of the guide tubes is fairly minimal assuming that the lines are straight and there isn't anything else inside them. My guess would be that you may have another issue. Reducing the drag in the guide tubes while it may reduce the problem of clogged nozzle, might just be hiding the symptoms of another problem.</p>
<p>I've heard, but never tried adding a dab of Canola oil to the tip of your filament prior to feeding it into your extruder. Specifically for Makerbots.</p>
<p>Link my source:
<a href="https://groups.google.com/forum/#!topic/makerbot/Wn-MKC1Ybm0%5B1-25%5D" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/makerbot/Wn-MKC1Ybm0%5B1-25%5D</a> </p>
| 224
|
<p>Why does <code>n</code> not equal to <code>8</code> in the following function?</p>
<pre><code>void foo(char cvalue[8])
{
int n = sizeof (cvalue);
}
</code></pre>
<p>But <code>n</code> <em>does</em> equal to <code>8</code> in this version of the function:</p>
<pre><code>void bar()
{
char cvalue[8];
int n = sizeof (cvalue);
}
</code></pre>
|
<p>Because you can't pass entire arrays as function parameters in C. You're actually passing a pointer to it; the brackets are syntactic sugar. There are no guarantees the array you're pointing to has size 8, since you could pass this function any character pointer you want.</p>
<pre><code>// These all do the same thing
void foo(char cvalue[8])
void foo(char cvalue[])
void foo(char *cvalue)
</code></pre>
|
<p>The size of the parameter on 32-bit systems will be 4 and on 64-bit systems compiled with -m64 will be 8. This is because arrays are passed as pointers in functions. The pointer is merely a memory address.</p>
| 7,146
|
<p>For best performance, is it better to use a virtual IDE HDD or virtual SCSI HDD?
If, SCSI, does it matter whether you use an BusLogic or LSILogic?</p>
|
<p>Go for the SCSI and LSILogic. IDE and BusLogic are for compatibility reasons. Like when you do physical2virtual...</p>
<p>There's a whitepaper from vmware showing the difference between LSILogic and BusLogic, which in my opinion is rather small:
<a href="http://www.vmware.com/pdf/ESX2_Storage_Performance.pdf" rel="nofollow noreferrer">http://www.vmware.com/pdf/ESX2_Storage_Performance.pdf</a></p>
<p>Edit after like three years:
With current ESX environments it's best to use the Paravirtual SCSI device.</p>
|
<p>I don't think that your choice of Virtual Disk type in VMWare matters for performance. What matters is the following: How much memory you have (the more the better), How many CPU cores you have (the more the better), and more specifically about disks, what matters most is the speed of the physical drive (a 15K RPM SCSI drive being best). If you have, for example, 3 physical HDs and 3 virtual HDs, then I would place one virtual HD in each physical HD. This is known to improve virtual HD performance. Also keep your virtual HDs defragmented.</p>
| 9,630
|
<p>Does anyone have a good solution for integrating some C# code into a java application? </p>
<p>The code is small, so I could re-write in java, but I would rather reuse the code if possible. Don't repeat yourself, etc. </p>
<p>Also, I know I can expose the C# as a web service or whatever, but it has some security/encryption stuff in there, so I would rather keep it tightly integrated if possible.</p>
<hr>
<p>Edit: It's going to be on a server-based app, so "downloading" another runtime is irrelevant.</p>
|
<p>You would use the Java Native Interface to call your C# code compiled into a DLL.</p>
<p>If its a small amount of C#, it would be much easier to port it to Java. If its a lot, this might be a good way to do it.</p>
<p>Here is a highlevel overview of it:</p>
<p><a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="noreferrer">http://en.wikipedia.org/wiki/Java_Native_Interface</a></p>
<p>Your other option would be to create a COM assembly from the C# code and use J-Interop to invoke it.</p>
<p><a href="http://sourceforge.net/projects/j-interop/" rel="noreferrer">http://sourceforge.net/projects/j-interop/</a></p>
|
<p>I would rewrite it if it's not too much trouble.
The web service would work, but it seems like that would be a lot of overhead just to reuse a little code.</p>
| 7,320
|
<p>I've been dealing with 3D printing for 1.5 years, but now own a CR-6 SE myself since the beginning of 2021. Most things are already quite clear but for 2 days I have had a problem with the adhesion of the prints.</p>
<p>Nearly all prints I have done so far used the filament shipped with the printer (PLA 1.75) and they came off the building plate after some cooling time by themselves. I used the default printer settings for PLA: 200 °C nozzle temperature, 60 °C printing bed.</p>
<p>Then 2 days ago the prints began to not stick to the bed anymore and I thought this could be because of dust and from touching the bed. So I cleaned the bed with IPA. The microfiber towel was yellowish afterward - so I thought that this must have been printing residues. Since then every print is kind of "welded" to the bed. There is no chance of loosening it without more IPA or way too much force.</p>
<p>I already tried:</p>
<ul>
<li>cleaning the bed with clean water - unfortunately, didn't work</li>
<li>setting the Z-offset from 0.1 back to 0.2 mm - also no success</li>
</ul>
<p>Today I also tried a spool of brand new PETG, with the following recommended settings: 240 °C nozzle temperature, 80 °C print bed - but the problem stayed the same.</p>
<p>Am I doing something wrong? Did I destroy the "Carborundum" coating (silicon carbide) of the glass plate?</p>
|
<p>It is likely the surface was damaged by the chemical cleaning, based on your description and <a href="https://3dprinting.stackexchange.com/questions/15392/cr-6-se-glass-build-plate-no-lifting-possible#comment28974_15392">octopus8's comment</a>. If you are unable to mechanically release the print, there is a chemical method that has worked for me (and at least one other SE user) in the past.</p>
<p>Bring the bed up to about 40 °C and turn off the heat to the bed. Apply with a dropper or swab a 50/50 mixture of denatured alcohol and water. It will seep under the part as well as evaporate. Attempt the mechanical release. If it fails, apply additional mixture and repeat. Continue to do this until the mixture does not evaporate as quickly.</p>
<p>If the part has not released, it may be necessary to repeat the heating and application.</p>
<p>If you wish to return to "normal" circumstances, a bed replacement is indicated.</p>
|
<p>Sounds like the bed came with a coating on it. If you can't find out what the coating is, but believe you already removed it, you could try glue sticks or hair spray. You can also find glue sticks specified for 3D printing. Elmer's glue sticks work. I'm yet to try glue sticks specified for a 3D printer. You can Search on 3D Printing for answers where people used adhesive sprays. The link in octopus8's comment mentions a resin coating. There are resin coatings being sold for a bed adhesive.</p>
| 1,838
|
<p>I'm using repository pattern with LINQ, have IRepository.DeleteOnSubmit(T Entity). It works fine, but when my entity class has interface, like this: </p>
<pre><code>public interface IEntity { int ID {get;set;} }
public partial class MyEntity: IEntity {
public int ID {
get { return this.IDfield; }
set { this.IDfield=value; }
}
}
</code></pre>
<p>and then trying to delete some entity like this: </p>
<pre><code>IEntity ie=repository.GetByID(1);
repoitory.DeleteOnSubmit(ie);
</code></pre>
<p>throws<br>
The member 'IEntity.ID' has no supported translation to SQL. </p>
<p>fetching data from DB works, but delete and insert doesn't. How to use interface against DataContext?</p>
<hr>
<p>Here it is:<br>
Exception message:
The member 'MMRI.DAL.ITag.idContent' has no supported translation to SQL. </p>
<p>Code: </p>
<pre><code>var d = repContent.GetAll().Where(x => x.idContent.Equals(idContent));
foreach (var tagConnect in d) <- error line
{
repContet.DeleteOnSubmit(tagConnect);
</code></pre>
<p>(it gets all tags from DB, and deletes them)</p>
<p>And stack trace: </p>
<pre><code>[NotSupportedException: The member 'MMRI.DAL.ITag.idContent' has no supported translation to SQL.]
System.Data.Linq.SqlClient.Visitor.VisitMember(SqlMember m) +621763
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +541
System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) +8
System.Data.Linq.SqlClient.SqlVisitor.VisitBinaryOperator(SqlBinary bo) +18
System.Data.Linq.SqlClient.Visitor.VisitBinaryOperator(SqlBinary bo) +18
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +196
System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) +8
System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +46
System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20
System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024
System.Data.Linq.SqlClient.SqlProvider.BuildQuery( ...
</code></pre>
<p>When I try do decorate partial class:</p>
<pre><code>[Column(Storage = "_idEvent", DbType = "Int NOT NULL", IsPrimaryKey = true)]
public int idContent
{ get { return this.idEvent; } set { this.idEvent=value; } }
</code></pre>
<p>it throws error "Invalid column name 'idContent'."</p>
|
<p>It appears Microsoft dropped support for <code>==</code> operator in interfaces when using linq-to-sql in MVC4 (or maybe it was never supported). You can however use <code>i.ID.Equals(someId)</code> in place of the <code>==</code> operator.</p>
<p>Casting <code>IQueryable</code> to <code>IEnumerable</code> works but <strong>should not be used!</strong> The reason is: <code>IQueryable</code> has funky implementation of <code>IEnumerable</code>. Whatever linq method you'll use on a <code>IQueryable</code> through the <code>IEnumerable</code> interface will cause the query to be executed first, have all the results fetched to the memory from the DB and eventually running the method localy on the data (normally those methods would be translated to SQL and executed in the DB). Imagine trying to get a single row from a table containing billion rows, fetching all of them only to pick one (and it gets much worse with careless casting of <code>IQueryable</code> to <code>IEnumerable</code> and lazy loading related data).</p>
<p>Apparently Linq has no problem using <code>==</code> operator with interfaces on local data (so only <code>IQueryable</code> is affected) and also with Entity Frameworks (or so I heard).</p>
|
<p>Try this:</p>
<pre><code>using System.Data.Linq.Mapping;
public partial class MyEntity: IEntity
{ [Column(Storage="IDfield", DbType="int not null", IsPrimaryKey=true)]
public int ID
{
get { return this.IDfield; }
set { this.IDfield=value; }
}
}
</code></pre>
| 3,514
|
<p>What materials work well for lubricating moving PLA, ABS, or PETG parts? I'm talking items like the
the <a href="https://www.thingiverse.com/thing:53451" rel="nofollow noreferrer">Gear Bearings</a> or <a href="https://www.thingiverse.com/thing:4575774" rel="nofollow noreferrer">Print in Place Engine</a>.</p>
<p>I've played with a few lubricants on my own, including hand lotion, trumpet valve oil, and carmex/vaseline. Of these, the vaseline has worked best for me so far, but I'd like to hear what has worked well for others, or especially if there's anyone here who understands the chemistry involved and could explain what to look for in different situations.</p>
|
<p>When dealing with lubrication of plastics, any solvent or reactive substance is to be avoided. Petroleum is risky and Vaseline™ is a brand name for petroleum jelly.</p>
<p>I've had quite good results using inert lubrication such as PTFE and silicone based lubes. PTFE is the generic term for <a href="http://www.chm.bris.ac.uk/motm/teflon/teflonv.htm" rel="noreferrer">Teflon™</a> and is quite a good lubricant. There are both silicone and PTFE greases for higher viscosity applications.</p>
<p>From the Teflon™ link:</p>
<blockquote>
<p>Teflon's amazing properties are down to its structure. Like most
polymers, Teflon has a carbon-based chain. However, instead of
reactive C-H bonds which occur in most polymers, Teflon has all its
hydrogens replaced by fluorines. These strong C-F bonds are extremely
resistant to attack by any other reagents, making Teflon very inert.
This means that no other molecules will react with or stick to Teflon.
The exception is Teflon itself, which will stick to itself quite
readily, forming thick layers or solid blocks. With a friction
coefficient of <0.1, Teflon has the second lowest friction coefficient
(surpassed only by diamond-like carbon), which makes it perfect for
non-stick items e.g. pans. DuPont invented the non-stick pan coated
with Teflon in 1956 and have manufactured it ever since. Teflon
coatings are so slippery that they are the only material that a gecko
cannot stick to.</p>
</blockquote>
<p>Who knew that gecko testing was a thing?</p>
<p><a href="https://en.wikipedia.org/wiki/Silicone_grease" rel="noreferrer">Wikipedia</a> for silicone grease:</p>
<blockquote>
<p>Although silicones are normally assumed to be chemically inert,
several historically significant compounds have resulted from
unintended reactions with silicones.</p>
</blockquote>
<p>Powdered graphite is also a good lubricant if one can tolerate loose powder in some constructions.</p>
<p>I've read of others using lithium grease, but not for plastic lubrication.</p>
|
<p>After some testing, I can say that any oil is a bad option.</p>
<p>I've found that light oils tend to soak into and <strong>through</strong> any 3D printed FDM parts because of the small voids between lines and in turns and corners.</p>
<p>It is possible that resin-printed parts could be more oil-resistant, but I don't have any for testing.</p>
| 1,751
|
<p>I have some ASP.NET web services which all share a common helper class they only need to instantiate one instance of <em>per server</em>. It's used for simple translation of data, but does spend some time during start-up loading things from the web.config file, etc. <em>The helper class is 100% thread-safe. Think of it as a simple library of utility calls. I'd make all the methods shared on the class, but I want to load the initial configuration from web.config.</em> We've deployed the web services to IIS 6.0 and using an Application Pool, with a Web Garden of 15 workers.</p>
<p>I declared the helper class as a Private Shared variable in Global.asax, and added a lazy load Shared ReadOnly property like this:</p>
<pre><code>Private Shared _helper As MyHelperClass
Public Shared ReadOnly Property Helper() As MyHelperClass
Get
If _helper Is Nothing Then
_helper = New MyHelperClass()
End If
Return _helper
End Get
End Property
</code></pre>
<p>I have logging code in the constructor for <code>MyHelperClass()</code>, and it shows the constructor running for each request, even on the same thread. I'm sure I'm just missing some key detail of ASP.NET but MSDN hasn't been very helpful.</p>
<p>I've tried doing similar things using both <code>Application("Helper")</code> and <code>Cache("Helper")</code> and I still saw the constructor run with each request.</p>
|
<p>You can place your Helper in the Application State. Do this in global.asax:</p>
<pre><code> void Application_Start(object sender, EventArgs e)
{
Application.Add("MyHelper", new MyHelperClass());
}
</code></pre>
<p>You can use the Helper that way:</p>
<pre><code> MyHelperClass helper = (MyHelperClass)HttpContext.Current.Application["MyHelper"];
helper.Foo();
</code></pre>
<p>This results in a single instance of the MyHelperClass class that is created on application start and lives in application state. Since the instance is created in Application_Start, this happens only once for each HttpApplication instance and not per Request.</p>
|
<p>I 'v done something like this in my own app in the past and it caused all kinds of weird errors.
Every user will have access to everyone else's data in the property. Plus you could end up with one user being in the middle of using it and than getting cut off because its being requested by another user.</p>
<p>No there not isolated.</p>
| 8,807
|
<p>I want to get an overview of files that are updated in TFS (that someone else checked in) that I don't have the latest version for.</p>
|
<p>In Visual Studio Source Control Explorer, right click on the directory you want to compare, and select "Compare". It will pop up a dialog with a couple of filtering options, and then show you what's out of date. </p>
|
<p>if they checked them in as part of a single changeset then you can find them that way. </p>
<p>(right click file in solution explorer, view history, double-click on the relevant changeset and you'll see all the related files for that checkin)</p>
<p>Is your question about finding this info via the TFS API via the website, or via the visual studio interface? </p>
| 5,445
|
<p>What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations?</p>
|
<p>Make liberal use of [SuppressMessage] attribute to begin with. At least at the beginning. Once you get the count to 0 via the attribute, you then put in a rule that new checkins may not introduce FxCop violations. </p>
<p>Visual Studio 2008 has a nice code analysis feature that allows you to ensure that code analysis runs on every build and you can treat warnings as errors. That might slow things down a bit so I recommend setting up a continuous integration server (like CruiseControl.NET) and having it run code analysis on every checkin.</p>
<p>Once you get it under control and aren't introducing new violations with every checkin, start to tackle whole classes of FxCop violations at a time with the goal of removing the SuppressMessageAttributes that you used.</p>
<p>The way to keep track of which ones you really want to keep is to always add a Justification value to the ones you really want to suppress.</p>
|
<p>An alternative to FxCop would be to use the tool <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. This tool lets write <strong>Code Rules over C# LINQ Queries</strong> (what we call <a href="http://www.ndepend.com/Features.aspx#CQL" rel="nofollow noreferrer">CQLinq</a>). <em>Disclaimer: I am one of the developers of the tool</em></p>
<p>More than <a href="http://www.ndepend.com/DefaultRules/webframe.html" rel="nofollow noreferrer">200 code rules</a> are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the <em>well-known</em> C# LINQ syntax.</p>
<p>To keep the number of false-positives low, CQLinq offers the unique capabilities to define what is the set <strong>JustMyCode</strong> through special code queries prefixed with <strong>notmycode</strong>. More explanations about this feature can be found <a href="http://www.ndepend.com/Doc_CQLinq_Syntax.aspx#NotMyCode" rel="nofollow noreferrer">here</a>. Here are for example two <em>notmycode</em> default queries:</p>
<ul>
<li><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Discard_generated_and_designer_Methods_from_JustMyCode.html" rel="nofollow noreferrer">Discard generated and designer Methods from JustMyCode</a></li>
<li><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Discard_generated_Types_from_JustMyCode.html" rel="nofollow noreferrer">Discard generated Types from JustMyCode</a></li>
</ul>
<p>To keep the number of false-positives low, with CQLinq you can also focus rules result only on code added or code refactored, since a <a href="http://www.ndepend.com/Doc_CI_Diff.aspx" rel="nofollow noreferrer">defined baseline in the past</a>. See the following rule, that detect methods too complex added or refactored since the baseline:</p>
<pre><code>warnif count > 0
from m in Methods
where m.CyclomaticComplexity > 20 &&
m.WasAdded() || m.CodeWasChanged()
select new { m, m.CyclomaticComplexity }
</code></pre>
<p>Finally, notice that with NDepend code rules can be verified <a href="http://www.ndepend.com/Doc_VS_CQL.aspx" rel="nofollow noreferrer">live in Visual Studio</a> and at build process time, in a <a href="http://www.ndepend.com/Doc_CI_Report.aspx#CQLRule" rel="nofollow noreferrer">generated HTML+javascript report</a>.</p>
| 4,663
|
<p>It's fairly common for E3D to sell silicone socks for their hot ends. There are also other companies that sell these silicone socks for their hot end cartridges.</p>
<p>According to a brief internet search, it seems the ignition temperature of silicone is surprisingly low - around 450 °C. This surprised me because I was under the impression silicone would just burn / evaporate if it were heated up to a much higher temperature.</p>
<p>If my thermistor/<a href="https://www.thissmarthouse.net/dont-burn-your-house-down-3d-printing-a-cautionary-tale/" rel="nofollow noreferrer">heatrod</a> slips off, my heatrod will glow into an orange temperature during thermal runway. This only happens briefly, but its color indicates it is reaching a temperature around 790 °C. </p>
<p>So, are silicone socks safe? Couldn't they ignite fairly easily?</p>
<p><a href="https://i.stack.imgur.com/XAH7r.png" rel="nofollow noreferrer" title="Incandescence chart for iron"><img src="https://i.stack.imgur.com/XAH7r.png" alt="Incandescence chart for iron" title="Incandescence chart for iron"></a></p>
|
<p>Neither your thermistor nor your heater cartridge should ever be capable of becoming loose from your hotend, let alone the fact it's capable of reaching 800 °C before your printer even notices (This is a massive issue in itself!!!)</p>
<p>Silicone socks are safe, unless you're printing materials with extremely high melting points, which is <em>usually</em> never.</p>
<p>If you're concerned it's going to autoignite mid-print, you have much bigger issues surrounding your hotend than a silicone sock.</p>
|
<p>Silicone socks are <strong>safe to use</strong>, provided your <strong>printer is safely operating</strong> and you are <strong>using the silicone socks in their operating temperature range</strong>.</p>
<hr />
<h1>Your current setup is NOT SAFE!</h1>
<hr />
<p>When the heater element falls out of the heater block (that should not happen in the first place, please secure it correctly) and heats up to about 800 °C this means that the printer has no active <a href="/q/8466">Thermal Runaway Protection (TRP)</a> enabled. Basically, when the thermistor doesn't measure a temperature rise while the voltage to the heater element is being scheduled, the firmware should shut down the voltage to the heater element. When this fails, the heater element can reach dangerously high temperatures to start burning anything that can catch a flame on touch. In deliberate tests, heaters have been able to melt the aluminium of the hotend:</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/qVjWg2vuWzk?start=129"></iframe>
</div></div></p>
<p>You <strong>should be worried at this point</strong> as you see <a href="https://www.thissmarthouse.net/dont-burn-your-house-down-3d-printing-a-cautionary-tale/" rel="noreferrer">from the link you provided</a> what happens if the heater is not shut off when the heater element is disconnected from the heater block:</p>
<p><a href="https://i.stack.imgur.com/eJput.png" rel="noreferrer" title="Burnt Anet A8 as a result of inactive TRP and heater cartridge falling out of the heater block"><img src="https://i.stack.imgur.com/eJput.png" alt="Burnt Anet A8 as a result of inactive TRP and heater cartridge falling out of the heater block" title="Burnt Anet A8 as a result of inactive TRP and heater cartridge falling out of the heater block" /></a></p>
<p>Please <strong>fix your printer ASAP</strong> by uploading a proper firmware with enabled TRP protection before proceeding to print anything or at least don't let it print without supervision and proper smoke/fire detection devices.</p>
| 1,515
|
<p>I am trying to <code>INSERT INTO</code> a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the <code>SQL</code> engine of the day (<a href="http://en.wikipedia.org/wiki/MySQL" rel="noreferrer">MySQL</a>, <a href="http://en.wikipedia.org/wiki/Oracle_Database" rel="noreferrer">Oracle</a>, <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="noreferrer">SQL Server</a>, <a href="http://en.wikipedia.org/wiki/IBM_Informix" rel="noreferrer">Informix</a>, and <a href="http://en.wikipedia.org/wiki/IBM_DB2" rel="noreferrer">DB2</a>).</p>
<p>Is there a silver-bullet syntax coming from an SQL standard (for example, <a href="http://en.wikipedia.org/wiki/SQL-92" rel="noreferrer">SQL-92</a>) that would allow me to insert the values without worrying about the underlying database?</p>
|
<p>Try:</p>
<pre><code>INSERT INTO table1 ( column1 )
SELECT col1
FROM table2
</code></pre>
<p>This is standard ANSI SQL and should work on any DBMS</p>
<p>It definitely works for:</p>
<ul>
<li>Oracle</li>
<li>MS SQL Server</li>
<li>MySQL</li>
<li>Postgres</li>
<li>SQLite v3</li>
<li>Teradata</li>
<li>DB2</li>
<li>Sybase</li>
<li>Vertica</li>
<li>HSQLDB</li>
<li>H2</li>
<li>AWS RedShift</li>
<li>SAP HANA</li>
<li>Google Spanner</li>
</ul>
|
<p>In informix it works as Claude said:</p>
<pre><code>INSERT INTO table (column1, column2)
VALUES (value1, value2);
</code></pre>
| 4,553
|
<p>I've been tasked with redesigning part of a ms-sql database structure which currently involves a lot of views, some of which contain joins to other views. </p>
<p>Anyway, I wonder if anyone here could recommend a utility to automatically generate diagrams to help me visualise the whole structure.</p>
<p>What's the best program you've used for such problems?</p>
|
<p>I am a big fan of Embarcadero's <a href="http://www.embarcadero.com/products/er-studio" rel="nofollow noreferrer">ER/Studio</a>. It is very powerful and produces excellent on-screen as well as printed results. They have a free trial as well, so you should be able to get in and give it a shot without too much strife.</p>
<p>Good luck!</p>
|
<p>If you are talking about MS SQL Server tables, I like the diagram support in SQL Server Management Studio. You just drag the tables from the explorer onto the canvas, and they are laid out for you along with lines for relationships. You'll have to do some adjusting by hand for the best looking diagrams, but it is a decent way to get diagrams.</p>
| 2,611
|
<p>I'm not overly familiar with Tomcat, but my team has inherited a complex project that revolves around a Java Servlet being hosted in Tomcat across many servers. Custom configuration management software is used to write out the server.xml, and various resources (connection pools, beans, server variables, etc) written into server.xml configure the servlet. This is all well and good.</p>
<p>However, the names of some of the resources aren't known in advance. For example, the Servlet may need access to any number of "Anonymizers" as configured by the operator. Each anonymizer has a unique name associated with it. We create and configure each anonymizer using java beans similar to the following:</p>
<pre><code><Resource
name="bean/Anonymizer_toon"
type="com.company.tomcatutil.AnonymizerBean"
factory="org.apache.naming.factory.BeanFactory"
className="teAnonymizer"
databaseId="50"
/>
<Resource
name="bean/Anonymizer_default"
type="com.company.tomcatutil.AnonymizerBean"
factory="org.apache.naming.factory.BeanFactory"
className="teAnonymizer"
databaseId="54"
/>
</code></pre>
<p>However, this appears to require us to have explicit entries in the Servlet's context.xml file for each an every possible resource name in advance. I'd like to replace the explicit context.xml entries with wildcards, or know if there is a better solution to this type of problem.</p>
<p>Currently:</p>
<pre><code> <ResourceLink name="bean/Anonymizer_default"
global="bean/Anonymizer_default"
type="com.company.tomcatutil.AnonymizerBean"/>
<ResourceLink name="bean/Anonymizer_toon"
global="bean/Anonymizer_toon"
type="com.company.tomcatutil.AnonymizerBean"/>
</code></pre>
<p>Replaced with something like:</p>
<pre><code> <ResourceLink name="bean/Anonymizer_*"
global="bean/Anonymizer_*"
type="com.company.tomcatutil.AnonymizerBean"/>
</code></pre>
<p>However, I haven't been able to figure out if this is possible or what the correct syntax might be. Can anyone make any suggestions about better ways to handle this?</p>
|
<p>I've had some luck with <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html" rel="noreferrer">the Java Service Wrapper</a></p>
|
<p>It's possible to implement a Windows service in 100% Java code by combining the use of <a href="https://jdk.java.net/panama/" rel="nofollow noreferrer">Foreign Memory and Linker API</a> (previewing from JDK16 upwards) with <a href="https://github.com/openjdk/jextract" rel="nofollow noreferrer">OpenJDK jextract project</a> to handle the Windows Service callbacks, and then use <a href="https://docs.oracle.com/en/java/javase/18/jpackage/packaging-overview.html" rel="nofollow noreferrer">jpackage</a> to produce a Windows EXE which can then be registered as a Windows Service.</p>
<p>See this example which outlines the work needed to implement a <a href="https://learn.microsoft.com/en-gb/windows/win32/services/svc-cpp" rel="nofollow noreferrer">Windows service</a>. All Windows service EXE must provide callbacks for the main entrypoint <a href="https://learn.microsoft.com/en-gb/windows/win32/api/winsvc/nc-winsvc-lpservice_main_functionw" rel="nofollow noreferrer">ServiceMain</a> and <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nc-winsvc-lphandler_function" rel="nofollow noreferrer">Service Control Handler</a>, and use API calls <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatcherw" rel="nofollow noreferrer">StartServiceCtrlDispatcherW</a>, <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-registerservicectrlhandlerw" rel="nofollow noreferrer">RegisterServiceCtrlHandlerExW</a> and <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-setservicestatus" rel="nofollow noreferrer">SetServiceStatus</a> in <code>Advapi.DLL</code>.</p>
<p>The flow of above callbacks in Java with Foreign Memory structures are:</p>
<pre><code>main()
Must register ServiceMain using StartServiceCtrlDispatcherW
Above call blocks until ServiceMain exits
void ServiceMain(int dwNumServicesArgs, MemoryAddress lpServiceArgVectors)
Must register SvcCtrlHandler using RegisterServiceCtrlHandlerExW
Use SetServiceStatus(SERVICE_START_PENDING)
Initialise app
Use SetServiceStatus(SERVICE_RUNNING)
wait for app shutdown notification
Use SetServiceStatus(SERVICE_STOPPED)
int SvcCtrlHandler(int dwControl, int dwEventType, MemoryAddress lpEventData, MemoryAddress lpContext)
Must respond to service control events and report back using SetServiceStatus
On receiving SERVICE_CONTROL_STOP reports SetServiceStatus(SERVICE_STOP_PENDING)
then set app shutdown notification
</code></pre>
<p>Once finished the Java application, jpackage can create runtime+EXE which can then be installed and registered as a Windows Service. Run as Adminstrator (spaces after = are important):</p>
<pre><code> sc create YourJavaServiceName type= own binpath= "c:\Program Files\Your Release Dir\yourjavaservice.exe"
</code></pre>
| 9,363
|
<p>I'm absolutely stunned by the fact that MS just couldn't get it right to navigate to the definition of a method, when you're combining C# and VB projects in one solution. If you're trying to navigate from VB to C#, it brings up the "Object Explorer", and if from C# to VB, it generates a metadata file.</p>
<p>Honestly, what is so complicated about jumping between different languages, especially if they're supposedly using the same CLR?</p>
<p>Does anyone know why this is, or if there's any workaround?
Did they get it right in VS 2008?</p>
<hr>
<p>@Keith, I am afraid you may be right about your answer. I am truly stunned that Microsoft screwed this up so badly. Does anyone have any ideas for a workaround?</p>
<hr>
<p>@Mladen Mihajlovic - that's exactly the situation I'm describing. Try it out yourself; project references don't make a shred of difference.</p>
|
<p>This is general to both languages.</p>
<ul>
<li>F12 in VB.Net always takes you to the object browser</li>
<li>F12 in C# always takes you to a meta-data definition</li>
</ul>
<p>This is a deliberate mechanism to try and match expected behaviour for upgrading users. The C# way gives you the right information, but the VB way is what users of VBA or VB6 will expect. </p>
<p>The behaviour is the same in VS2008.</p>
<p>These are the rules for external projects, both should take you to the code if it is in the same solution.</p>
<hr>
<p>You're quite right - VB projects treat C# projects as external and vice versa - you can't navigate from code in one to the other. I've tested this in the latest VS2008 and it's still an issue.</p>
<p>It also fails to get complete meta-data. Add a method to your C# code and it won't appear in VB's intellisense until you compile the C# assembly.</p>
<p>This is similar to how components appear in the toolstrip, so I figure the normal navigate to code functionality is a feature of code with a common compilers, and everything else uses some kind of reflection.</p>
<p>As long as you're still building a PDB it should be able to find the files, I guess it doesn't because they need it to support release builds too. It couldn't find the line of code without the PDB lookups. </p>
|
<p>Make sure that your reference is to the VB <em>project</em> and not just a DLL file.</p>
| 8,897
|
<p>Lately I had to change some code on older systems where not all of the code has unit tests.<br>
Before making the changes I want to write tests, but each class created a lot of dependencies and other anti-patterns which made testing quite hard.<br>
Obviously, I wanted to refactor the code to make it easier to test, write the tests and then change it.<br>
Is this the way you'd do it? Or would you spend a lot of time writing the hard-to-write tests that would be mostly removed after the refactoring will be completed?</p>
|
<p>First of all, <a href="http://devver.net/blog/2008/07/tips-for-unit-testing/" rel="noreferrer">here's a great article with tips on unit testing</a>. Secondly, I found a great way to avoid making tons of changes in old code is to just refactor it a little until you can test it. One easy way to do this is to make private members protected, and then override the protected field.</p>
<p>For example, let's say you have a class that loads some stuff from the database during the constructor. In this case, you can't just override a protected method, but you can extract the DB logic to a protected field and then override it in the test.</p>
<pre><code>public class MyClass {
public MyClass() {
// undesirable DB logic
}
}
</code></pre>
<p>becomes</p>
<pre><code>public class MyClass {
public MyClass() {
loadFromDB();
}
protected void loadFromDB() {
// undesirable DB logic
}
}
</code></pre>
<p>and then your test looks something like this:</p>
<pre><code>public class MyClassTest {
public void testSomething() {
MyClass myClass = new MyClassWrapper();
// test it
}
private static class MyClassWrapper extends MyClass {
@Override
protected void loadFromDB() {
// some mock logic
}
}
}
</code></pre>
<p>This is somewhat of a bad example, because you could use DBUnit in this case, but I actually did this in a similar case recently because I wanted to test some functionality totally unrelated to the data being loaded, so it was very effective. I've also found such exposing of members to be useful in other similar cases where I need to get rid of some dependency that has been in a class for a long time.</p>
<p>I would recommend against this solution if you are writing a framework though, unless you really don't mind exposing the members to users of your framework.</p>
<p>It's a bit of a hack, but I've found it quite useful.</p>
|
<p>I am not sure why would you say that unit tests are going be removed once refactoring is completed. Actually your unit-test suite should run after main build (you can create a separate "tests" build, that just runs the unit tests after the main product is built). Then you will immediately see if changes in one piece break the tests in other subsystem. Note it's a bit different than running tests during build (as some may advocate) - some limited testing is useful during build, but usually it's unproductive to "crash" the build just because some unit test happens to fail.</p>
<p>If you are writing Java (chances are), check out <a href="http://www.easymock.org/" rel="nofollow noreferrer">http://www.easymock.org/</a> - may be useful for reducing coupling for the test purposes.</p>
| 2,894
|
<p>When implementing a needle search of a haystack in an object-oriented way, you essentially have three alternatives:</p>
<pre><code>1. needle.find(haystack)
2. haystack.find(needle)
3. searcher.find(needle, haystack)</code></pre>
<p>Which do you prefer, and why?</p>
<p>I know some people prefer the second alternative because it avoids introducing a third object. However, I can't help feeling that the third approach is more conceptually "correct", at least if your goal is to model "the real world".</p>
<p>In which cases do you think it is justified to introduce helper objects, such as the searcher in this example, and when should they be avoided?</p>
|
<p>Usually actions should be applied to what you are doing the action on... in this case the haystack, so I think option 2 is the most appropriate.</p>
<p>You also have a fourth alternative that I think would be better than alternative 3:</p>
<pre><code>haystack.find(needle, searcher)
</code></pre>
<p>In this case, it allows you to provide the manner in which you want to search as part of the action, and so you can keep the action with the object that is being operated on.</p>
|
<p>Definitely the third, IMHO.</p>
<p>The question of a needle in a haystack is an example of an attempt to find one object in a large collection of others, which indicates it will need a complex search algorithm (possibly involving magnets or (more likely) child processes) and it doesn't make much sense for a haystack to be expected to do thread management or implement complex searches.</p>
<p>A searching object, however, is dedicated to searching and can be expected to know how to manage child threads for a fast binary search, or use properties of the searched-for element to narrow the area (ie: a magnet to find ferrous items).</p>
| 4,361
|
<p>I have a Crystal Report which is viewed via a CrystalReportViewer control on an .aspx page (using VS2008). </p>
<p>The report has two data-driven FieldObjects (which can contain a variable number of chars) which I would like to display on the same line beside each other. </p>
<p>Problem is when the text in the first FieldObject is too long it overlaps the text in the second FieldObject. </p>
<p>I have tried setting the 'CanGrow=True' and 'MaxNumberOfLines=1' on the first FieldObject to 'push' the second FieldObject further to the right, but this didn't work. </p>
<p><strong>How do I get the second FieldObject to always display immediately after the first FieldObject regardless of the length of the text in the first?</strong> </p>
<p>Cheers in advance of any knowledge you can drop.</p>
|
<p>you can add a text object to the report. And while editing the text of the text object, drag the field you want to show from the object explorer into the text box. Then hit space, then drag the second field in to the same text box. Your two fields will always be one space a part. You could, of course, add more spaces or any other text you want.</p>
|
<p>Or you can create a function which returns field1 + " " + field2 and add the function to the report.</p>
| 5,407
|
<p>If you create an Oracle dblink you cannot directly access LOB columns in the target tables.</p>
<p>For instance, you create a dblink with:</p>
<pre><code>create database link TEST_LINK
connect to TARGETUSER IDENTIFIED BY password using 'DATABASESID';
</code></pre>
<p>After this you can do stuff like:</p>
<pre><code>select column_a, column_b
from data_user.sample_table@TEST_LINK
</code></pre>
<p>Except if the column is a LOB, then you get the error:</p>
<pre><code>ORA-22992: cannot use LOB locators selected from remote tables
</code></pre>
<p>This is <a href="http://docs.oracle.com/cd/B10501_01/appdev.920/a96591/adl04mng.htm#98328" rel="noreferrer">a documented restriction</a>.</p>
<p>The same page suggests you fetch the values into a local table, but that is... kind of messy:</p>
<pre><code>CREATE TABLE tmp_hello
AS SELECT column_a
from data_user.sample_table@TEST_LINK
</code></pre>
<p>Any other ideas?</p>
|
<p>Yeah, it is messy, I can't think of a way to avoid it though.<br>
You could hide some of the messiness from the client by putting the temporary table creation in a stored procedure (and using "execute immediate" to create they table)<br>
One thing you will need to watch out for is left over temporary tables (should something fail half way through a session, before you have had time to clean it up) - you could schedule an oracle job to periodically run and remove any left over tables. </p>
|
<p>Do you have a specific scenario in mind?
For example, if the LOB holds files, and you are on a company intranet, perhaps you can write a stored procedure to extract the files to a known directory on the network and access them from there.</p>
| 5,901
|
<p>When I first got my 3D printer (a FlashForge Adventurer 3), it came with a sample pack of filament. With this filament, I was able to use skirts for my first layer. When the sample filament ran out, I switched to Hatchbox PLA filament. For some reason, I cannot use skirts with the Hatchbox filament. Now, whenever I try to print something with a skirt, the print moves around, ruining it. The only first-layer that works now are rafts, which I do not like, as they use up more filament and are more of a pain to remove. Is anyone else having this problem? If so, what are some workarounds to this issue?<img src="https://i.stack.imgur.com/913g2.jpg" alt="Here are the failed prints. I terminated them mid-way, as they started to shift on the build plate." /></p>
<blockquote>
<p>Here are the failed prints. I terminated them mid-way, as they started
to shift on the build plate.</p>
</blockquote>
|
<p>PLA is a forgiving filament, you can even print such filament without a heated bed. Although there are differences in quality between brands, PLA shouldn't need a raft to be printed. Hatchbox filament is not considered as a low quality type of filament; it is economical and has been around since 2013. A raft is a structured platform that is specifically used for high temperature and or high shrinkage types of filament, PLA is not such a filament and shouldn't need a raft. This implies that something is wrong with getting the filament sticking to the plate. Good adhesion requires a levelled bed, a correct initial nozzle to build plate distance (e.g. paper thickness) and possibly an adhesive like a glue stick, special adhesion spray, a textured bed or blue tape, etc.</p>
|
<p>Please try one (or more) of the following:</p>
<ol>
<li><p>Change the temperature of your heated bed (50 - 60 °C)</p>
</li>
<li><p>Check your nozzle height (0.15 - 0.25 mm is what I use)</p>
</li>
<li><p>Make sure your bed is level (Maybe use a leaving stick (or whatever those bubble things are called))</p>
</li>
<li><p>Use adhesion. Start with painter's tape (least damaging, easy to remove), then use a glue stick or even hair spray if necessary.</p>
</li>
<li><p>Be sure the bed is clean (I recommend glass cleaner 1-3 squirts and then a light scrub of a paper towel)</p>
</li>
</ol>
| 1,933
|
<p>What is the most efficient way to determine how many comments a particular blog post has? We want to store the data for a new web app. We have a list of permalink URl's as well as the RSS feeds. </p>
|
<p>If I understand correctly, you want a heuristic to estimate the number of comments in an HTML page which is known to be a blog post, yes?</p>
<p>Very often, a specific blog will have some features which make it easy to work out. If you look at mine over at <a href="http://kstruct.com/" rel="nofollow noreferrer">http://kstruct.com/</a> you'll see that all the pages with comments say 'X Responses', so if you were able to do some work on a per blog basis, it's probably not really difficult.</p>
<p>If you needed something generic, I guess there are a few common features that comments have that you might be able to detect. For one, any links in them are quite likely to have rel="nofollow" attributes, so seeing that within a block might imply that it's a comment. </p>
<p>The main interesting thing to look for would be changes in the structure of posts for m the same site. For example, there's also a very good chance that each comment will have its own anchor so people can link directly to it, so you could look at the differing numbers of <a name="XXX"> tags in a given page on the same site to get an idea of the relative numbers of comments.</p>
<p>As Michael Stum pointed out, if the pages have a Comment-RSS feed, your life is made a lot easier because you can get the comment data in a structured format.</p>
<p>All in all, though, I think it's going to be quite a challenging problem to solve in general.</p>
|
<p>Blogs almost always have an RSS feed for comments. If you have that, then you can determine the exact number of comments, since the feeds 99% of the time follow a standard. Even if the blog is your own, if you are already generating an RSS feed, then don't bother making a call to your DB. You already did that to generate the feed, so it makes sense that you would just traverse the XML nodes. That way you don't have additional overhead (depending on how often you want to get this information).</p>
| 7,018
|
<p>Are the naming conventions similar in different languages? If not, what are the differences?</p>
|
<p>As others have said, things vary a lot, but here's a rough overview of the most commonly used naming conventions in various languages:</p>
<p><code>lowercase, lowercase_with_underscores</code>:</p>
<p>Commonly used for local variables and function names (typical C syntax).</p>
<p><code>UPPERCASE, UPPERCASE_WITH_UNDERSCORES:</code></p>
<p>Commonly used for constants and variables that never change. Some (older) languages like BASIC also have a convention for using all upper case for all variable names.</p>
<p><code>CamelCase, javaCamelCase:</code></p>
<p>Typically used for function names and variable names. Some use it only for functions and combine it with lowercase or lowercase_with_underscores for variables. When javaCamelCase is used, it's typically used both for functions and variables.</p>
<p>This syntax is also quite common for external APIs, since this is how the Win32 and Java APIs do it. (Even if a library uses a different convention internally they typically export with the (java)CamelCase syntax for function names.)</p>
<p><code>prefix_CamelCase, prefix_lowercase, prefix_lowercase_with_underscores:</code></p>
<p>Commonly used in languages that don't support namespaces (i.e. C). The prefix will usually denote the library or module to which the function or variable belongs. Usually reserved to global variables and global functions. Prefix can also be in UPPERCASE. Some conventions use lowercase prefix for internal functions and variables and UPPERCASE prefix for exported ones.</p>
<p>There are of course many other ways to name things, but most conventions are based on one of the ones mentioned above or a variety on those.</p>
<p>BTW: I forgot to mention Hungarian notation on purpose.</p>
|
<p>Years ago an wise old programmer taught me the evils of <a href="http://en.wikipedia.org/wiki/Hungarian_notation" rel="nofollow noreferrer">Hungarian notation</a>, this was a real legacy system, Microsoft adopted it some what in the Windows SDK, and later in MFC. It was designed around loose typed languages like C, and not for strong typed languages like C++. At the time I was programming Windows 3.0 using Borland's Turbo Pascal 1.0 for Windows, which later became Delphi. </p>
<p>Anyway long story short at this time the team I was working on developed our own standards very simple and applicable to almost all languages, based on simple prefixes -</p>
<ul>
<li>a - argument </li>
<li>l - local </li>
<li>m - member </li>
<li>g - global</li>
</ul>
<p>The emphasis here is on scope, rely on the compiler to check type, all you need care about is scope, where the data lives. This has many advantages over nasty old Hungarian notation in that if you change the type of something via refactoring you don't have to search and replace all instances of it.</p>
<p>Nearly 16 years later I still promote the use of this practice, and have found it applicable to almost every language I have developed in. </p>
| 7,192
|
<p>Do you have any experience of designing a Real Shared-Nothing Architecture?
Would you have some readings to recommend me?</p>
|
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0596102356" rel="nofollow noreferrer" rel="nofollow noreferrer">Building Scalable Web Sites</a> by <a href="http://flickr.com" rel="nofollow noreferrer">Flickr</a> architect <a href="http://www.iamcal.com/" rel="nofollow noreferrer">Cal Henderson</a> is pretty much the holy book for scalable web architectures.</p>
<p>The <a href="http://danga.com/words/" rel="nofollow noreferrer">presentations</a> by <a href="http://bradfitz.com/" rel="nofollow noreferrer">Brad Fitzpatrick</a> of <a href="http://danga.com" rel="nofollow noreferrer">Danga Interactive</a>, creators of LiveJournal, are also excellent case studies. Check out <a href="http://danga.com/words/2007_06_usenix/usenix.pdf" rel="nofollow noreferrer">this one</a> first.</p>
|
<p>I think that <a href="http://www.sitepoint.com/blogs/2004/07/01/the-j2ee-guy-still-doesnt-get-php/" rel="nofollow noreferrer">The J2EE guy still doesn’t get PHP</a> is (still) worth a read.</p>
| 3,981
|
<p>Is it possible to delete an GAE application after it has been created?</p>
<p>I made a mistake while typing the name and now have a dummy application that I haven't been able to remove.</p>
|
<p>With the new Google Cloud console, you can still disable GAE applications as before (App Engine --> Settings --> Disable). They cannot currently be deleted. However you can delete the entire project by going to IAM --> Settings --> Shut Down. This button is in the header and a bit tricky to spot. It looks like this:</p>
<p><a href="https://i.stack.imgur.com/5EnZv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5EnZv.png" alt="enter image description here"></a></p>
<hr>
<p>As of <a href="http://googleappengine.blogspot.com/2009/10/app-engine-sdk-126-released-with.html" rel="noreferrer">AppEngine SDK 1.2.6</a> it's possible to <a href="http://code.google.com/appengine/kb/adminconsole.html#delete_app" rel="noreferrer">delete apps completely</a>. But beware, the app-id won't be usable again.</p>
|
<p>I wanted to delete some legacy Google App Engine applications I made years ago, but when I tried to delete them from the new Google Cloud Platform (like this: <a href="https://support.google.com/cloud/answer/6251787#shut-down-a-project" rel="nofollow">https://support.google.com/cloud/answer/6251787#shut-down-a-project</a>) I kept getting "You do not have permission" errors. The solution I found was to sign up for a free trial of Google Cloud Platform, then I was able to delete them.</p>
| 6,403
|
<p>I need to call a web service written in .NET from Java. The web service implements the WS-Security stack (either WSE 2 or WSE 3, it's not clear from the information I have). </p>
<p>The information that I received from the service provider included WSDL, a policyCache.config file, some sample C# code, and a sample application that can successfully call the service.</p>
<p>This isn't as useful as it sounds because it's not clear how I'm supposed to use this information to write a Java client. If the web service request isn't signed according to the policy then it is rejected by the service. I'm trying to use Apache Axis2 and I can't find any instructions on how I'm supposed to use the policyCahce.config file and the WSDL to generate a client.</p>
<p>There are several examples that I have found on the Web but in all cases the authors of the examples had control of both the service and the client and so were able to make tweaks on both sides in order to get it to work. I'm not in that position.</p>
<p>Has anyone done this successfully?</p>
|
<p>This seems to be a popular question so I'll provide an overview of what we did in our situation.</p>
<p>It seems that services built in .NET are following an older ws-addressing standard (<a href="http://schemas.xmlsoap.org/ws/2004/03/addressing/" rel="noreferrer">http://schemas.xmlsoap.org/ws/2004/03/addressing/</a>) and axis2 only understands the newer standard (<a href="http://schemas.xmlsoap.org/ws/2004/08/addressing/" rel="noreferrer">http://schemas.xmlsoap.org/ws/2004/08/addressing/</a>).</p>
<p>In addition, the policyCache.config file provided is in a form that the axis2 rampart module can't understand.</p>
<p>So the steps we had to do, in a nutshell:</p>
<ul>
<li>Read the policyCache.config and try to understand it. Then rewrite it into a policy that rampart could understand. (Some <a href="http://www.scribd.com/doc/466238/Official-Documentation-ws-apache-org-Axis2-Part-2" rel="noreferrer">updated docs</a> helped.)</li>
<li>Configure rampart with this policy.</li>
<li>Take the keys that were provided in the .pfx file and convert them to a java key store. There is a utility that comes with Jetty that can do that.</li>
<li>Configure rampart with that key store.</li>
<li>Write a custom axis2 handler that backward-converts the newer ws-addressing stuff that comes out of axis2 into the older stuff expected by the service.</li>
<li>Configure axis2 to use the handler on outgoing messages.</li>
</ul>
<p>In the end it was a lot of configuration and code for something that is supposed to be an open standard supported by the vendors.</p>
<p>Although I'm not sure what the alternative is...can you wait for the vendors (or in this case, the one vendor) to make sure that everything will inter-op?</p>
<p>As a postscript I'll add that I didn't end up doing the work, it was someone else on my team, but I think I got the salient details correct. The other option that I was considering (before my teammate took over) was to call the WSS4J API directly to construct the SOAP envelope as the .NET service expected it. I think that would have worked too.</p>
|
<p><a href="http://cwiki.apache.org/CXF20DOC/ws-support.html" rel="nofollow noreferrer">CXF</a> - I'd look into CXF. I've used it to create a web service and client in java using ws-secuirty. I also connected a .net web service to it.</p>
<p>They have pretty good documentation too. I had more luck with it than axis.</p>
| 3,717
|
<p>I have some code for starting a thread on the .NET CF 2.0:</p>
<pre><code>ThreadStart tStart = new ThreadStart(MyMethod);
Thread t = new Thread(tStart);
t.Start();
</code></pre>
<p>If I call this inside a loop the items completely out of order. How do introduce a wait after <code>t.Start()</code>, so that the work on the thread completes before the code continues? Will BeginInvoke/EndInvoke be a better option for this than manually creating threads?</p>
|
<p>How much order do you need to impose on the threads? If you just need all of the work started in the loop to finish before the code continues, but you don't care about the order the work within the loop finishes, then calling Join is the answer. To add more detail to <a href="https://stackoverflow.com/questions/6890/compact-framework-how-to-wait-for-thread-complete-before-continuing#6935">Kevin Kenny's answer,</a> you should call Join <em>outside</em> the loop. This means you will need a collection to hold references to the threads you started:</p>
<pre><code>// Start all of the threads.
List<Thread> startedThreads = new List<Thread>();
foreach (...) {
Thread thread = new Thread(new ThreadStart(MyMethod));
thread.Start();
startedThreads.Add(thread);
}
// Wait for all of the threads to finish.
foreach (Thread thread in startedThreads) {
thread.Join();
}
</code></pre>
<p>In contrast, if you called Join inside the loop, the result would basically be the same as not using threads at all. Each iteration of the loop body would create and start a thread but then immediately Join it and wait for it to finish.</p>
<p>If the individual threads produce some result (write a message in a log, for example) then the messages may still appear out of order because there's no coordination between the threads. It is possible to get the threads to output their results in order by coordinating them with a Monitor.</p>
|
<p>If I'm reading this properly, you're starting work items on bunch of threads but you're concerned that the threads are completing out of order, and, would prefer to wait until each thread completes in the order they were started ? </p>
<p>If this is the case then I'm not sure why you're creating a thread per work item. Maybe you could expand?</p>
<p>If you did need to wait for a thread to complete the you could just do:</p>
<pre><code>t.Join();
</code></pre>
| 2,856
|
<p>I'm looking for a way to poll different servers and check that SQL server is up and running. I'm writing my code in C#. I don't particularly care about individual databases, just that SQL server is running and responsive.</p>
<p>Any ideas?</p>
|
<p>Well, the brute force solution is to attempt to initiate a connection with the database on each server. That will tell you whether it's running, though you could have timeout issues.</p>
<p>The more elegant (but more difficult... isn't that always the way?) solution would be to use WMI to connect to the remote machine and find out if the SQL server process is running.</p>
|
<p>I would certainly go with Vincent's answer. Just make absolutely certain you are closing and disposing the tcp connections properly etc. WMI seems a bit of overkill to me if that is all you're after.</p>
| 4,297
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.