instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>In the course of your software development lifecycle, what essential design artifacts do you produce? What makes them essential to your practice?</p> <p>The project I'm currently on has been in production for 8+ years. This web application has been actively enhanced and maintained over that time. While we have CMMI based policies and processes in place, with portions of our practice being well defined, the design phase has been largely overlooked. Best practices, anyone? </p>
<p>Having worked on a lot of waterfall projects in the past and a lot of adhoc and agile projects more recently, there's a number of design artifacts I like to create although I can't state enough that it really depends on the details of the project (methodology/team structure/timescale/tools etc).</p> <p>For a generic, server-based 'enterprise application' I'd want the bare minimum to be something along these lines:</p> <ul> <li>A detailed functional design document (aka spec). Generally something along the lines of Joel s' <a href="http://www.joelonsoftware.com/articles/WhatTimeIsIt.html" rel="nofollow noreferrer">WhatsTimeIsIt example spec</a>, although probably with some UML use-case diagrams.</li> <li>A software techical design document. Not necessarily detailed for 100% system coverage but detailed in all the key areas and containing all the design decisions. Being a bit of an UML freak it'd be nice to see lots of pictures along the lines of package diagrams, component diagrams, key feature class diagrams, and probably some sequence diagrams thrown in for good measure.</li> <li>An infrastructure design document. Probably with UML deployment diagram for the conceptual deisng and perhaps a network diagram for something more physical.</li> </ul> <p>When I say document any of the above might be broken down into multiple documents, or perhaps stored on a wiki/some other tool. </p> <p>As for their usefulness, my philosophy has always been that a development team should always be able to hand over an application to a support team without having to hand over their phone numbers. If the design artifacts don't clealry indicate what the application does, how it does it, and where it does it then you know the support team are going to give the app the same care and attention they would a rabid dog. </p> <p>I should mention I'm not vindicating the practice of handing software over from a dev team to a support team once it's <em>finished</em>, which raises all manner of interesting issues, I'm just saying it should be possible if the management so desired.</p>
<p>I don't think anything can take the place of a good old fashioned design spec for the following reasons: </p> <ul> <li>It serves as a means of communicating how you will build an application to others. </li> <li>It lets you get ideas out of your head so you don't worry about tracking a million things at the same time.</li> <li>If you have to pause a project and return to it later you're not starting your thought process over again.</li> </ul> <p>I like to see various bits of info in a design spec:</p> <ul> <li>General explanation of your approach to the challenge at hand</li> <li>How will you monitor your application?</li> <li>What are the security concerns and how are they addressed?</li> <li>Flowcharts / sequence diagrams</li> <li>Open issues</li> <li>Known limitations</li> </ul> <p>Unit tests, while a fantastic and arguably critical item to include in your application development, don't cover all of these topics.</p>
6,667
<p>Okay, so I'm running a small test webserver on my private network. I've got a machine running Windows 2000 Pro, and I'm trying to run an ASP.NET app through IIS.</p> <p>I wrote it so that the webpage would use the registry to store certain settings (connection strings, potentially volatile locations of other web services, paths in the local filesystem where certain information is stored etc...) Of course, it worked fine when testing with VStudio.NET 2005, because the user running the app has elevated privileges. However, running it on IIS I get a "Access to the registry key 'HKEY_LOCAL_MACHINE\Software' is denied.", which suggests the IIS user doesn't have read access to that part of the registry (I only do reads through the website itself, never writes).</p> <p>I was like "okay, simple enough, I'll just go give that user rights to that part of the registry through regedit." The problem is, I don't see an option anywhere in regedit to change security settings... at all. Which got me thinking... I don't think I've ever actually had to change security settings for registry hives/keys before, and I don't think I know how to do it.</p> <p>Half an hour of searching the web later, I haven't found any usable information on this subject. What I'm wondering is... how DO you change security rights to portions of the registry? I'm stumped, and it seems my ability to find the answer on Google is failing me utterly... and since I just signed up here, I figured I'd see if anyone here knew. =)</p>
<p>If your having touble with RegEdit in Windows 2000 you can try the following:</p> <ul> <li>Copy the Windows XP RegEdt32.exe to the Windows 2000 Machine</li> <li>Using a Windows XP Machine, connect to the Windows 2000 registry remotely: File > Connect Network Registry</li> </ul>
<p>You can set permissions at the folder level for which you want to grant user permissions read/write access. </p> <p>In your case, right click on the "Software" folder and select "Permissions".</p> <p>You'll probably know the rest from there.</p> <p>EDIT: If you still run into issues, you may want to modify your web.config file and use impersonation to have your web application run as a certain user account. Then you can put a tighter reign on the controls.</p>
4,888
<p>I'm wanting to change my movie clips to actionscript classes in AS3. Is there a standard list of things I need to do to make sure the classes work?</p>
<p>Check out these resources:</p> <p>Grant Skinners Introductory AS3 Workshop slidedeck <a href="http://gskinner.com/talks/as3workshop/" rel="nofollow noreferrer">http://gskinner.com/talks/as3workshop/</a></p> <p>Lee Brimelow : 6 Reasons to learn ActionScript 3 <a href="http://www.adobe.com/devnet/actionscript/articles/six_reasons_as3.html" rel="nofollow noreferrer">http://www.adobe.com/devnet/actionscript/articles/six_reasons_as3.html</a></p> <p>Colin Moock : Essential ActionScript 3 (considered the "bible" for ActionScript developers): <a href="https://rads.stackoverflow.com/amzn/click/com/0596526946" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Essential-ActionScript-3-0/dp/0596526946</a></p> <p>mike chambers</p> <p>mesh@adobe.com</p>
<p>Don't forget this excellent devnet article meant for transitioning from AS2 to AS3:</p> <p><a href="http://www.adobe.com/devnet/actionscript/articles/actionscript_tips.html" rel="nofollow noreferrer">http://www.adobe.com/devnet/actionscript/articles/actionscript_tips.html</a></p>
9,316
<p>I have a a property defined as:</p> <pre><code>[XmlArray("delete", IsNullable = true)] [XmlArrayItem("contact", typeof(ContactEvent)), XmlArrayItem("sms", typeof(SmsEvent))] public List&lt;Event&gt; Delete { get; set; } </code></pre> <p>If the List&lt;> Delete has no items</p> <pre><code>&lt;delete /&gt; </code></pre> <p>is emitted. If the List&lt;> Delete is set to null</p> <pre><code>&lt;delete xsi:nil="true" /&gt; </code></pre> <p>is emitted. Is there a way using attributes to get the delete element not to be emitted if the collection has no items?</p> <p><a href="https://stackoverflow.com/questions/69296/xml-serialization-and-empty-collections#69407">Greg</a> - Perfect thanks, I didn't even read the IsNullable documentation just assumed it was signalling it as not required.</p> <p><a href="https://stackoverflow.com/questions/69296/xml-serialization-and-empty-collections#69518">Rob Cooper</a> - I was trying to avoid ISerializable, but Gregs suggestion works. I did run into the problem you outlined in (1), I broke a bunch of code by just returning null if the collection was zero length. To get around this I created a EventsBuilder class (the class I am serializing is called Events) that managed all the lifetime/creation of the underlying objects of the Events class that spits our Events classes for serialization.</p>
<p>If you set IsNullable=false or just remove it (it is false by default), then the "delete" element will not be emitted. This will work only if the collection equals to null.</p> <p>My guess is that there is a confusion between "nullability" in terms of .NET, and the one related to nullable elements in XML -- those that are marked by xml:nil attribute. XmlArrayAttribute.IsNullable property controls the latter.</p>
<p>You could always implement IXmlSerializer and perform the serialization manually.</p> <p>See <a href="http://www.codeproject.com/KB/cs/IXmlSerializable.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/IXmlSerializable.aspx</a> for an example.</p>
9,470
<p>I have read about JavaFX, and like all new technologies I wanted to get my hands "dirty" with it. However, although it talks of multiplatform support, I can't find specifics on this.</p> <p>What platforms support a JavaFX application? All those with Java SE? ME? Does it depend upon the APIs in JavaFX that I use?</p>
<p>JavaFX has three planned distributions.</p> <ul> <li>JavaFX Desktop will run on Windows, Mac, <s>Linux, and Solaris</s> at FCS and will require Java SE. Support for Linux and Solaris will be forthcoming.</li> <li>JavaFX TV and JavaFX Mobile have no announce target platforms. Also unannounced is whether they will run on ME or SE, and if ME which profiles.</li> </ul> <p>One important platform distinction is that JavaFX Desktop will support Swing components while JavaFX Mobile will not (only scene graph for graphics). JavaFX TV the least publicly concrete of the three at this time.</p>
<p>JavaFx is not a new runtime. It is the same JRE but a new language/compiler with some a few new APIs to make it all works....</p> <p>Using Netbeans, you can build applications on any platform. As of today, the APIs are beta. Classfiles produced by the compiler are JRE 6 compatible.</p>
8,361
<p>For scripting languages, what is the most effective way to utilize a console when developing? Are there ways to be more productive with a console than a "compile and run" only language?</p> <p>Added clarification: I am thinking more along the lines of Ruby, Python, Boo, etc. Languages that are used for full blown apps, but also have a way to run small snippets of code in a console.</p>
<blockquote> <p>I am thinking more along the lines of Ruby, ...</p> </blockquote> <p>Well for Ruby the <code>irb</code> interactive prompt is a great tool for "practicing" something simple. Here are the things I'll mention about the irb to give you an idea of effective use:</p> <ul> <li><p><em>Automation</em>. You are allowed a <code>.irbrc</code> file that will be automatically executed when launching irb. That means you can load your favorite libraries or do <em>whatever</em> you want in full Ruby automatically. To see what I mean check out some of the ones at <a href="https://web.archive.org/web/20110824004021/http://dotfiles.org:80/.irbrc" rel="nofollow noreferrer">dotfiles.org</a>.</p></li> <li><p><em>Autocompletion</em>. That even makes writing code easier. Can't remember that string method to remove newlines? <code>"".ch&lt;tab&gt;</code> produces chop and chomp. <em>NOTE: you have to enable autocompletion for irb yourself</em></p></li> <li><p><em>Divide and Conquer</em>. irb makes the small things really easy. If you're writing a function to manipulate strings, the ability to test the code interactively right in the prompt saves a lot of time! For instance you can just open up irb and start running functions on an example string and have working and tested code already ready for your library/program. </p></li> <li><p><em>Learning, Experimenting, and Hacking</em>. Something like this would take a very long time to test in C/C++, even Java. If you tried testing them all at once you might seg-fault and have to start over.</p> <p>Here I'm just learning how the <code>String#[]</code> function works.</p> <pre><code>joe[~]$ irb &gt;&gt; "12341:asdf"[/\d+/] # =&gt; "12341" &gt;&gt; "12341:asdf"[/\d*/] # =&gt; "12341" &gt;&gt; "12341:asdf"[0..5] # =&gt; "12341:" &gt;&gt; "12341:asdf"[0...5] # =&gt; "12341" &gt;&gt; "12341:asdf"[0, ':'] TypeError: can't convert String into Integer from (irb):5:in `[]' from (irb):5 &gt;&gt; "12341:asdf"[0, 5] # =&gt; "12341" </code></pre></li> <li><p><em>Testing and Benchmarking</em>. Now they are nice and easy to perform. <a href="http://ozmm.org/posts/time_in_irb.html" rel="nofollow noreferrer">Here</a> is someone's idea to emulate the Unix <code>time</code> function for quick benchmarking. Just add it to your <code>.irbrc</code> file and its always there!</p></li> <li><p><em>Debugging</em> - I haven't used this much myself but there is always the ability to debug code <a href="https://web.archive.org/web/20080912141043/http://www.rubycentral.com:80/pickaxe/trouble.html" rel="nofollow noreferrer">like this</a>. Or pull out some code and run it in the irb to see what its actually doing.</p></li> </ul> <p>I'm sure I'm missing some things but I hit on my favorite points. You really have zero limitation in shells so you're limited only by what you can think of doing. I almost always have a few shells running. Bash, Javascript, and Ruby's irb to name a few. I use them for a lot of things!</p>
<p>I've added a shortcut to my Control-Shift-C key combination to bring up my Visual Studio 2008 Console. This alone has saved me countless seconds when needing to register a dll or do any other command. I imagine if you leverage this with another command tool and you may have some massive productivity increases.</p>
5,248
<p><strong>NOTE: <em>XMLIgnore</em> is NOT the answer!</strong></p> <p>OK, so following on from my question on <a href="https://stackoverflow.com/questions/20084/xml-serialization-and-inherited-types">XML Serialization and Inherited Types</a>, I began integrating that code into my application I am working on, stupidly thinking all will go well..</p> <p>I ran into problems with a couple of classes I have that implement <em>IEnumerable</em> and <em>ICollection&lt;T&gt;</em></p> <p>The problem with these is that when the XMLSerializer comes to serialize these, it views them as an external property, and instead of using the property we would like it to (i.e. the one with our <em>AbstractXmlSerializer</em> ) it comes here and falls over (due to the type mismatch), pretty much putting us back to square one. You cannot decorate these methods with the <strong>XmlIgnore</strong> attribute either, so we cannot stop it that way.</p> <p>My current solution is to remove the interface implementation (in this current application, its no real big deal, just made the code prettier).</p> <p><strong>Do I need to swallow my pride on this one and accept it cant be done?</strong> I know I have kinda pushed and got more out of the XmlSerializer than what was expected of it :)</p> <hr /> <h3>Edit</h3> <p>I should also add, I am currently working in framework 2.</p> <hr /> <h3>Update</h3> <p>I have accepted <a href="https://stackoverflow.com/questions/31799/preventing-xml-serialization-of-ienumerable-and-icollectiont-inherited-types#31810">lomaxx's answer</a>. In my scenario I cannot actually do this, but I do know it will work. Since their have been no other suggestions, I ended up removing the interface implementation from the code.</p>
<p>you can get around this problem by getting hold of the System.RunTime.Serialization dll (it's a .net 3.x assembly) and referencing it from your .net 2.0 application. This works because the .net 3.0 binaries are compiled to run on the .net 2.0 CLR.</p> <p>By doing this, you get access to the DataContractSerliazer which I've used to get around a similar problem where I wanted to pass in a ICollection as a parameter to a webservice and the xmlserializer didn't know how to deal with it properly.</p> <p>If you're cool with using the .net 3.x dll in your 2.x application you should be able to use the DataContractSerializer to solve this problem</p>
<p>If you use these attributes:</p> <pre><code> [XmlArray("ProviderPatientLists")] [XmlArrayItem("File")] public ProviderPatientList Files { get { return _ProviderPatientLists; } set { _ProviderPatientLists = value; } } </code></pre> <p>Where ProviderPatientList inherit's <code>List&lt;PatientList&gt;</code></p> <p>You can then have more control over the xml outputed will create </p> <p> </p>
5,168
<p>There are two popular closure styles in javascript. The first I call <em>anonymous constructor</em>:</p> <pre><code>new function() { var code... } </code></pre> <p>and the <em>inline executed function</em>:</p> <pre><code>(function() { var code... })(); </code></pre> <p>are there differences in behaviour between those two? Is one "better" over the other?</p>
<p>Both cases will execute the function, the only real difference is what the return value of the expression may be, and what the value of "this" will be inside the function.</p> <p>Basically behaviour of</p> <pre><code>new expression </code></pre> <p>Is effectively equivalent to</p> <pre><code>var tempObject = {}; var result = expression.call(tempObject); if (result is not an object) result = tempObject; </code></pre> <p>Although of course tempObject and result are transient values you can never see (they're implementation details in the interpreter), and there is no JS mechanism to do the "is not an object" check.</p> <p>Broadly speaking the "new function() { .. }" method will be slower due to the need to create the this object for the constructor.</p> <p>That said this should be not be a real difference as object allocation is not slow, and you shouldn't be using such code in hot code (due to the cost of creating the function object and associated closure).</p> <p>Edit: one thing i realised that i missed from this is that the <code>tempObject</code> will get <code>expression</code>s prototype, eg. (before the <code>expression.call</code>) <code>tempObject.__proto__ = expression.prototype</code></p>
<p>Yes, there are differences between the two.</p> <p>Both are anonymous functions and execute in the exact same way. But, the difference between the two is that in the second case scope of the variables is restricted to the anonymous function itself. There is no chance of accidentally adding variables to the global scope.</p> <p>This implies that by using the second method, you are not cluttering up the global variables scope which is good as these global variable values can interfere with some other global variables that you may use in some other library or are being used in a third party library.</p> <p>Example:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; new function() { a = "Hello"; alert(a + " Inside Function"); }; alert(a + " Outside Function"); (function() { var b = "World"; alert(b + " Inside Function"); })(); alert(b + " Outside Function"); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In the above code the output is something like:</p> <blockquote> <p>Hello Inside Function<br> Hello Outside Function<br> World Inside Function</p> </blockquote> <p>... then, you get an error as 'b' is not defined outside the function!</p> <p>Thus, I believe that the second method is better... safer!</p>
2,812
<p>OK, I know what you're thinking, &quot;why write a method you do not want people to use?&quot; Right?</p> <p>Well, in short, I have a class that needs to be serialized to XML. In order for the <a href="https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=vs.110%29.aspx" rel="noreferrer"><code>XmlSerializer</code></a> to do its magic, the class must have a default, empty constructor:</p> <pre><code>public class MyClass { public MyClass() { // required for xml serialization } } </code></pre> <p>So, I need to have it, but I don't want people to <em>use</em> it, so <strong>is there any attribute that can be use to mark the method as &quot;DO NOT USE&quot;?</strong></p> <p>I was thinking of using the <em>Obsolete</em> attribute (since this can stop the build), but that just seems kinda &quot;wrong&quot;, is there any other way of doing this, or do I need to go ahead and bite the bullet? :)</p> <h2>Update</h2> <p>OK, I have accepted Keith's answer, since I guess in my heart of hearts, I totally agree. This is why I asked the question in the first place, I don't like the notion of having the <em>Obsolete</em> attribute.</p> <h3>However...</h3> <p>There <em>is</em> still a problem, while we are being notified in intellisense, ideally, we would like to break the build, so is there any way to do this? Perhaps create a custom attribute?</p> <p><strong>More focused question has been created <a href="https://stackoverflow.com/questions/28150/create-an-attribute-to-break-the-build">here</a>.</strong></p>
<p>If a class is <a href="https://msdn.microsoft.com/en-us/library/system.serializableattribute%28v=vs.110%29.aspx" rel="noreferrer"><code>[Serialisable]</code></a> (i.e. it can be copied around the place as needed) the param-less constructor is needed to deserialise.</p> <p>I'm guessing that you want to force your code's access to pass defaults for your properties to a parameterised constructor.</p> <p>Basically you're saying that it's OK for the <a href="https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=vs.110%29.aspx" rel="noreferrer"><code>XmlSerializer</code></a> to make a copy and then set properties, but you don't want your own code to.</p> <p>To some extent I think this is over-designing. </p> <p>Just add XML comments that detail what properties need initialising (and what to). </p> <p>Don't use <a href="https://msdn.microsoft.com/en-us/library/system.obsoleteattribute%28v=vs.110%29.aspx" rel="noreferrer"><code>[Obsolete]</code></a>, because it isn't. Reserve that for genuinely deprecated methods.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.obsoleteattribute.aspx" rel="nofollow noreferrer"><code>ObsoleteAttribute</code></a> will probably work in your situation - you can even cause the build to break if that method is used. </p> <p>Since obsolete warnings occur at compile time, and since the reflection needed for serialization occurs at runtime, marking that method obsolete won't break serialization, but will warn developers that the method is not there to be used.</p>
4,743
<p>One of the topics that seems to come up regularly on mailing lists and online discussions is the merits (or lack thereof) of doing a Computer Science Degree. An argument that seems to come up time and again for the negative party is that they have been coding for some number of years and they have never used recursion.</p> <p>So the question is:</p> <ol> <li>What is recursion?</li> <li>When would I use recursion?</li> <li>Why don't people use recursion?</li> </ol>
<p>There are a number of good explanations of <a href="http://en.wikipedia.org/wiki/Recursion_%28computer_science%29" rel="noreferrer">recursion</a> in this thread, this answer is about why you shouldn't use it in most languages.* In the majority of major imperative language implementations (i.e. every major implementation of C, C++, Basic, Python, Ruby,Java, and C#) <a href="http://en.wikipedia.org/wiki/Iteration" rel="noreferrer">iteration</a> is vastly preferable to recursion.</p> <p>To see why, walk through the steps that the above languages use to call a function:</p> <ol> <li>space is carved out on <a href="http://en.wikipedia.org/wiki/Call_stack" rel="noreferrer">the stack</a> for the function's arguments and local variables</li> <li>the function's arguments are copied into this new space</li> <li>control jumps to the function</li> <li><strong><em>the function's code runs</em></strong></li> <li>the function's result is copied into a return value</li> <li>the stack is rewound to its previous position</li> <li>control jumps back to where the function was called</li> </ol> <p>Doing all of these steps takes time, usually a little bit more than it takes to iterate through a loop. However, the real problem is in step #1. When many programs start, they allocate a single chunk of memory for their stack, and when they run out of that memory (often, but not always due to recursion), the program crashes due to a <a href="http://en.wikipedia.org/wiki/Stack_overflow" rel="noreferrer">stack overflow</a>.</p> <p>So in these languages recursion is slower and it makes you vulnerable to crashing. There are still some arguments for using it though. In general, code written recursively is shorter and a bit more elegant, once you know how to read it.</p> <p>There is a technique that language implementers can use called <a href="http://en.wikipedia.org/wiki/Tail_call_optimization" rel="noreferrer">tail call optimization</a> which can eliminate some classes of stack overflow. Put succinctly: if a function's return expression is simply the result of a function call, then you don't need to add a new level onto the stack, you can reuse the current one for the function being called. Regrettably, few imperative language-implementations have tail-call optimization built in. </p> <p>* <em>I love recursion. <a href="http://www.haskell.org/" rel="noreferrer">My favorite static language</a> doesn't use loops at all, recursion is the only way to do something repeatedly. I just don't think that recursion is generally a good idea in languages that aren't tuned for it.</em></p> <p>** By the way Mario, the typical name for your ArrangeString function is "join", and I'd be surprised if your language of choice doesn't already have an implementation of it.</p>
<p>I have created a recursive function to concatenate a list of strings with a separator between them. I use it mostly to create SQL expressions, by passing a list of fields as the '<em>items</em>' and a '<em>comma+space</em>' as the separator. Here's the function (It uses some Borland Builder native data types, but can be adapted to fit any other environment):</p> <pre><code>String ArrangeString(TStringList* items, int position, String separator) { String result; result = items-&gt;Strings[position]; if (position &lt;= items-&gt;Count) result += separator + ArrangeString(items, position + 1, separator); return result; } </code></pre> <p>I call it this way:</p> <pre><code>String columnsList; columnsList = ArrangeString(columns, 0, ", "); </code></pre> <p>Imagine you have an array named '<em>fields</em>' with this data inside it: '<em>albumName</em>', '<em>releaseDate</em>', '<em>labelId</em>'. Then you call the function:</p> <pre><code>ArrangeString(fields, 0, ", "); </code></pre> <p>As the function starts to work, the variable '<em>result</em>' receives the value of the position 0 of the array, which is '<em>albumName</em>'.</p> <p>Then it checks if the position it's dealing with is the last one. As it isn't, then it concatenates the result with the separator and the result of a function, which, oh God, is this same function. But this time, check it out, it call itself adding 1 to the position.</p> <pre><code>ArrangeString(fields, 1, ", "); </code></pre> <p>It keeps repeating, creating a LIFO pile, until it reaches a point where the position being dealt with IS the last one, so the function returns only the item on that position on the list, not concatenating anymore. Then the pile is concatenated backwards.</p> <p>Got it? If you don't, I have another way to explain it. :o)</p>
2,515
<p>I want to port data from one server's database to another server's database. The databases are both on a different mssql 2005 server. Replication is probably not an option since the destination database is generated from scratch on a [time interval] basis.</p> <p>Preferebly I would do something like</p> <pre><code>insert * from db1/table1 into db2/table2 where rule1 = true </code></pre> <p>It's obvious that connection credentials would go in somehwere in this script.</p>
<p>I think what you want to do is create a linked server as per <a href="http://web.archive.org/web/20150628090613/https://msdn.microsoft.com/en-us/library/aa213778(SQL.80).aspx" rel="nofollow noreferrer">this webarchive snapshot of msdn article from 2015</a> or <a href="https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-ver15" rel="nofollow noreferrer">this article from learn.microsoft.com</a>. You would then select using a 4 part object name eg:</p> <pre><code>Select * From ServerName.DbName.SchemaName.TableName </code></pre>
<pre><code>CREATE VIEW newR1 AS SELECT * from OPENQUERY ([INSTANCE_NAME], 'select * from DbName.SchemaName.TableName') </code></pre>
9,585
<p>I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it timed out.</p> <p>What's the best way to programatically list, and iterate through, this many files?</p> <p>Edit: My coworker suggested using the MS indexing service. Has anyone tried this approach, and (how) has it worked?</p>
<p>I've worked on a SAN system in the past with telephony audio recordings which had issues with numbers of files in a single folder - that system became unusable somewhere near 5,000 (on Windows 2000 Advanced Server with an application in C#.Net 1.1)- the only sensible solution that we came up with was to change the folder structure so that there were a more reasonable number of files. Interestingly Explorer would also time out!</p> <p>The convention we came up with was a structure that broke the structure up in years, months and days - but that will depend upon your system and whether you can control the directory structure...</p>
<p>None. .NET relies on underlying Windows API calls that really, really hate that amount of files themselves.</p> <p>As Ronnie says: split them up.</p>
2,562
<p>I am looking to print an HTD Timing Belt pulley to be used in a laboratory setting that can get <em>very</em> cold for extended periods of time. By &quot;very cold&quot; I mean adjacent metal chambers get cooled with liquid nitrogen to lower than -200 °C. For the purposes of having a threshold temperature tolerance, assume that the metal chambers coming directly in contact with the pulley may get as cold as mK close to absolute zero.</p> <p>While it was my intention to print this pulley out of PLA, I am unsure whether or not it will be able to withstand negative temperatures of this magnitude or if it will become brittle--or something else will happen to the structure of the print when it experiences these temperatures. I am open to printing any other material if there are some materials that will hold up better than PLA for low temperatures. It is preferable for me to print this part instead of machine it for the sake of a deadline. I was also wondering if there is some infill pattern, infill density, or other structural print parameters that would help reinforce a printed part against becoming brittle when imposed to such low temperatures.</p>
<p>I found <a href="https://www.curbellplastics.com/Research-Solutions/Technical-Resources/Technical-Resources/Plastic-Materials-in-Cryogenic-Environments#:%7E:text=Plastics%20offer%20a%20number%20of,wear%20surfaces%20without%20external%20lubrication." rel="nofollow noreferrer">this article</a> which seems to suggest PTFE is a good choice of plastic for a cryogenic environment. I've read that there are PTFE filaments available for FDM printers, though there are some caveats. First, you will need an all-metal hot end; enough heat to melt a PTFE filament will melt the PTFE filament guide if it is in contact with the nozzle. Second, you will likely need to edit your printer's firmware to permit printing at the high temperatures required. Third, it may require some testing to determine whether FDM printed PTFE will meet your mechanical needs (shear strength, layer adhesion, etc.) and fourth, you might need an unusual build surface, since the polymers used for many existing surfaces can't take the temperatures needed for bed adhesion.</p> <p>Finally, as with a PTFE guide tube in contact with the nozzle, at the temperatures required you need to be aware of and take precautions against outgassing by the melting PTFE.</p>
<p>You could try PETG. PETG labware works down to -70, and there is a video clip where a PET bottle filled with liquid nitrogen that withstands appreciable pressure. But for whichever material is used, thermal cycling may be a problem.</p>
1,967
<p>How do you handle database exceptions in your application?<br> Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic?<br> Do you try to recover from some kind of DB errors (e.g. timeouts)?</p> <p>Here are some approaches:</p> <ol> <li>Validate data prior passing it to DB</li> <li>Left validation to DB and handle DB exceptions properly</li> <li>Validate on both sides</li> <li>Validate some obvious constraints in business logic and left complex validation to DB </li> </ol> <p>What approach do you use? Why?</p> <p><strong>Updates:</strong> </p> <p>I'm glad to see growing discussion.<br> Let’s try to sum up community answers. </p> <p>Suggestions: </p> <ul> <li>Validate on both sides</li> <li>Check business logic constraints on client side, let DB do integrity checks <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39406">from hamishmcn</a></li> <li>Check early to avoid bothering DB <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39461">from ajmastrean</a></li> <li>Check early to improve user experience <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39428">from Will</a></li> <li>Keep DB interacting code in place to simplify development <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39406">from hamishmcn</a></li> <li>Object-relational mapping (NHibernate, Linq, etc.) can help you to deal with constrains <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39461">from ajmastrean</a></li> <li>Client side validation is necessary for security reasons <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39487">from Seb Nilsson</a></li> </ul> <p>Do you have anything else to say? This is converted to Validation specific question. We are missing the core, i.e. "Database related Error best practices" which ones to handle and Which ones to Bubble up?</p>
<p>@aku: DRY is nice, but its not always possible. Validation is one of those places, as you will have three completely different and unrelated places where validation is not only possible but absolutely needed: Within the UI, within the business logic, and within the database.</p> <p>Think of a web application. You want to reduce trips to the server, so you include javascript validation of client data entry. But you can't trust what the user enters, so you must perform validation within your business logic before touching the database. And the database must have its own validation in order to prevent data corruption. </p> <p>There's no clean way to unify these three different types of validation within a single component. </p> <p>There are some attempts being made to unify cross-cutting responsibilities like validation within policy injectors like the P&amp;P group's <a href="http://blogs.msdn.com/tomholl/archive/2007/02/23/announcing-the-policy-injection-application-block.aspx" rel="noreferrer">Policy Injection Application Block</a> combined with their <a href="http://rds.yahoo.com/_ylt=A0geu.w0Or1ImvQAR19XNyoA;_ylu=X3oDMTBybnZlZnRlBHNlYwNzcgRwb3MDMQRjb2xvA2FjMgR2dGlkAw--/SIG=13f2oa1b9/EXP=1220447156/**http%3a//blogs.msdn.com/tomholl/archive/2006/11/27/validation-application-block-revealed.aspx" rel="noreferrer">Validation Application Block</a>, but these are still code based. If you have validation that's not in code, you still have to maintain parallel logic separately...</p>
<p>The sorts of apps that I was writing (I've since moved jobs) were in-house fat-client apps.<br> I would try to keep the business logic in the client, and do more mechanical validation on the db (ie validation that only related to the procedure's ability to run, as opposed to higher level validation).<br> In short, validate where you can, and try to keep related types of validation together.</p>
6,039
<p>In my current job the supervisor's practice is to only check in production ready code. Most recently the project I was on involved work by 3 different developers with some file overlap. This meant manually integrating changes despite the fact that some changes took a day and then it was done. I wanted to see if this was a common practice and get suggestions on how to change this practice with the knowledge that many times my opinion means little in the grand scheme of things.</p>
<p>You can use various ways to handle this situation, depending on your source control system. </p> <p>Private branches: Allow you to check in and work on code while you go, merging back and forth at appropriate times.</p> <p>Shelvesets/pacakaged changesets: Allow you to store changesets and send them around for review - ensuring they're production ready before check in.</p> <p>As to whether this is an appropriate way to work, we don't allow check-in to main branches without prior review. To pass review your code must pass various automated tools, and then must be acceptable to your peer reviewer. For some definitions of "production ready" - this is it. Therefore, we do something like what you do. However, we use private branches to ensure that check-ins can still be made while this is in progress, and that other check-ins don't have to interfere. </p> <p>If production ready means tested in an integration environment, then it sounds like you may need staging branches or something similar.</p>
<p>I would personally not approve of this because sometimes that's the best way to catch problem code with less experienced developers (by seeing it as they are working on it) and when you "check in early and often" you can rollback to earlier changes you made (as you were developing) if you decide that some changes you made earlier was actually a better idea. </p>
6,639
<p>I work with C# at work but dislike how with webforms it spews out a lot of JavaScript not including the many lines for viewstate that it creates.</p> <p>That's why I like coding with PHP as I have full control.</p> <p>But I was just wondering how this sites HTML is so clean and elegant?</p> <p>Does using MVC have something to do with it? I see that JQuery is used but surely you still use asp:required validators? If you do, where is all the hideous code that it normally produces?</p> <p>And if they arent using required field validators, why not? Surely it's quicker to develop in than using JQuery?</p> <p>One of the main reasons I code my personal sites in PHP was due to the more elegant HTML that it produces but if I can produce code like this site then I will go full time .net!</p>
<p>One of the goals of ASP.NET MVC is to give you control of your markup. However, there have always been choices with ASP.NET which would allow you to generate relatively clean HTML.</p> <p>For instance, ASP.NET has always offered a choice with validator controls. Do you value development speed over markup? Use validators. Value markup over development speed? Pick another validation mechanism. Your comments on validators are kind of contradictory there - it's possible to use ASP.NET and still make choices for markup purity over development speed.</p> <p>Also, with webforms, we've had the CSS Friendly Control Adapters for a few years which will modify the controls to render more semantic markup. ASP.NET 3.5 included the ListView, which makes it really easy to write repeater type controls which emit semantic HTML. We used ASP.NET webforms on the Microsoft PDC site and have kept the HTML pretty clean: <a href="http://microsoftpdc.com/Agenda/Speakers.aspx" rel="nofollow noreferrer">http://microsoftpdc.com/Agenda/Speakers.aspx</a> - the Viewstate could probably be disabled on most pages, although in reality it's only a few dozen bytes.</p>
<p>You were on the right track. It is the fact that they are using the ASP.NET MVC web framework. It allows you to have full control of your output html.</p>
3,385
<p>I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created. </p> <p>How can I make the dialog box show something like this:</p> <pre><code>There was an error. Go to this page to fix it. wwww.TheWebPageToFix.com </code></pre> <p>Thanks.</p>
<p>You could try asking them if they wish to visit via window.prompt:</p> <pre><code>if(window.prompt('Do you wish to visit the following website?','http://www.google.ca')) location.href='http://www.google.ca/'; </code></pre> <p>Also, Internet Explorer supports modal dialogs so you could try showing one of those:</p> <pre><code>if (window.showModalDialog) window.showModalDialog("mypage.html","popup","dialogWidth:255px;dialogHeight:250px"); else window.open("mypage.html","name","height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes"); </code></pre>
<p>Or use window.open and put the <a href="http://qa.techinterviews.com/q/20060809080754AAs7gKM" rel="nofollow noreferrer">link there</a>.</p>
8,141
<p>I see many user interface control libraries for .NET, but where can I get similar stuff for win32 using simply C/C++?</p> <p>Things like prettier buttons, dials, listviews, graphs, etc.</p> <p>Seems every Win32 programmers' right of passage is to end up writing his own collection. :/</p> <hr> <p>No MFC controls please. I only do pure C/C++. And with that said, I also don't feel like adding a multi-megabyte framework to my application just so that I can have a prettier button.</p> <hr> <p>I apologize for leaving out one tiny detail, and that is that my development is for Windows Mobile.</p> <p>So manifest files are out.</p> <p>I just notice how many developer companies have gone crazy with making pretty looking .NET components and wondered where the equivalent C/C++ Win32 components have gone?</p> <p>I read about how many people ended up writing their own gradient button class, etc. So you would think that there would be some commercial classes for this stuff. It's just weird.</p> <p>I'll take a closer look at QT and investigate its GUI support for such things. This is the challenge when you're the one man in your own uISV. No other developers to help you "get things done".</p>
<p>I've used <a href="http://trolltech.com/products/qt/" rel="noreferrer">Trolltech's Qt framework</a> in the past and had great success with it: In addition, it's also cross-platform, so in theory you can target Win, Mac, &amp; Linux (provided you don't do anything platform-specific in the rest of your code, of course ;) )</p> <p>Edit: I notice that you're targeting Windows Mobile; that definitely adds to Qt's strength, as its cross-platform support extends to <a href="http://trolltech.com/products/qt/features/platforms/index" rel="noreferrer">WinCE and Embedded Linux</a> as well.</p>
<p>The MFC feature pack is derived from <a href="http://www.bcgsoft.com/" rel="nofollow noreferrer">BCGSoft components</a>.</p>
8,871
<p>I am writing a Browser Helper Object for ie7, and I need to detect DOM modification (i.e. via AJAX). So far I couldn't find any feasible solution.</p>
<p>You want to use <a href="http://msdn.microsoft.com/en-us/library/aa703624(VS.85).aspx" rel="nofollow noreferrer">IMarkupContainer2::CreateChangeLog</a>.</p>
<p>The best thing I could recommend is the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;displaylang=en" rel="nofollow noreferrer">Internet Explorer Developer Toolbar</a> which allow you to view changes in the DOM.</p>
5,485
<p>I'm using ASP.NET MVC Preview 4 and would like to know how to use the routing engine for form submissions.</p> <p>For example, I have a route like this:</p> <pre><code>routes.MapRoute( "TestController-TestAction", "TestController.mvc/TestAction/{paramName}", new { controller = "TestController", action = "TestAction", id = "TestTopic" } ); </code></pre> <p>And a form declaration that looks like this:</p> <pre><code>&lt;% using (Html.Form("TestController", "TestAction", FormMethod.Get)) { %&gt; &lt;input type="text" name="paramName" /&gt; &lt;input type="submit" /&gt; &lt;% } %&gt; </code></pre> <p>which renders to:</p> <pre><code>&lt;form method="get" action="/TestController.mvc/TestAction"&gt; &lt;input type="text" name="paramName" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p>The resulting URL of a form submission is:</p> <pre><code>localhost/TestController.mvc/TestAction?paramName=value </code></pre> <p>Is there any way to have this form submission route to the desired URL of:</p> <pre><code>localhost/TestController.mvc/TestAction/value </code></pre> <p>The only solutions I can think of are to create a separate action that just checks the request parameters, or to use Javascript.</p>
<p>Solution:</p> <pre><code>public ActionResult TestAction(string paramName) { if (!String.IsNullOrEmpty(Request["paramName"])) { return RedirectToAction("TestAction", new { paramName = Request["paramName"]}); } /* ... */ } </code></pre>
<p>In your route, get rid of the {paramName} part of the URL. It should be:</p> <p>TestController.mvc/TestAction</p> <p>As that is the URL you want the request to route to. Your form will then post to that URL. Posted form values are mapped to parameters of an action method automatically, so don't worry about not having that data passed to your action method.</p>
2,992
<p>I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs?</p>
<p><code>FindFirstChangeNotification</code> is fine, but for slightly more ultimate power you should be using <code>ReadDirectoryChangesW.</code> (In fact, it's even recommended in the documentation!)</p> <p>It doesn't require a function pointer, it does require you to manually decode a raw buffer, it uses Unicode file names, but it is generally better and more flexible.</p> <p>On the other hand, if you want to do what FileMon does, you should probably do what FileMon does and use <a href="http://msdn.microsoft.com/en-us/library/ms790748.aspx" rel="noreferrer">IFS to create and install a file system filter</a>.</p>
<p>You can use FileSystemWatcher class. Very efficient but cannot work with Network shared drives.</p>
3,733
<p>Anybody know of a way to copy a file from path A to path B and suppressing the Windows file system cache?<br> Typical use is copying a large file from a USB drive, or server to your local machine. Windows seems to swap everything out if the file is really big, e.g. 2GiB. Prefer example in C#, but I'm guessing this would be a Win32 call of some sort if possible.</p>
<p>Even more important, there are FILE_FLAG_WRITE_THROUGH and FILE_FLAG_NO_BUFFERING.</p> <p>MSDN has a nice article on them both: <a href="http://support.microsoft.com/kb/99794" rel="noreferrer">http://support.microsoft.com/kb/99794</a></p>
<p>Eseutil is a correct answer, also since Win7 / 2008 R2, you can use the /j switch in Xcopy, which has the same effect.</p>
7,115
<p>What are the best file permission settings for PHP scripts? Any suggestions on ways to figure out the minimum required permissions?</p>
<p>You could do this fairly simply with refspecs.</p> <pre><code>git pull origin git diff @{1}.. </code></pre> <p>That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly record the current version:</p> <pre><code>current=`git rev-parse HEAD` git pull origin git diff $current.. </code></pre> <p>I personally use an alias that simply shows me a log, in reverse order (i.e. oldest to newest), sans merges, of all the commits since my last pull. I run this every time my pull updates the branch:</p> <pre><code>git config --global alias.lcrev 'log --reverse --no-merges --stat @{1}.. </code></pre>
<p>If you drop this into your bash profile you'll be able to run grin (git remote incoming) and grout (git remote outgoing) to see diffs of commits that are incoming and outgoing for origin master.</p> <pre><code>function parse_git_branch { git branch --no-color 2&gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' } function gd2 { echo branch \($1\) has these commits and \($2\) does not git log $2..$1 --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local } function grin { git fetch origin master gd2 FETCH_HEAD $(parse_git_branch) } function grout { git fetch origin master gd2 $(parse_git_branch) FETCH_HEAD } </code></pre>
8,611
<p>Suppose we have a table A:</p> <pre><code>itemid mark 1 5 2 3 </code></pre> <p>and table B:</p> <pre><code>itemid mark 1 3 3 5 </code></pre> <p>I want to join A*B on A.itemid=B.itemid both right and left ways. i.e. result:</p> <pre><code>itemid A.mark B.mark 1 5 3 2 3 NULL 3 NULL 5 </code></pre> <p>Is there a way to do it in one query in MySQL?</p>
<p>It's called a full outer join and it's not supported natively in MySQL, judging from its <a href="http://dev.mysql.com/doc/refman/4.1/en/join.html" rel="noreferrer">docs</a>. You can work around this limitation using UNION as described in the comments to the page I linked to.</p> <p>[edit] Since others posted snippets, here you go. You can see explanation on the linked page.</p> <pre><code>SELECT * FROM A LEFT JOIN B ON A.id = B.id UNION ALL SELECT * FROM A RIGHT JOIN B ON A.id = B.id WHERE A.id IS NULL </code></pre>
<p>This works for me on SQL Server:</p> <pre><code>select isnull(a.id, b.id), a.mark, b.mark from a full outer join b on b.id = a.id </code></pre>
3,099
<p>Whenever I use my MacBook away from my desk and later plug it into an external display (as primary), I get into the state of having windows deposited in both the notebook monitor and the external one.</p> <p>To move all windows to a single screen, my current solution is to "Turn on mirroring" in the display preferences and then turn it off again. This is rather tedious, though. Does anyone know of a better way?</p> <hr> <p>I'm afraid the script posted by @<a href="https://stackoverflow.com/questions/39066/move-all-windows-to-a-single-monitor-with-two-attached-in-mac-os-x#39097">erlando</a> does absolutely nothing for me, running Mac OS X 10.5.4. (I.e., with windows on both screens, running the script moves not a single one of them, and it does not return any errors.) I guess I'll just have to stick with using the "mirror/unmirror" method mentioned above.</p> <hr> <p>@<a href="https://stackoverflow.com/questions/39066/move-all-windows-to-a-single-monitor-with-two-attached-in-mac-os-x#47233">Denton</a>: I'm afraid those links provide scripts for getting windows which are orphaned from <em>any</em> screen back onto the display. I ‘just’ want to move all windows from a secondary display onto the primary display.</p>
<p><code>Cmd+F1</code> appears to be a Mirror Displays shortcut in Snow Leopard. Don't know about Lion, etc, though.</p> <p>Just tap it twice and see what happens (-:</p> <p>For the people who prefer to set up their function keys to act in the old-fashioned way (not as brightness/sound controls etc.), it will be <code>Cmd+Fn+F1</code></p>
<p>Here is a command-line script to do just that: <a href="http://zach.in.tu-clausthal.de/software/" rel="nofollow noreferrer">http://zach.in.tu-clausthal.de/software/</a>.</p> <p>It's a little down the page under &quot;Move Off-Screen Windows to the Main Screen&quot;.</p> <hr /> <pre><code>-- Source: http://www.jonathanlaliberte.com/2007/10/19/move-all-windows-to-your-main-screen/ -- and: http://www.macosxhints.com/article.php?story=2007102012424539 -- -- Improvements: -- + code is more efficient and more elegant now -- + windows are moved also, if they are &quot;almost&quot; completely off-screen -- (in the orig. version, they would be moved only if they were completely off-screen) -- + windows are moved (if they are moved) to their closest position on-screen -- (in the orig. version, they would be moved to a &quot;home position&quot; (0,22) ) -- Gabriel Zachmann, Jan 2008 -- Example list of processes to ignore: {&quot;xGestures&quot;} or {&quot;xGestures&quot;, &quot;OtherApp&quot;, ...} property processesToIgnore : {&quot;Typinator&quot;} -- Get the size of the Display(s), only useful if there is one display -- otherwise it will grab the total size of both displays tell application &quot;Finder&quot; set _b to bounds of window of desktop set screen_width to item 3 of _b set screen_height to item 4 of _b end tell tell application &quot;System Events&quot; set allProcesses to application processes repeat with i from 1 to count allProcesses --display dialog (name of (process i)) as string if not (processesToIgnore contains ((name of (process i)) as string)) then try tell process i repeat with x from 1 to (count windows) set winPos to position of window x set _x to item 1 of winPos set _y to item 2 of winPos set winSize to size of window x set _w to item 1 of winSize set _h to item 2 of winSize --display dialog (name as string) &amp; &quot; - width: &quot; &amp; (_w as string) &amp; &quot; height: &quot; &amp; (_h as string) if (_x + _w &lt; 40 or _y + _h &lt; 50 or _x &gt; screen_width - 40 or _y &gt; screen_height - 40) then if (_x + _w &lt; 40) then set _x to 0 if (_y + _h &lt; 50) then set _y to 22 if (_x &gt; screen_width - 40) then set _x to screen_width - _w if (_x &lt; 0) then set _x to 0 end if if (_y &gt; screen_height - 40) then set _y to screen_height - _h if (_y &lt; 22) then set _y to 22 end if set position of window x to {_x, _y} end if end repeat end tell end try end if end repeat end tell </code></pre>
6,011
<p>Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see <a href="http://blogs.msdn.com/pcreehan/archive/2007/05/04/what-does-unsupported-mean.aspx" rel="noreferrer">here</a> and <a href="http://blogs.msdn.com/mstehle/archive/2007/10/03/fyi-why-are-mapi-and-cdo-1-21-not-supported-in-managed-net-code.aspx" rel="noreferrer">here</a>)</p> <p><strong>All I want to do is launch the default e-mail client</strong> with subject, body, <strong>AND one or more attachments</strong>. </p> <p>So I've been looking into <a href="http://pinvoke.net/default.aspx/mapi32.MAPISendDocuments" rel="noreferrer">MAPISendDocuments</a> and it seems to work. But I haven't been able to gather courage to actually use the function in production code.</p> <p>Has anybody used this function a lot? Do you have any horror stories?</p> <p><em>PS. No, I won't shellExecute Outlook.exe with command line arguments for attachments.</em></p> <p><em>PPS. Attachment support is a</em> requirement <em>, so Mailto: solutions do not cut it for me.</em></p>
<p>Have a separate helper EXE that takes command-line params (or pipe to its StandardInput) that does what is required and call that from your main app. This keeps the MAPI stuff outside of your main app's process space. OK, you're still mixing MAPI and .NET but in a very short-lived process. The assumption is that MAPI and the CLR start causing issues with longer-running processes.</p> <p>We use Dmitry Streblechenko's superb <a href="http://www.dimastr.com/redemption/" rel="noreferrer">Redemption Data Objects</a> library which allows us to write such "shim" code in JScript and invoke that, which keeps the CLR and MAPI worlds in separate processes, but in a supported fashion.</p> <p>@Chris Fournier re. writing an unmanaged DLL. This won't work because the issue is mixing MAPI and managed code <em>in the same process</em>.</p>
<p>For someone experienced with MAPI, it would take them less time to crank out the code to do exactly what you want from unmanaged code (read: plain C++) than typing this post and reading the response (no offense).</p> <p>You're lucky the functionality you need is limited. All you need is a simple C++ utility to take the params you need on the command-line and issue the right MAPI calls. Then, you all this utility from your managed code just as you'd to execute any other process.</p> <p>HTH</p>
2,648
<p>How can I execute <code>a.exe</code> using the Cygwin shell?</p> <p>I created a C file in Eclipse on Windows and then used Cygwin to navigate to the directory. I called gcc on the C source file and <code>a.exe</code> was produced. I would like to run <code>a.exe</code>.</p>
<p>./a.exe at the prompt</p>
<p>Just call it</p> <pre><code>&gt; a </code></pre> <p>Make sure it will be found (path).</p>
5,662
<p>I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, however that is the most important property (don't really care about the parent). Is there a way to have it do lazy loading? Would that even fix it?</p>
<p>In the designer, select a property on an entity in the diagram, and in the <em>Code Generation</em> section in the properties window, set <strong>Delay Loaded</strong> to <em>True</em> .</p> <p>See <a href="http://www.davidhayden.com/blog/dave/archive/2007/08/05/LINQToSQLLazyLoadingPropertiesSpecifyingPreFetchWhenNeededPerformance.aspx" rel="nofollow noreferrer">this blog post</a>.</p>
<p>This site is not good for my pre-existing biases, turns out <em>this one</em> was an ill-configured route not lazy/eager loading</p>
7,643
<p>What software do you use when designing classes and their relationship, or just pen and paper?</p>
<p>I find pen and paper very useful, and I try to get as far away from a computer as possible. If I do it on the compy, I'm always too tempted to start programming the solution. That inevitably leads to me changing things later that I would have spotted in the planning phase had I actually spent a good measure of time on it.</p>
<p>Mostly pen and paper, although I occasionally break out Visio and just do some rough diagrams.</p> <p>Would be nice to have a fancy tool I guess, but it would just be another thing to learn.</p>
3,526
<p>I am looking for a CMS that would be incredibly user-friendly and would have the following features:</p> <ul> <li>really simple message board (no login required)</li> <li>family tree</li> <li>story telling area</li> <li>photo section</li> <li>news section</li> </ul> <p>Is there anything out there like this that is really easily configurable? I've already messed around with Mambo and Family Connects, but I didnt like either of those. In the past I've just programmed my own websites, for lack of easily implementable features. However, I've assuming there's something I need out there just like this, that I can't find. Thanks.</p> <hr> <p>I don't want anyone to have to login, for one. The is for a family website, and much of my family really don't know what a website is, let alone how to use one. I want a super simple website with huge buttons and not a whole lot of distractions. Family Connects is a good example of what I want, except the photo album is horrible. I want people to post messages without logging in or signing up, and haven't seen that ability in mambo sites I've looked at.</p>
<p>I can understand your stipulation that your users (family) shouldn't have to sign up - but without a sign-in, your site will be a free-for-all for spammers, hackers and other bored Internet denizens. </p> <p>That said, my suggestion is to use WordPress for a front end - register your family members yourself, and use a very basic template - or better yet, create one.</p>
<p>I've setup <a href="http://www.cmsmadesimple.org/" rel="nofollow noreferrer">CMS Made Simple</a> a couple times now. It's all PHP and you can edit it to your heart's content. Give it a try.</p>
4,504
<p>Alright, so I'm working on an application which will use a Linux back-end running PostgreSQL to serve up images to a Windows box with the front end written in C#.NET, though the front-end should hardly matter. My question is:</p> <ul> <li><strong>What is the best way to deal with storing images in Postgres?</strong></li> </ul> <p>The images are around 4-6 megapixels each, and we're storing upwards of 3000. It might also be good to note: this is not a web application, there will at most be about two front-ends accessing the database at once.</p>
<p>Re jcoby's answer:</p> <p>bytea being a "normal" column also means the value being read completely into memory when you fetch it. Blobs, in contrast, you can stream into stdout. That helps in reducing the server memory footprint. Especially, when you store 4-6 MPix images.</p> <p>No problem with backing up blobs. pg_dump provides "-b" option to include the large objects into the backup.</p> <p>So, I prefer using pg_lo_*, you may guess.</p> <p>Re Kris Erickson's answer:</p> <p>I'd say the opposite :). When images are not the only data you store, don't store them on the file system unless you absolutely have to. It's such a benefit to be always sure about your data consistency, and to have the data "in one piece" (the DB). BTW, PostgreSQL is great in preserving consistency.</p> <p>However, true, reality is often too performance-demanding ;-), and it pushes you to serve the binary files from the file system. But even then I tend to use the DB as the "master" storage for binaries, with all the other relations consistently linked, while providing some file system-based caching mechanism for performance optimization. </p>
<p>If your images are small, consider storing them as base64 in a plain text field. </p> <p>The reason is that while base64 has an overhead of 33%, with compression that mostly goes away. (See <a href="https://lemire.me/blog/2019/01/30/what-is-the-space-overhead-of-base64-encoding/" rel="noreferrer">What is the space overhead of Base64 encoding?</a>) Your database will be bigger, but the packets your webserver sends to the client won't be. In html, you can inline base64 in an &lt;img src=""> tag, which can possibly simplify your app because you won't have to serve up the images as binary in a separate browser fetch. Handling images as text also simplifies things when you have to send/receive json, which doesn't handle binary very well.</p> <p>Yes, I understand you could store the binary in the database and convert it to/from text on the way in and out of the database, but sometimes ORMs make that a hassle. It can be simpler just to treat it as straight text just like all your other fields. </p> <p>This is definitely the right way to handle thumbnails.</p> <p>(OP's images are not small, so this is not really an answer to his question.)</p>
7,810
<p>Anyone have a good rule of thumb for choosing between different implementations of Java Collection interfaces like List, Map, or Set?</p> <p>For example, generally why or in what cases would I prefer to use a Vector or an ArrayList, a Hashtable or a HashMap?</p>
<p>I really like this cheat sheet from Sergiy Kovalchuk's blog entry, but unfortunately it is offline. However, the Wayback Machine has a <a href="https://web.archive.org/web/20200802192003/http://www.sergiy.ca/guide-to-selecting-appropriate-map-collection-in-java/" rel="noreferrer">historical copy</a>:</p> <p><img src="https://i.stack.imgur.com/EmzXy.gif" alt="Java Map/Collection Cheat Sheet" /></p> <p>More detailed was Alexander Zagniotov's flowchart, also offline therefor also a historical <a href="https://web.archive.org/web/20130424223516/http://initbinder.com/articles/cheat-sheet-for-selecting-maplistset-in-java.html" rel="noreferrer">copy of the blog</a>:</p> <p><a href="https://i.stack.imgur.com/GfpyN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GfpyN.png" alt="Alexander Zaniotov's flowchart for choosing Collection implementations" /></a></p> <p>Excerpt from the blog on concerns raised in comments: &quot;This cheat sheet doesn't include rarely used classes like WeakHashMap, LinkedList, etc. because they are designed for very specific or exotic tasks and shouldn't be chosen in 99% cases.&quot;</p>
<p>I found Bruce Eckel's Thinking in Java to be very helpful. He compares the different collections very well. I used to keep a diagram he published showing the inheritance heirachy on my cube wall as a quick reference. One thing I suggest you do is keep in mind thread safety. Performance usually means not thread safe. </p>
7,087
<p>As a long time Microsoft developer, I find <a href="http://en.wikipedia.org/wiki/Microsoft_Developer_Network" rel="noreferrer">MSDN</a> to be an invaluable resource.</p> <p>However, when tinkering at home I am not able to play with the best latest technologies and the different offerings coming from Microsoft as I cannot justify paying such a hefty price for what is essentially a pastime.</p> <p>The <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express" rel="noreferrer">Express editions</a> are great, but fall flat when trying to use the more advanced feature I am used to from the versions I use at work. I cannot get the latest betas and play with the new offerings, not legally, anyway.</p> <p>Apart from getting an <a href="http://en.wikipedia.org/wiki/Microsoft_Most_Valuable_Professional" rel="noreferrer">MVP</a>, how would one go about getting an MSDN subscription for an acceptable price for a non-professional environment?</p> <hr/> <p>I am aware of the Empower program, but I thought it was geared towards getting <em>commercial</em> software to market. If this is not the case, it appears like the way for me to go. Thanks!</p>
<p>There is an Empower program that Microsoft has available. It gives you several Premium subscriptions for cheap, with the catch that you have to be an ISV working towards an actual product.</p> <p><a href="https://partner.microsoft.com/global/program/40066412" rel="nofollow noreferrer">This</a> (Not available anymore - broken link) gives you all the software you'll need for development, and even a few "real world" licenses for certain apps (like Office)</p> <p>After a couple of years, you have to pay full price though. The logic being that you should have a product on the market, and can afford it. </p>
<p>Many MVP's have gift subscriptions that they can give away, so it pays off to be visible in the community.</p> <p>Speak at your local user group, start (or participate) in an open source project, start a blog... just generally get your name out there.</p> <p>Eventually you'll get one (or an MVP :)).</p> <p>What I've found is that if you pay attention there are plenty of opportunities to snag a free copy of Office or Visual Studio at local Microsoft events.</p> <p>Good luck!</p>
6,395
<p>What is the shortcut key for <em>Run to cursor</em> in Visual Studio 2008?</p>
<p>The shortcut key is <kbd>CTRL</kbd>+<kbd>F10</kbd>.</p>
<p>You can first hit</p> <pre><code>Ctrl + Shift + P </code></pre> <p>Then type &quot;<code>&gt; Run to Cursor</code>&quot;</p> <p>if you click on &quot;gear&quot; icon on the right, you can double click and set the shortcut at your convenience.</p> <p>Also you can c/p: <code>@command:editor.debug.action.runToCursor</code></p> <p><a href="https://i.stack.imgur.com/yzGeF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yzGeF.png" alt="enter image description here" /></a></p>
6,969
<p>I'm trying to connect two 3D printed parts (ABS) together with a threaded connection. Thus, I need to fix a threaded metal nut (M4) inside a corresponding slot which I've implemented in the design.</p> <p>Right now I apply a conventional super glue on the nut and press it inside the print, wait for a couple of hours and then use it.</p> <p>Problem is that the nut keeps falling out of the print when I apply a more tension to the bolt. Can you please advise me on how to make this method work. Maybe some of you aware of special glue for that purposes?</p>
<p>One good option would be to - if possible - change the design, so the nut is inserted from the opposite side, so that the bolt just pulls it in tighter rather than pulling it out.</p> <p>Another option would be to instead of using a nut, use a <a href="https://www.matterhackers.com/articles/fasteners-for-3d-printing" rel="noreferrer">brass threaded insert</a>. These are like nuts, except they have ridges that are specifically aimed at locking it inside the plastic.</p>
<p>Just heat the nut with a soldering iron to seat it into place (after the print). I've done this many times myself.</p> <p>EDIT: Try a bit of acetone, to allow the ABS near the nut to reflow.</p>
601
<p>I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. </p> <p>For what do you use regular expressions?</p> <p>P.S. sorry for my bad english</p>
<p>Consider an example in Ruby:</p> <pre><code>puts "Matched!" unless /\d{3}-\d{4}/.match("555-1234").nil? puts "Didn't match!" if /\d{3}-\d{4}/.match("Not phone number").nil? </code></pre> <p>The "/\d{3}-\d{4}/" is the regular expression, and as you can see it is a VERY concise way of finding a match in a string.</p> <p>Furthermore, using groups you can extract information, as such:</p> <pre><code>match = /([^@]*)@(.*)/.match("myaddress@domain.com") name = match[1] domain = match[2] </code></pre> <p>Here, the parenthesis in the regular expression mark a capturing group, so you can see exactly WHAT the data is that you matched, so you can do further processing.</p> <p>This is just the tip of the iceberg... there are many many different things you can do in a regular expression that makes processing text REALLY easy.</p>
<blockquote> <p>A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as <code>*.txt</code> to find all text files in a file manager. The regex equivalent is <code>.*\.txt$</code>.</p> </blockquote> <p>A great resource for regular expressions: <a href="http://www.regular-expressions.info" rel="nofollow noreferrer">http://www.regular-expressions.info</a></p>
2,695
<p>I want to hook up an Arduino to my Creality printer running Marlin firmware, such that I can have a few physical buttons mounted on the machine that will execute commands such as preheat, home, disable steppers, and so on, so that I don't have to navigate through the clunky LCD screen.</p> <p>Ideally it would work in addition to the normal LCD and serial functionality, so it would not impede me from using Ultimaker Cura to print via USB, etc.</p> <p>What is the best way to do this?</p>
<p>One option would be to have your printer controlled by an Octoprint server. You would then use the <a href="https://github.com/chunkysteveo/OctoPrintAPI" rel="nofollow noreferrer">Octoprint Api plugin</a> to use your arduino to send commands to octoprint - and from there, your printer. Octoprint has a fairly fully-featured rest api that allows you to send arbitrary GCODE to your printer (<a href="http://docs.octoprint.org/en/master/api/printer.html#send-an-arbitrary-command-to-the-printer" rel="nofollow noreferrer">see here</a>). You would then hook up your buttons to some code that sends the gcode commands to the printer when pressed. It's certainly not as simple as installing a plugin - you'll have to write some interface code, but it looks like those APIs should be able to do what you want, without interfering with the standard controls at all.</p>
<p>There's already Arduino inside the printer (to be precise: the printer board with spare pins). Im sure its possible to hook up a switch then change firmware to send G-codes; 1 pin per series of commands?</p>
1,137
<p>There is a legacy CVS repository, which contains a large number of directories, sub-directories, and paths. There is also a large number of branches and tags that do not necessarilly cover all paths &amp; files - usually a subset. How can I find out, which branch / tag covers, which files and paths?</p> <p>CVS log already provides the list of tags per file. The task requires me to transpose this into files per tag. I could not find such functionality in current WinCVS (CVSNT) implementation. Given ample empty cycles I can write a Perl script that would do that, the algorithm is not complex, but it needs to be done.</p> <p>I would imagine there are some people who needed such information and solved this problem. Thus, I think should be a readily available (open source / free) tool for this.</p>
<p>To determine what tags apply to a particular file use:</p> <pre><code>cvs log &lt;filename&gt; </code></pre> <p>This will output all the versions of the file and what tags have been applied to the version.</p> <p>To determine what files are included in a single tag, the only thing I can think of is to check out using the tag and see what files come back. The command for that is any of:</p> <pre><code>cvs update -r &lt;tagname&gt; cvs co &lt;modulename&gt; -r &lt;tagname&gt; cvs export &lt;modulename&gt; -r &lt;tagname&gt; </code></pre>
<p>I don't know of any tool that can help you, but if you are writing your own, I can save you from one headace: Directories in CVS cannot be tagget. Only the files within them have tags (and that is what determines what is checked out when you check out a directory on a specific tag).</p>
4,843
<p>If all of my <code>__init__.py</code> files are empty, do I have to store them into version control, or is there a way to make <code>distutils</code> create empty <code>__init__.py</code> files during installation?</p>
<p>In Python, <code>__init__.py</code> files actually have a meaning! They mean that the folder they are in is a Python module. As such, they have a real role in your code and should most probably be stored in Version Control.</p> <p>You could well imagine a folder in your source tree that is NOT a Python module, for example a folder containing only resources (e.g. images) and no code. That folder would not need to have a <code>__init__.py</code> file in it. Now how do you make the difference between folders where distutils should create those files and folders where it should not ?</p>
<p>In Python, <code>__init__.py</code> files actually have a meaning! They mean that the folder they are in is a Python module. As such, they have a real role in your code and should most probably be stored in Version Control.</p> <p>You could well imagine a folder in your source tree that is NOT a Python module, for example a folder containing only resources (e.g. images) and no code. That folder would not need to have a <code>__init__.py</code> file in it. Now how do you make the difference between folders where distutils should create those files and folders where it should not ?</p>
8,521
<p>I have a WinForms program written on .NET 2 which hosts a webbrowser control and renders asp.net pages from a known server.</p> <p>I would like to be able to drag, say, a tree node from a treeview in my winforms app into a specific location in the hosted web page and have it trigger a javascript event there. Currently, I can implement the <code>IDocHostUIHandler</code> interface and getting drag\drop events on the browser control, then call <code>Navigate("javascript:fire_event(...)")</code> on the control to execute a script on the page. However, I want this to work only when I drop data on a <em>specific</em> part of the page.</p> <p>One solution, I suppose, would be to bite the bullet and write a custom browser plugin in the form of an activex control, embed that in the location I want to drop to and let that implement the needed drag\drop interfaces.</p> <p>Would that work? Is there a cleaner approach? Can I take advantage of the fact that the browser control is hosted in my app and provide some further level of interaction?</p>
<p>Take a look at the <a href="http://browserplus.yahoo.com/" rel="nofollow noreferrer">BrowserPlus</a> project at Yahoo.</p> <p>It looks like they have built a toolkit so that you don't have to do the gritty work of writing the browser plugin yourself.</p>
<p>If you can find out the on screen position of the part of the page you are interested in, you could compare this with the position of the mouse when you receive the drop event. I'm not sure how practical this is if you can get the info out of the DOM or whatnot.</p> <p>As an alternative could you implement the mouse events on the bit of the page using javascript?</p>
2,682
<p>This might seem like a stupid question I admit. But I'm in a small shop me plus two designers. Our backups are getting out of hand because they just copy/paste files if they need to make a change (version). </p> <p>I was all set to try Subversion to handle all of our files my text (code) files and their photoshop/illustrator and asset files. That is until I noticed there was a new version of Adobe Version Cue v3. We've tried previously to use version cue but it got complicated and the designers quickly stopped using it.</p> <p>Looking for anyone that has some experience with version 3 of Version Cue.</p> <p>Thanks for the great feedback. Maybe I should have asked what's the best tool to use for Versioning Photoshop and related files. I did notice the binary file issue and was worried about trying to explain it and keep it "working". I signed up for the beta at Gridiron thanks for that!</p> <p><a href="https://stackoverflow.com/questions/36186/best-versioning-tools-to-use-for-photoshopillustrator-and-related-binary-files">Here</a> is the other question related to this one.</p>
<p><a href="http://www.pixelnovel.com/timeline" rel="nofollow noreferrer">PixelNovel Timeline</a> is a dedicated Subversion client for Photoshop - works as a plugin and shows all you versions in an additional Photoshop palette. It also comes with a <a href="http://www.pixelnovel.com" rel="nofollow noreferrer">web storage where you can view your files via a web browser</a>. Give it a go - may be it's exactly what you are after....</p>
<p>Subversion is not an ideal solution for binary files, regardless of how little has changed it will save a new copy each time you check it in. Moreover, although Subversion has some locking capabilities, it doesn't lock by default, which means that if two persons modify the same binary file the one that checks in the last will overwrite the other one's changes. </p> <p>Also, there's no tool out there that's as integrated with the Adobe design tools as Version Cue is. </p> <p>Subversion is great for text-based content, but really really not suited to the kind of files you will be working with.</p>
5,674
<p>I want to return <code>StudentId</code> to use elsewhere outside of the <em>scope</em> of the <code>$.getJSON()</code></p> <pre><code>j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here </code></pre> <p>I would imagine this has to do with scoping, but it doesn't seem to work the same way <em>c#</em> does</p>
<p>Yeah, my previous answer does not work because I didn't pay any attention to your code. :)</p> <p>The problem is that the anonymous function is a callback function - i.e. getJSON is an async operation that will return at some indeterminate point in time, so even if the scope of the variable were outside of that anonymous function (i.e. a closure), it would not have the value you would think it should:</p> <pre><code>var studentId = null; j.getJSON(url, data, function(result) { studentId = result.Something; }); // studentId is still null right here, because this line // executes before the line that sets its value to result.Something </code></pre> <p>Any code that you want to execute with the value of studentId set by the getJSON call needs to happen either <strong>within</strong> that callback function or <strong>after</strong> the callback executes.</p>
<p>hmm, if you've serialized an object with the <code>StudentId</code> property then I think that it will be:</p> <pre><code>var studentId; function(json) { if (json.length &gt; 0) studentId = json[0].StudentId; } </code></pre> <p>But if you're just returning the <code>StudentId</code> itself maybe it's:</p> <pre><code>var studentId; function(json) { if (json.length &gt; 0) studentId = json[0]; } </code></pre> <p>Edit: Or maybe <code>.length</code> isn't even required (I've only returned generic collections in JSON).</p> <p>Edit #2, this works, I just tested:</p> <pre><code>var studentId; jQuery.getJSON(url, data, function(json) { if (json) studentId = json; }); </code></pre> <p>Edit #3, here's the actual JS I used:</p> <pre><code>$.ajax({ type: "POST", url: pageName + "/GetStudentTest", contentType: "application/json; charset=utf-8", dataType: "json", data: "{id: '" + someId + "'}", success: function(json) { alert(json); } }); </code></pre> <p>And in the aspx.vb:</p> <pre><code>&lt;System.Web.Services.WebMethod()&gt; _ &lt;System.Web.Script.Services.ScriptMethod()&gt; _ Public Shared Function GetStudentTest(ByVal id As String) As Integer Return 42 End Function </code></pre>
5,103
<p>I currently have a relatively small (4 or 5 tables, 5000 rows) MySQL database that I would like to convert to an sqlite database. As I'd potentially have to do this more than once, I'd be grateful if anyone could recommend any useful tools, or at least any easily-replicated method.</p> <p>(I have complete admin access to the database/machines involved.)</p>
<p>I've had to do similar things a few times. The easiest approach for me has been to write a script that pulls from one data source and produces an output for the new data source. Just do a <code>SELECT *</code> query for each table in your current database, and then dump all the rows into an <code>INSERT INTO</code> query for your new database. You can either dump this into a file or pipe it straight into the database frontend.</p> <p>It's not pretty, but honestly, pretty hardly seems to be a major concern for things like this. This technique is quick to write, and it works. Those are my primary criteria for things like this.</p> <p>You might want to check out <a href="http://www.perlmonks.org/index.pl?node_id=150476" rel="noreferrer">this thread</a>, too. It looks like a couple of people have already put together basically what you need. I didn't look that far into it, though, so no guarantees.</p>
<p>If it's just a few tables you could probably script this in your preferred scripting langauge and have it all done by the time it'd take to read all the replies or track down a suitable tool. I would any way. :)</p>
2,881
<p>I'm talking about <a href="http://en.wikipedia.org/wiki/Quality_of_service" rel="noreferrer">http://en.wikipedia.org/wiki/Quality_of_service</a>. With streaming stackoverflow podcasts and downloading the lastest updates to ubuntu, I would like to have QoS working so I can use stackoverflow without my http connections timing out or taking forever.</p> <p>I'm using an iConnect 624 ADSL modem which has QoS built-in but I can't seem to get it to work. Is it even possible to control the downstream (ie. from ISP to your modem)?</p>
<p>I don't know if this will help you, but I've never been a fan of using the ISP provided box directly. Personally I use a <a href="http://www.newegg.com/Product/ProductList.aspx?Submit=ENE&amp;DEPA=0&amp;Description=wrt54gl&amp;x=0&amp;y=0" rel="nofollow noreferrer">Linksys wrt54gl</a>, with <a href="http://www.dd-wrt.com" rel="nofollow noreferrer">DD-wrt</a>, behind(DMZ) my ISP provided box.</p> <p>DD-wrt has excellent QoS management.</p> <p>Sorry I can't be more help with your existing hardware. </p>
<p>You just need the <a href="http://www.arvanta.net/~mps/linux-tc.html" rel="nofollow noreferrer">tc command</a> to handle the QoS on Linux boxen. However I wouldn't expect that much from it because of the results I obtained and <a href="https://stackoverflow.com/questions/583532/software-router-traffic-monitoring/583987#583987">detailed here</a>.</p>
2,656
<p>In a shellscript, I'd like to set the IP of my box, run a command, then move to the next IP. The IPs are an entire C block.</p> <p>The question is how do I set the IP of the box without editing a file? What command sets the IP on Slackware?</p> <p>Thanks</p>
<p>As mentioned in other answers, you can use either the ifconfig command or the ip command. ip is a much more robust command, and I prefer to use it. A full script which loops through a full class C subnet adding the IP, doing stuff, then removing it follows. Note that it doesn't use .0 or .255, which are the network and broadcast addresses of the subnet. Also, when using the ip command to add or remove an address, it's good to include the mask width, as well (the /24 at the end of the address).</p> <pre><code>#!/bin/bash SUBNET=192.168.135. ETH=eth0 for i in {1..254} do ip addr add ${SUBNET}${i}/24 dev ${ETH} # do whatever you want here ip addr del ${SUBNET}${i}/24 dev ${ETH} done</code></pre>
<p>It should be something like: <code>ifconfig eth0 192.168.0.42 up</code></p> <p>Replace eth0 by the network interface of your network card, obviously adapt the ip address to your needs and the up is only necessary once, but doesn't hurt if you run it each time. </p>
9,967
<p>If I have a variable in C# that needs to be checked to determine if it is equal to one of a set of variables, what is the best way to do this?</p> <p>I'm not looking for a solution that stores the set in an array. I'm more curious to see if there is a solution that uses boolean logic in some way to get the answer.</p> <p>I know I could do something like this: </p> <pre><code>int baseCase = 5; bool testResult = baseCase == 3 || baseCase == 7 || baseCase == 12 || baseCase == 5; </code></pre> <p>I'm curious to see if I could do something more like this:</p> <pre><code>int baseCase = 5; bool testResult = baseCase == (3 | 7 | 12 | 5); </code></pre> <p>Obviously the above won't work, but I'm interested in seeing if there is something more succinct than my first example, which has to repeat the same variable over and over again for each test value.</p> <p><strong>UPDATE:</strong><br> I decided to accept CoreyN's answer as it seems like the most simple approach. It's practical, and still simple for a novice to understand, I think.</p> <p>Unfortunately where I work our system uses the .NET 2.0 framework and there's no chance of upgrading any time soon. Are there any other solutions out there that don't rely on the .NET 3.5 framework, besides the most obvious one I can think of: </p> <pre><code>new List&lt;int&gt;(new int[] { 3, 6, 7, 1 }).Contains(5); </code></pre>
<pre><code> bool b = new int[] { 3,7,12,5 }.Contains(5); </code></pre>
<p>Since you did not specify what type of data you have as input I'm going to assume you can partition your input into powers of 2 -> 2,4,8,16... This will allow you to use the bits to determine if your test value is one of the bits in the input.</p> <p>4 => 0000100<br> 16 => 0010000<br> 64 => 1000000</p> <p>using some binary math... </p> <p>testList = 4 + 16 + 64 => 1010100<br> testValue = 16<br> testResult = testList &amp; testValue</p>
3,897
<p>I have made a custom 3D printer with RAMPS electronics. I have printed a Benchy (ship) well, but when I try to print anything with teeth (spiral vase), gears (bearing), or a circle (rocket), the Y-axis skip steps in a regular rate giving 70-60 degrees skew along the printing the Y-direction, but each layer is perfect, this happen when printing <a href="https://www.thingiverse.com/thing:53451" rel="nofollow noreferrer">gear bearing</a>.</p> <ul> <li><p>I have checked Y-axis ball bearing, motor, tension belt and I have replaced my 6 mm glass with 1 mm without any difference in shift.</p> </li> <li><p>I have once make it work, but I don't why or how (I have lowered speed to 50 and did some random things).</p> </li> <li><p>I have printed from Pronterface and when I pause it, then home Y, the skipping in Y is corrected.</p> </li> <li><p>If I drive my X/Y-axis with no microstepping, then the skipping is much larger.</p> </li> <li><p>I only use Slic3r for G-code generation.</p> </li> </ul> <p><a href="https://i.stack.imgur.com/uNGn5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uNGn5.jpg" alt="with no micro stepping" /></a></p> <p><a href="https://i.stack.imgur.com/kFu7S.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kFu7S.jpg" alt="with 32 micro stepping" /></a></p> <p><a href="https://i.stack.imgur.com/uu8zT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uu8zT.jpg" alt="with 32 micro stepping" /></a> <a href="https://i.stack.imgur.com/c7g52.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c7g52.jpg" alt="with 32 micro stepping" /></a> <a href="https://i.stack.imgur.com/0G0dq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0G0dq.jpg" alt="with 32 micro stepping" /></a> question:</p> <ul> <li><p>What is the cause for that skipping?</p> </li> <li><p>If there is more than one possibility, how could I check them separately?</p> </li> <li><p>I have changed my Y-axis motor with no change.</p> </li> <li><p>I have swapped X&amp;Y connections with no change - still Y skips.</p> </li> <li><p>I have lowered jerk and max. speed and it prints gear bearing well and it is spinning, but when I tried to print spiral vase Y motor skipped.</p> </li> </ul>
<p>The welding option is only appropriate if you have the tool needed for it, the lighter welding is really hard to do and if your printer allows it you could just watch for the moment the spool runs out and push the new filament as the last of the previous one gets extruded, that's what I used to do on my bowden extruder reprap and apart from a really negligible retraction problem on one layer it just works</p> <p>Or you could go the cool way:</p> <ul> <li>Use the last of the filament for friction/iron welding to fix or glue 3D printed parts together</li> <li>Use it as regular filament with a 3D printer pen to fix 3D printed parts</li> <li>"Use it for pin/studs/rivets/hinges in prints." as tjb1 said</li> <li>Stock it with your failed/ waste 3D printed parts and use them in a recyclebot later to make new filament or simply melt it in an oven to make plastic boards/injection molding material</li> <li>Throw it away but that would be a waste over time</li> </ul>
<ul> <li><p>Weld the fragment to the beginning of a new spool and use it that way. <a href="http://www.i3dinno.com/easywelder-p186486.html" rel="noreferrer">Most are made from metal</a> so they aren't that easy to make at home. Here is another <a href="https://3dprinting.stackexchange.com/questions/1345/how-to-connect-filament-end-to-end">answer</a> that lists other methods to weld filament including using heat shrink tubing.</p></li> <li><p>As you mentioned, you can use it for friction welding.</p></li> <li><p>Use it for pin/studs/rivets/hinges in prints.</p></li> <li><p>Throw it away. 1.75mm * 1Kg is about 330m of filament, 3mm * 1Kg is about 110m of filament. The leftover isn't worth much when you consider how much is on a spool.</p></li> </ul>
726
<p>What are the libraries that support XPath? Is there a full implementation? How is the library used? Where is its website?</p>
<p><a href="http://xmlsoft.org/python.html" rel="noreferrer">libxml2</a> has a number of advantages:</p> <ol> <li>Compliance to the <a href="http://www.w3.org/TR/xpath" rel="noreferrer">spec</a></li> <li>Active development and a community participation </li> <li>Speed. This is really a python wrapper around a C implementation. </li> <li>Ubiquity. The libxml2 library is pervasive and thus well tested.</li> </ol> <p>Downsides include:</p> <ol> <li>Compliance to the <a href="http://www.w3.org/TR/xpath" rel="noreferrer">spec</a>. It's strict. Things like default namespace handling are easier in other libraries.</li> <li>Use of native code. This can be a pain depending on your how your application is distributed / deployed. RPMs are available that ease some of this pain.</li> <li>Manual resource handling. Note in the sample below the calls to freeDoc() and xpathFreeContext(). This is not very Pythonic.</li> </ol> <p>If you are doing simple path selection, stick with <a href="http://effbot.org/zone/element-xpath.htm" rel="noreferrer">ElementTree</a> ( which is included in Python 2.5 ). If you need full spec compliance or raw speed and can cope with the distribution of native code, go with libxml2.</p> <p><strong>Sample of libxml2 XPath Use</strong></p> <hr> <pre><code>import libxml2 doc = libxml2.parseFile("tst.xml") ctxt = doc.xpathNewContext() res = ctxt.xpathEval("//*") if len(res) != 2: print "xpath query: wrong node set size" sys.exit(1) if res[0].name != "doc" or res[1].name != "foo": print "xpath query: wrong node set value" sys.exit(1) doc.freeDoc() ctxt.xpathFreeContext() </code></pre> <p><strong>Sample of ElementTree XPath Use</strong></p> <hr> <pre><code>from elementtree.ElementTree import ElementTree mydoc = ElementTree(file='tst.xml') for e in mydoc.findall('/foo/bar'): print e.get('title').text</code></pre> <hr>
<p><a href="http://pyxml.sourceforge.net" rel="nofollow noreferrer" title="PyXML">PyXML</a> works well. </p> <p>You didn't say what platform you're using, however if you're on Ubuntu you can get it with <code>sudo apt-get install python-xml</code>. I'm sure other Linux distros have it as well. </p> <p>If you're on a Mac, xpath is already installed but not immediately accessible. You can set <code>PY_USE_XMLPLUS</code> in your environment or do it the Python way before you import xml.xpath:</p> <pre><code>if sys.platform.startswith('darwin'): os.environ['PY_USE_XMLPLUS'] = '1' </code></pre> <p>In the worst case you may have to build it yourself. This package is no longer maintained but still builds fine and works with modern 2.x Pythons. Basic docs are <a href="http://pyxml.sourceforge.net/topics/howto/section-XPath.html" rel="nofollow noreferrer">here</a>.</p>
3,018
<p>I am looking for a lean and well constructed open source implementation of a B-tree library written in C. It needs to be under a non-GPL license so that it can be used in a commercial application. Ideally, this library supports the B-tree index to be stored/manipulated as a disk file so that large trees can be built using a configurable (ie: minimal) RAM footprint.</p> <p>Note: Since there seemed to be some confusion, a Binary Tree and a B-Tree are <em>not</em> the same thing.</p>
<p>Check out QDBM: <a href="http://fallabs.com/qdbm/" rel="noreferrer">http://fallabs.com/qdbm/</a>. It's LGPL (can be used in commercial app), implements a disk backed hash and/or B+ tree with arbitrary key/value pairs, and builds on a variety of platforms. </p>
<p>Maybe you can considere the berkeley db. It is using a b-tree internally.</p>
5,230
<p>I'm working with a project involving 3D printing's terminology, but I'm not such an expert... so I was asking myself if someone can explain the meaning of the "downstream" adjective in this field. </p> <p>More precisely, I'm dealing with this sentence: "Handle any downstream task", which I really can't understand because it has a very poor context. </p> <p>I also have this sentence with the adjective that I'm having trouble with:</p> <blockquote> <p>Confidently send your surfaces downstream knowing your results are usable design surfaces.</p> </blockquote>
<p>Without more anymore context "downstream" could be in reference to a print that would be sent to another machine for post-processing. The post-processing machine is "downstream" from the machine used to make the print in the first place.</p>
<p>Imagine an assembly line and the flow of the material along that line. That flow is analogous to a river, and therefore any machining/processing following on from <em>any point</em> along that line is considered to be downstream of <em>that point</em>.</p> <p>From <a href="https://en.wikipedia.org/wiki/Downstream_(manufacturing)" rel="nofollow noreferrer">Wikipedia - Downstream (Manufacturing)</a></p> <blockquote> <p>Downstream in manufacturing refers to processes that occur later on in a production sequence or production line. </p> </blockquote>
1,139
<p>Does anyone have tips on improving build plate adhesion in DLP printers? I've heard a thin layer of resin or UV glue applied to the plate will help, but we're not sure if we leave the resin/glue wet, or cure it before we start the print. Apologies for the ignorance here, but I'm just trying to avoid gluing my build plate to the bottom of the resin vat! Any advice would be appreciated.</p> <p><strong><em>Update</em></strong> I had a product called ProtoGlass recommended to me in another forum, that apparently works as a good build plate primer for the resin we're trying to grow (BlueCast x5). Ordering today, and I'll update further with the results.</p>
<p>You do not need to use any glue or any other adhesion modifier to increase your build plate adhesion. Take these steps instead:</p> <ol> <li>Make sure your <strong>build plate is level</strong></li> <li>Use proper attachment layer (<strong>raft</strong>) - see <a href="https://ameralabs.com/blog/attachment-layer-need-know/" rel="nofollow noreferrer">3D printing raft in resin 3D printing: what you need to know</a>.</li> <li>Increase <strong>bottom layer exposure</strong></li> <li>Make sure your <strong>resin is not cold</strong> (25+ °C works best)</li> <li>Make sure your <strong>build plate is flat and even</strong>. Sometimes they come faulty from the factory. Lay it flat on the glass and see if all corners touch it evenly.</li> <li><strong>Sand your build plate</strong></li> <li>Make sure to use high <strong>quality FEP</strong>. If it get's scratched or cloudy - change it.</li> <li>Make sure the <strong>tension of your FEP</strong> is right. Not too tight, not too loose.</li> </ol>
<p>I have heard that adding a few pieces of masking tape to the print surface improves adhesion.</p>
1,370
<p>I see often (rewritten) URLs without ID in it, like on some wordpress installations. What is the best way of achieve this?</p> <p>Example: site.com/product/some-product-name/</p> <p>Maybe to keep an array of page names and IDs in cache, to avoid DB query on every page request? How to avoid conflicts, and what are other issues on using urls without IDs?</p>
<p>Using an ID presents the same conundrum, really--you're just checking for a different value in your database. The "some-product-name" part of your URL above is also something unique. Some people call them slugs (Wordpress, also permalinks). So instead of querying the database for a row that has the particular ID, you're querying the database for a row that has a particular slug. You don't need to know the ID to retrieve the record.</p>
<p>As long as product names are unique it shouldn't be an issue. It won't take any longer (at least not significant) to look up a product by unique name than numeric ID as long as the column is indexed.</p>
3,420
<p>Suppose you have an ActiveRecord::Observer in one of your Ruby on Rails applications - how do you test this observer with rSpec?</p>
<p>You are on the right track, but I have run into a number of frustrating unexpected message errors when using rSpec, observers, and mock objects. When I am spec testing my model, I don't want to have to handle observer behavior in my message expectations. </p> <p>In your example, there isn't a really good way to spec "set_status" on the model without knowledge of what the observer is going to do to it. </p> <p>Therefore, I like to use the <a href="http://patmaddox.com/2007/11/23/better-rails-testing-decoupling-observers/" rel="noreferrer">"No Peeping Toms" plugin.</a> Given your code above and using the No Peeping Toms plugin, I would spec the model like this: </p> <pre><code>describe Person do it "should set status correctly" do @p = Person.new(:status =&gt; "foo") @p.set_status("bar") @p.save @p.status.should eql("bar") end end </code></pre> <p>You can spec your model code without having to worry that there is an observer out there that is going to come in and clobber your value. You'd spec that separately in the person_observer_spec like this: </p> <pre><code>describe PersonObserver do it "should clobber the status field" do @p = mock_model(Person, :status =&gt; "foo") @obs = PersonObserver.instance @p.should_receive(:set_status).with("aha!") @obs.after_save end end </code></pre> <p>If you REALLY REALLY want to test the coupled Model and Observer class, you can do it like this:</p> <pre><code>describe Person do it "should register a status change with the person observer turned on" do Person.with_observers(:person_observer) do lambda { @p = Person.new; @p.save }.should change(@p, :status).to("aha!) end end end </code></pre> <p>99% of the time, I'd rather spec test with the observers turned off. It's just easier that way. </p>
<p>no_peeping_toms is now a gem and can be found here: <a href="https://github.com/patmaddox/no-peeping-toms" rel="nofollow">https://github.com/patmaddox/no-peeping-toms</a></p>
5,301
<p>Do any asynchronous connectors exist for Mysql that can be used within a C or C++ application? I'm looking for something that can be plugged into a <a href="http://en.wikipedia.org/wiki/Reactor_pattern" rel="noreferrer" title="reactor pattern">reactor pattern</a> written in <a href="http://www.boost.org/doc/libs/release/libs/asio/index.html" rel="noreferrer" title="Boost.Asio">Boost.Asio</a>.</p> <p>[Edit:] Running a synchronous connector in threads is not an option.</p>
<p><a href="http://forums.mysql.com/read.php?45,183339,183339" rel="nofollow noreferrer">http://forums.mysql.com/read.php?45,183339,183339</a> enjoy</p> <p>Updated link to the original article showing how to do async mysql queries:</p> <p><a href="http://jan.kneschke.de/projects/mysql/async-mysql-queries-with-c-api/" rel="nofollow noreferrer">http://jan.kneschke.de/projects/mysql/async-mysql-queries-with-c-api/</a></p>
<p>I think the only solution will be to create an asynchronous service that wraps a <a href="http://dev.mysql.com/downloads/connector/odbc/5.1.html" rel="nofollow noreferrer">standard connector</a>. You'll need to understand the ODBC APIs though.</p>
5,937
<p>We have some files on our website that users of our software can download. Some of the files are in virtual folders on the website while others are on our ftp. The files on the ftp are generally accessed by clicking on an ftp:// link in a browser - most of our customers do not have an ftp client. The other files are accessed by clicking an http:// link in a browser.</p> <p>Should I move all the files to the ftp? or does it not matter? Whats the difference?</p>
<p>HTTP has many advantages over FTP:</p> <ul> <li>it is available in more places (think workplaces which block anything other than HTTP/S)</li> <li>it works nicely with proxies (FTP requires extra settings for the proxy - like making sure that it allows the CONNECT method)</li> <li>it provides built-in compression (with GZIP) which almost all browsers can handle (as opposed to FTP which has a non-official "MODE Z" extension)</li> <li>NAT gateways must be configured in a special mode to support active FTP connections, while passive FTP connections require them to allow access to all ports (it it doesn't have conneciton tracking)</li> <li>some FTP clients insist on opening a new data connection for each data transfer, which can leave you with a lot of "TIME_WAIT" sockets</li> </ul>
<p>Both FTP and HTTP seem sufficient for your needs, so I would definitely recommend choosing the <em>simplest</em> approach, which is either to leave things as they currently are or consolidate on HTTP.</p> <p>Personally, I would put everything on HTTP. If nothing else, it eliminates an extra server. There is no compelling reason to choose FTP over HTTP anymore, and there are a few small advantages to HTTP (as others have pointed out).</p>
3,502
<p>I was browsing <a href="https://stackoverflow.com/questions/5119/what-are-the-best-rss-feeds-for-programmersdevelopers">this thread</a>, which has good recommendation but a bit too general for me.</p> <p>So, if anyone has a collection of nice game programming feeds,please share them. :)</p> <p>(both general and specific topics are welcome)</p>
<p>My first suggestion would be to use a drop-in logging tool like log4net, which will make formatting much more automatic.</p> <p>If you are going to go the route of two files (and I agree with Craig that a database is probably a better choice,) you can probably save yourself a lot of heartache by having one file that is as sparse as you can make it for later fast searches and one that holds all the information in one place (metadata and data) rather than creating a metadata-only format.</p>
<p>If you are catpuring logging information for future searching and anaylsis perhaps a database would be a better answer. </p> <p>As for your solution. Flat files do not scale well at all where as a database scale much better. I wouldn't split the files either, that just compounds the scalability issue. If you have to use a flat file I would probably try keeping the meta data in a csv (less over head) and the data in a series of files indexed by the csv file. That way all the data doesn't impact your index file. Just my thoughts.</p>
7,348
<p>In C#, <code>int</code> and <code>Int32</code> are the same thing, but I've read a number of times that <code>int</code> is preferred over <code>Int32</code> with no reason given. Is there a reason, and should I care?</p>
<p>The two are indeed synonymous; <code>int</code> will be a little more familiar looking, <code>Int32</code> makes the 32-bitness more explicit to those reading your code. I would be inclined to use <code>int</code> where I just need 'an integer', <code>Int32</code> where the size is important (cryptographic code, structures) so future maintainers will know it's safe to enlarge an <code>int</code> if appropriate, but should take care changing <code>Int32</code>s in the same way.</p> <p>The resulting code will be identical: the difference is purely one of readability or code appearance.</p>
<p>The bytes int can hold depends on what you compiled it for, so when you compile your program for 32 bit processors, it holds numbers from 2^32/2 to -2^32/2+1, while compiled for 64 bit it can hold from 2^64/2 to -2^64/2+1. int32 will always hold 2^32 values.</p> <p><strong>Edit</strong> : Ignore my answer, I didn't see C#. My answer was intended for C and C++. I've never used C#</p>
8,795
<p>I'm running into a perplexing problem with an ActiveX control I'm writing - sometimes, Internet Explorer appears to fail to properly unload the control on process shutdown. This results in the control instance's destructor not being called.</p> <p>The control is written in C++, uses ATL and it's compiled using Visual Studio 2005. The control instance's destructor is always called when the user browses away from the page the control is embedded in - the problem only occurs when the browser is closed. </p> <p>When I run IE under a debugger, I don't see anything unusual - the debugger doesn't catch any exceptions, access violations or assertion failures, but the problem is still there - I can set a breakpoint in the control's destructor and it's never hit when I close the broswer.</p> <p>In addition, when I load a simple HTML page that embeds multiple instances of the control I don't see the problem. The problem only appears to happen when the control is instantiated from our web application, which inserts tags dynamically into the web page - of course, not knowing what causes this problem, I don't know whether this bit of information is relevant or not, but it does seem to indicate that this might be an IE problem, since it's data dependent. </p> <p>When I run the simple test case under the debugger, I can set a breakpoint in the control's destructor and it's hit every time. I believe this rules out a problem with the control itself (say, an error that would prevent the destructor from ever being called, like an interface leak.)</p> <p>I do most of my testing with IE 6, but I've seen the problem occur on IE 7, as well. I haven't tested IE 8.</p> <p>My working hypothesis right now is that there's something in the dynamic HTML code that causes the browser to leak an interface on the ActiveX control. So far, I haven't been able to produce a good test case that reproduces this outside of the application, and the application is a bit too large to make a good test case.</p> <p>I was hoping that someone might be able to provide insight into possible IE bugs that are known to cause this kind of behavior. The answer provided below, by the way, is too general - I'm looking for a specific set of circumstances that is known to cause this. Surely someone out there has seen this before.</p>
<p>To debug a problem in COM with C++ where an object's (C++) destructor is not being called, the best approach is to focus on how the COM object's refcounts are being incremented or decremented. What is probably happening is that somebody is incrementing the refcount one too many times, and then not decrementing it the same number of times. This leads to the object not being freed.</p> <p>It is possible that your dynamic HTML is simply showing up a bug in IE, which doesn't happen if you use a static page.</p> <p>If there is a bug in IE, the trick would be to figure out what causes the bug to appear, and what you can do to trick IE into releasing your COM object properly (like, making the HTML go away).</p>
<p>Another approach - add cleanup code to your <a href="http://msdn.microsoft.com/en-us/library/ms682583.aspx" rel="nofollow noreferrer">DllMain</a> function (adding that function if it doesn't already exist). Then regardless of reference counts (and reference count errors), when your DLL is unloaded you can clean yourself up:</p> <pre><code>BOOL WINAPI DllMain(HINSTANCE, DWORD dwReason, LPVOID) { if (dwReason == DLL_PROCESS_DETACH) { CleanUpAnyObjectsStillAlive(); } } </code></pre> <p>Oh, and a word of warning - don't take too long doing your cleanup - if you do, I can't promise the process shutdown won't kill you anyway.</p>
9,090
<p><a href="https://stackoverflow.com/questions/2556/whats-the-best-online-payment-processing-solution">This question</a> talks about different payment processors and what they cost, but I'm looking for the answer to what do I need to do if I want to accept credit card payments?</p> <p>Assume I need to <em>store</em> credit card numbers for customers, so that the obvious solution of relying on the credit card processor to do the heavy lifting is not available.</p> <p><a href="https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml" rel="noreferrer">PCI Data Security</a>, which is apparently the standard for storing credit card info, has a bunch of general requirements, but <a href="http://en.wikipedia.org/wiki/PCI_DSS" rel="noreferrer">how does one implement them</a>? </p> <p>And what about the vendors, like <a href="http://usa.visa.com/merchants/risk_management/cisp_payment_applications.html" rel="noreferrer">Visa</a>, who have their own best practices?</p> <p>Do I need to have keyfob access to the machine? What about physically protecting it from hackers in the building? Or even what if someone got their hands on the backup files with the sql server data files on it?</p> <p>What about backups? Are there other physical copies of that data around?</p> <p>Tip: <a href="http://transfs.com/blog/" rel="noreferrer">If you get a merchant account, you should negotiate that they charge you "interchange-plus" instead of tiered pricing.</a> With tiered pricing, they will charge you different rates based on what type of Visa/MC is used -- ie. they charge you more for cards with big rewards attached to them. Interchange plus billing means you only pay the processor what Visa/MC charges them, plus a flat fee. (Amex and Discover charge their own rates directly to merchants, so this doesn't apply to those cards. You'll find Amex rates to be in the 3% range and Discover could be as low as 1%. Visa/MC is in the 2% range). <a href="http://transfs.com/" rel="noreferrer">This service is supposed to do the negotiation for you</a> (I haven't used it, this is not an ad, and I'm not affiliated with the website, but this service is greatly needed.)</p> <p><em>This blog post gives a <a href="http://blog.boxedice.com/2009/05/20/taking-payments-online-merchant-account-payment-processor-fees/" rel="noreferrer">complete rundown of handling credit cards</a> (specifically for the UK).</em></p> <hr> <p>Perhaps I phrased the question wrong, but I'm looking for tips like these:</p> <ol> <li>Use <a href="http://www.rsa.com/node.aspx?id=1156" rel="noreferrer">SecurID</a> or <a href="http://www.aladdin.com/etoken/" rel="noreferrer">eToken</a> to add an additional password layer to the physical box.</li> <li>Make sure the box is in a room with a physical lock or keycode combination.</li> </ol>
<p>I went through this process not to long ago with a company I worked for and I plan on going through it again soon with my own business. If you have some network technical knowledge, it really isn't that bad. Otherwise you will be better off using Paypal or another type of service.</p> <p>The process starts by getting a <strong><a href="https://stackoverflow.com/questions/2556/whats-the-best-online-payment-processing-solution">merchant account</a></strong> setup and tied to your bank account. You may want to check with your bank, because a lot of major banks provide merchant services. You may be able to get deals, because you are already a customer of theirs, but if not, then you can shop around. If you plan on accepting Discover or American Express, those will be separate, because they provide the merchant services for their cards, no getting around this. There are other special cases also. This is an application process, be prepared.</p> <p>Next you will want to purchase an <strong>SSL certificate</strong> that you can use for securing your communications for when the credit card info is transmitted over public networks. There are plenty of vendors, but my rule of thumb is to pick one that is a brand name in a way. The better they are known, the better your customer has probably heard of them.</p> <p>Next you will want to find a <strong><a href="http://en.wikipedia.org/wiki/Payment_gateway" rel="noreferrer">payment gateway</a></strong> to use with your site. Although this can be optional depending on how big you are, but majority of the time it won't be. You will need one. The payment gateway vendors provide a way to talk to the Internet Gateway API that you will communicate with. Most vendors provide HTTP or TCP/IP communication with their API. They will process the credit card information on your behalf. Two vendors are <a href="http://www.authorize.net/" rel="noreferrer">Authorize.Net</a> and <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside" rel="noreferrer">PayFlow Pro</a>. The link I provide below has some more information on other vendors.</p> <p>Now what? For starters there are guidelines on what your application has to adhere to for transmitting the transactions. During the process of getting everything setup, someone will look at your site or application and make sure you are adhering to the guidelines, like using SSL and that you have terms of use and policy documentation on what the information the user is giving you is used for. Don't steal this from another site. Come up with your own, hire a lawyer if you need to. Most of these things fall under the PCI Data Security link Michael provided in his question.</p> <p>If you plan on storing the credit card numbers, then you better be prepared to put some security measures in place internally to protect the info. Make sure the server the information is stored on is only accessible to members who need to have access. Like any good security, you do things in layers. The more layers you put in place the better. If you want you can use key fob type security, like <a href="http://www.rsa.com/node.aspx?id=1156" rel="noreferrer">SecureID</a> or <a href="http://www.aladdin.com/etoken/default.aspx" rel="noreferrer">eToken</a> to protect the room the server is in. If you can't afford the key fob route, then use the two key method. Allow a person who has access to the room to sign out a key, which goes along with a key they already carry. They will need both keys to access the room. Next you protect the communication to the server with policies. My policy is that the only thing communicating to it over the network is the application and that information is encrypted. The server should not be accessible in any other form. For backups, I use <a href="http://www.truecrypt.org/" rel="noreferrer">truecrypt</a> to encrypt the volumes the backups will be saved to. Anytime the data is removed or stored somewhere else, then again you use truecrypt to encrypt the volume the data is on. Basically where ever the data is, it needs to be encrypted. Make sure all processes for getting at the data carries auditing trails. use logs for access to the server room, use cameras if you can, etc... Another measure is to encrypt the credit card information in the database. This makes sure that the data can only be viewed in your application where you can enforce who sees the information.</p> <p>I use <a href="http://www.pfsense.com/" rel="noreferrer">pfsense</a> for my firewall. I run it off a compact flash card and have two servers setup. One is for fail over for redundancy.</p> <p>I found this <a href="http://www.west-wind.com/presentations/aspnetecommerce/aspnetecommerce.asp" rel="noreferrer">blog post</a> by Rick Strahl which helped tremendously to understand doing e-commerce and what it takes to accept credit cards through a web application.</p> <p>Well, this turned out to be a long answer. I hope these tips help. </p>
<p>There's a lot to the whole process. The single easiest way to do it is to use services similar to paypal, so that you never actually handle any credit card data. Apart from that, there's a quite a bit of stuff to go through to get approved to offer credit card services on your website. You should probably talk with your bank, and the people who issue your merchant ID to help you in setting up the process.</p>
7,397
<p>I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: <em><a href="http://www.gallup.com" rel="nofollow noreferrer">www.gallup.com</a></em> and <em><a href="http://www.rassmussenreports.com" rel="nofollow noreferrer">www.rassmussenreports.com</a></em></p> <p>I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of the random data matches pollsters numbers. (Most companies poll numbers are three day averages)</p> <p>Currently, it works well for one iteration, but my goal is to have it produce the most common simulation that matches the average polling data. I could then change the code of anywhere from 1 to 1000 iterations.</p> <p>And this is my problem. At the end of the test I have an array in a single variable that looks something like this:</p> <pre><code>[40.1, 39.4, 56.7, 60.0, 20.0 ..... 19.0] </code></pre> <p>The program currently produces one array for each correct simulation. <em>I can store each array in a single variable, but I then have to have a program that could generate 1 to 1000 variables depending on how many iterations I requested!?</em></p> <p>How do I avoid this? I know there is an intelligent way of doing this that doesn't require the program to generate variables to store arrays depending on how many simulations I want.</p> <p>Code testing for McCain:</p> <pre><code> test = [] while x &lt; 5: test = round(100*random.random()) mctest.append(test) x = x +1 mctestavg = (mctest[0] + mctest[1] + mctest[2])/3 #mcavg is real data if mctestavg == mcavg[2]: mcwork = mctest </code></pre> <p>How do I repeat without creating multiple mcwork vars?</p>
<p>Would something like this work?</p> <pre><code>from random import randint mcworks = [] for n in xrange(NUM_ITERATIONS): mctest = [randint(0, 100) for i in xrange(5)] if sum(mctest[:3])/3 == mcavg[2]: mcworks.append(mctest) # mcavg is real data </code></pre> <p>In the end, you are left with a list of valid <code>mctest</code> lists.</p> <p>What I changed:</p> <ul> <li>Used a <a href="https://web.archive.org/web/20080928230016/http://docs.python.org:80/tut/node7.html#SECTION007140000000000000000" rel="nofollow noreferrer">list comprehension</a> to build the data instead of a for loop</li> <li>Used <code>random.randint</code> to get random integers</li> <li>Used <a href="http://docs.python.org/tut/node5.html" rel="nofollow noreferrer">slices</a> and <code>sum</code> to calculate the average of the first three items</li> <li>(To answer your actual question :-) ) Put the results in a list <code>mcworks</code>, instead of creating a new variable for every iteration</li> </ul>
<p>A neat way to do it is to use a list of lists in combination with Pandas. Then you are able to create a 3-day rolling average. This makes it easy to search through the results by just adding the real ones as another column, and using the loc function for finding which ones that match.</p> <pre><code>rand_vals = [randint(0, 100) for i in range(5))] df = pd.DataFrame(data=rand_vals, columns=['generated data']) df['3 day avg'] = df['generated data'].rolling(3).mean() df['mcavg'] = mcavg # the list of real data # Extract the resulting list of values res = df.loc[df['3 day avg'] == df['mcavg']]['3 day avg'].values </code></pre> <p>This is also neat if you intend to use the same random values for different polls/persons, just add another column with their real values and perform the same search for them. </p>
8,428
<p>As an exercise for myself, I was translating a sample program into various languages. Starting in C#, I had a visitor-pattern interface like so:</p> <pre><code>interface Visitor { void Accept(Bedroom x); void Accept(Bathroom x); void Accept(Kitchen x); void Accept(LivingRoom x); } </code></pre> <p>Moving to ruby (or python, or whatever), I no longer get dispatch from the compiler based on type. Should I do the dispatch in the visitor itself?</p> <pre><code>class Cleaner def accept(x) acceptBedroom(x) if Bedroom === x acceptBathroom(x) if Bathroom === x acceptKitchen(x) if Kitchen===x acceptLivingRoom(x) if LivingRoom===x end ... </code></pre> <p>Or should I do the dispatch in the different specializaions of the room:</p> <pre><code>class Bathroom&lt;Room def initialize(name) super(name) end def accept(visitor) visitor.acceptBathroom(self) end end </code></pre> <p>Or is there another preferred idiom that is used in dynamic languages?</p>
<p>You can force the keyboard focus to stay on the <code>TextBox</code> by handling the <code>PreviewLostKeyBoardFocus</code> event like this:</p> <pre class="lang-xml prettyprint-override"><code> &lt;TextBox PreviewLostKeyboardFocus=&quot;TextBox_PreviewLostKeyboardFocus&quot; /&gt; </code></pre> <pre class="lang-cs prettyprint-override"><code> private void TextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { e.Handled = true; } </code></pre>
<p>It sounds to me that you'll want to handle two events:</p> <p>GotFocus: Will trigger when the textbox gains focus. You can store the initial value of the box.</p> <p>LostFocus: Will trigger when the textbox loses focus. At this point you can do your validation and decide if you want to roll back or not.</p>
6,606
<p>I have just built a Prusa i3 MK2 printer. One of its features is automatic XYZ axes calibration done using inductive probe which is located next to the nozzle.</p> <p>In my case, this calibration procedure failed with the message: </p> <blockquote> <p><em>XYZ calibration failed. Please consult the manual.</em></p> </blockquote> <p>The <a href="http://www.prusa3d.com/downloads/manual/prusa3d_manual_mk2_en.pdf" rel="nofollow noreferrer">manual</a> on this problem reads:</p> <blockquote> <ol> <li><strong>XYZ calibration failed. Bed calibration point was not found.</strong><br> Calibration routine did not find a bed sensor point. The printer stops close to the bed point, which it failed to detect. Please verify, that the printer is assembled correctly, that all axes move freely, the pulleys do not slip and the print nozzle is clean. If everything looks good, re-run the X/Y calibration and verify with a sheet of paper between the nozzle and the print bed that the print nozzle does not touch the print bed during the calibration routine. If you feel a friction of the nozzle against the sheet of paper and the nozzle is clean, you need to screw the PINDA probe slightly lower and re-run the X/Y calibration.</li> <li><strong>XYZ calibration failed. Please consult the manual.</strong><br> The calibration points were found in positions far from what should be expected for a properly assembled printer. Please follow the instructions of case 1).</li> </ol> </blockquote> <p>My nozzle is new, therefore clean and I have already checked that all axes move without any problems. The manual does not seem to offer any additional advice.</p> <p>I tried to put the PINDA probe lower. It had helped the calibration, but at the same time the probe was lower than the nozzle, which means I couldn't print with it being on the extruder.</p> <p>What else can I check? How to find the issue? This is my first printer, so I'm totally clueless.</p>
<p>One thing, and the one that eventually solved my problem, is to update the firmware. Firmware update instructions: <a href="http://manual.prusa3d.com/Guide/Upgrading+firmware/66" rel="nofollow noreferrer">Upgrading firmware - Prusa3D</a></p> <p>The only thing you might get stuck on is selecting the right COM port.</p> <ol> <li>Go to the device manager (run <code>devmgmt.msc</code>) <img src="https://i.stack.imgur.com/yphCl.png" alt="image description"></li> <li>In COM and LPT section, you should see port for your printer by name. Select that port number in the firmware update tool.</li> </ol> <p>In my case, I had to run the calibration twice before it worked. I had no problems since then.</p>
<p>I suggest that you ask on <a href="http://shop.prusa3d.com" rel="nofollow noreferrer">shop.prusa3d.com</a> and click the Forum tab button. The folks there are very friendly and knowledgable. I'm sure you can get some help. You can also email support.</p> <p>There is also a question form at the bottom of <a href="http://www.prusa3d.com" rel="nofollow noreferrer">www.prusa3d.com</a> where you can ask questions.</p> <p>I'm sure you can get it going. I have a MK2 also and it has done very well by me!</p>
513
<p>Questions like:</p> <blockquote> <p><em>x</em> 3d printer is good?</p> </blockquote> <p>or</p> <blockquote> <p>if it is my first printer, which model would you recommend</p> </blockquote> <p>or</p> <blockquote> <p>What printer model to buy?</p> </blockquote> <p>are on-topic?</p> <p>I think if you ask</p> <blockquote> <p><strong>I can not do <em>x</em> with my 3d printer, what printer to do <em>x</em>?</strong></p> </blockquote> <p>Can be on-topic</p>
<p>These are shopping questions, plain and simple. They are such obvious <a href="https://en.wikipedia.org/wiki/Broken_windows_theory" rel="nofollow noreferrer">broken windows</a> that it is important that they are closed as quickly as possible.</p> <p>On <em>Robotics</em> I have the following <a href="https://robotics.meta.stackexchange.com/a/177/37">canned response</a> for shopping questions, and I would highly recommend adapting it for 3dprinting:</p> <p><code>Welcome to *robotics* XXX, but I'm afraid that *[shopping questions](http://blog.stackoverflow.com/2010/11/qa-is-hard-lets-go-shopping/)* really aren't a good fit for a stack exchange site. We prefer *[practical, answerable questions based on actual problems that you face](https://robotics.stackexchange.com/help/dont-ask)*. Take a look at [ask] and [about] for more information on how stack exchange works, and the [*Robotics* question checklist](https://robotics.meta.stackexchange.com/q/1302/37) for details of how to write a good question.</code></p> <p>This renders as:</p> <blockquote> <p>Welcome to <em>robotics</em> XXX, but I'm afraid that <em><a href="http://blog.stackoverflow.com/2010/11/qa-is-hard-lets-go-shopping/">shopping questions</a></em> really aren't a good fit for a stack exchange site. We prefer <em><a href="https://robotics.stackexchange.com/help/dont-ask">practical, answerable questions based on actual problems that you face</a></em>. Take a look at <a href="https://robotics.stackexchange.com/questions/how-to-ask">How to Ask</a>, <a href="https://robotics.stackexchange.com/about">tour</a> and the <a href="https://robotics.meta.stackexchange.com/q/1302/37"><em>Robotics</em> question checklist</a> for more information on how stack exchange works.</p> </blockquote> <p>I then close the question as "Primarily Opinion Based". These questions are almost never edited to adhere to community guidelines, but at least I have done my best to welcome people to the community and minimise the risk that they will leave and never come back.</p>
<p>I don't think any of these types of questions should be on-topic. They're all heavily opinion-based. I think even the last one ("What 3D printer can do X?") isn't a good question, because possibly very many printers might be able to do it, and then the answers quickly devolve into subjective recommendations.</p> <p>It would be better to ask something among the lines of "I want to do X with printer Y, is it possible?" - but even that might turn into a subjective discussion quickly.</p>
17
<p>Say I have a line in an emacs buffer that looks like this:</p> <pre><code>foo -option1 value1 -option2 value2 -option3 value3 \ -option4 value4 ... </code></pre> <p>I want it to look like this:</p> <pre><code>foo -option1 value1 \ -option2 value2 \ -option3 value3 \ -option4 value4 \ ... </code></pre> <p>I want each option/value pair on a separate line. I also want those subsequent lines indented appropriately according to mode rather than to add a fixed amount of whitespace. I would prefer that the code work on the current block, stopping at the first non-blank line or line that does not contain an option/value pair though I could settle for it working on a selected region. </p> <p>Anybody know of an elisp function to do this? </p>
<p>Nobody had what I was looking for so I decided to dust off my elisp manual and do it myself. This seems to work well enough, though the output isn't precisely what I asked for. In this version the first option goes on a line by itself instead of staying on the first line like in my original question.</p> <pre class="lang-lisp prettyprint-override"><code>(defun tcl-multiline-options () "spread option/value pairs across multiple lines with continuation characters" (interactive) (save-excursion (tcl-join-continuations) (beginning-of-line) (while (re-search-forward " -[^ ]+ +" (line-end-position) t) (goto-char (match-beginning 0)) (insert " \\\n") (goto-char (+(match-end 0) 3)) (indent-according-to-mode) (forward-sexp)))) (defun tcl-join-continuations () "join multiple continuation lines into a single physical line" (interactive) (while (progn (end-of-line) (char-equal (char-before) ?\\)) (forward-line 1)) (while (save-excursion (end-of-line 0) (char-equal (char-before) ?\\)) (end-of-line 0) (delete-char -1) (delete-char 1) (fixup-whitespace))) </code></pre>
<p>Personally, I do stuff like this all the time.</p> <p>But I don't write a function to do it unless I'll be doing it every day for a year.</p> <p>You can easily do it with query-replace, like this:</p> <p>m-x (query-replace " -option" "^Q^J -option")</p> <p>I say ^Q^J as that is what you'll type to quote a newline and put it in the string.</p> <p>Then just press 'y' for the strings to replace, and 'n' to skip the wierd corner cases you'd find.</p> <p>Another workhorse function is query-replace-regexp that can do replacements of regular expressions.</p> <p>and also grep-query-replace, which will perform query-replace by parsing the output of a grep command. This is useful because you can search for "foo" in 100 files, then do the query-replace on each occurrence skipping from file to file.</p>
9,443
<p>In Visual Studio 2005-2015 it is possible to find all lines containing certain references and display them in a "Find Results" window.</p> <p>Now that these result lines are displayed, is there any keyboard shortcut that would allow adding debug breakpoints to all of them?</p>
<p><strong><em>This answer does not work for Visual Studio 2015 or later. A more recent answer can be found <a href="https://stackoverflow.com/questions/38061627/how-do-i-add-debug-breakpoints-to-lines-displayed-in-a-find-results-window-in?rq=1">here</a>.</em></strong></p> <p>You can do this fairly easily with a Visual Studio macro. Within Visual Studio, hit Alt-F11 to open the Macro IDE and add a new module by right-clicking on MyMacros and selecting Add|Add Module...</p> <p>Paste the following in the source editor:</p> <pre><code>Imports System Imports System.IO Imports System.Text.RegularExpressions Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports System.Diagnostics Public Module CustomMacros Sub BreakpointFindResults() Dim findResultsWindow As Window = DTE.Windows.Item(Constants.vsWindowKindFindResults1) Dim selection As TextSelection selection = findResultsWindow.Selection selection.SelectAll() Dim findResultsReader As New StringReader(selection.Text) Dim findResult As String = findResultsReader.ReadLine() Dim findResultRegex As New Regex("(?&lt;Path&gt;.*?)\((?&lt;LineNumber&gt;\d+)\):") While Not findResult Is Nothing Dim findResultMatch As Match = findResultRegex.Match(findResult) If findResultMatch.Success Then Dim path As String = findResultMatch.Groups.Item("Path").Value Dim lineNumber As Integer = Integer.Parse(findResultMatch.Groups.Item("LineNumber").Value) Try DTE.Debugger.Breakpoints.Add("", path, lineNumber) Catch ex As Exception ' breakpoints can't be added everywhere End Try End If findResult = findResultsReader.ReadLine() End While End Sub End Module </code></pre> <p>This example uses the results in the "Find Results 1" window; you might want to create an individual shortcut for each result window.</p> <p>You can create a keyboard shortcut by going to Tools|Options... and selecting <strong>Keyboard</strong> under the <strong>Environment</strong> section in the navigation on the left. Select your macro and assign any shortcut you like. </p> <p>You can also add your macro to a menu or toolbar by going to Tools|Customize... and selecting the <strong>Macros</strong> section in the navigation on the left. Once you locate your macro in the list, you can drag it to any menu or toolbar, where it its text or icon can be customized to whatever you want.</p>
<p>Paul, thanks a lot, but I have the following error (message box), may be I need to restart my PC:</p> <pre><code>Error --------------------------- Error HRESULT E_FAIL has been returned from a call to a COM component. --------------------------- OK --------------------------- </code></pre> <p>I would propose the following solution that's very simple but it works for me</p> <pre><code>Sub BreakPointsFromSearch() Dim n As Integer = InputBox("Enter the number of search results") For i = 1 To n DTE.ExecuteCommand("Edit.GoToNextLocation") DTE.ExecuteCommand("Debug.ToggleBreakpoint") Next End Sub </code></pre>
9,872
<p>I've to admin a small website for my alumni group which is hosted by my ISV. The url is something like www.myIsv.com/myWebSite/ which is quite ugly and very forgetable. The main admin of the webserver has registered a domain name www.mysmallwebsite.com and put a index.html with this content:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;www.mysmallwebsite.com&lt;/title&gt; &lt;/head&gt; &lt;frameset&gt; &lt;frame src="http://www.myIsv.com/myWebSite/" name="redir"&gt; &lt;noframes&gt; &lt;p&gt;Original location: &lt;a href="www.myIsv.com/myWebSite/"&gt;http://www.myIsv.com/myWebSite/&lt;/a&gt; &lt;/p&gt; &lt;/noframes&gt; &lt;/frameset&gt; &lt;/html&gt; </code></pre> <p>It works fine, but some features like PHP Session variables doesn't work anymore! Anyone has a suggestion for correcting that?</p> <p>Edit: This doesn't work both on IE and on Firefox (no plugins)</p> <p>Thanks</p>
<p>Sessions are tied to the server <strong>AND</strong> the domain. Using frameset across domain will cause all kind of breakage because that's just not how it was designed to do. </p> <p>Try using apache mod rewrite to create a "passthrough redirection", the "<strong>proxy</strong>" flag ([P]) in the rule is the magic flag that you need</p> <p>Documentation at <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" rel="nofollow noreferrer">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a></p>
<p>What do you mean? Are you saying that when you go from www.mysmallwebsite.com to www.myIsv.com/myWebSite/ then the PHP session is lost?</p> <p>PHP recognizes the session with an ID (alpha-numeric hash generated on the server). The ID is passed from request to request using a cookie called PHPSESSID or something like that (you can view the cookies a websites sets with the help of your browser ... on Firefox you have Firebug + FireCookie and the wonderful Web Developer Toolbar ... with which you can view the list of cookies without a sweat).</p> <p>So ... PHP is passing the session ID through the PHPSESSID cookie. But you can pass the session ID as a plain GET request parameters.</p> <p>So when you place the html link to the ugly domain name, assuming that it is the same PHP server (with the same sessions initialized), you can put it like this ...</p> <pre><code>www.myIsv.com/myWebSite/?PHPSESSID=&lt;?=session_id()?&gt; </code></pre> <p>I haven't worked with PHP for a while, but I think this will work. </p>
5,929
<p>For last two weeks I have been struggling with flow rate adjustments. I'm using an UM2, colorFabb XT 1.75mm and Slic3r. Before printing a test cube I made flow rate adjustments using the "Perimeter test" (printed a hallow cube with 1 layer thin perimeter line). I then compared the desired value of the perimeter's width with the value from the g-code and adjusted the flow rate. I repeated this procedure until I got exactly the thickness I needed. After that, I printed a 15x15x15 mm cube and observed under extrusion on top layer. Also, the dimensions of the cube in the x-y plane were smaller than expected (0.4mm shorter than they should be). I have done this a few times now, and still get the same result. :/ Furthermore, I was unable to adjust width by dividing the desired value of the width of the perimeter by a real value, I got slightly smaller extrusion multiplier (One I got by division is 0.9 , but 9.5 relates to desired width). Do you have some suggestion guys?<a href="https://i.stack.imgur.com/pcfx5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/pcfx5.jpg" alt="Cubes I have got with corrected extrusion multiplier"></a></p> <p>Update:</p> <p>I'll try to explain the calibration method I have used. </p> <ol> <li>I have made in Solidwork 15x15x15 mm cube. </li> <li>The cube was imported into Slic3r, where I have set the infill to 0% and number of sides shells equal to 1 and number of top and bottom shells equal to 0 (It gave me one layer thin wall in shape of cube). </li> <li>I printed it out and measured the width using caliper and compared with the perimeter's width from g-code. </li> <li>I have got something about 0.7, but the extrusion width in g-code is 0.65, so I changed extrusion multiplier by 0.65/0.7 = 0.93 (what is not actually true, because I got correct value on 0.95 only) </li> <li>I have repeated the procedure for many times, and always got wrong dimensions and under extrusion. There is the video about method I just have explained: <a href="https://www.youtube.com/watch?v=cnjE5udkNEA" rel="noreferrer">https://www.youtube.com/watch?v=cnjE5udkNEA</a></li> </ol>
<p>It looks like you overtune it. I think it's because top layer of hollow object doesn't have any support (which is obvious) but because of that the filament is not oblate that's why it looks like underextruded.</p> <p>If you really need hollow object then set number of top layers to 3..5 then check if it helps. I know it's not really what you expect but IMO this could help here. (I usually set 2 bottom layers and 3 top and it's quite enought.) You can also experiment with speed of top leyer. I would say the faster the better in this issue as the the first top layer should be as flat as possible then next top layer will have better support. And of course cooling should be set to max (as for the bridges).</p> <p>Here is an explanation why you get underextrusion. <a href="https://i.stack.imgur.com/RNxqc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RNxqc.png" alt="enter image description here"></a></p> <p>A is wall (perimeter) B is (ceiling) top layer. </p> <p>Empty outlines are what you expect but filled shapes are what you really get. Differences are of course slightly smaller but it's to clearly explain the issue</p> <p>Please also check Printer Settings > Advanced > Top solid infill.</p>
<p>I've had that issue on my 3D printing shop. </p> <p>That kind of problem usually happens when the extruder driving gear gets worn out. This makes the extruder loose it's grip on the filament and diminishes the flow of the extrusion, resulting on the prints you show on your photo.</p> <p>Depending on the time you have with your printer and the use you give it the gear will get worn out between 8 to 12 months and you will have to change it to avoid the flow issues.</p> <p>I recommend you to open the extruder and check if the driving gear is worn so that you can order a new one.</p>
296
<p>I'm 3D printing almost 2 years, and I expected to have better result after changing to complete smooth rods with new bearings.</p> <p>I have a problem with my Z axis giving me inconsistent prints; I already replaced the leadscrews, E3D clone with Bowden tube, I decided to replace all smooth rods on all axis and also the bearings. After I replaced all this, my prints are still bad, also I'm very dissapointed with the results after the replacements. I have checked all I could think of; PID tuning, belts, ....) but I'm running out of ideas.</p> <p><a href="https://i.stack.imgur.com/33DQZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/33DQZ.jpg" alt="inconsistent print layer results"></a></p> <p>Printing settings:</p> <ul> <li>print speed is 40mm/s, </li> <li>retraction is 3mm at 30mm/s, </li> <li>extruder 205&deg;C for the first layer, then 200&deg;C</li> </ul>
<p>From the pictures can be seen that you have good lead screws as there is no cyclic anomaly/wobble present at the side. It appears as though the lines at the sides of the print are more or less random X/Y positional inaccurate.</p> <p>These lines can be caused by various reasons. From what is read you tried to improve the mechanical system by upgrading the hardware. It could still be the case that there is still some backlash or play left in the system (e.g. I had once had too much tolerance on the holes of the linear shafts in the printed X-Z mounts causing similar problems). Vibration should be looked into also, e.g. do you have a binding bearing or a large mass on the printer that interacts with the carriage movement like a spool holder on top of your frame. Or maybe the micro-stepping does not work optimally, so check the stepper driver currents.</p> <p>If it is no mechanical issue, it could be that you are facing inconsistent extrusion caused by variation in filament thickness or gear slipping or too much tension on the filament by friction in unspooling. Or else a hotend temperature variation. Maybe insulation on the hotend helps.</p>
<p>From the pictures can be seen that you have good lead screws as there is no cyclic anomaly/wobble present at the side. It appears as though the lines at the sides of the print are more or less random X/Y positional inaccurate.</p> <p>These lines can be caused by various reasons. From what is read you tried to improve the mechanical system by upgrading the hardware. It could still be the case that there is still some backlash or play left in the system (e.g. I had once had too much tolerance on the holes of the linear shafts in the printed X-Z mounts causing similar problems). Vibration should be looked into also, e.g. do you have a binding bearing or a large mass on the printer that interacts with the carriage movement like a spool holder on top of your frame. Or maybe the micro-stepping does not work optimally, so check the stepper driver currents.</p> <p>If it is no mechanical issue, it could be that you are facing inconsistent extrusion caused by variation in filament thickness or gear slipping or too much tension on the filament by friction in unspooling. Or else a hotend temperature variation. Maybe insulation on the hotend helps.</p>
1,075
<p>I am trying to print this really cool <a href="https://www.thingiverse.com/thing:4551901/comments" rel="nofollow noreferrer">flying toy model</a> on my <a href="https://toybox.com/" rel="nofollow noreferrer">ToyBox</a> 3D printer, but when I try to print the &quot;copter_key-175.stl&quot; file it complains it is a &quot;non-manifold shape&quot;. How can I fix this .stl file?</p> <hr /> <p>[update START]</p> <p><em>Update for future readers:</em> I haven't tried it yet, but the Free and Open Source slicer software, <a href="https://github.com/slic3r/Slic3r" rel="nofollow noreferrer">Slic3r</a>, boasts this feature worth trying:</p> <blockquote> <p><strong>auto-repair</strong> of non-manifold meshes (and ability to re-export them);</p> </blockquote> <p>Update again: the <strong>best slicers</strong>, it seems, based on my research, are:</p> <ol> <li><strong>Cura</strong> (FOSS and professionally supported),</li> <li><strong>PrusaSlicer</strong> (FOSS, forked from Slic3r, and also professionally supported now).</li> </ol> <p>Articles to look at:</p> <ol> <li><a href="https://www.google.com/search?q=slic3r%20vs%20cura&amp;oq=slic3r%20vs%20cura&amp;aqs=chrome..69i57j69i65.2775j0j4&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow noreferrer">Google search for &quot;slic3r vs cura&quot;</a> <ol> <li>Slic3r vs Cura (Cura wins; Slic3r lags due to no full-time company-sponsored development): <a href="https://all3dp.com/2/slic3r-vs-cura-3d-printer-slicer-software-shootout/" rel="nofollow noreferrer">https://all3dp.com/2/slic3r-vs-cura-3d-printer-slicer-software-shootout/</a></li> </ol> </li> <li><a href="https://www.google.com/search?q=prusaslicer%20vs%20cura&amp;oq=prusaslicer%20vs%20cura&amp;aqs=chrome..69i57.10468j0j4&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow noreferrer">Google search for &quot;prusaslicer vs cura&quot;</a> <ol> <li>PrusaSlicer vs Cura (Cura wins, but just barely, since both are professionally supported with full-time developers): <a href="https://all3dp.com/2/prusaslicer-vs-cura-differences/" rel="nofollow noreferrer">https://all3dp.com/2/prusaslicer-vs-cura-differences/</a></li> </ol> </li> </ol> <p>[update END]</p> <hr /> <p>Note that I have printed many ToyBox-designed models perfectly with this printer over the last 24 hrs.</p> <p>I have also split the model (to cut the last few cm off the end and shorten it) using this technique here in TinkerCad, then exported the part as a shorter part so I could print on the smaller bed of the ToyBox printer.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/1SwSqROgLpY?start=0"></iframe> </div></div></p> <p>Here is what the &quot;key&quot; is supposed to look like:</p> <p><a href="https://i.stack.imgur.com/hTkbn.jpg" rel="nofollow noreferrer" title="3D rendering of 'key'"><img src="https://i.stack.imgur.com/hTkbn.jpg" alt="3D rendering of 'key'" title="3D rendering of 'key'" /></a></p> <p>And here is how it comes out instead. Notice the misaligned teeth and layers about halfway through. Once I saw it was botched, I stopped the print early.</p> <p><a href="https://i.stack.imgur.com/9BQTr.jpg" rel="nofollow noreferrer" title="Side view of 3D printed 'key'"><img src="https://i.stack.imgur.com/9BQTr.jpg" alt="Side view of 3D printed 'key'" title="Side view of 3D printed 'key'" /></a></p> <p><a href="https://i.stack.imgur.com/1gm0T.jpg" rel="nofollow noreferrer" title="Top view of 3D printed 'key'"><img src="https://i.stack.imgur.com/1gm0T.jpg" alt="Top view of 3D printed 'key'" title="Top view of 3D printed 'key'" /></a></p> <p><a href="https://i.stack.imgur.com/GqYyf.jpg" rel="nofollow noreferrer" title="Angled view of 3D printed 'key'"><img src="https://i.stack.imgur.com/GqYyf.jpg" alt="Angled view of 3D printed 'key'" title="Angled view of 3D printed 'key'" /></a></p> <p><a href="https://i.stack.imgur.com/RE9sB.jpg" rel="nofollow noreferrer" title="Back view of 3D printed 'key'"><img src="https://i.stack.imgur.com/RE9sB.jpg" alt="Back view of 3D printed 'key'" title="Back view of 3D printed 'key'" /></a></p> <p><strong>How can I make it print properly and/or how can I fix the .stl file?</strong></p> <h2>Notes:</h2> <ul> <li>My operating system is Linux Ubuntu 20.04</li> <li>I have Windows 10 running in the VirtualBox virtual machine in case I need to run Fusion 360 or something in Windows</li> <li>I tried installing Meshmixer inside Windows 10 and it won't open. I had read online it can be used to fix .stl files, so I was going to look into that. <a href="https://i.stack.imgur.com/yfPSh.png" rel="nofollow noreferrer" title="Screenshot of Meshmixer Error Report dialog box"><img src="https://i.stack.imgur.com/yfPSh.png" alt="Screenshot of Meshmixer Error Report dialog box" title="Screenshot of Meshmixer Error Report dialog box" /></a></li> </ul> <h2>Related:</h2> <ul> <li>my comment on <a href="https://www.thingiverse.com/thing:4551901/comments#comment-6238246" rel="nofollow noreferrer">Thingiverse</a></li> <li>my help request on <a href="https://maketoys.zendesk.com/hc/en-us/community/posts/4411413024916-Cannot-split-part-in-editor-Something-went-wrong-please-try-again-" rel="nofollow noreferrer">Toybox</a></li> <li>Another person seeking help for this: <a href="https://tinkercad.zendesk.com/hc/en-us/community/posts/360038762593-Non-Manifold-Model" rel="nofollow noreferrer">tinkercad.zendesk.com: Non-Manifold Model</a></li> </ul>
<h2>ToyBox 3D printer true print dimensions and limit switch problems</h2> <p>So I figured out that the problem is my print area is so small the printer was occasionally fully pressing and triggering the end-point limit switches! This apparently causes it to stop slightly early, shifting the next layer as it prints.</p> <p><a href="https://www.toyboxuae.com/blogs/news/what-are-toybox-specifications" rel="nofollow noreferrer">The printer specs</a> state that it has a print volume of <strong>9 x 8 x 10 cm</strong>. However, the print design area and viewer at <a href="https://www.make.toys/" rel="nofollow noreferrer">https://www.make.toys/</a> shows the design volume like this</p> <p><a href="https://i.stack.imgur.com/zouQc.png" rel="nofollow noreferrer" title="Screenshot of ToyBox viewer"><img src="https://i.stack.imgur.com/zouQc.png" alt="Screenshot of ToyBox viewer" title="Screenshot of ToyBox viewer" /></a></p> <p>In the square grid shown on the base plate there is 1 cm per square, except that as you can see, the far left and far-right columns are &lt; 1 square. Therefore, looking at this image, the usable bed area appears to be about <strong>7.25 cm x 8 cm</strong> (the grid size shown in the images), NOT 8 cm x 9 cm.</p> <p>Furthermore, if you do NOT have the &quot;Skip First Ring&quot; option checked on the &quot;Build&quot; tab in the image below, the printer does a &quot;wipe clean&quot; maneuver in the shape of a spiral, circle, or ring around the object to be printed just before beginning the print. This wipes off any dangling stray print material before beginning the print. If your object fully covers the print bed dimensions, however, that ring will be even wider, causing the printer to hit its limit switches.</p> <p>(<strong>The model in this image is 10.4 cm long, which is too long, causing my printer to hit its limit switches, skewing the layers while printing.</strong>)</p> <p><a href="https://i.stack.imgur.com/HAZQ7.png" rel="nofollow noreferrer" title="Screenshot of ToyBox viewer with the 'Skip First Ring' option highlighted"><img src="https://i.stack.imgur.com/HAZQ7.png" alt="Screenshot of ToyBox viewer with the 'Skip First Ring' option highlighted" title="Screenshot of ToyBox viewer with the 'Skip First Ring' option highlighted" /></a></p> <p>So, the problem is that my part is too big. WithOUT that &quot;Skip First Ring&quot; box checked, the dimensions are probably further reduced by another 5 mm or so on X and Y dimensions, bringing it down to about <strong>6.75 cm x 7.5 cm</strong> <em>usable print area.</em> My part was 10.4 cm long. The Pythagorean Theorem says that <span class="math-container">$A^2 + B^2 = C^2$</span>, so <span class="math-container">$C = \sqrt(A^2 + B^2)$</span> = <span class="math-container">$\sqrt(6.75cm^2 + 7.5cm^2)$</span> = <strong>10.09 cm max</strong> on the diagonal. <strong>My 10.4 cm long part was too long. The printer hit the limit switches, botching the layers.</strong></p> <p>Had I checked that box <em>maybe</em> I could have gotten away with a part closer to <span class="math-container">$\sqrt(7.25^2 + 8^2)$</span> = <strong>10.8 cm long</strong>, but that's really pushing the limits of this printer. <strong>In the end, shrinking the part a bit more to be about 10 cm or less was all I needed to do!</strong></p> <p>UPDATE: I've also proven conclusively by designing in <a href="http://www.TinkerCad.com" rel="nofollow noreferrer">www.TinkerCad.com</a> and printing on the ToyBox that the max allowed print height is exactly <strong>9 cm</strong>, and it will indeed print properly all the way up to that height.</p> <hr /> <h2>I'd still like a flying propeller</h2> <p>That being said, even though <a href="https://www.thingiverse.com/thing:4551901" rel="nofollow noreferrer">the &quot;key&quot; of the model in my question</a> printed pretty well in the end, the helicopter blade (propeller) printed horribly because the design is flawed and has a bunch of missing material and air gaps around the hub, making the propeller completely unusable!</p> <p>Instead, I <a href="https://www.thingiverse.com/thing:1885007" rel="nofollow noreferrer">switched to this thing shown below</a>, shrunk it down to 0.6x to fit my printer, set my printer settings from medium to fine resolution, and got pretty good results! I still need to further tweak and edit the design on <a href="https://www.tinkercad.com" rel="nofollow noreferrer">https://www.tinkercad.com</a> to give the pull key better clearance, and better connection with the hub gear, and I think I'll be able to get a great result! I got it to fly a few times up to 8 ft high or so, but the pull is very rough and inconsistent, so the model needs further tweaking.</p> <p><a href="https://i.stack.imgur.com/g6G53.png" rel="nofollow noreferrer" title="Screenshot of the Thingiverse page for the helicopter model"><img src="https://i.stack.imgur.com/g6G53.png" alt="Screenshot of the Thingiverse page for the helicopter model" title="Screenshot of the Thingiverse page for the helicopter model" /></a></p> <p><sub>Keywords: ToyBox 3D printer helicopter and toybox printer clearances, print dimensions, print volume, specs, print settings</sub></p>
<p>Non-manifold objects are only accidentally solid, as sometimes it becomes unclear what is the inside and what is the outside. Some slicers attempt to fix this and do a good job of guessing how to correct it. Also, some non-manifold errors are easier to fix than others.</p> <p>If your slicer is complaining about a part file being non-manifold or you suspect that this is causing a problem, you should bring it into a surface mesh editor like meshlab or blender and try to fix it with the manifold test and repair tools in either of these programs.</p> <p>Typical ways an STL file could be non-manifold include:</p> <ul> <li>cracks between faces caused by round off error</li> <li>missing faces</li> <li>flipped faces</li> <li>interior faces</li> <li>faces that intersect somewhere other than an edge</li> </ul>
2,062
<p>In Perl, you can execute system commands using system() or `` (backticks). You can even capture the output of the command into a variable. However, this hides the program execution in the background so that the person executing your script can't see it. </p> <p>Normally this is useful but sometimes I want to see what is going on behind the scenes. How do you make it so the commands executed are printed to the terminal, and those programs' output printed to the terminal? This would be the <code>.bat</code> equivalent of "@echo on".</p>
<p>As I understand, system() will print the result of the command, but not assign it. Eg.</p> <pre><code>[daniel@tux /]$ perl -e '$ls = system(&quot;ls&quot;); print &quot;Result: $ls\n&quot;' bin dev home lost+found misc net proc sbin srv System tools var boot etc lib media mnt opt root selinux sys tmp usr Result: 0 </code></pre> <p>Backticks will capture the output of the command and not print it:</p> <pre><code>[daniel@tux /]$ perl -e '$ls = `ls`; print &quot;Result: $ls\n&quot;' Result: bin boot dev etc home lib </code></pre> <p>etc...</p> <p><strong>Update:</strong> If you want to print the name of the command being <code>system()</code> 'd as well, I think <a href="https://stackoverflow.com/questions/17225/echo-system-commands-to-terminal-in-perl#17304">Rudd</a>'s approach is good. Repeated here for consolidation:</p> <pre><code>sub execute { my $cmd = shift; print &quot;$cmd\n&quot;; system($cmd); } my $cmd = $ARGV[0]; execute($cmd); </code></pre>
<p>Hmm, interesting how different people are answering this different ways. It looks to me like <a href="https://stackoverflow.com/questions/17225/echo-system-commands-to-terminal-in-perl#17245">mk</a> and <a href="https://stackoverflow.com/questions/17225/echo-system-commands-to-terminal-in-perl#17293">Daniel Fone</a> interpreted it as wanting to see/manipulate the stdout of the command (neither of their solutions capture stderr fwiw). I think <a href="https://stackoverflow.com/questions/17225/echo-system-commands-to-terminal-in-perl#17304">Rudd</a> got closer. One twist you could make on Rudd's response is to overwite the built in system() command with your own version so that you wouldn't have to rewrite existing code to use his execute() command.</p> <p>using his execute() sub from Rudd's post, you could have something like this at the top of your code:</p> <pre><code>if ($DEBUG) { *{"CORE::GLOBAL::system"} = \&amp;{"main::execute"}; } </code></pre> <p>I think that will work but I have to admit this is voodoo and it's been a while since I wrote this code. Here's the code I wrote years ago to intercept system calls on a local (calling namespace) or global level at module load time:</p> <pre><code> # importing into either the calling or global namespace _must_ be # done from import(). Doing it elsewhere will not have desired results. delete($opts{handle_system}); if ($do_system) { if ($do_system eq 'local') { *{"$callpkg\::system"} = \&amp;{"$_package\::system"}; } else { *{"CORE::GLOBAL::system"} = \&amp;{"$_package\::system"}; } } </code></pre>
3,791
<p>Is there an easy way of using the <code>RegularExpressionValidator</code> control while ignoring white space?</p> <p>I can use a custom validator control with <code>Regex</code> and <code>IgnorePatternWhitespace</code>, but it would be good to just have an option in the <code>RegularExpressionValidator</code> control.</p>
<p>Surround your regex with</p> <blockquote> <p>(?x: )</p> </blockquote> <p>so "a b c" becomes "(?x:a b c)</p>
<p>Remember that the regular expression validator want to validate with javascript, too, so you want to make sure your expression will work with both the .Net and javascript regex engines. That means that using .IgnorePatterWhitespace isn't the best idea.</p>
8,152
<p>I have generated a few 3D prints in G-code using KISSlicer and Slic3r, but when I load them into Ultimaker Cura I'm unable to get anything. The number of layers says one but I cannot see anything and print option is not working. I have viewed these G-codes online and they are fine. I'm using a Lulzbot KITTAZ with v2 toolhead (hexagon) and I can print only using Ultimaker Cura. Please tell me what the reason for this is.</p>
<p>Cura prior to version 2.5 does not take G-code as an input. I'm not sure what you mean by "print only using Cura." Don't you have a SD slot on your control board? For that matter, why can't you drive the USB port from Slic3r? </p> <p>Remember: G-code is the equivalent of "compiled code," the raw commands which drive the printer, while STL or OBJ, etc., are the "source code," which you edit to get the shape you want.</p> <p>I've looked at a few apps which will render a 3D image on your computer from G-code, but I don't know off-hand of one which will "decompile" into a STL or mesh file.</p>
<p>Cura prior to version 2.5 does not take G-code as an input. I'm not sure what you mean by "print only using Cura." Don't you have a SD slot on your control board? For that matter, why can't you drive the USB port from Slic3r? </p> <p>Remember: G-code is the equivalent of "compiled code," the raw commands which drive the printer, while STL or OBJ, etc., are the "source code," which you edit to get the shape you want.</p> <p>I've looked at a few apps which will render a 3D image on your computer from G-code, but I don't know off-hand of one which will "decompile" into a STL or mesh file.</p>
448
<p>As part of a JavaScript Profiler for IE 6/7 I needed to load a custom debugger that I created into IE. I got this working fine on XP, but couldn't get it working on Vista (full story here: <a href="http://damianblog.com/2008/09/09/tracejs-v2-rip/" rel="nofollow noreferrer">http://damianblog.com/2008/09/09/tracejs-v2-rip/</a>).</p> <p>The call to GetProviderProcessData is failing on Vista. Anyone have any suggestions?</p> <p>Thanks, Damian</p> <pre><code>// Create the MsProgramProvider IDebugProgramProvider2* pIDebugProgramProvider2 = 0; HRESULT st = CoCreateInstance(CLSID_MsProgramProvider, 0, CLSCTX_ALL, IID_IDebugProgramProvider2, (void**)&amp;pIDebugProgramProvider2); if(st != S_OK) { return st; } // Get the IDebugProgramNode2 instances running in this process AD_PROCESS_ID processID; processID.ProcessId.dwProcessId = GetCurrentProcessId(); processID.ProcessIdType = AD_PROCESS_ID_SYSTEM; CONST_GUID_ARRAY engineFilter; engineFilter.dwCount = 0; PROVIDER_PROCESS_DATA processData; st = pIDebugProgramProvider2-&gt;GetProviderProcessData(PFLAG_GET_PROGRAM_NODES|PFLAG_DEBUGGEE, 0, processID, engineFilter, &amp;processData); if(st != S_OK) { ShowError(L"GPPD Failed", st); pIDebugProgramProvider2-&gt;Release(); return st; } </code></pre>
<p>It would help to know what the error result was.</p> <p>Possible problems I can think of:</p> <p>If your getting permission denied, your most likely missing some requried <a href="http://msdn.microsoft.com/en-us/library/aa375728(VS.85).aspx" rel="nofollow noreferrer">Privilege</a> in your ACL. New ones are sometimes not doceumented well, check the latest Platform SDK headers to see if any new ones that still out. It may be that under vista the Privilege is not assigned my default to your ACL any longer.</p> <p>If your getting some sort of Not Found type error, then it may be 32bit / 64bit problem. Your debbugging API may only be available under 64bit COM on vista 64. The 32bit/64bit interoperation can be very confusing.</p>
<p>I'm not familiar with these interfaces, but unexpected failures in Vista may require being past a UAC prompt. Have you tried starting the debugger with admin privileges?</p>
8,528
<p>I'm about to implement a feature in our application that allows the user to 'upload' a PDF or Microsoft PowerPoint document, which the application will then make available to other users in a viewer (so they don't get to 'download' it in the 'Save as..' sense).</p> <p>I already know how to save and retrieve arbitrary binary information in database columns, but as this will be a commonly used feature of our application I fear that solution would lead to enormously large database tables (as we know one of our customers will want to put video in PowerPoint documents).</p> <p>I know there's a way to create a 'directory' object in Oracle, but is there a way to use this feature to store and retrieve binary files saved elsewhere on the Database Server?</p> <p>Or am I being overly paranoid about the database size?</p> <p>(for completeness our application is .Net WinForms using <a href="http://www.devart.com/oranet/" rel="nofollow noreferrer">CoreLab / DevArt OraDirect.Net drivers</a> to Oracle 10g)</p>
<p>Couple of options: You could put the BLOB column in its own tablespace, with its own storage characteristics; you could store the BLOBs in their own table, linked to the other table by an ID column. In either case as you suggested you could define the column as a BFILE which means the actual file is stored externally from the database in a directory. What might be a concern there is that BFILE LOBs do not participate in transactions and are not recoverable with the rest of the database.</p> <p>This is all discussed in the Oracle 10gR2 SQL reference, chapter 2, starting on page 23.</p>
<p>I guess it depends what you consider enormously large.</p> <p>It really does depend on the use case. If the documents are only being accessed rarely then putting it in the database would be fine (with the advantage of getting "free" backups, eg, with the database).</p> <p>If these are files which are going to be hit over and over again, you might be better to put them directly on disk and just store the location, or even (if its really high bandwidth) look into something like <a href="http://en.wikipedia.org/wiki/MogileFS" rel="nofollow noreferrer">MogileFS</a></p> <p>No one is going to be able to give you a Yes or no answer for this.</p>
8,837
<p>I have a counter in hardware that I can observe for timing considerations. It counts miliseconds and is stored in a 16 bit unsigned value. How do I safely check if a timer value has passed a certain time and safely handle the inevitable rollover:</p> <pre><code>//this is a bit contrived, but it illustrates what I'm trying to do const uint16_t print_interval = 5000; // milliseconds static uint16_t last_print_time; if(ms_timer() - last_print_time &gt; print_interval) { printf("Fault!\n"); last_print_time = ms_timer(); } </code></pre> <p>This code will fail when ms_timer overflows to 0.</p>
<p>You don't actually need to do anything here. The original code listed in your question will work fine, assuming <code>ms_timer()</code> returns a value of type uint16_t.</p> <p>(Also assuming that the timer doesn't overflow twice between checks...) </p> <p>To convince yourself this is the case, try the following test:</p> <pre><code>uint16_t t1 = 0xFFF0; uint16_t t2 = 0x0010; uint16_t dt = t2 - t1; </code></pre> <p><code>dt</code> will equal <code>0x20</code>.</p>
<p>Sometimes I do it like this:</p> <pre><code>#define LIMIT 10 // Any value less then ULONG_MAX ulong t1 = tick of last event; ulong t2 = current tick; // This code needs to execute every tick if ( t1 &gt; t2 ){ if ((ULONG_MAX-t1+t2+1)&gt;=LIMIT){ do something } } else { if ( t2 - t1 &gt;= LIMT ){ do something } </code></pre>
8,667
<p>How can I efficiently and effectively detect the version and, for that matter, any available information about the instance of <a href="http://silverlight.net/" rel="nofollow noreferrer">Silverlight</a> currently running on the browser?</p>
<p>The Silverlight control only has an <a href="http://msdn.microsoft.com/en-us/library/system.windows.interop.silverlighthost.isversionsupported(VS.95).aspx" rel="nofollow noreferrer">IsVersionSupported function</a>, which returns true / false when you give it a version number, e.g.:</p> <pre><code>if(slPlugin.isVersionSupported("2.0")) { alert("I haz some flavour of Silverlight 2"); </code></pre> <p>You can be as specific as you want when checking the build, since the version string can include all of the following:</p> <ul> <li>major - the major number</li> <li>minor - the minor number</li> <li>build - the build number</li> <li>revision - the revision number</li> </ul> <p>So we can check for a specific build number as follows:</p> <pre><code>if(slPlugin.isVersionSupported("2.0.30523")) { alert("I haz Silverlight 2.0.30523, but could be any revision."); </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/bb693297.aspx#replace_version" rel="nofollow noreferrer">Silverlight 1.0 Beta included a control.settings.version property, which was replaced with the isVersionSupported() method</a>. The idea is that you shouldn't be programming against specific versions of Silverlight. Rather, you should be checking if the client has <em>at least</em> verion 1.0, or 2.0, etc.</p> <p>That being said, you can get the Silverlight version number in Firefox by checking the Silverlight plugin description:</p> <pre><code>alert(navigator.plugins["Silverlight Plug-In"].description); </code></pre> <p>Shows '2.0.30523.8' on my computer.</p> <p>Note that it is possible to brute force it by iterating through all released version numbers. <a href="http://pages.citebite.com/w3o7qsydtr" rel="nofollow noreferrer">Presumably that's what BrowserHawk does</a> - they'll report which version of Silverlight the client has installed.</p>
<p>Look in silverlight.js:</p> <p><a href="http://forums.asp.net/p/1135746/1997617.aspx#1997617" rel="nofollow noreferrer">http://forums.asp.net/p/1135746/1997617.aspx#1997617</a></p>
4,104
<p>My company is currently using Sage MAS as their ERP system. While integrating our shopping cart is not going to be impossible, it uses COM and has it's own challenges.</p> <p>I was wondering if there was a more developer friendly ERP out there. I have looked into Microsoft Dynamics but getting information on ERP systems that isn't a bunch of business jargon is next to impossible.</p> <p>I will be using C# 3.whatever and .NET MVC.</p>
<p>MS Dyanamics is very cool app. V3 was fully Web Serviced V4 i assume even more- all actions are exposed as webservices, there is a big license hit on MS CRM due to "internet" licensing.</p> <p>We use CRMv3 in a totally .NET SOA here and its great.</p> <p>You should have no problems doing the integration - security aside =></p>
<p>I've done a bit of integration between ASP.NET and Dynamics AX4 - it has a .NET API called Business Connector that gives you access to AX's full internal object model - if AX does it, your web app can do it too. My app had to execute arbitrary AX business logic functions and, apart from the crummy API documentation (I've been spoiled by MSDN), it was all pretty easy. The Business Connector is the lowest-level API - there's a bunch of web service options as well that work at a higher level.</p>
3,118
<p>I want to use XML instead of SQLServer for a simple website. </p> <p>Are their any good tutorials, code examples, and/or tools available to make a (prefer VB.NET) wrapper class to handle the basic list, insert, edit, and delete (CRUD) code?</p> <p>The closest one I found was on a Telerik Trainer video/code for their Scheduler component where they used XML to handle the scheduling data in the demo. They created an ObjectDataSource class. Here is a <a href="http://www.telerik.com/support/teleriktrainer/teleriktrainerpreview/b332i-bb-b332c-a.aspx" rel="nofollow noreferrer">LINK</a> to that demo if anyone is interested.</p> <p>[Reply to Esteban]</p> <p>it would make deployment easier for clients that use godaddy where the database isn't in the app_data folder. also backing up those websites would be as simple as FTP the entire thing.</p> <p>i have concerns about possible collisions on saving. especially if I add something as simple as a click counter to say a list of mp3 files visitors to the site can access.</p>
<p>In these days of <strong>SQL Server Express</strong>, I'd say there's really no reason for you not to use a database.</p> <p>I know this doesn't really answer your question, but I'd hate to see you roll out code that will be a nightmare to maintain and scale.</p> <p>Maybe you could tell us why you want to use <strong>XML</strong> files instead of a proper database.</p>
<p>It would make deployment easier for clients that use go-daddy where the database isn't in the app_data folder. also backing up those websites would be as simple as FTP the entire thing. </p> <p>I have concerns about possible collisions on saving. especially if I add something as simple as a click counter to say a list of mp3 files visitors to the site can access.</p>
5,954
<p>Coming from a corporate IT environment, the standard was always creating a class library project for each layer, Business Logic, Data Access, and sometimes greater isolation of specific types.</p> <p>Now that I am working on my own web application project, I don't see a real need to isolate my code in this fashion. </p> <p>I don't have multiple applications that need to share this logic or service enable it. I also don't see any advantage to deployment scenarios.</p> <p>I am leaning towards putting all artifacts in one web application, logically separated by project folders.</p> <p>I wanted to know what the thoughts are of the community.</p> <hr> <p>Let me add more information...</p> <p>I am writing this application using MVC preview 5, so the unit testing piece will be supported by the separation of concerns inherit in the framework. I do like to have tests for everything!</p>
<p>Start with the simplest thing possible and add complexity if and when required. Sounds as though a single assembly would work just fine for your case. However, do take care not to violate the layers by having layer A access an internal member of layer B. That would make it harder to pull the layers into separate assemblies at a later date.</p>
<p>I'd say it depends on how serious you are about testing and unit-testing.</p> <p>If you plan to only do user/manual tests, or use basically, only test from the UI downward, then it doesn't really make a difference.</p> <p>On the other hand, if you plan on doing sort of unit-testing, or business rules validation, it definitely makes sense to split up your work into different assemblies.</p> <p>Even for smaller personal projects, I find this approach makes my life easier as the project goes on. I still run everything from the same solution, just with a web project for the UI, library for the business rules / application logic and another library for the DAL.</p>
8,333
<p>MSDN displays the following for CreatePatternBrush:</p> <blockquote> <p>You can delete a pattern brush without affecting the associated bitmap by using the DeleteObject function. Therefore, you can then use this bitmap to create any number of pattern brushes.</p> </blockquote> <p>My question is the opposite. If the HBRUSH is long lived, can I delete the HBITMAP right after I create the brush? IE: does the HBRUSH store its own copy of the HBITMAP?</p> <p>In this case, I'd like the HBRUSH to have object scope while the HBITMAP would have method scope (the method that creates the HBRUSH).</p>
<p>The HBRUSH and HBITMAP are entirely independent. The handles can be deleted entirely independent from each other, and, once created, no changes to either object will effect the other.</p>
<p>I think the bitmap must outlive the brush: the brush just references the existing bitmap rather than copying it.</p> <p>You could always try it and see what happened.</p>
7,977
<p>I have a custom validation function in JavaScript in a user control on a .Net 2.0 web site which checks to see that the fee paid is not in excess of the fee amount due. </p> <p>I've placed the validator code in the <code>ascx</code> file, and I have also tried using <code>Page.ClientScript.RegisterClientScriptBlock()</code> and in both cases the validation fires, but cannot find the JavaScript function.</p> <p>The output in Firefox's error console is <code>"feeAmountCheck is not defined"</code>. Here is the function (this was taken directly from firefox->view source)</p> <pre><code>&lt;script type="text/javascript"&gt; function feeAmountCheck(source, arguments) { var amountDue = document.getElementById('ctl00_footerContentHolder_Fees1_FeeDue'); var amountPaid = document.getElementById('ctl00_footerContentHolder_Fees1_FeePaid'); if (amountDue.value &gt; 0 &amp;&amp; amountDue &gt;= amountPaid) { arguments.IsValid = true; } else { arguments.IsValid = false; } return arguments; } &lt;/script&gt; </code></pre> <p>Any ideas as to why the function isn't being found? How can I remedy this without having to add the function to my master page or consuming page?</p>
<p>Try changing the argument names to <code>sender</code> and <code>args</code>. And, after you have it working, switch the call over to <code>ScriptManager.RegisterClientScriptBlock</code>, regardless of AJAX use.</p>
<p>While I would still like an answer to why my javascript wasn't being recognized, the solution I found in the meantime (and should have done in the first place) is to use an <code>Asp:CompareValidator</code> instead of an <code>Asp:CustomValidator</code>.</p>
2,380
<p>I'm currently working on a JavaScript tool that, during the course of its execution, will ultimately traverse each node in the DOM. Because this has potential to be a very expensive task, I'd like to benchmark the performance of this script.</p> <p>What's the best, free tool for benchmarking a script such as this across the major browsers? Ideally, I'd like the tool (or set of tools, even):</p> <ul> <li> **To generate some form of report based on the results of the test.** It can be as simple as a table showing execution times, or as complex as generating some form of a chart. Either way is fine. </li> <li> **To be free.** it's not that I don't believe in paying for software, it's just that I don't have a major need for a tool like this in my typical day-to-day tasks. </li> </ul> <p>If possible, I'd also like the tool to generate varying levels of complex pages so that I can stress test a set of DOMs. This isn't a necessity - if I need to do so, I can write one myself; however, I'd figure I'd poll the community first to see if something already exists.</p>
<p><strong><a href="http://getfirebug.com" rel="noreferrer">Firebug</a></strong> does include JS profiling, and it is probably the best out there. While I've had problems with Firebug's debugger, its profiler is currently top-of-the-line. <strong><a href="http://www.mozilla.org/projects/venkman/" rel="noreferrer">Venkman</a></strong> is also an older JS debugger/profiler for Firefox, just in case you run into Firebug issues.</p> <p>Using these tools should get you just about all the profiling you need across all browsers even though you'll only be monitoring Firefox. If you truly need to get down to dirty details of IE profiling and the like, there are a number of tools online that inject profiling calls into your javascript to help monitor all profiler-lacking browsers....but even to a JS performance nazi like me, this seems unnecessary.</p> <p><strong><em>Note:</em></strong> A new, very promising IE8 JS profiler has recently been announced: <a href="http://blogs.msdn.com/ie/archive/2008/09/11/introducing-the-ie8-developer-tools-jscript-profiler.aspx" rel="noreferrer">http://blogs.msdn.com/ie/archive/2008/09/11/introducing-the-ie8-developer-tools-jscript-profiler.aspx</a>.</p>
<p>Jeff posted <a href="http://www.codinghorror.com/blog/archives/001023.html" rel="nofollow noreferrer">The great browser javascript shutdown</a></p> <p><a href="http://www2.webkit.org/perf/sunspider-0.9/sunspider.html" rel="nofollow noreferrer"><H2>SunSpider JavaScript Benchmark</H2></a></p> <p>But i wonder where the download link is ;)</p>
7,734
<p>For a particular project I have, no server side code is allowed. How can I create the web site in php (with includes, conditionals, etc) and then have that converted into a static html site that I can give to the client?</p> <p>Update: Thanks to everyone who suggested wget. That's what I used. I should have specified that I was on a PC, so I grabbed the windows version from here: <a href="http://gnuwin32.sourceforge.net/packages/wget.htm" rel="noreferrer">http://gnuwin32.sourceforge.net/packages/wget.htm</a>.</p>
<p>If you have a Linux system available to you use <a href="http://www.gnu.org/software/wget/" rel="noreferrer">wget</a>:</p> <pre><code>wget -k -K -E -r -l 10 -p -N -F -nH http://website.com/ </code></pre> <p>Options</p> <ul> <li>-k : convert links to relative</li> <li>-K : keep an original versions of files without the conversions made by wget</li> <li>-E : rename html files to .html (if they don’t already have an htm(l) extension)</li> <li>-r : recursive… of course we want to make a recursive copy</li> <li>-l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.</li> <li>-p : download all necessary files for each page (css, js, images)</li> <li>-N : Turn on time-stamping.</li> <li>-F : When input is read from a file, force it to be treated as an HTML file.</li> <li>-nH : By default, wget put files in a directory named after the site’s hostname. This will disabled creating of those hostname directories and put everything in the current directory.</li> </ul> <p>Source: <a href="http://blog.jphoude.qc.ca/2007/10/16/creating-static-copy-of-a-dynamic-website/" rel="noreferrer">Jean-Pascal Houde's weblog</a></p>
<p>I do it on my own web site for certain pages that are guaranteed not to change -- I simply run a shell script that could be boiled to (warning: bash pseudocode):</p> <pre><code>find site_folder -name \*.static.php -print -exec Staticize {} \; </code></pre> <p>with Staticize being:</p> <pre><code># This replaces .static.php with .html TARGET_NAME="`dirname "$1"`/"`basename "$1" .static.php`".html php "$1" &gt; "$TARGET_NAME" </code></pre>
9,210
<p>I have a user script that would be much more useful if it could dynamically change some of its execution dependent on what the user wanted. Passing simple switches would easily solve this problem but I don't see any way to do it.</p> <p>I also tried embedding a keyword in the script name, but <em>Xcode</em> copies the script to a guid-looking filename before execution, so that won't work either.</p> <p>So does anyone know of a way to call a user script with some sort of argument? (other that the normal <code>%%%var%%%</code> variables)</p> <hr /> <h3>EDIT:</h3> <p>User scripts are accessible via the script menu in Xcode's menubar (between the Window and Help menus). My question is not about &quot;run script&quot; build phase scripts. My apologies for leaving that somewhat ambiguous.</p>
<p>You can't pass parameters to user scripts — instead, user scripts operate on the context you're working in (e.g. the selected file, the selected text, etc.).</p> <p>You should use the context to determine what the user really wants.</p>
<p>User scripts are accessible via the script menu in Xcode's menubar (between the Window and Help menus). Wasn't sure what else to call them. What I'm asking about are not "run script" build phase scripts.</p>
6,974
<p>I need to deploy an application on the WAS ND 6.1 and do not know anything about it and cannot afford to go to training...</p>
<p>Getting started with WAS ND can be a bit overwhelming. The redbooks mentioned above to give you a good introduction, especially the first few chapters but they are often over 500 pages long. IBM also provides an educational assistant which is a presentation style overview and that may give a good point to start with. The link to the educational assistant is shown below:</p> <p><a href="http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp</a></p>
<p>This course from IBM would also be excellent but a bit pricy!!!</p> <p><a href="http://www.redbooks.ibm.com/abstracts/sg247304.html?Open" rel="nofollow noreferrer">http://www.redbooks.ibm.com/abstracts/sg247304.html?Open</a></p>
9,053
<p>I'm playing around with a native (non-web) single-player game I'm writing, and it occured to me that having a daily/weekly/all-time <strong>online highscore list</strong> (think Xbox Live Leaderboard) would make the game much more interesting, adding some (small) amount of community and competition. However, I'm afraid people would see such a feature as an invitation to hacking, which would discourage regular players due to impossibly high scores.</p> <p>I thought about the obvious ways of preventing such attempts (public/private key encryption, for example), but I've figured out reasonably simple ways hackers could circumvent all of my ideas (extracting the public key from the binary and thus sending fake encrypted scores, for example).</p> <p>Have you ever implemented an online highscore list or leaderboard? Did you find a reasonably hacker-proof way of implementing this? If so, how did you do it? What are your experiences with hacking attempts?</p>
<p>At the end of the day, you are relying on trusting the client. If the client sends replays to the server, it is easy enough to replicable or modify a successful playthrough and send that to the server.</p> <p>Your best bet is to raise the bar for cheating above what a player would deem worth surmounting. To do this, there are a number of proven (but oft-unmentioned) techniques you can use:</p> <ol> <li>Leave blacklisted cheaters in a honeypot. They can see their own scores, but no one else can. Unless they verify by logging in with a different account, they think they have successfully hacked your game.</li> <li>When someone is flagged as a cheater, defer any account repercussions from transpiring until a given point in the future. Make this point random, within one to three days. Typically, a cheater will try multiple methods and will eventually succeed. By deferring account status feedback until a later date, they fail to understand what got them caught.</li> <li>Capture all game user commands and send them to the server. Verify them against other scores within a given delta. For instance, if the player used the shoot action 200 times, but obtained a score of 200,000, but the neighboring players in the game shot 5,000 times to obtain a score of 210,000, it may trigger a threshold that flags the person for further or human investigation.</li> <li>Add value and persistence to your user accounts. If your user accounts have unlockables for your game, or if your game requires purchase, the weight of a ban is greater as the user cannot regain his previous account status by simply creating a new account through a web-based proxy.</li> </ol>
<p>Usually, the biggest defender against cheating and hacking is a community watch. If a score seems rather suspicious, a user can report the score for cheating. And if enough people report that score, the replay can be checked by the admins for validity. It is fairly easy to see the difference between a bot an an actual player, if there's already a bunch of players playing the game in full legitimacy.</p> <p>The admins must oversee only those scores that get questioned, because there is a small chance that a bunch of users might bandwagon to remove a perfectly hard-earned score. And the admins only have to view the few scores that do get reported, so it's not too much of their time, even less for a small game.</p> <p>Even just knowing that if you work hard to make a bot, just to be shot down again by the report system, is a deterrent in itself.</p> <p>Perhaps even encrypting the replay data wouldn't hurt, either. Replay data is often small, and encrypting it wouldn't take too much more space. And to help improve that, the server itself would try out the replay by the control log, and make sure it matches up with the score achieved.</p> <p>If there's something the anti-cheat system can't find, users will find it.</p>
4,557
<p>I'm trying to troubleshoot an issue with my 3D printer (Robo 3D R1+). It cannot print vertical walls well any more. Here is a picture of what it looks like:</p> <p><a href="https://i.stack.imgur.com/4Y4PE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Y4PE.jpg" alt="enter image description here"></a></p> <p>The walls are very inconsistent. To correct this issue, I've tried:</p> <ul> <li>Changing the nozzle</li> <li>Tightening the hotend (to remove wobble)</li> <li>Dehydrating the filament</li> <li>Using brand new (good quality) filament</li> <li>Printing faster &amp; slower</li> <li>Printing hotter &amp; cooler</li> <li>Trying different slicers (Ultimaker Cura &amp; Simplify3D)</li> <li>Putting on a belt tightener</li> </ul> <p>The 5 motor drivers are all new as well, but this was already happening before I changed them.</p>
<p>Mmm... you've tried lots of obvious things. I don't have a printer the same as yours, so my help is generic. </p> <p>How about a thorough check of extruder and filament path, since it may be just inconsistent filament feed? I've seen something similar happen when the filament reel was not rolling freely. Less likely, but also check that the frame is still solid and nothing has come loose.</p>
<p>Despite the picture being a bit small and blurry, it is quite obvious that something is off. A better picture might help closing in on the problem with more precision.</p> <p>From what I can see it could be wrong extrusion settings. I'm making a wild guess based on personal experience that the printer is over extruding way too much. I had similar looking parts a few years back after a firmware update. I simply forgot to update the steps/mm for the extruder. </p> <p>Any recent firmware or hardware updates? From your explanation I understand you changed the drivers. Maybe an issue based on microstepping? (The corner looks like the nozzle was realy in the material while printing.)</p>
1,576
<p>I've got a database server that I am unable to connect to using the credentials I've been provided. However, on the staging version of the same server, there's a linked server that points to the production database. Both the staging server and the linked server have the same schema.</p> <p>I've been reassured that I should expect to be able to connect to the live server before we go live. Unfortunately, I've reached a point in my development where I need more than the token sample records that are currently in the staging database. So, I was hoping to connect to the linked server.</p> <p>Thus far in my development against this schema has been against the staging server itself, using Subsonic objects. That all works fine.</p> <p>I can connect via SQL Server Management Studio to that linked server and execute my queries directly. I can also execute 'manual" queries in C# against the linked server by having my connection string hook up to the staging server and running my queries as </p> <p>SELECT * FROM OpenQuery([LINKEDSERVER],'QUERY')</p> <p>However, the Subsonic objects are what's enabling me to bring this project in on time and under budget, so I'm not looking to do straight queries in my code.</p> <p>What I'm looking for is whether there's a way to state the connection string to the linked server. I've looked at lots of forum entries, etc. on the topic and most of the answers seem to completely gloss over the "linked server" portion of the question, focusing on basic connection string syntax.</p>
<p>I don't believe that you can access a linked server directly from an application without the OpenQuery syntax. Depending on the complexity of your schema, it might make sense to write a routine or sproc to populate your staging database with data from your live database.</p> <p>You might also consider looking at Redgates SQL Data Generator or any other data gen tool. Redgates is pretty easy to use.</p> <p>One other idea - can you get a backup of the live database that you can install in development to do your testing? If its just data for development and testing that you seek, you probably want to stay away from connecting to your production database at all.</p>
<p>creating a linked server from .NET doesn't make any sense since a linked server is nothing but a connection from one sqlserver to another server (sql, file, excel, sybase etc etc), in essence it is just a connection string (you can impersonate and do some other stuff when creating a linked server). </p>
3,877
<p>How to decide whether to use threads or create separate process altogether in your application to achieve parallelism.</p>
<p>Threads are more light weight, and for the making several "workers" just to utilize all availabe CPUs or cores, you're better of with threads.</p> <p>When you need the workers to be better isolated and more robust, like with most servers, go with sockets. When one thread crashes badly, it usually takes down the entire process, including other threads working in that process. If a process turns sour and dies, it doesn't touch any other process, so they can happily go on with their bussiness as if nothing happened.</p>
<p>In Windows, processes are heavier to create then threads. So if you have several smaller tasks a thread or thread pool would be better. Or use a process pool to recycle the processes. Also sharing state between processes is more work then sharing state between threads. But then again: Threads could destabilize a complete process taking other threads down with it. If you want to minimize the chance of that happening you could go for separate processes. .Net's AppDomains might be a middle ground between both. </p>
8,842
<p>Recently I have been doing more complicated math in OpenSCAD and I have run into something that I find strange. Take a simple math expression: <code>2 / 2 / 2</code>. By any programming language this will equal 0.5 (1/2), and OpenSCAD agrees. Something like this: <code>2 / -2 / 2</code> should also be -0.5 for the same reason. However, OpenSCAD thinks this is -2. That is <code>echo(2 / -2 / 2);</code> gives <code>ECHO: -2</code>. My calculator, other programming languages (and myself) all say its -0.5.</p> <p>Is this a quirk of OpenSCAD, or am I missing something obvious?</p>
<p>I suspect the behavior you are seeing is an undocumented feature (aka, bug) of OpenSCAD. I've found in the latest stable release that if the - is placed on either end, the result is -0.5, but in the middle, my results are the same as yours. Surrounding the -2 with parentheses results in a correct answer, however.</p> <p>It appears that the parentheses turns a mathematical operation into a signed integer. It follows that the operations without the parentheses is right to left:</p> <p>2/2 = 1, negative 1 with the minus, 2/-1 = -2</p>
<p>I <a href="https://github.com/openscad/openscad/issues/2894" rel="nofollow noreferrer">filed this issue as a bug with the OpenSCAD project</a>, and there is now <a href="https://github.com/openscad/openscad/pull/2895" rel="nofollow noreferrer">a fix merged into master</a>, as well as a test case to prevent regression. The latest nightly builds should handle this correctly from here on out.</p>
1,257
<p>I'm currently using and enjoying using the Flex MVC framework <a href="http://www.puremvc.org" rel="noreferrer">PureMVC</a>. I have heard some good things about Cairngorm, which is supported by Adobe and has first-to-market momentum. And there is a new player called Mate, which has a good deal of buzz.</p> <p>Has anyone tried two or three of these frameworks and formed an opinion?</p> <p>Thanks!</p>
<p><a href="http://mate.asfusion.com/" rel="noreferrer">Mate</a> is my pick. The first and foremost reason is that it is completely unobtrusive. My application code has no dependencies on the framework, it is highly decoupled, reusable and testable. </p> <p>One of the nicest features of Mate is the declarative configuration, essentially you wire up your application in using tags in what is called an event map -- basically a list of events that your application generates, and what actions to take when they occur. The event map gives a good overview of what your application does. Mate uses Flex' own event mechanism, it does not invent its own like most other frameworks. You can dispatch an event from anywhere in the view hierarchy and have it bubble up to the framework automatically, instead of having to have a direct line, like Cairngorms CairngormEventDispatcher or PureMVC's notification system.</p> <p>Mate also uses a form of dependency injection (leveraging bindings) that makes it possible to connect your models to your views without either one knowing about the other. This is probably the most powerful feature of the framework.</p> <p>In my view none of the other Flex application frameworks come anywhere near Mate. However, these are the contenders and why I consider them to be less useful:</p> <p>PureMVC actively denies you many of the benefits of Flex (for example bindings and event bubbling) in order for the framework to be portable -- a doubious goal in my view. It is also over-engineered, and as invasive as they come. Every single part of your application depends on the framework. However, PureMVC isn't terrible, just not a very good fit for Flex. An alternative is <a href="http://code.google.com/p/flexmvcs/" rel="noreferrer">FlexMVCS</a>, an effort to make PureMVC more suitable for Flex (unfortunately there's no documentation yet, just source). </p> <p>Cairngorm is a bundle of anti-patterns that lead to applications that are tightly coupled to global variables. Nuff said (but if you're interested, <a href="http://blog.iconara.net/2008/04/13/architectural-atrocities-part-x-cairngorms-model-locator-pattern/" rel="noreferrer">here are some more of my thoughts</a>, and <a href="http://blog.iconara.net/2008/12/13/architectural-atrocities-part-10-cairngorms-service-locator/" rel="noreferrer">here too</a>).</p> <p><a href="http://code.google.com/p/swizframework" rel="noreferrer">Swiz</a> is a framework inspired by the Spring framework for Java and Cairngorm (trying to make up for the worst parts of the latter). It provides a dependency injection container and uses metadata to enable auto-wiring of dependencies. It is interesting, but a little bizzare in that goes to such lengths to avoid the global variables of Cairngorm by using dependency injection but then uses a global variable for central event dispatching.</p> <p>Those are the ones I've tried or researched. There are a few others that I've heard about, but none that I think are widely used. Mate and Swiz were both presented at the recent 360|Flex conference, and there are videos available (<a href="http://mate.asfusion.com/news/360-flex-presentation" rel="noreferrer">the Mate folks have instructions on how to watch them</a>)</p>
<p>Bear in mind that Cairngorm is THE adobe sponsored framework, and now hosted on opensource.adobe.com. Also note that it's by far the most prolific amongst developers at the moment.</p> <p>If you know Cairngorm and are looking for a job, you won't go far wrong.</p>
5,768
<p>Is there a good way to debug errors in the Visual Studio Designer?</p> <p>In our project we have tons of UserControls and many complex forms. For the complex ones, the Designer often throws various exceptions which doesn't help much, and I was wondering if there's some nice way to figure out what has gone wrong.</p> <p>The language is C#, and we're using Visual Studio 2005.</p>
<p>I've been able to debug some control designer issues by running a second instance of VS, then from your first VS instance do a "Debug -> Attach to Process" and pick "devenv".</p> <p>The first VS instance is where you'll set your breakpoints. Use the second instance to load up the designer to cause the "designer" code to run.</p>
<p>Each one is different and they can sometimes be obscure. As a first step, I would do the following: </p> <ul> <li>Use source control and save often. When a designer error occurs, get a list of all changes to the affected controls that have occurred recently and test each one until you find the culprit</li> <li>Be sure to check out the initialization routines of the controls involved. Very often these errors will occur because of some error or bad dependency that is called through the default constructor for a control (an error that may only manifest itself in VS)</li> </ul>
6,074
<p>Has anybody got any kind of experience with dynamic programming using WCF. By dynamic programming I mean runtime consumption of WSDL's. I have found one blog entry/tool: <a href="http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx</a></p> <p>Has anybody here found good tools for this?</p>
<p>This is one of the weirder aspects of WCF. You can dynamically create a channelfactory, but only with a known type.</p> <p>I came up with a solution that is not perfect, but does work:</p> <p>Create an interface, "IFoo" which contains a single method, say <code>Execute()</code>. In your ESB, dynamically create a <code>ChannelFactory&lt;IFoo&gt;</code> for the endpoint that you want to connect to. Set the connection properties (URI, etc.).</p> <p>Now, you can attach services dynamically to your ESB, provided that they always implement the "IFoo" interface.</p>
<p>I am actually considering making a small ESB, where a user can add a webservice to route to at run time. So I can not add WSDLs statically </p>
6,264
<p>When objects from a CallList intersect the near plane I get a flicker..., what can I do?</p> <p>Im using OpenGL and SDL.</p> <p>Yes it is double buffered.</p>
<p>It sounds like you're getting z-fighting.</p> <p>"Z-fighting is a phenomenon in 3D rendering that occurs when two or more primitives have similar values in the z-buffer, and is particularly prevalent with coplanar polygons. The effect causes pseudo-random pixels to be rendered with the color of one polygon or another in a non-deterministic manner, varying as the scene is animated, causing one polygon to "win" the z test, then another, and so on." (From <a href="http://en.wikipedia.org/wiki/Z-fighting" rel="noreferrer">wikipedia</a>)</p> <p>You can get more information about the problem in the <a href="http://www.opengl.org/resources/faq/technical/depthbuffer.htm" rel="noreferrer">OpenGL FAQ</a>.</p> <p>glPolygonOffset might help, but you can also get yourself into trouble with it. Tom Forsyth has a good explanation in his <a href="http://tomsdxfaq.blogspot.com/2002_07_01_archive.html#79344425#79344425" rel="noreferrer">FAQ</a> Note: It talks about ZBIAS, but that's just the DirectX equivilent.</p>
<p>Ah, you meant the <em>near</em> plane. :)</p> <p>Well...another thing when drawing polygons in the same plane is to use <a href="http://www.cs.sfu.ca/~haoz/teaching/htmlman/polygonoffset.html" rel="nofollow noreferrer">glPolygonOffset</a></p> <p>From the description</p> <pre><code> glPolygonOffset is useful for rendering hidden-line images, for applying decals to surfaces, and for rendering solids with highlighted edges. </code></pre>
7,903
<p>I've got an <code>JComboBox</code> with a custom <code>inputVerifyer</code> set to limit MaxLength when it's set to editable.</p> <p>The verify method never seems to get called.<br> The same verifyer gets invoked on a <code>JTextField</code> fine.</p> <p>What might I be doing wrong?</p>
<p>I found a workaround. I thought I'd let the next person with this problem know about. </p> <p>Basically. Instead of setting the inputVerifier on the ComboBox you set it to it's "Editor Component". </p> <pre><code>JComboBox combo = new JComboBox(); JTextField tf = (JTextField)(combo.getEditor().getEditorComponent()); tf.setInputVerifier(verifyer); </code></pre>
<p>Show us a small section of your code.</p> <pre><code>package inputverifier; import javax.swing.*; class Go { public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { runEDT(); }}); } private static void runEDT() { new JFrame("combo thing") {{ setLayout(new java.awt.GridLayout(2, 1)); add(new JComboBox() {{ setEditable(true); setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { System.err.println("Hi!"); return true; } }); }}); add(new JTextField()); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); setVisible(true); }}; } } </code></pre> <p><a href="http://bugs.sun.com" rel="nofollow noreferrer">Looks like it's a problem with JComboBox being a composite component.</a> I'd suggest avoiding such nasty UI solutions.</p>
7,818
<p>Is there a portable, not patent-restricted way to play compressed sound files in C# / .Net? I want to play short "jingle" sounds on various events occuring in the program.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx" rel="noreferrer">System.Media.SoundPlayer</a> can handle only WAV, but those are typically to big to embed in a downloadable apllication. MP3 is protected with patents, so even if there was a fully managed decoder/player it wouldn't be free to redistribute. The best format available would seem to be OGG Vorbis, but I had no luck getting any C# Vorbis libraries to work (I managed to extract a raw PCM with <a href="https://github.com/mono/csvorbis" rel="noreferrer">csvorbis</a> but I don't know how to play it afterwards).</p> <p>I neither want to distribute any binaries with my application nor depend on P/Invoke, as the project should run at least on Windows and Linux. I'm fine with bundling .Net assemblies as long as they are license-compatible with GPL.</p> <p>[this question is a follow up to a <a href="http://lists.ximian.com/pipermail/mono-devel-list/2007-June/023863.html" rel="noreferrer">mailing list discussion on mono-dev</a> mailing list a year ago]</p>
<p>I finally revisited this topic, and, using help from <a href="https://stackoverflow.com/a/7152153/3205">BrokenGlass on writing WAVE header</a>, updated csvorbis. I've added an <a href="https://github.com/mono/csvorbis/blob/master/OggDecoder/OggDecodeStream.cs" rel="nofollow noreferrer">OggDecodeStream</a> that can be passed to <code>System.Media.SoundPlayer</code> to simply play any (compatible) Ogg Vorbis stream. Example usage:</p> <pre><code>using (var file = new FileStream(oggFilename, FileMode.Open, FileAccess.Read)) { var player = new SoundPlayer(new OggDecodeStream(file)); player.PlaySync(); } </code></pre> <p>'Compatible' in this case means 'it worked when I tried it out'. The decoder is fully managed, works fine on Microsoft .Net - at the moment, there seems to be a regression in Mono's <code>SoundPlayer</code> that causes distortion.</p> <p>Outdated:</p> <p><s> <code>System.Diagnostics.Process.Start("fullPath.mp3");</code></p> <p>I am surprised but the <a href="https://stackoverflow.com/questions/35896/how-can-i-play-compressed-sound-files-in-c-in-a-portable-way#35987">method Dinah mentioned</a> actually works. However, I was thinking about playing short "jingle" sounds on various events occurring in the program, I don't want to launch user's media player each time I need to do a 'ping!' sound.</p> <p>As for the code project link - this is unfortunately only a P/Invoke wrapper.</s></p>
<p>There is no way for you to do this without using something else for your play handling.</p> <p>Using the System.Diagnostic will launch an external software and I doubt you want that, right? You just want X sound file to play in the background when Y happens in your program, right?</p> <p>Voted up because it looks like an interesting question. :D</p>
5,648
<p>In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields.</p> <p>I get the following error:</p> <pre><code>TypeError: __init__() got an unexpected keyword argument 'core' </code></pre> <p>[Edit] However, by just removing the core argument I get a "This field is required." error in the admin interface on attempted submission. How does one accomplish what core=False is meant to do using newforms admin?</p>
<p>To get rid of "This field is required," you need to make it not required, by using blank=True (and possibly null=True as well, if it's not a CharField).</p>
<p>This is simple. I started getting this problems a few revisions ago. Basically, just remove the "core=True" parameter in the ImageField in the models, and then follow the instructions <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects" rel="nofollow noreferrer">here</a> to convert to what the newforms admin uses.</p>
5,440
<p>Is there an online resource somewhere that maintains statistics on the install-base of Java including JRE version information? If not, is there any recent report that has some numbers?</p> <p>I'm particularly interested in Windows users, but all other OS's are welcome too.</p>
<p>Take a look at <a href="http://www.pixel-technology.com/freeware/tessnet2/" rel="noreferrer">tessnet</a></p>
<p>Disclaimer: I work for Atalasoft</p> <p>Our <a href="http://www.atalasoft.com/products/dotimage/ocr" rel="nofollow noreferrer">OCR module supports Tesseract</a> and if that proves to not be good enough, you can upgrade to a better engine and just change one line of code (we provide a common interface to multiple OCR engines).</p>
5,026
<p>I'm interested in finding out how the recently-released (<a href="http://mirror.facebook.com/facebook/hive/hadoop-0.17/" rel="noreferrer">http://mirror.facebook.com/facebook/hive/hadoop-0.17/</a>) Hive compares to HBase in terms of performance. The SQL-like interface used by Hive is very much preferable to the HBase API we have implemented.</p>
<p>It's hard to find much about Hive, but I found this <a href="http://wiki.apache.org/hadoop/Hive" rel="noreferrer">snippet</a> on the Hive site that leans heavily in favor of HBase (bold added):</p> <p>Hive is based on Hadoop which is a batch processing system. Accordingly, this system does not and <strong>cannot promise low latencies on queries</strong>. The paradigm here is strictly of submitting jobs and being notified when the jobs are completed as opposed to real time queries. As a result it should not be compared with systems like Oracle where analysis is done on a significantly smaller amount of data but the analysis proceeds much more iteratively with the response times between iterations being less than a few minutes. <strong>For Hive queries response times for even the smallest jobs can be of the order of 5-10 minutes and for larger jobs this may even run into hours.</strong></p> <p>Since HBase and HyperTable are all about performance (being modeled on Google's BigTable), they sound like they would certainly be much faster than Hive, at the cost of functionality and a higher learning curve (e.g., they don't have joins or the SQL-like syntax).</p>
<p>To compare Hive with Hbase, I'd like to recall the definition below:</p> <blockquote> <p>A database designed to handle transactions isn’t designed to handle analytics. It isn’t structured to do analytics well. A data warehouse, on the other hand, is structured to make analytics fast and easy.</p> </blockquote> <p><strong>Hive is a data warehouse infrastructure built on top of Hadoop which is suitable for long running ETL jobs. Hbase is a database designed to handle real time transactions</strong></p>
4,391
<p>I'm aware of some of the test data generators out there, but most seem to just fill name and address style databases [feel free to correct me].</p> <p>We have a large integrated and normalised application - e.g. invoices have part numbers linked to stocking tables, customer numbers linked to customer tables, change logs linked to audit information, etc which are obviously difficult to fill randomly. Currently we obfuscate real life data to get test data (but not very well).</p> <p>What tools\methods do you use to create large volumes of data to test with?</p>
<p>Where I work we use <a href="http://www.red-gate.com/products/SQL_Data_Generator/index.htm" rel="nofollow noreferrer">RedGate Data Generator</a> to generate test data.</p> <p>Since we work in the banking domain. When we have to work with nominative data (Credit card numbers, personnal ID, phone numbers) we developed an application that can <em>mask</em> these database fields so we can work with them as real data.</p> <p>I can say with Redgate you can get close to what your real data can look like on a production server since you can customize every field of every table in your BD.</p>
<p>Joel also mentioned RedGate in <a href="https://blog.stackoverflow.com/2008/06/podcast-11/">podcast #11</a></p>
3,701