instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I'm implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. "page"):</p> <pre><code>"Default.aspx?page=1" "Default.aspx?page=2" "Default.aspx?someother=true&amp;page=2" </code></pre> <p>etc.</p> <p>Is there a simple helper method that I can use in the Render method ... uhmm ... like:</p> <pre><code>Page.ClientScript.SomeURLBuilderMethodHere(this,"page","1"); Page.ClientScript.SomeURLBuilderMethodHere(this,"page","2"); </code></pre> <p>That will take care of generating a correct URL, maintain existing query string items and not create duplicates eg. page=1&amp;page=2&amp;page=3?</p> <p>Rolling up my own seems like such an unappealing task.</p>
<p>I'm afraid I don't know of any built-in method for this, we use this method that takes the querystring and sets parameters</p> <pre><code> /// &lt;summary&gt; /// Set a parameter value in a query string. If the parameter is not found in the passed in query string, /// it is added to the end of the query string /// &lt;/summary&gt; /// &lt;param name="queryString"&gt;The query string that is to be manipulated&lt;/param&gt; /// &lt;param name="paramName"&gt;The name of the parameter&lt;/param&gt; /// &lt;param name="paramValue"&gt;The value that the parameter is to be set to&lt;/param&gt; /// &lt;returns&gt;The query string with the parameter set to the new value.&lt;/returns&gt; public static string SetParameter(string queryString, string paramName, object paramValue) { //create the regex //match paramname=* //string regex = String.Format(@"{0}=[^&amp;]*", paramName); string regex = @"([&amp;?]{0,1})" + String.Format(@"({0}=[^&amp;]*)", paramName); RegexOptions options = RegexOptions.RightToLeft; // Querystring has parameters... if (Regex.IsMatch(queryString, regex, options)) { queryString = Regex.Replace(queryString, regex, String.Format("$1{0}={1}", paramName, paramValue)); } else { // If no querystring just return the Parameter Key/Value if (queryString == String.Empty) { return String.Format("{0}={1}", paramName, paramValue); } else { // Append the new parameter key/value to the end of querystring queryString = String.Format("{0}&amp;{1}={2}", queryString, paramName, paramValue); } } return queryString; } </code></pre> <p>Obviously you could use the QueryString <code>NameValueCollection</code> property of the URI object to make looking up the values easier, but we wanted to be able to parse any querystring.</p>
<p>Oh and we have this method too that allows you to put in a whole URL string without having to get the querystring out of it</p> <pre><code>public static string SetParameterInUrl(string url, string paramName, object paramValue) { int queryStringIndex = url.IndexOf("?"); string path; string queryString; if (queryStringIndex &gt;= 0 &amp;&amp; !url.EndsWith("?")) { path = url.Substring(0, queryStringIndex); queryString = url.Substring(queryStringIndex + 1); } else { path = url; queryString = string.Empty; } return path + "?" + SetParameter(queryString, paramName, paramValue); } </code></pre>
6,954
<p>I'm a single developer looking to get off of Visual Source Safe and move to svn.</p> <p>A quick search brings up several tools, but I don't see a clear winner and I can't afford to spend a lot of time testing different tools.</p> <p>Has anyone done this successfully, and can recommend a method?</p>
<p>I recommend just adding your code to a new Subversion repository rather than importing from VSS. VSS has a convoluted version control model that doesn't translate well to many other systems, and just starting fresh is usually the best way to avoid taking that clutter with you.</p> <p>If you need to keep the history around, make your VSS repository read-only.</p>
<p>I have used some script (I can't remember which one) to assist in a VSS to SVN conversion. It was a bit painful and finicky but ended up working, and kept all history. I had to keep all the history for political reasons at the time; if I had my way I probably would have thrown away the history and imported all the code into SVN.</p> <p>Also for political reasons, I wrote some really hacky scripts that kept VSS updated with changes from Subversion. These worked for a while but kept breaking every week or two, until somebody renamed a directory or something and the whole thing fell apart. By that time it was okay to simply continue using Subversion.</p>
8,395
<p>I would like to obtain a 3D model of my insoles. I tried to scan it with 123D catch but finding reference points is difficult because the insole is black.</p> <p>How could I improve the scanning? I attach a photo of the insole to show its not easy shape.</p> <p>I thought about placing a grid of white spots on the surface, but will it be enough?</p> <p>Also, is it recommended to keep the camera still and rotate the object (I have a rotating stand) or should I move the camera? in the second case, the accuracy of the photos will be lower, while rotating 5-10 degrees the stand every time is extremely easy.</p> <p>As background should I use a checkerboard or something else not repetitive?</p> <p>I noticed that the insole has basically three different "levels", joined smoothly with each other. These "planes" are sloped the same way, so that if I change the pitch of the insole by about 10 degrees, they will be horizontal. Would it improve the accuracy?</p> <p>Edit: the insole is perfectly new, newer worn before.</p> <p><a href="https://i.stack.imgur.com/ziQp5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ziQp5.jpg" alt="enter image description here"></a></p> <p><strong>Update</strong></p> <p>I dotted the insole with white paint (the white eraser paint used in office and school) and I took a series of photos with the insole in top of a tripod, laying on a flat white cardboard support. 55 photos in total at 3 different elevations (side, medium, high). I also did a test with fixed camera and rotating object.</p> <p>Photoscan did not work well in general. Keeping the object fixed produces the best results, but poor.</p> <p>123D Catch did a much better job! again with fixed object and moving camera. Still, treating the resulting mesh was difficult and the accuracy could be improved.</p> <p>Autodesk Remake 2017 worked VERY well, as you can see in the attached screenshot, and it allows the editing of the mesh to remove useless parts of the model. I haven't tried yet to process the photos with the camera fixed and the rotating object. I did the processing locally (it's slow!) with maximum details and resolution.</p> <p><a href="https://i.stack.imgur.com/gKzja.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/gKzja.jpg" alt="enter image description here"></a></p>
<p>Usually, the largest variability in 3D imaging is lighting, closely followed by the color scheme. You'll probably want to heed some of the following points:</p> <ul> <li>No colors in the background/stand, keep to shades (unless otherwise specified for scanner)</li> <li>No gradients. This applies to poor lighting causing a "gradient" light effect</li> <li>Set the backdrop beyond the range of the scanner if possible (like with Skanect w/ Microsoft Kinect)</li> <li>Ideally set the backdrop and especially the stand in contrast with the color of the object.</li> </ul> <p>You're right, a typical 3D scanner will have a difficult time with darker colors due to physics. However, there are no rules that say you can't change the color of the object.</p> <p>In this application, <strong>I would suggest just going ahead and spray painting the object and scanning it</strong>. Scanning the insole is going to require super tight tolerances in scanning as I'm assuming the insole is naturally worn due to use. </p> <p>Completely alternatively from 3D scanning, you could try using a 3D touch probe like on a CMM (Coordinate Measuring Machine). It will take longer, but a touch probe doesn't care what color the object is.</p> <p><strong>Update</strong></p> <p>The touch probe comment seems to be a hit, so I'll elaborate. My experience with touch probes comes only from manufacturing technology and can be found and in a variety of different machine tools:</p> <ul> <li>Mills</li> <li>Lathes</li> <li>CMMs</li> <li>Vision Systems</li> <li>"Romer" Arms (aka portable CMM)</li> </ul> <p>You could probably get away with searching for a local machine shop (or job shop) and asking if they have a machine for reverse engineering. The quickest and easiest machine for reverse engineering (in my experience) is a portable CMM, I recommend Googling it.</p> <p>Alternatively, I've heard of people adding touch probes to their 3D Printers, but I haven't seen it before. In theory, a basic touch probe can easily be achieved by using a momentary switch. If you're good with programming and maybe a bit of Arduino, you could do the following:</p> <ul> <li>Add momentary (normally off) switch to Arduino </li> <li>Find a way of attaching the switch (below nozzles)</li> <li>Connect to your 3d printer in your preferred method and preferred programming language. I've used the provided libraries in Python that come with installing MakerWare in order to connect to my MakerBot.</li> <li>Write your routine to sequentially move the new probe in a grid pattern and then incrementally move the Z up until you get a signal from your Arduino that the momentary has been switched on.</li> <li>For each trigger, append a simple text file with a new line containing the coordinates.</li> <li>once complete, you should have a "point cloud" of your insole which, if formatted correctly, will be able to import into CAD software</li> </ul> <p>There are a few file types off the top of my head that can be used including:</p> <ul> <li>.pts</li> <li>.XYZ</li> <li>.CSV</li> </ul>
<p>I don't have enough reputation to comment. </p> <p>This is a short pointer to another webpage: <a href="https://www.sculpteo.com/blog/2016/01/20/turning-a-picture-into-a-3d-model/" rel="nofollow">https://www.sculpteo.com/blog/2016/01/20/turning-a-picture-into-a-3d-model/</a><br> It may be helpful. </p>
338
<p>We have a simple domain model: Contact, TelephoneNumber and ContactRepository. Contact is entity, it has an identity field. TelephoneNumber is typical value object: hasn't any identity and couldn't be loaded separately from the Contact instance.</p> <p>From other side we have web application for manipulating the contacts. 1st page is "ContactList", next page is "Contact/C0001" which shows the contact details and the list of telephone numbers.</p> <p>We have to implement telepone numbers edit form. The first approximation thought is to add some page which will be navigable like 'ThelephoneNumber/T0001'. </p> <p>But ThelephoneNumber is is Value Object class and its instance couldn't be identified this way.</p> <p>What is the best practice for resolving this issue? How can we identify non-identifieble objects in the stateless applications?</p>
<p>Does the value objects state identify that particular instance? If not you could just pass back the old value and the new value when the edit form is submitted, then update any objects with the old state to the new state. </p> <p>I would rather have a page like Contact/C0001/ThelephoneNumber, and use both the contact id and the value objects class to identify the instance you want to change.</p> <p>Unless I've completely misunderstood what you're asking.</p>
<p>I would make the TelephoneNumber just contain a bunch of numbers (maybe make it plural), and refer to it this way: Contact/C0001/TelephoneNumber(s)</p>
9,784
<p>If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?</p> <p>I'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current version seems to be working fine. What version would hit the sweet spot but still allow me to enjoy the newest and coolest language enhancements?</p>
<p>As python is in kind of an transition phase towards python 3 with breaking backward compatibility I don't think it is a good idea to go python 3 only. Based on the <a href="http://www.python.org/dev/peps/pep-3000/#timeline" rel="nofollow noreferrer">time line</a> there will be at least one or two following releases of the 2.x series after 2.6/3.0 in october.</p> <p>Beside not having python 3 available on your target platforms, it will take some time until important external python libraries will be ported and usable on python 3.</p> <p>So as Matthew suggests staying at 2.4/2.5 and keeping the <a href="http://www.python.org/dev/peps/pep-3000/#compatibility-and-transition" rel="nofollow noreferrer">transition</a> plan to python 3 in mind is a solid choice.</p>
<p>If the project is going to be mainstream and will be run on Linux the <strong>only</strong> sensible choise is 2.4 - just because it is a pain to get anything else installed as default on Enterprise Linuxes.</p> <p>In any case, any <em>modern</em> OS will/can have 2.4 or newer.</p>
6,938
<p>I needed some simple string encryption, so I wrote the following code (with a great deal of "inspiration" from <a href="http://www.codeproject.com/KB/security/DotNetCrypto.aspx" rel="noreferrer">here</a>):</p> <pre><code> // create and initialize a crypto algorithm private static SymmetricAlgorithm getAlgorithm(string password) { SymmetricAlgorithm algorithm = Rijndael.Create(); Rfc2898DeriveBytes rdb = new Rfc2898DeriveBytes( password, new byte[] { 0x53,0x6f,0x64,0x69,0x75,0x6d,0x20, // salty goodness 0x43,0x68,0x6c,0x6f,0x72,0x69,0x64,0x65 } ); algorithm.Padding = PaddingMode.ISO10126; algorithm.Key = rdb.GetBytes(32); algorithm.IV = rdb.GetBytes(16); return algorithm; } /* * encryptString * provides simple encryption of a string, with a given password */ public static string encryptString(string clearText, string password) { SymmetricAlgorithm algorithm = getAlgorithm(password); byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(clearText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, algorithm.CreateEncryptor(), CryptoStreamMode.Write); cs.Write(clearBytes, 0, clearBytes.Length); cs.Close(); return Convert.ToBase64String(ms.ToArray()); } /* * decryptString * provides simple decryption of a string, with a given password */ public static string decryptString(string cipherText, string password) { SymmetricAlgorithm algorithm = getAlgorithm(password); byte[] cipherBytes = Convert.FromBase64String(cipherText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, algorithm.CreateDecryptor(), CryptoStreamMode.Write); cs.Write(cipherBytes, 0, cipherBytes.Length); cs.Close(); return System.Text.Encoding.Unicode.GetString(ms.ToArray()); } </code></pre> <p>The code appears to work fine, except that when decrypting data with an incorrect key, I get a CryptographicException - "Padding is invalid and cannot be removed" - on the cs.Close() line in decryptString. </p> <p>example code:</p> <pre><code> string password1 = "password"; string password2 = "letmein"; string startClearText = "The quick brown fox jumps over the lazy dog"; string cipherText = encryptString(startClearText, password1); string endClearText = decryptString(cipherText, password2); // exception thrown </code></pre> <p>My question is, is this to be expected? I would have thought that decrypting with the wrong password would just result in nonsense output, rather than an exception.</p>
<p>Although this have been already answered I think it would be a good idea to explain <strong>why</strong> it is to be expected.</p> <p>A padding scheme is usually applied because most cryptographic filters are not semantically secure and to prevent some forms of cryptoatacks. For example, usually in RSA the <a href="http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding" rel="noreferrer">OAEP</a> padding scheme is used which prevents some sorts of attacks (such as a chosen plaintext attack or <a href="http://en.wikipedia.org/wiki/Blinding_(cryptography)" rel="noreferrer">blinding</a>).</p> <p>A padding scheme appends some (usually) random garbage to the message m before the message is sent. In the OAEP method, for example, two Oracles are used (this is a simplistic explanation):</p> <ol> <li>Given the size of the modulus you padd k1 bits with 0 and k0 bits with a random number.</li> <li>Then by applying some transformation to the message you obtain the padded message wich is encrypted and sent.</li> </ol> <p>That provides you with a randomization for the messages and with a way to test if the message is garbage or not. As the padding scheme is reversible, when you decrypt the message whereas you can't say anything about the integrity of the message itself you can, in fact, make some assertion about the padding and thus you can know if the message has been correctly decrypted or you're doing something wrong (i.e someone has tampered with the message or you're using the wrong key)</p>
<p>The answer updated by the user "atconway" worked for me.</p> <p>The problem was not with the padding but the key which was different during encryption and decryption. The key and iv should be same during encypting and decrypting the same value.</p>
3,285
<p>I am creating a windows service and want to know best practices for this. In all my windows Program I have a form that asks the user if he wants to report the error and if he answers yes I created a case in FogBugz. What should I do in a windows service. </p>
<p>Since you're not going to have a user interacting with the program, I'd say make configuration variable (in an app.config file) responsible for sending/not sending the data. That way users who don't want to report errors can just change a flag in a config file. I'd personally have it turned on by default and then give them guidance on how to turn it off it they wanted to.</p>
<p>Since you're not going to have a user interacting with the program, I'd say make configuration variable (in an app.config file) responsible for sending/not sending the data. That way users who don't want to report errors can just change a flag in a config file. I'd personally have it turned on by default and then give them guidance on how to turn it off it they wanted to.</p>
7,120
<p>I've recently designed a non-self-aligning caged deep-groove ball bearing. Now I'd love to get one 3D printed.</p> <p>However, assembling those can be tricky and I highly doubt it's even plausible to print them. All the components themselves can be printed without a problem, but I'm not sure whether I'll be able to put them all together in the end.</p> <p>What are my options?</p> <p>FDM printers are probably out, although it would be great if I can find a way to use those. Would an SLA or perhaps an SLS printer be able to pull it off?</p> <p>Of course the thing still has to work (move) in the end.</p> <p><a href="https://i.stack.imgur.com/OuWFEm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OuWFEm.jpg" alt="Caged deep-grooved ball bearing - MatVis"></a></p>
<p>No, that's not (entirely) true. There might be some loss of quality if you print multiple objects at once, because when the printhead "hops" from one object to another it might leave a mark or ooze out some material. Also, a large number of retractions in a short period of time might lead to inconsistent extrusion.</p> <p>However, none of this is particular to "filling out the board" as it happens even if you print only two objects at a time (or even when you're printing only one object with multiple islands).</p> <p>It all depends on your printer (and in particular how well it handles retractions). If you're willing to do a small amount of cleanup afterwards (to remove the strings and blobs) then printing multiple objects at a time is completely viable.</p>
<p>Just to add to the other answers already here, I've also had problems with layer adhesion when filling up the print bed on an extrusion printer. The longer the print head spends working on details around a single layer, the more chance the layer has to cool off before the next layer gets started. I've started to suspect that layers that take longer to print end up with less adhesion to the next layer.</p>
426
<p>I'm using Visual Studio (2005 and up). I am looking into trying out making an application where the user can change language for all menues, input formats and such. How would I go on doing this, as I suppose that there is some complete feature within .Net that can help me with this?</p> <p>I need to take the following into account (and fill me in if I miss some obvious stuff)</p> <ul> <li>Strings (menues, texts)</li> <li>Input data (parsing floats, dates, etc..)</li> <li>Should be easy to add support for another language</li> </ul>
<p>I'm not an expert with .NET by any means but Localization is never just as simple as "swapping out String values" or "changing date formats". There is much more to be taken into consideration such as layout, proper text placement.</p> <p>Take Chinese for example. The way you read is top to bottom not left to right. If properly localized the app should take that into account.</p> <p><a href="http://msdn.microsoft.com/en-us/library/y99d1cd3(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/y99d1cd3(VS.80).aspx</a> seems to be a good start though if you're dealing with Windows Forms.</p>
<p>For strings you should just separate your strings from your code (having an XML/DLL that will transform string IDs to real strings is one way to go). However you do need to make sure that you are supporting double byte characters for some languages (this is relevant if you use C/C++).</p> <p>For input data what you want is to have different locale's. In Java this is relatively easy, and if you use C# it probably is quite easy also. In C/C++ I don't really know. The basic idea is that the input parsers should be different based on the locale selected at that time. So each field (textfield, textbox, etc.) must have an abstract parser that is then implemented by a different class depending on the locale (right to left, double byte, etc.).</p> <p>Check the Java implementation for details on how they did it. It is quite functional.</p>
9,169
<p>I am currently writing a simple, timer based mini app in C# that performs an action n times every k seconds.<br> I am trying to adopt a test driven development style, so my goal is to unit test all parts of the app.</p> <p>So, my question is: Is there a good way to unit test a timer based class?</p> <p>The problem, as I see it, is that there is a big risk that the tests will take uncomfortably long to execute, since they must wait so and so long for the desired actions to happen.<br> Especially if one wants realistic data (seconds), instead of using the minimal time resolution allowed by the framework (1 ms?).<br> I am using a mock object for the action, to register the number of times the action was called, and so that the action takes practically no time.</p>
<p>What I have done is to mock the timer, and also the current system time, that my events could be triggered immediately, but as far as the code under test was concerned time elapsed was seconds.</p>
<p>I think what I would do in this case is test the code that actually executes when the timer ticks, rather than the entire sequence. What you really need to decide is whether it is worthwhile for you to test the actual behaviour of the application (for example, if what happens after every tick changes drastically from one tick to another), or whether it is sufficient (that is to say, the action is the same every time) to just test your logic.</p> <p>Since the timer's behaviour is guaranteed never to change, it's either going to work properly (ie, you've configured it right) or not; it seems to be to be wasted effort to include that in your test if you don't actually need to.</p>
3,314
<p>In a project of mine the SQL statements that are executed against a SQL Server are failing for some unknown reason. Some of the code is already used in production so debugging it is not an easy task. Therefore I need a way to see in the database itself what SQL statements are used, as the statements are generated at runtime by the project and could be flawed when certain conditions are met. </p> <p>I therefore considered the possibility to monitor the incoming statements and check myself if I see any flaws. </p> <p>The database is running on a SQL Server 2005, and I use SQL server management studio express as primary tool to manipulate the database. So my question is, what is the best way to do this?</p>
<p>Seeing how you use the Management Studio Express, I will assume you don't have access to the MSSQL 2005 client tools. If you do, install those, because it includes the SQL profiler which does exactly what you want (and more!). For more info about that one, see <a href="http://msdn.microsoft.com/en-us/library/ms181091.aspx" rel="noreferrer">msdn</a>.</p> <p>I found <a href="http://sqlprofiler.googlepages.com/" rel="noreferrer">this</a> a while ago, because I was thinking about the exact same thing. I have access to the client tools myself, so I don't really need to yet, but that access is not unlimited (it's through my current job). If you try it out, let me know if it works ;-)</p>
<p>Best way is to fire up profiler, start a trace, save the trace and then rerun the statements</p>
6,960
<p>I've seen this all over the place: </p> <blockquote> <p>Download here! SHA1 = 8e1ed2ce9e7e473d38a9dc7824a384a9ac34d7d0</p> </blockquote> <p>What does it mean? How does a hash come into play as far as downloads and... What use can I make of it? Is this a legacy item where you used to have to verify some checksum after you downloaded the whole file?</p>
<p>It's a security measure. It allows you to verify that the file you just downloaded is the one that the author posted to the site. Note that using hashes from the same website you're getting the files from is not especially secure. Often a good place to get them from is a mailing list announcement where a PGP-signed email contains the link to the file and the hash.</p> <p>Since this answer has been ranked so highly compared to the others for some reason, I'm editing it to add the other major reason mentioned first by the other authors below, which is to verify the integrity of the file after transferring it over the network.</p> <p>So:</p> <ul> <li>Security - verify that the file that you downloaded was the one the author originally published</li> <li>Integrity - verify that the file wasn't damaged during transmission over the network.</li> </ul>
<p>With a has (MD5, SHA-1) one input matches only with one output, and then if you down load the file and calculate the hash again should obtain the same output. If the output is different the file is corrupt.</p> <pre><code>If (hash(file) == “Hash in page”) validFile = true; else validFile = false; </code></pre>
4,096
<p>We have a third party dll that is used in our web service hosted in IIS6. The problem is that once this dll is loaded into memory, the exception <a href="http://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx" rel="nofollow noreferrer">AccessViolationException</a> gets thrown if a thread different then the one that created it tries to execute any code within the dll. The worker process is multi threaded and each call to the web service will get a random thread from the pool. We tried to unload it from memory and reload it each time we needed it, but I guess only the front end is .Net and the rest is unmanaged so it never actually gets completely unloaded from memory. We are using VB and .Net 2.0. Any suggestions?</p> <p>(Response to Rob Walker)</p> <p>We thought about creating a new thread and using it to call the dll, but how do we make the thread sit and wait for calls? How do you delegate the call to the thread without having the Dispatcher class supplied by .Net 3.0? Creating a hidden form and putting it in a message loop might work. And then we could call the Invoke() method of the form. But I can see many problems occurring if we create a form inside an IIS hosted web service.</p>
<p>I have read about a class in .net 3.0 called <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.aspx" rel="nofollow noreferrer">Dispatcher</a> that allows you to put a thread in a loop and then call the method Invoke() using a delegate to execute a method using the thread. But this solution will not work if you cannot update to .Net 3.0. Another solution would be to host the third party dll in another application on the server and use some form of <a href="http://msdn.microsoft.com/en-us/library/system.runtime.remoting.aspx" rel="nofollow noreferrer">Remoting</a> to access it. But you may still have a problem with the Remoting because it behaves similar to IIS and will also pick a random thread to execute the code . To get around this, you could put a wrapper around the dll and use it to delegate the calls to the UI thread by using the Invoke() method of the form.</p>
<p>You could create a service that hosts the extra DLL. Via remoting you access the service, this will dispatch the calls the the thread that manages the DLL.</p> <p>This way you have control over the thread that calls the DLL, and over the lifetime of the thread.</p>
6,630
<p>We have a build box that uses CruiseControl.Net and has been building VB.Net and C# projects using msbuild. All I have installed on the box as far as .Net is concerned is .Net 2.0 SDK (I'm trying to keep the box as clean as possible). We are now trying to get a C++ app building on this box. The problem we are running into is that the header files (e.g. windows.h) are not installed with the SDK. </p> <p>Do I have to install VS 2005 to get this to work?</p> <p><strong>Edit:</strong></p> <p>As a couple people have answered, I had actually downloaded the 3.5 Platform SDK, but the applications built on this box MUST run on boxes that do not have 3.5 installed. By installing the 3.5 SDK on my 2.0 build box, am I compromising my build box?</p> <p><strong>Edit:</strong></p> <p>I'm going to leave this as unanswered, but thought I would add that I went ahead and installed Visual Studio on the box and all is well. I hate having to do that, but didn't want to run the risk of having a 3.5 SDK on my 2.0 build box. I would still love to hear a better solution.</p>
<p>Visual Studio is not needed, but for C++ you need the Platform SDK as well:</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&amp;displaylang=en</a></p> <p>Edit: There is also one for Windows 2008/Vista, not sure which is the correct one:</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en</a></p>
<p>No, you have to install the windows platform SDK.</p> <p>You'll need to download this:</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en</a></p> <p><strong>Edit:</strong> @<a href="https://stackoverflow.com/questions/43766/vsnet-2005-required-on-build-box-with-net-20-c-projects#43770">Michael Stum</a> You need the Server 2008 / Vista / .NET 3.5 SDK version.</p>
6,534
<p>Using Oracle 10g with our testing server what is the most efficient/easy way to backup and restore a database to a static point, assuming that you always want to go back to the given point once a backup has been created.</p> <p>A sample use case would be the following</p> <ol> <li>install and configure all software</li> <li>Modify data to the base testing point</li> <li>take a backup somehow (this is part of the question, how to do this)</li> <li>do testing</li> <li>return to step 3 state (restore back to backup point, this is the other half of the question)</li> </ol> <p><strong>Optimally this would be completed through sqlplus or rman or some other scriptable method.</strong></p>
<p>You do not need to take a backup at your base time. Just enable flashback database, create a guaranteed restore point, run your tests and flashback to the previously created restore point.</p> <p>The steps for this would be:</p> <ol> <li>Startup the instance in mount mode.<p> startup force mount;</li> <li>Create the restore point.<p> create restore point before_test guarantee flashback database;</li> <li>Open the database.<p> alter database open;</li> <li>Run your tests.<p></li> <li>Shutdown and mount the instance.<p> shutdown immediate; startup mount;</li> <li>Flashback to the restore point.<p> flashback database to restore point before_test;</li> <li>Open the database.<p> alter database open;</li> </ol>
<p>@Michael Ridley solution is perfectly scriptable, and will work with any version of oracle.</p> <p>This is exactly what I do, I have a script which runs weekly to</p> <ol> <li>Rollback the file system</li> <li>Apply production archive logs</li> <li>Take new "Pre-Data-Masking" FS snapshot</li> <li>Reset logs</li> <li>Apply "preproduction" data masking.</li> <li>Take new "Post-Data-Masking" snapshot (allows rollback to post masked data)</li> <li>Open database</li> </ol> <p>This allows us to keep our development databases close to our production database.</p> <p>To do this I use ZFS.</p> <p>This method can also be used for your applications, or even you entire "environment" (eg, you could "rollback" your entire environment with a single (scripted) command.</p> <p>If you are running 10g though, the first thing you'd probably want to look into is Flashback, as its built into the database.</p>
9,321
<p>I have a List of Foo.</p> <p>Foo has a string property named Bar.</p> <p>I'd like to use <strong>LINQ</strong> to get a string[] of <strong>distinct</strong> values for Foo.Bar in List of Foo.</p> <p>How can I do this?</p>
<p>I'd go lambdas... wayyy nicer</p> <pre><code>var bars = Foos.Select(f =&gt; f.Bar).Distinct().ToArray(); </code></pre> <p>works the same as what @lassevk posted.</p> <p>I'd also add that you might want to keep from converting to an array until the last minute. </p> <p>LINQ does some optimizations behind the scenes, queries stay in its query form until explicitly needed. So you might want to build everything you need into the query first so any possible optimization is applied altogether.</p> <p>By evaluation I means asking for something that explicitly requires evalution like "Count()" or "ToArray()" etc.</p>
<p>Shouldn't you be able to do something like:</p> <pre><code>var strings = (from a in fooList select a.Bar).Distinct(); string[] array = strings.ToArray(); </code></pre>
6,169
<p>I'm a keyboard junkie. I love having a key sequence to do everything. What are your favorite keyboard shortcuts?</p> <p>I'll start by naming a couple of mine:</p> <p>1 - <kbd>Alt</kbd>-<kbd>Space</kbd> to access the windows menu for the current window</p> <p>2 - <kbd>F2</kbd> to rename a file in Windows Explorer</p>
<p><strong><kbd>Win</kbd> + <kbd>1</kbd> .. <kbd>9</kbd></strong> -- Start quick launch shortcut at that index (Windows&nbsp;Vista).</p> <p><strong><kbd>Ctrl</kbd> + <kbd>Scroll Lock</kbd>, <kbd>Scroll Lock</kbd></strong> -- Crash your computer: <em><a href="http://support.microsoft.com/kb/244139" rel="noreferrer">Windows feature lets you generate a memory dump file by using the keyboard</a></em></p> <p>@gabr -- <kbd>Win</kbd> + <kbd>D</kbd> is <em>show desktop</em>, <kbd>Win</kbd> + <kbd>M</kbd> minimizes all windows. Hitting <kbd>Win</kbd> + <kbd>D</kbd> twice brings everything back as it has only shown the desktop window in front of the other windows.</p>
<p>I don't have favorites among keyboard shortcuts -- they are all utility entities to me...</p> <p>Except for <kbd><img src="https://farm6.staticflickr.com/5214/5472803412_953823394a_o.jpg" width="15"/></kbd>+<kbd>L</kbd>, which means another coffee break!</p>
7,593
<ul> <li>What's the optimal level of concurrency that the C++ implementation of BerkeleyDB can reasonably support?</li> <li>How many threads can I have hammering away at the DB before throughput starts to suffer because of resource contention?</li> </ul> <p>I've read the manual and know how to set the number of locks, lockers, database page size, etc. but I'd just like some advice from someone who has real-world experience with BDB concurrency.</p> <p>My application is pretty simple, I'll be doing gets and puts of records that are about 1KB each. No cursors, no deleting.</p>
<p>It depends on what kind of application you are building. Create a representative test scenario, and start hammering away. Then you will know the definitive answer.</p> <p>Besides your use case, it also depends on CPU, memory, front-side bus, operating system, cache settings, etcetera.</p> <p>Seriously, just test your own scenario.</p> <p>If you need some numbers (that actually may mean nothing in your scenario):</p> <ul> <li><a href="http://www.oracle.com/technology/products/berkeley-db/pdf/berkeley-db-perf.pdf" rel="noreferrer">Oracle Berkeley DB: Performance Metrics and Benchmarks</a></li> <li><a href="http://staff.rcost.unisannio.it/visaggio/berkleyDB.pdf" rel="noreferrer">Performance Metrics &amp; Benchmarks:<br> Berkeley DB</a></li> </ul>
<p>What I did when working against a database of unknown performance was to measure turnaround time on my queries. I kept upping the thread count until turn-around time dropped, and dropping the thread count until turn-around time improved (well, it was processes in my environment, but whatever). </p> <p>There were moving averages and all sorts of metrics involved, but the take-away lesson was: just adapt to how things are working at the moment. You never know when the DBAs will improve performance or hardware will be upgraded, or perhaps another process will come along to load down the system while you're running. So adapt.</p> <p>Oh, and another thing: avoid process switches if you can - batch things up.</p> <hr> <p>Oh, I should make this clear: this all happened at run time, not during development.</p>
2,277
<p>I was wondering if there are any code or class libraries out there on how to implement multithreading or "green threading" in ActionScript.</p> <p>As you've might seen, Scott Peterson is developing some kind of toolset, but I haven't found any more info on this other than his performance on the Adobe MAX Chicago event.</p> <p>Regards Niclas</p>
<p>Here's a Green Threading lib from Drew Cummins:</p> <p><a href="http://blog.generalrelativity.org/?p=29" rel="nofollow noreferrer">http://blog.generalrelativity.org/?p=29</a></p>
<p>I'm a graphics guy, not a programmer, so I'm not sure this will help you. BUT!</p> <p>I make all my GUIs multi-frame "movies" and write each gui thread on a different frame. Make sure that you only have 1-3 threads, and set your FPS to 30 or 60.</p> <p>This is useful for little projects because its bug-resistant and implementation is done for you.</p>
9,561
<p>How do I get started?</p>
<p>I have found the easiest way to achieve this by using Clojure. Here is the example code: <pre><code> (ns example (:require [clojure.contrib.sql :as sql]) (:import [java.sql Types]))</p> <p>(def devdb {:classname "oracle.jdbc.driver.OracleDriver" :subprotocol "oracle" :subname "thin:username/password@localhost:1509:devdb" :create true})</p> <p>(defn exec-ora-stored-proc [input-param db callback] (sql/with-connection db (with-open [stmt (.prepareCall (sql/connection) "{call some_schema.some_package.test_proc(?, ?, ?)}")] (doto stmt (.setInt 1 input-param) (.registerOutParameter 2 Types/INTEGER) (.registerOutParameter 3 oracle.jdbc.driver.OracleTypes/CURSOR) (.execute)) (callback (. stmt getInt 2) (. stmt getObject 3)))))</p> <p>(exec-ora-stored-proc 123 ;;input param value devdb (fn [err-code res-cursor] (println (str "ret_code: " err-code)) ;; prints returned refcursor rows (let [resultset (resultset-seq res-cursor)] (doseq [rec resultset] (println rec))))) </pre></code></p>
<p>You'll need an interface to the Oracle SQL database. As Bob pointed out, Allegro CL has such an interface.</p> <p><a href="http://clisp.cons.org/impnotes/oracle.html" rel="nofollow noreferrer">GNU CLISP apparently comes with an interface to the database as well.</a></p>
9,207
<p>How can I get PDO to work on my mac (os x 10.5)? I'm using the built in php and php in Zend/Eclipse. Can't seem to find useful drivers for it at all.</p>
<p>I had to install the PDO_PGSQL driver recently on Leopard, and I ran across a multitude of problems. In my search for answers, I stumbled across this question. Now I have it successfully installed, and so, even though this question is quite old, I hope that what I've found can help others (like myself) who will undoubtedly run into similar problems.</p> <p>The first thing you'll need to do is <a href="http://pear.php.net/manual/en/installation.getting.php" rel="noreferrer">install PEAR</a>, if you haven't done so already, since it doesn't come installed on Leopard by default.</p> <p>Once you do that, use the PECL installer to download the PDO_PGSQL package:</p> <pre><code>$ pecl download pdo_pgsql $ tar xzf PDO_PGSQL-1.0.2.tgz </code></pre> <p>(Note: you may have to run <code>pecl</code> as the superuser, i.e. <code>sudo pecl</code>.)</p> <p>After that, since the PECL installer can't install the extension directly, you'll need to build and install it yourself:</p> <pre><code>$ cd PDO_PGSQL-1.0.2 $ phpize $ ./configure --with-pdo-pgsql=/path/to/your/PostgreSQL/installation $ make &amp;&amp; sudo make install </code></pre> <p>If all goes well, you should have a file called "<code>pdo_pgsql.so</code>" sitting in a directory that should look something like "<code>/usr/lib/php/extensions/no-debug-non-zts-20060613/</code>" (the PECL installation should have outputted the directory it installed the extension to).</p> <p>To finalize the installation, you'll need to edit your <code>php.ini</code> file. Find the section labeled "Dynamic Extensions", and underneath the list of (probably commented out) extensions, add this line:</p> <pre><code>extension=pdo_pgsql.so </code></pre> <p>Now, assuming this is the first time you've installed PHP extensions, there are two additional steps you need to take in order to get this working. First, in <code>php.ini</code>, find the <code>extension_dir</code> directive (under "Paths and Directories"), and change it to the directory that the <code>pdo_pgsql.so</code> file was installed in. For example, my <code>extension_dir</code> directive looks like:</p> <pre><code>extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20060613" </code></pre> <p>The second step, if you're on a 64-bit Intel Mac, involves making Apache run in 32-bit mode. (If there's a better strategy, I'd like to know, but for now, this is the best I could find.) In order to do this, edit the property list file located at <code>/System/Library/LaunchDaemons/org.apache.httpd.plist</code>. Find these two lines:</p> <pre><code>&lt;key&gt;ProgramArguments&lt;/key&gt; &lt;array&gt; </code></pre> <p>Under them, add these three lines:</p> <pre><code>&lt;string&gt;arch&lt;/string&gt; &lt;string&gt;-arch&lt;/string&gt; &lt;string&gt;i386&lt;/string&gt; </code></pre> <p>Now, just restart Apache, and PDO_PGSQL will be up and running.</p>
<p>This is what worked for me</p> <pre><code>brew install php55-pdo-pgsql </code></pre> <p>This installs PHP 5.5.32 and PostgreSQL 9.5. I already had PostgreSQL 9.4 installed so I uninstalled the homebrew version with:</p> <pre><code>brew uninstall postgres </code></pre> <p>You then have to update /etc/apache2/httpd.conf to point to the correct PHP version and restart Apache:</p> <pre><code>LoadModule php5_module /usr/local/Cellar/php55/5.5.32/libexec/apache2/libphp5.so </code></pre> <p>My OSX version is Yosemite.</p>
8,704
<p>I have 1 process that receives incoming connection from port 1000 in 1 <strong>linux</strong> server. However, 1 process is not fast enough to handle all the incoming request.</p> <p>I want to run multiple processes in the server but with 1 end-point. In this way, the client will only see 1 end-point/process not multiple.</p> <p>I have checked LVS and other Load Balancing Solution. Those solutions seem geared towards multiple servers load-balancing.</p> <p>Any other solution to help on my case?</p> <hr> <p>i am looking something more like nginx where i will need to run multiple copies of my app.</p> <p>Let me try it out.</p> <p>Thanks for the help.</p>
<p>You also may want to go with a web server like <a href="http://www.nginx.net" rel="nofollow noreferrer">nginx</a>. It can load balance your app against multiple ports of the same app, and is commonly used to load balance Ruby on Rails apps (which are single threaded). The downside is that you need to run multiple copies of your app (one on each port) for this load balancing to work.</p>
<p>i am thinking to run multiple application similar to <a href="http://ypopsemail.com/" rel="nofollow noreferrer">ypops</a>.</p>
6,708
<p>I am working on a web application using Python (Django) and would like to know whether MySQL or PostgreSQL would be more suitable when deploying for production.</p> <p>In one <a href="https://blog.stackoverflow.com/2008/06/podcast-8/">podcast</a> Joel said that he had some problems with MySQL and the data wasn't consistent.</p> <p>I would like to know whether someone had any such problems. Also when it comes to performance which can be easily tweaked?</p>
<p><strong>A note to future readers:</strong> The text below was last edited in August 2008. That's nearly 11 years ago as of this edit. Software can change rapidly from version to version, so before you go choosing a DBMS based on the advice below, do some research to see if it's still accurate. Check for newer answers below.</p> <hr> <p>Better?</p> <p>MySQL is much more commonly provided by web hosts.</p> <p>PostgreSQL is a much more mature product.</p> <p>There's <a href="http://www.databasejournal.com/features/mysql/article.php/3288951" rel="noreferrer">this discussion addressing your "better" question</a> </p> <p>Apparently, according to <a href="http://www.teknico.net/devel/myvspg/index.en.html" rel="noreferrer">this web page</a>, MySQL is fast when concurrent access levels are low, and when there are many more reads than writes. On the other hand, it exhibits low scalability with increasing loads and write/read ratios. PostgreSQL is relatively slow at low concurrency levels, but scales well with increasing load levels, while providing enough isolation between concurrent accesses to avoid slowdowns at high write/read ratios. It goes on to link to a number of performance comparisons, because these things are very... sensitive to conditions.</p> <p>So if your decision factor is, "<strong>which is faster?</strong>" Then the answer is "it depends. <strong>If it really matters, test your application against both.</strong>" And if you really, really care, you get in two DBAs (one who specializes in each database) and get them to tune the crap out of the databases, and then choose. It's astonishing how expensive <em>good</em> DBAs are; and <em>they are worth every cent</em>. </p> <p>When it matters. </p> <p>Which it probably doesn't, so just pick whichever database you like the sound of and go with it; better performance can be bought with more RAM and CPU, and more appropriate database design, and clever stored procedure tricks and so on - and all of that is cheaper and easier for random-website-X than agonizing over which to pick, MySQL or PostgreSQL, and specialist tuning from expensive DBAs.</p> <p><hr> Joel also said in that podcast that comment would come back to bite him because people would be saying that MySQL was a piece of crap - Joel couldn't get a <code>count</code> of rows back. The plural of anecdote is not data. <a href="https://stackoverflow.fogbugz.com/default.asp?W6080" rel="noreferrer">He said</a>:</p> <blockquote> <p>MySQL is the only database I've ever programmed against in my career that has had data integrity problems, where you do queries and you get nonsense answers back, that are incorrect. </p> </blockquote> <p>and he also said:</p> <blockquote> <p>It's just an anecdote. And that's one of the things that frustrates me, actually, about blogging or just the Internet in general. [...] There's just a weird tendency to make anecdotes into truths and I actually as a blogger I'm starting to feel a little bit guilty about this</p> </blockquote>
<p>MySQL is a <a href="http://en.wikipedia.org/wiki/Relational_database_management_system" rel="nofollow noreferrer">relational database management system</a> while PostgreSQL is an <a href="http://en.wikipedia.org/wiki/Object-relational_database_management_system" rel="nofollow noreferrer"><strong>object</strong>-relational database management system</a>. PostgreSQL is suited well for C++ or Java developers, as it gives us more control over how queries are written. ORDBMS also gives us Objects and User Defined Types. The SQL queries themselves are much closer to the ISO standards than MySQL.<br> Do you need an ORDBMS or a RDBMS? That will better answer your question. </p>
4,703
<p>Is it possible to pass a reference to a function to another function in F#? Specifically, I'd like to pass lambda functions like</p> <p>foo(fun x -> x ** 3)</p> <p>More specifically, I need to know how I would refer to the passed function in a function that I wrote myself.</p>
<p>Yes, it is possible. The <a href="http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc207785549" rel="noreferrer">manual</a> has this example:</p> <pre><code>&gt; List.map (fun x -&gt; x % 2 = 0) [1 .. 5];; val it : bool list = [false; true; false; true; false] </code></pre>
<p>Functions are first class citizens in F#. You can therefore pass them around just like you want to.</p> <p>If you have a function like this:</p> <pre><code>let myFunction f = f 1 2 3 </code></pre> <p>and <strong>f</strong> is function then the return value of <strong>myFunction</strong> is <strong>f</strong> applied to 1,2 and 3.</p>
6,569
<p>I have just received and bypassed a problem with LightWindow and IE7 where, on page load, it throws a JavaScript error on line 444 of <code>lightwindow.js</code>, claiming that the <code>object does not support this property or method</code>. Despite finding various postings on various forums, no Google result I could find had a solution, so I am posting this here in the hopes that it will help someone / myself later.</p> <p>Many suggested a specific order of the script files but I was already using this order (prototype, scriptaculous, lightwindow).</p> <p>These are the steps I took that seemed to finally work, I write them here only as a record as I do not know nor have time to test which ones specifically "fixed" the issue:</p> <ol> <li>Moved the call to lightwindow.js to the bottom of the page.</li> <li>Changed line 444 to: <code>if (this._getGalleryInfo(link.rel)) {</code></li> <li>Changed line 1157 to: <code>if (this._getGalleryInfo(this.element.rel)) {</code></li> <li>Finally, I enclosed (and this is dirty, my apologies) lines 1417 to 1474 with a <code>try/catch</code> block, swallowing the exception.</li> </ol> <p><strong>EDIT:</strong> </p> <p>I realised that this broke Firefox. Adding the following as line 445 now makes it work - <code>try { gallery = this._getGalleryInfo(link.rel); } catch (e) { }</code></p> <p>It's not a very nice fix, but my page (which contains a lightwindow link with no "rel" tag, several lightwindow links which do have "rel" tags, and one "inline" link) works just fine in IE7 now. Please comment if you have anything to add about this issue or problems with / improvements to my given solution.</p>
<p>Instead of the try..catch maybe you could try using </p> <pre><code>if( this &amp;&amp; this._getGalleryInfo ) { //use the function } </code></pre> <p>you could also check in the same way <strong>this.element.rel</strong> ( <code>if(this &amp;&amp; this.element &amp;&amp; this.element.rel)</code> ... ) before using it.</p> <p>It looks like there's a case that the <code>_getGalleryInfo</code> or <code>this.element.rel</code> has not yet been initialized so it wouldn't exist yet. Check if it exists then if I does use it.</p> <p>of course i could be completely wrong, the only way to know is by testing it out.</p>
<p>I had the same problem with Lightwindow 2.0, IE6, IE7, IE8 (beta); I resolved in the following way for IE6, IE7, IE8 (beta).</p> <p>Instead of:<br/> &nbsp;<code>if(gallery = this._getGalleryInfo(link.rel))</code><br/> I put on lines 443 and 1157:<br/> &nbsp;<code>gallery = this._getGalleryInfo(link.rel)</code><br/> &nbsp;<code>if(gallery)</code><br/></p> <p>Hope this will help!</p>
6,333
<p><img src="https://i.stack.imgur.com/fY6wJ.jpg" alt="Failed first and second layer of print"></p> <p>I have only been able to get my prints this far. They just can’t stop skipping pulling material up towards the nozzle which then melts pulls of another random bit. At first I thought it was motor skipping, so I strengthened the spring, but even after that and calibrating the bed, I couldn’t figure out exactly how to fix this issue. Hopefully someone has some idea what is wrong.</p>
<p>So, contrary to what people were saying, my problem came from my spring that controlled filament flow. There was too much tension and it caused motor skipping. I did get rid of the overlap with the blue tape, but otherwise I had to clamp down my spring and that fixed the issue.</p>
<p>I would get rid of the blue tape and go with glass and hairspray. Glass gives you more of a flat surface. You are printing with the aluminum build plate which over time c an warp. The glass with give you a much flatter and level surface to print om. Blue Tape is actually not a great surface to print on. Hairspray using a chemical compound that actually is related to a PLA makeup. This compound in Aquanet Hairspray will bond to the PLA and release when cold. Using both the glass and hairspray will give you and even build plate and a clean smooth surface that it will stick to better than blue tape. </p>
1,221
<p>From time to time I get a System.Threading.ThreadStateException when attempting to restart a thread. The code in question is as follows:</p> <pre><code>// Make sure the thread is done stopping while (this.mThread.ThreadState == ThreadState.Running) { Thread.Sleep(0); } // Respawn a thread if the current one is stopped or doesn't exist if (this.mThread == null || this.mThread.ThreadState == ThreadState.Stopped) { this.mThread = new Thread(new ParameterizedThreadStart(Monitor)); } // Start the thread if (check) { this.mThread.Start(60000); } else { this.mThread.Start(0); } </code></pre> <p>So two questions - is this the correct way of doing things, and it is, is there a way to prevent the error from occurring?</p>
<p>It's possible for a thread to be in more than one state at once therefore the ThreadState property is actually a bitmap of possible states. So testing for equality with just one state will not give you the right result. You would need to do something like:</p> <pre><code>if((mThread.ThreadState &amp; ThreadState.Running) != 0) </code></pre> <p>However, checking thread state is the wrong to do anything. I'm not entirely clear what you're trying to achieve but I will guess that you're waiting for a thread to terminate before restarting it. In that case you should do:</p> <pre><code>mThread.Join(); mThread = new Thread(new ParameterizedThreadStart(Monitor)); if(check) mThread.Start(60000); else mThread.Start(0); </code></pre> <p>Although if you describe the problem you're trying to solve in more detail I'm almost certain there will be a better solution. Waiting around for a thread to end just to restart it again doesn't seem that efficient to me. Perhaps you just need some kind of inter-thread communication?</p> <p>John.</p>
<p>A ThreadStateException is thrown because you're trying to start a thread that's not in a startable state. The most likely situations would be that it's already running, or that it has fully exited.</p> <p>There are potentially a couple things that might be happening. First is, the thread might have transitioned from Running to StopRequested, which isn't fully stopped yet, so your logic doesn't create a new thread, and you're trying to start a thread which has just finished running or is about to finish running (neither of which is a valid state for restarting).</p> <p>The other possibility is that the thread was aborted. Threads which are aborted go to the Aborted state, not the Stopped state, and of course are also not valid for restarting.</p> <p>Really, the only kind of thread that is still alive that can be "restarted" is one that's suspended. You might want to use this conditional instead:</p> <p><code>if (this.mThread == null || this.mThread.ThreadState != ThreadState.Suspended)</code></p>
3,417
<p>I'm printing a Soma cube I found on Thingiverse -- it's a puzzle toy I remember from the early 1970s, and the kind of thing that ought to be really easy-peasy to print. Each of the seven pieces is made of four cubes (or three for one piece) joined face to face in every possible combination, so that they can be assembled to make a single 3x3 cube (the claim in the day was, in literally tens of millions of ways -- though many of those were reflections or rotations of others).</p> <p>Problem is, in order for the seven pieces to fit together correctly to make the 3x3 cube, they have to be flat and square on all faces, and dimensionally accurate.</p> <p>I have an Ender 3 that's just a few weeks old (first print was May 8th to 9th of this year, also my own first 3D print). I'm printing these parts in gray Amazon Basics PLA at 200 °C, with the Creality coated glass build surface at 55 °C. I'm printing on a raft; the first layer goes down well, but over the course of the first forty or so layers, I get this:</p> <p><a href="https://i.stack.imgur.com/GCk17.jpg" rel="nofollow noreferrer" title="Raft lifting from build surface"><img src="https://i.stack.imgur.com/GCk17.jpg" alt="Raft lifting from build surface" title="Raft lifting from build surface" /></a></p> <p>I presume this is due to the upper layers shrinking, though the horizontal dimensions look fine at the level where I stopped the print. I have Cura Slicer 4.9.1 set to print with no part cooling for initial layer, increasing to 100 % at layer 4. When I removed this part (immediately after stopping the print, so the bed was still in the low 50s), it was still stuck fairly well -- except where it had lifted.</p> <p>What's causing this warping/lifting?</p>
<blockquote> <p>What's causing this warping/lifting?</p> </blockquote> <p>The warping and lifting is caused by insufficient adhesion. This can be caused by an incorrect first layer (it is difficult to see the raft, but generally, rafts have no solid bottom, so less adhesion as there is less material), e.g. not sufficiently squished to the plate. Note that a raft is absolutely unnecessary for PLA, you should use it for high temperature filaments that experience a lot of shrinkage, PLA does not.</p> <p>What you should do is make sure the bed is completely clean and free from grease. Use isopropyl/isopropanol alcohol to clean the bed.</p> <p>Temperature of the bed should be fine, but you could try to notch it up with 5 °C.</p> <p>I've seen people use an adhesive between the bed and the print, even on coated beds. But, I can imagine you don't want to try that, it needs more cleaning.</p> <p>Also, make sure that the printer isn't in front of a window or in the path of an air-conditioning airflow.</p>
<ol> <li><p>What has worked for me is to keep the bed temperature constant at 60 °C. Use a higher extrusion temperature for the first layer to promote adhesion. (Differences in PLA composition could cause these temperatures to vary.)</p> </li> <li><p>Sometimes it helps to have an bed temperature for the 1st layer as high as 75 °C to promote adhesion. While depositing the first layer with this bed temperature promotes adhesion, leaving the bed temperature this high actually decreases it, besides risking the print sagging under its weight.</p> </li> <li><p>Additional adhesion layers such as glue sticks might help.</p> </li> <li><p>If not already using it, less stiff fill patterns (rectangular) can help, as well as a lower percentage fill.</p> </li> </ol>
1,975
<p>UPDATED: I'm asking this from a <strong>development perspective</strong>, however to illustrate, a canoical <em>non-development</em> example that comes to mind is that if it costs, say, $10,000 to keep a uptime rate of 99%, then it theoretically can cost $100,000 to keep a rate of 99.9%, and possibly $1,000,000 to keep a rate of 99.99%. </p> <p>Somewhat like calculus in approaching 0, as we closely approach 100%, the cost can increase exponentially. Therefore, as a developer or PM, where do you decide that the deliverable is "good enough" given the time and monetary constraints, e.g.: are you getting a good ROI at 99%, 99.9%, 99.99%?</p> <p>I'm using a non-development example because I'm not sure of a solid metric for development. Maybe in the above example "uptime" could be replaced with "function point to defect ratio", or some such reasonable measure rate of bugs vs. the complexity of code. I would also welcome input regarding all stages of a software development lifecycle.</p> <p>Keep the classic <a href="http://en.wikipedia.org/wiki/Project_triangle" rel="nofollow noreferrer">Project Triangle</a> constraints in mind (quality vs. speed vs. cost). And let's assume that the customer wants <em>the best quality you can deliver</em> given the original budget.</p>
<p>There's no way to answer this without knowing <em>what happens when your application goes down</em>.</p> <ul> <li>If someone dies when your application goes down, uptime is worth spending millions or even billions of dollars on (aerospace, medical devices).</li> <li>If someone may be injured if your software goes down, uptime is worth hundreds of thousands or millions of dollars (industrial control systems, auto safety devices)</li> <li>If someone looses millions of dollars if your software goes down, uptime is worth spending millions on (financial services, large e-commerce apps).</li> <li>If someone looses thousands of dollars if your software goes down, uptime is worth spending thousands on (retail, small e-commerce apps).</li> <li>If someone will swear at the computer and looses productivity while it reboots when your software goes down, then uptime is worth spending thousands on (most internal software).</li> <li>etc.</li> </ul> <p>Basically take (cost of going down) x (number of times the software will go down) and you know how much to spend on uptime.</p>
<p>To expand on what "17 of 26" said, the answer depends on value to the customer. In the case of critical software, like aircrafct controller applications, the value to the customer of a high quality rating by whatever measure they use is quite high. To the user of an RSS feed reader, the value of high quality is considerably lower.</p> <p>It's all about the <em>customer</em> (notice I didn't say user - sometimes they're the same, and sometimes they're not).</p>
7,833
<p>I wrote a simple tool to generate a DBUnit XML dataset using queries that the user enters. I want to include each query entered in the XML as a comment, but the DBUnit API to generate the XML file doesn't support inserting the comment where I would like it (above the data it generates), so I am resorting to putting the comment with ALL queries either at the top or bottom.</p> <p>So my question: is it valid XML to place it at either location? For example, above the XML Declaration:</p> <pre><code>&lt;!-- Queries used: ... --&gt; &lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;dataset&gt; ... &lt;/dataset&gt; </code></pre> <p>Or below the root node:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;dataset&gt; ... &lt;/dataset&gt; &lt;!-- Queries used: ... --&gt; </code></pre> <p>I plan to initially try above the XML Declaration, but I have doubts on if that is valid XML, despite the claim from <a href="http://en.wikipedia.org/wiki/Xml#Well-formed_documents:_XML_syntax" rel="noreferrer">wikipedia</a>:</p> <blockquote> <p>Comments can be placed anywhere in the tree, including in the text if the content of the element is text or #PCDATA.</p> </blockquote> <p>I plan to post back if this works, but it would be nice to know if it is an official XML standard.</p> <p><strong>UPDATE:</strong> See <a href="https://stackoverflow.com/questions/50824/can-xml-comments-go-anywhere#50976">my response below</a> for the result of my test.</p>
<p>According to the <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-comments" rel="noreferrer">XML specification</a>, a well-formed XML document is:</p> <blockquote> <p><code>document ::= prolog element Misc*</code></p> </blockquote> <p>where <code>prolog</code> is</p> <blockquote> <p><code>prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?</code></p> </blockquote> <p>and <code>Misc</code> is</p> <blockquote> <p><code>Misc ::= Comment | PI | S</code></p> </blockquote> <p>and</p> <blockquote> <p><code>XMLDecl ::= '&lt;?xml' VersionInfo EncodingDecl? SDDecl? S? '?&gt;'</code></p> </blockquote> <p>which means that, if you want to have comments at the top, you cannot have an XML type declaration. </p> <p>You can, however, have comments after the declaration and outside the document element, either at the top or the bottom of the document, because <code>Misc*</code> can contain comments.</p> <p>The specification agrees with Wikipedia on comments:</p> <blockquote> <p>2.5 Comments</p> <p>[Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity references MUST NOT be recognized within comments.</p> </blockquote> <p>All of this together means that you can put comments <strong>anywhere that's not inside other markup</strong>, except that you <strong>cannot have an XML declaration if you lead with a comment</strong>.</p> <p>However, while in theory theory agrees with practice, in practice it doesn't, so I'd be curious to see how your experiment works out.</p>
<p>The processing instruction must be the very first thing in the XML content (see <a href="http://www.w3.org/TR/REC-xml/#sec-comments" rel="nofollow noreferrer">XML comment</a> and <a href="http://www.w3.org/TR/REC-xml/#sec-pi" rel="nofollow noreferrer">processing instructions</a>). The following should work:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;!-- Queries used: ... --&gt; &lt;dataset&gt; ... &lt;/dataset&gt; </code></pre>
7,365
<p>I have a WCF service from which I want to return a DataTable. I know that this is often a highly-debated topic, as far as whether or not returning DataTables is a good practice. Let's put that aside for a moment.</p> <p>When I create a DataTable from scratch, as below, there are no problems whatsoever. The table is created, populated, and returned to the client, and all is well:</p> <pre><code>[DataContract] public DataTable GetTbl() { DataTable tbl = new DataTable("testTbl"); for(int i=0;i&lt;100;i++) { tbl.Columns.Add(i); tbl.Rows.Add(new string[]{"testValue"}); } return tbl; } </code></pre> <p>However, as soon as I go out and hit the database to create the table, as below, I get a CommunicationException "The underlying connection was closed: The connection was closed unexpectedly."</p> <pre><code>[DataContract] public DataTable GetTbl() { DataTable tbl = new DataTable("testTbl"); //Populate table with SQL query return tbl; } </code></pre> <p>The table is being populated correctly on the server side. It is significantly smaller than the test table that I looped through and returned, and the query is small and fast - there is no issue here with timeouts or large data transfer. The same exact functions and DataContracts/ServiceContracts/BehaviorContracts are being used.</p> <p>Why would the way that the table is being populated have any bearing on the table returning successfully?</p>
<p>For anyone having similar problems, I have solved my issue. It was several-fold.</p> <ul> <li>As Darren suggested and Paul backed up, the Max..Size properties in the configuration needed to be enlarged. The SvcTraceViewer utility helped in determining this, but it still does not always give the most helpful error messages. </li> <li>It also appears that when the Service Reference is updated on the client side, the configuration will sometimes not update properly (e.g. Changing config values on the server will not always properly update on the client. I had to go in and change the Max..Size properties multiple times on both the client and server sides in the course of my debugging)</li> <li><p>For a DataTable to be serializable, it needs to be given a name. The default constructor does not give the table a name, so:</p> <pre><code>return new DataTable(); </code></pre> <p>will not be serializable, while:</p> <pre><code>return new DataTable("someName"); </code></pre> <p>will name the table whatever is passed as the parameter. </p> <p>Note that a table can be given a name at any time by assigning a string to the <code>TableName</code> property of the DataTable.</p> <pre><code>var table = new DataTable(); table.TableName = "someName"; </code></pre></li> </ul> <p>Hopefully that will help someone.</p>
<p>I think Darren is most likely correct - the default values provided for WCF are laughably small and if you bump into them you end up with errors that can be difficult to track down. They seem to appear as soon as you attempt to do anything beyond a simple test case. I wasted more time than I'd like to admit debugging problems that turned out to be related to the various configuration (size) settings on both the client and server. I think I ended up modifying almost all of them, ex. MaxBufferPoolSize, MaxBufferSize, MaxConnections, MaxReceivedMessageSize, etc. </p> <p>Having said that, the SvcTraceViewer utility also mentioned is great. I did run into a few cases where it wasn't as helpful as I would have liked, but overall it's a nice tool for analyzing the communications flow and errors.</p>
3,380
<p>My Ender 3 LCD display was working ok, I went to turn it on recently but is not showing any signal of life anymore...</p> <p>I have tried unplugging and plugging again, is there a way to test if the screen still works?</p> <p>What is the issue? Or should I just buy and install a new LCD?</p>
<p>There are a few issues that could cause this. Roughness in your z-axis lead screw as pointed out by @TheLamestUsername is a leading contender I would say. I'd also extended that answer to include checking the belts for your X and Y axes as well as making sure that the rods the gantry slide on are smooth since the fault appears to be in about the same X-Y location as well in the one image.</p> <p>However, there are a few alternatives as well. Check/confirm that the material that you're using doesn't have a lot of absorbed moisture in it. This can cause little bits of steam to 'pop' when they're extruded causing some bubbles</p> <p>Because of how the material is folding at the location in the &quot;updated&quot; image this looks to be an issue with the starting and stopping. All of the layer's problems appear to be happening when the gantry moves up to the next layer. Essentially more material is coming out of the nozzle there (I think) than is what should be. Confirming material diameter with some calipers can help if there's just an offset (not too unlikely I don't think).</p> <p>If the diameters are dead on I'd suggest reducing the nozzle temperature by a few degrees. The sensors used to measure the temperature aren't usually all that accurate, though their precision is often pretty good. While you may have it set at 200C that might not be the actual temperature. Calibration of the thermal sensors can drift over time, so while it might have been good on the last roll it may have drifted slightly. Or the material might be of slightly different composition. Try lowering the nozzle temp by 2-5 degrees and see if that has any effect.</p> <p>You may also have a retraction setting that can be modified. Pulling the material back ever so slightly when it finishes the one layer as it moves to the next could alos reduce some of the extra material that's coming out.</p>
<p>The fact that the bumps were in the same spots on multiple occasions points to z-axis problems. Turn your printer off and manually turn the z-axis all the way from bottom to top. If there are any tight spots, there is some <em>z-axis binding</em>. If there are no tight spots, skip to the last paragraph.</p> <p>Try taking off the z-axis by removing the set screws (pictured below). Remember which side was pointing up for a later step.</p> <p><a href="https://i.stack.imgur.com/GnC4r.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GnC4r.jpg" alt="enter image description here" /></a></p> <p>Once you do that, clean the screw thoroughly with a brush, cloth, solution, or a combination of those. Put the screw back in the opposite way this time.</p> <p>If you get no bumps, then it was indeed the z-axis</p> <p>If the bumps are still there, try lowering your temperature some more(200 is still a little high compared to what I do for PLA), and <a href="https://all3dp.com/2/extruder-calibration-6-easy-steps-2/" rel="nofollow noreferrer">calibrate your e-steps</a> if you haven't already.</p>
1,689
<p>We have an issue using the <code>PEAR</code> libraries on <code>Windows</code> from <code>PHP</code>.</p> <p>Pear contains many classes, we are making use of a fair few, one of which is the Mail class found in <code>Mail.php</code>. We use PEAR on the path, rather than providing the full explicit path to individual PEAR files:</p> <pre><code>require_once('Mail.php'); </code></pre> <p>Rather than:</p> <pre><code>require_once('/path/to/pear/Mail.php'); </code></pre> <p>This causes issues in the administration module of the site, where there is a <code>mail.php</code> file (used to send mails to users). If we are in an administrative screen that sends an email (such as the user administration screen that can generate and email new random passwords to users when they are approved from the moderation queue) and we attempt to include <code>Mail.php</code> we "accidentally" include mail.php.</p> <p>Without changing to prepend the full path to the PEAR install explicitly requiring the PEAR modules (non-standard, typically you install PEAR to your path...) is there a way to enforce PHP on Windows to require files case-sensitively?</p> <p>We are adding the PEAR path to the include path ourselves, so have control over the path order. We also recognize that we should avoid using filenames that clash with PEAR names regardless of case, and in the future will do so. This page however (which is not an include file, but a controller), has been in the repository for some years, and plugins specifically generate URLS to provide links/redirects to this page in their processing.</p> <blockquote> <p>(We support Apache, Microsoft IIS, LightHTTPD and Zeus, using PHP 4.3 or later (including PHP5))</p> </blockquote>
<p>As it's an OS level thing, I don't believe there's an easy way of doing this.</p> <p>You could try changing your include from <code>include('Mail.php');</code> to <code>include('./Mail.php');</code>, but I'm not certain if that'll work on a Windows box (not having one with PHP to test on).</p>
<p>If you are using PHP 4, you can take advantage of <a href="http://bugs.php.net/bug.php?id=43821" rel="nofollow noreferrer">this</a> bug. Off course that is a messy solution...</p> <p>Or you could just rename your mail.php file to something else...</p>
8,902
<p>I've been printing for a week now on my new printer and have been getting great results, including great adhesion. However, most of my prints have had a fairly small footprint.</p> <p>Now, I'm stepping up the types of items I'm printing, and I've started to run into a problem. Long, thin parts are starting to lift off the bed, especially at the edges of the bed.</p> <p>I've read <a href="https://3dprinting.stackexchange.com/questions/61/why-do-the-corners-of-my-abs-object-lift-off-the-bed">the question dealing with this issue with ABS</a> and realize some (most) could apply to me. However, I'm printing entirely in PLA on a non-heated bed.</p> <p>My question is: What is the best way to go about troubleshooting this problem? In which order should I attempt fixes to narrow down the problem most quickly?</p> <p>Printer: Monoprice Maker Architect 3D (Very similar to Makerbot)</p> <p>Material: PLA</p> <p>Heated Bed: No</p> <p>Bed Material: Something similar to BuildTak on top of an acrylic bed. (The sheet of material came unlabeled with the printer and I haven't been able to track down exactly what it is.)</p>
<p>There are several things you could try without spending much but even PLA will warp on an unheated bed. I had a Legacy Kossel that I switched to an acrylic bed and had many issues with warping and prints pulling off the bed. </p> <p>Some cheap things to try would be...</p> <ol> <li>Adding a brim to the print.</li> <li>Blue painters tape on the acrylic, remove the other material if doing this.</li> <li>Place cheap piece of glass/mirror on bed and use hairspray/gluestick.</li> <li>Use hairspray/gluestick directly on acrylic. You must be careful here because first layer height is very critical to prevent damage to the acrylic from the plastic welding. A layer of hairspray or glue should prevent it but dial in your height before printing.</li> <li>If you aren't currently using a fan, you could try sealing the sides to prevent drafts. I doubt this would change much since you are using PLA but it's an option.</li> <li>If these are your designs, there are steps you can take to reduce warping as seen <a href="http://hackaday.com/2011/11/15/a-technique-to-avoid-warping-on-large-3d-prints/">here.</a></li> </ol> <p>Also many other suggestions <a href="http://www.makerbot.com/blog/2011/06/23/12-ways-to-fight-warping-and-curling">here.</a></p>
<p>Try a dilute solution of PVA glue (approx. 5:1 water:PVA) applied to the bed or the BuildTak like sheet and allowed to dry. Keep the ambient temperature as high as possible (but not so high as to soften any plastic on the printer obviously). Big brims help - consider adding them to the model rather than just applying them in the slicer. I've used 12&nbsp;mm by 0.5&nbsp;mm deep circles to good effect, particularly on acutely angled parts of the model or the extremities.</p>
146
<p>Is there a method for handling errors from COM objects in RDML? For instance, when calling Word VBA methods like <code>PasteSpecial</code>, an error is returned and the LANSA application crashes. I cannot find anything in the documentation to allow handling of these errors.</p> <p>Actually, error handling in general is a weak-point for LANSA and RDML, but that's another topic.</p>
<blockquote> <ol> <li>Does anyone know of anyway to reduce/optimize the PDF export phase and or the size of the PDF without lowering the total page count?</li> </ol> </blockquote> <p>I have a few ideas and questions:<br> 1. Is this a graphics-heavy report? If not, do you have tables that start out as text but are converted into a graphic by the SSRS PDF renderer (check if you can select the text in the PDF)? 41K per page might be more than it should be, or it might not, depending on how information-dense your report is. But we've had cases where we had minor issues with a report's layout, like having a table bleed into the page's margins, that resulted in the SSRS PDF renderer "throwing up its hands" and rendering the table as an image instead of as text. Obviously, the fewer graphics in your report, the smaller your file size will be.<br> 2. Is there a way that you could easily break the report into pieces? E.g., if it's a 10-location report, where Location 1 is followed by Location 2, etc., on your final report, could you run the Location 1 portion independent of the Location 2 portion, etc.? If so, you could join the 10 sub-reports into one final PDF using <a href="http://pdfsharp.com/" rel="nofollow noreferrer">PDFSharp</a> after you've received them all. This leads to some difficulties with page numbering, but nothing insurmountable.</p> <blockquote> <p>3. Does anyone else have any other theories as to why this runs on the server but not through the API?</p> </blockquote> <p>My guess would be the sheer size of the report. I don't remember everything about what's an IIS setting and what's SSRS-specific, but there might be some overall IIS settings (maybe in Metabase.xml) that you would have to be updated to even allow that much data to pass through. </p> <p>You could isolate the question of whether the time is the problem by taking one of your working reports and building in a long wait time in your stored procedures with WAITFOR (assuming SQL Server for your DBMS).</p> <p>Not solutions, per se, but ideas. Hope it helps.</p>
<blockquote> <ol> <li>Does anyone know of anyway to reduce/optimize the PDF export phase and or the size of the PDF without lowering the total page count?</li> </ol> </blockquote> <p>I have a few ideas and questions:<br> 1. Is this a graphics-heavy report? If not, do you have tables that start out as text but are converted into a graphic by the SSRS PDF renderer (check if you can select the text in the PDF)? 41K per page might be more than it should be, or it might not, depending on how information-dense your report is. But we've had cases where we had minor issues with a report's layout, like having a table bleed into the page's margins, that resulted in the SSRS PDF renderer "throwing up its hands" and rendering the table as an image instead of as text. Obviously, the fewer graphics in your report, the smaller your file size will be.<br> 2. Is there a way that you could easily break the report into pieces? E.g., if it's a 10-location report, where Location 1 is followed by Location 2, etc., on your final report, could you run the Location 1 portion independent of the Location 2 portion, etc.? If so, you could join the 10 sub-reports into one final PDF using <a href="http://pdfsharp.com/" rel="nofollow noreferrer">PDFSharp</a> after you've received them all. This leads to some difficulties with page numbering, but nothing insurmountable.</p> <blockquote> <p>3. Does anyone else have any other theories as to why this runs on the server but not through the API?</p> </blockquote> <p>My guess would be the sheer size of the report. I don't remember everything about what's an IIS setting and what's SSRS-specific, but there might be some overall IIS settings (maybe in Metabase.xml) that you would have to be updated to even allow that much data to pass through. </p> <p>You could isolate the question of whether the time is the problem by taking one of your working reports and building in a long wait time in your stored procedures with WAITFOR (assuming SQL Server for your DBMS).</p> <p>Not solutions, per se, but ideas. Hope it helps.</p>
3,613
<p>I am trying to iterate over all the elements of a static array of strings in the best possible way. I want to be able to declare it on one line and easily add/remove elements from it without having to keep track of the number. Sounds really simple, doesn't it?</p> <p>Possible non-solutions:</p> <pre><code>vector&lt;string&gt; v; v.push_back("abc"); b.push_back("xyz"); for(int i = 0; i &lt; v.size(); i++) cout &lt;&lt; v[i] &lt;&lt; endl; </code></pre> <p>Problems - no way to create the vector on one line with a list of strings</p> <p>Possible non-solution 2:</p> <pre><code>string list[] = {"abc", "xyz"}; </code></pre> <p>Problems - no way to get the number of strings automatically (that I know of).</p> <p>There must be an easy way of doing this.</p>
<p>C++ 11 added initialization lists to allow the following syntax:</p> <pre><code>std::vector&lt;std::string&gt; v = {"Hello", "World"}; </code></pre> <p>Support for this C++ 11 feature was added in at least <a href="http://gcc.gnu.org/projects/cxx0x.html" rel="noreferrer">GCC 4.4</a> and only in <a href="https://msdn.microsoft.com/en-us/library/hh567368.aspx#corelanguagetable" rel="noreferrer">Visual Studio 2013</a>.</p>
<pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &lt;boost/assign/list_of.hpp&gt; int main() { const std::vector&lt; std::string &gt; v = boost::assign::list_of( "abc" )( "xyz" ); std::copy( v.begin(), v.end(), std::ostream_iterator&lt; std::string &gt;( std::cout, "\n" ) ); } </code></pre>
5,540
<p>I have a Monoprice Maker Ultimate 3D printer (a rebranded Wanhao Duplicator 6) and out of the box the hotend temps when set to 200 would vary between 190 and 210. I used repetier-host to run <a href="https://reprap.org/wiki/PID_Tuning" rel="nofollow noreferrer">PID tuning</a> and stored the last set of values it gave when it finished, however I'm still seeing around 5 degree temp swings.</p> <p>Here's a screenshot of the temp during a Benchy print from Octoprint:</p> <p><a href="https://i.stack.imgur.com/I3HxO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I3HxO.png" alt="Temperature swings"></a></p> <p>I tried PID tuning again, which gave different values, but basically the same results. Is there anything I can do to improve this? The Maker Select Plus I had only seemed to vary +/- 1 degree so I'm assuming this is more than expected. (I don't actually know what the implications are, so I don't know whether it is/will affect my print quality).</p> <p>Is there another way of tuning (I don't fancy manually tweaking numbers and testing for hours), or if I do more than 8 cycles (the default on the Wiki page linked above) would that improve the accuracy?</p>
<p>If you are sure that PID is enabled (and not using bang-bang heating, as this gives a very similar heating profile) and did not fix the fluctuations, the best guess for this phenomenon is that the printer board has incorrect capacitors installed on the printer board. This is not very uncommon and can be found on the internet. You should at least show the graph to the vendor and ask for support.</p> <p>If incorrect or faulty capacitors are the cause it requires desoldering, and resoldering new ones. If this is out of your comfort zone, it is better to steer your communication with the vendor to replacing the board.</p>
<h1>Software</h1> <p>You might want to look at your firmware. When running a PID tune, the firmware decides on a smoothing.</p> <p>in Marlin, <code>configuration.h</code> contains a line that determines how much the machine shall try to work out the curves. For my ender 3 it reads:</p> <pre><code>#define PID_K1 0.95 // Smoothing factor within the PID </code></pre> <p>Playing with the value carefully might result in better calibration.</p> <h1>Hardware</h1> <p>A different trick to <em>widen</em> the waves might come from adjusting the physical properties of the printer:</p> <ul> <li>Make sure that no draft from the cool end fans runs over the heater block. If it does, a shroud or a little tinfoil can help to dampen the changes.</li> <li>e3D uses a silicon sock to isolate their heater blocks and prevent air drafting over them.</li> </ul>
1,130
<p>I want to search for files containing DOS line endings with grep on Linux. Something like this:</p> <pre class="lang-sh prettyprint-override"><code>grep -IUr --color '\r\n' . </code></pre> <p>The above seems to match for literal <code>rn</code> which is not what is desired.</p> <p>The output of this will be piped through xargs into todos to convert crlf to lf like this</p> <pre><code>grep -IUrl --color '^M' . | xargs -ifile fromdos 'file' </code></pre>
<p>grep probably isn't the tool you want for this. It will print a line for every matching line in every file. Unless you want to, say, run todos 10 times on a 10 line file, grep isn't the best way to go about it. Using find to run file on every file in the tree then grepping through that for "CRLF" will get you one line of output for each file which has dos style line endings:</p> <pre><code>find . -not -type d -exec file "{}" ";" | grep CRLF</code></pre> <p>will get you something like:</p> <pre><code>./1/dos1.txt: ASCII text, with CRLF line terminators ./2/dos2.txt: ASCII text, with CRLF line terminators ./dos.txt: ASCII text, with CRLF line terminators</code></pre>
<p>If, like me, your minimalist unix doesn't include niceties like the <strong>file</strong> command, and backslashes in your <strong>grep</strong> expressions just don't cooperate, try this:</p> <pre><code>$ for file in `find . -type f` ; do &gt; dump $file | cut -c9-50 | egrep -m1 -q ' 0d| 0d' &gt; if [ $? -eq 0 ] ; then echo $file ; fi &gt; done </code></pre> <p>Modifications you may want to make to the above include:</p> <ul> <li>tweak the <strong>find</strong> command to locate only the files you want to scan</li> <li>change the <strong>dump</strong> command to <strong>od</strong> or whatever file dump utility you have</li> <li>confirm that the <strong>cut</strong> command includes both a leading and trailing space as well as just the hexadecimal character output from the <strong>dump</strong> utility</li> <li>limit the <strong>dump</strong> output to the first 1000 characters or so for efficiency</li> </ul> <p>For example, something like this may work for you using <strong>od</strong> instead of <strong>dump</strong>:</p> <pre><code> od -t x2 -N 1000 $file | cut -c8- | egrep -m1 -q ' 0d| 0d|0d$' </code></pre>
9,952
<p>I am working on a site where users can login to get more private information. My client has another site else where that uses <em>nt authentication</em> for accessing it.</p> <p>What they want to do is have a <code>button</code> on the site I am working on under the private area that will send them to the <em>nt authenticated</em> site, but not require them to log on to that site instead passing the <em>username</em> and <em>password</em> that they used to log into my site to the other site for them.</p> <p>Is it possible to do this? and how would I accomplish it? Is there a better way to do this?</p>
<p>Here's an (untested) theory, the details of which will greatly depend on what types of authentication the Sharepoint site will accept. I'll tackle <a href="http://en.wikipedia.org/wiki/Basic_access_authentication" rel="nofollow noreferrer">Basic</a>, since it's the easiest.</p> <p>You'll write out some JavaScript that uses XMLHttpRequest to submit a request to the Sharepoint site, and add their username and password to the request headers. Their browser will run that JavaScript, and get logged into the Sharepoint site.</p> <p>Now, when they click the link, the client's browser should have the cached credentials to send to the Sharepoint site.</p> <p>Possible issues:</p> <ul> <li>XMLHttpRequest does not allow cross domain auth</li> <li>Browser and XHR don't share auth info</li> <li>Sharepoint and XHR can't agree on auth method</li> </ul> <p>Another option is to proxy the connection to Sharepoint, which allows you to login server side (bypassing XHR limitations and browser security) - but requiring load on your server and possibly some URL target issues.</p>
<p>How will the other site validate your username and password?</p> <p>Ideally your site shouldn't even be remembering the user's password to be able to pass it to another site (you store hashes of the password, not the password itself, and only use the actually password during validation).</p> <p>What if your site provided a token to the user, who presents that token to the new site, which in turn asks your site to validate the token. Basically the second site is trusting you to tell them who the user is.</p> <p>This all breaks down if the second site is actually using the Windows accounts for anything other than just retrieving a user name (for example permissions on the underlying file), since the user is not logged on as the actual Windows user account in this scenario.</p>
6,576
<p>I am looking for a very fast way to filter down a collection in C#. I am currently using generic <code>List&lt;object&gt;</code> collections, but am open to using other structures if they perform better.</p> <p>Currently, I am just creating a new <code>List&lt;object&gt;</code> and looping thru the original list. If the filtering criteria matches, I put a copy into the new list.</p> <p>Is there a better way to do this? Is there a way to filter in place so there is no temporary list required?</p>
<p>If you're using C# 3.0 you can use linq, which is way better and way more elegant:</p> <pre class="lang-c# prettyprint-override"><code>List&lt;int&gt; myList = GetListOfIntsFromSomewhere(); // This will filter ints that are not &gt; 7 out of the list; Where returns an // IEnumerable&lt;T&gt;, so call ToList to convert back to a List&lt;T&gt;. List&lt;int&gt; filteredList = myList.Where(x =&gt; x &gt; 7).ToList(); </code></pre> <p>If you can't find the <code>.Where</code>, that means you need to import <code>using System.Linq;</code> at the top of your file.</p>
<p>If your list is very big and you are filtering repeatedly - you can sort the original list on the filter attribute, binary search to find the start and end points.</p> <p>Initial time O(n*log(n)) then O(log(n)).</p> <p>Standard filtering will take O(n) each time.</p>
4,581
<p>I'm trying to implement some drag and drop functionality for a material system being developed at my work. Part of this system includes a 'Material Library' which acts as a repository, divided into groups, of saved materials on the user's hard drive.</p> <p>As part of some UI polish, I was hoping to implement a 'highlight' type feature. When dragging and dropping, windows that you can legally drop a material onto will very subtly change color to improve feedback to the user that this is a valid action.</p> <p>I am changing the bar with 'Basic Materials' (Just a CWnd with a CStatic) from having a medium gray background when unhighlighed to a blue background when hovered over. It all works well, the OnDragEnter and OnDragExit messages seem robust and set a flag indicating the highlight status. Then in OnCtrlColor I do this:</p> <pre><code> if (!m_bHighlighted) { pDC-&gt;FillSolidRect(0, 0, m_SizeX, kGroupHeaderHeight, kBackgroundColour); } else { pDC-&gt;FillSolidRect(0, 0, m_SizeX, kGroupHeaderHeight, kHighlightedBackgroundColour); } </code></pre> <p>However, as you can see in the screenshot, the painting 'glitches' below the dragged object, leaving the original gray in place. It looks really ugly and basically spoils the whole effect.</p> <p>Is there any way I can get around this?</p>
<p>Remote debugging is a godsend for debugging visual issues. It's a pain to set up, but having a VM ready for remote debugging will pay off for sure.</p> <p>What I like to do is set a ton of breakpoints in my paint handling, as well as in the framework paint code itself. This allows you to effectively "freeze frame" the painting without borking it up by flipping into devenv. This way you can get the true picture of who's painting in what order, and where you've got the chance to break in a fill that rect the way you need to.</p>
<p>It almost looks like the CStatic doesn't know that it needs to repaint itself, so the background color of the draggable object is left behind. Maybe try to invalidate the CStatic, and see if that helps at all?</p>
9,998
<p>If I have a Perl hash with a bunch of (key, value) pairs, what is the preferred method of iterating through all the keys? I have heard that using <code>each</code> may in some way have unintended side effects. So, is that true, and is one of the two following methods best, or is there a better way?</p> <pre><code># Method 1 while (my ($key, $value) = each(%hash)) { # Something } # Method 2 foreach my $key (keys(%hash)) { # Something } </code></pre>
<p>The rule of thumb is to use the function most suited to your needs.</p> <p>If you just want the keys and do not plan to ever <em>read</em> any of the values, use keys():</p> <pre><code>foreach my $key (keys %hash) { ... } </code></pre> <p>If you just want the values, use values():</p> <pre><code>foreach my $val (values %hash) { ... } </code></pre> <p>If you need the keys <em>and</em> the values, use each():</p> <pre><code>keys %hash; # reset the internal iterator so a prior each() doesn't affect the loop while(my($k, $v) = each %hash) { ... } </code></pre> <p>If you plan to change the keys of the hash in any way <em>except</em> for deleting the current key during the iteration, then you must not use each(). For example, this code to create a new set of uppercase keys with doubled values works fine using keys():</p> <pre><code>%h = (a =&gt; 1, b =&gt; 2); foreach my $k (keys %h) { $h{uc $k} = $h{$k} * 2; } </code></pre> <p>producing the expected resulting hash:</p> <pre><code>(a =&gt; 1, A =&gt; 2, b =&gt; 2, B =&gt; 4) </code></pre> <p>But using each() to do the same thing:</p> <pre><code>%h = (a =&gt; 1, b =&gt; 2); keys %h; while(my($k, $v) = each %h) { $h{uc $k} = $h{$k} * 2; # BAD IDEA! } </code></pre> <p>produces incorrect results in hard-to-predict ways. For example:</p> <pre><code>(a =&gt; 1, A =&gt; 2, b =&gt; 2, B =&gt; 8) </code></pre> <p>This, however, is safe:</p> <pre><code>keys %h; while(my($k, $v) = each %h) { if(...) { delete $h{$k}; # This is safe } } </code></pre> <p>All of this is described in the perl documentation:</p> <pre><code>% perldoc -f keys % perldoc -f each </code></pre>
<p>I woudl say:</p> <ol> <li>Use whatever's easiest to read/understand for most people (so keys, usually, I'd argue)</li> <li>Use whatever you decide consistently throught the whole code base. </li> </ol> <p>This give 2 major advantages:</p> <ol> <li>It's easier to spot "common" code so you can re-factor into functions/methiods.</li> <li>It's easier for future developers to maintain.</li> </ol> <p>I don't think it's more expensive to use keys over each, so no need for two different constructs for the same thing in your code.</p>
2,517
<p>A few months back I was tasked with implementing a unique and random code for our web application. The code would have to be user friendly and as small as possible, but still be essentially random (so users couldn't easily predict the next code in the sequence).</p> <p>It ended up generating values that looked something like this:</p> <pre><code>Af3nT5Xf2 </code></pre> <p>Unfortunately, I was never satisfied with the implementation. Guid's were out of the question, they were simply too big and difficult for users to type in. I was hoping for something more along the lines of 4 or 5 characters/digits, but our particular implementation would generate noticeably patterned sequences if we encoded to less than 9 characters.</p> <p>Here's what we ended up doing:</p> <p>We pulled a unique sequential 32bit id from the database. We then inserted it into the center bits of a 64bit RANDOM integer. We created a lookup table of easily typed and recognized characters (A-Z, a-z, 2-9 skipping easily confused characters such as L,l,1,O,0, etc.). Finally, we used that lookup table to base-54 encode the 64-bit integer. The high bits were random, the low bits were random, but the center bits were sequential.</p> <p>The final result was a code that was much smaller than a guid and looked random, even though it absolutely wasn't.</p> <p>I was never satisfied with this particular implementation. What would you guys have done?</p>
<p>In .NET you can use the RNGCryptoServiceProvider method GetBytes() which will "fill an array of bytes with a cryptographically strong sequence of random values" (from ms documentation).</p> <pre><code>byte[] randomBytes = new byte[4]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetBytes(randomBytes); </code></pre> <p>You can increase the lengh of the byte array and pluck out the character values you want to allow.</p>
<p>If by user friendly, you mean that a user could type the answer in then I think you would want to look in a different direction. I've seen and done implementations for initial random passwords that pick random words and numbers as an easier and less error prone string. </p> <p>If though you're looking for a way to encode a random code in the URL string which is an issue I've dealt with for awhile then I what I have done is use 64-bit encoded GUIDs.</p>
5,504
<p>Prefixing variable and method names with an underscore is a common convention for marking things as private. Why does all the methods on the page tracker class in the Google Analytics tracking code (<code>ga.js</code>) start with an underscore, even the ones that are clearly public, like <code>_getTracker</code> and <code>_trackPageView</code>?</p>
<p>Because Google can't be bothered to follow the <a href="http://yuiblog.com/blog/2007/06/12/module-pattern/" rel="noreferrer">Module Pattern</a> and therefore they don't want accidental collisions in the global namespace?</p>
<p>I've always read this like so:</p> <p>If the property/method is prefixed with an underscore, it is for some "internal" workings. Therefore if you are about to use/call/alter this property/method, you had better darn well know what you are doing, and or expect it to possibly be renamed/removed in a future release.</p>
8,407
<p>I have a set of base filenames, for each name 'f' there are exactly two files, 'f.in' and 'f.out'. I want to write a batch file (in Windows XP) which goes through all the filenames, for each one it should:</p> <ul> <li>Display the base name 'f'</li> <li>Perform an action on 'f.in'</li> <li>Perform another action on 'f.out'</li> </ul> <p>I don't have any way to list the set of base filenames, other than to search for *.in (or *.out) for example.</p>
<p>Assuming you have two programs that process the two files, process_in.exe and process_out.exe:</p> <pre><code>for %%f in (*.in) do ( echo %%~nf process_in "%%~nf.in" process_out "%%~nf.out" ) </code></pre> <p>%%~nf is a substitution modifier, that expands %f to a file name only. See other modifiers in <a href="https://technet.microsoft.com/en-us/library/bb490909.aspx" rel="noreferrer">https://technet.microsoft.com/en-us/library/bb490909.aspx</a> (midway down the page) or just in the next answer.</p>
<p>Echoing f.in and f.out will seperate the concept of what to loop and what not to loop when used in a for /f loop.</p> <pre><code>::Get the files seperated echo f.in&gt;files_to_pass_through.txt echo f.out&gt;&gt;files_to_pass_through.txt for /F %%a in (files_to_pass_through.txt) do ( for /R %%b in (*.*) do ( if "%%a" NEQ "%%b" ( echo %%b&gt;&gt;dont_pass_through_these.txt ) ) ) ::I'm assuming the base name is the whole string "f". ::If I'm right then all the files begin with "f". ::So all you have to do is display "f". right? ::But that would be too easy. ::Let's do this the right way. for /f %%C in (dont_pass_through_these.txt) ::displays the filename and not the extention echo %~nC ) </code></pre> <p>Although you didn't ask, a good way to pass commands into f.in and f.out would be to...</p> <pre><code>for /F %%D "tokens=*" in (dont_pass_through_these.txt) do ( for /F %%E in (%%D) do ( start /wait %%E ) ) </code></pre> <p>A link to all the Windows XP commands:<a href="https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true" rel="nofollow noreferrer">link</a></p> <p>I apologize if I did not answer this correctly. The question was very hard for me to read.</p>
6,071
<p>So in my simple learning website, I use the built in ASP.NET authentication system. </p> <p>I am adding now a user table to save stuff like his zip, DOB etc. My question is:</p> <ol> <li>In the new table, should the key be the user name (the string) or the user ID which is that GUID looking number they use in the <code>asp_ tables</code>. </li> <li>If the best practice is to use that ugly guid, does anyone know how to get it? it seems to not be accessible as easily as the name (<code>System.Web.HttpContext.Current.User.Identity.Name</code>)</li> <li>If you suggest I use neither (not the guid nor the userName fields provided by ASP.NET authentication) then how do I do it with ASP.NET authentication? One option I like is to use the email address of the user as login, but how to I make ASP.NET authentication system use an email address instead of a user name? (or there is nothing to do there, it is just me deciding I "know" userName is actually an email address?</li> </ol> <p>Please note:</p> <ul> <li>I am not asking on how get a GUID in .NET, I am just referring to the userID column in the <code>asp_ tables</code> as guid.</li> <li>The user name is unique in ASP.NET authentication.</li> </ul>
<p>You should use some unique ID, either the GUID you mention or some other auto generated key. However, this number should never be visible to the user.</p> <p>A huge benefit of this is that all your code can work on the user ID, but the user's name is not really tied to it. Then, the user can change their name (which I've found useful on sites). This is especially useful if you use email address as the user's login... which is very convenient for users (then they don't have to remember 20 IDs in case their common user ID is a popular one).</p>
<p>I agree with Mike Stone. I would also suggest only using a GUID in the event you are going to be tracking an enormous amount of data. Otherwise, a simple auto incrementing integer (Id) column will suffice.</p> <p>If you do need the GUID, .NET is lovely enough that you can get one by a simple...</p> <pre><code>Dim guidProduct As Guid = Guid.NewGuid() </code></pre> <p>or</p> <pre><code>Guid guidProduct = Guid.NewGuid(); </code></pre>
2,689
<p>I've been asked to help out on an XNA project with the AI. I'm not totally new to the concepts (pathfinding, flocking, etc.) but this would be the first "real" code. I'd be very thankful for any resources (links or books); I want to make sure I do this right.</p>
<p>The standard textbook and a great place to start is Russel and Norvig's <a href="https://rads.stackoverflow.com/amzn/click/com/0137903952" rel="noreferrer" rel="nofollow noreferrer"><em>Artificial Intelligence: A Modern Approach</em></a>. You can also get <a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-034Spring-2005/CourseHome/" rel="noreferrer">MIT's Intro AI course</a> via <a href="http://ocw.mit.edu/" rel="noreferrer">OpenCourseWare</a></p>
<p>I would second: Programming Game AI by example (Matt Buckland) </p> <p>This book gives great algorithms that should easly port to XNA.</p>
4,443
<p>After noticing that my ender 3 couldn't print a 'perfect' circle I decided to use a <a href="https://www.thingiverse.com/thing:1278865" rel="nofollow noreferrer">calibration cube</a> to see if that could be the issue. These were my results:</p> <p><a href="https://i.stack.imgur.com/OHJOF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OHJOF.jpg" alt="X Y Z" /></a></p> <p>I did have some successful prints before noticing these problems but it would be great if anyone could help/find a solution.</p> <p>I think it may be because of the belts tension as I had accidentally over stretched it by putting it over the wheels instead of under: is it worth getting a new belt then?</p> <p>I use 20% infill, with triangle pattern in cura, using the standard 0.4mm nozzle.</p> <h1>Edit</h1> <p>After doing a <a href="https://www.thingiverse.com/thing:3090144" rel="nofollow noreferrer">different testprint</a> and measuring, it revealed that both had an accurate 20mm Y and Z, but only an 18.5mm X. Might I have destroyed my belt when I mounted it overstrained?</p> <h1>Edit2:</h1> <p>After purchasing a new X belt, the calibration cube was much closer at 19 x 20 x 20. But still not at a good enough tolerance for my liking. Additionally, when printing a cylinder, two relatively flat edges were printed with it either side (perpendicular to the x-axis).</p>
<p>Your top layer looks like you need to add additional top layers and there are signs of a slight bit of over-extrusion in that top layer (red). On the other hand, it looks like the top layer is not sliced nicely resulting in gaps and holes (yellow), which might be a fault of the test print.</p> <p><a href="https://i.stack.imgur.com/pJooa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pJooa.jpg" alt="Z, defects marked" /></a></p> <p>The X on the file you used is not centered, resulting in the off look in the print.</p> <p>I suggest you try a different calibration print before starting to tinker with the hardware, for example <a href="https://www.thingiverse.com/thing:3090144" rel="nofollow noreferrer">this</a>.</p> <p>I suggest to use concentric only for the top layers and instead rely on a simple Zig-Zag pattern for the intermediate layers, as this usually generates a better connection to straight walls.</p> <h1>EDIT1:</h1> <p>After considering the miss-dimension in X only, you might want to look to <a href="https://3dprinting.stackexchange.com/questions/3344/calibrating-steps-order">calibrate your X steps</a>.</p> <p>The stretching of the belt might be an issue, but you might get away <em>easy</em> if you just check belt tension and manage to get it right again.</p> <p>As I have an ender-3 myself, I know you might need to <a href="https://3dprinting.stackexchange.com/questions/6399/recalibrating-home-position">flash</a> <a href="https://3dprinting.stackexchange.com/questions/6657/export-firmware-as-a-hex?noredirect=1&amp;lq=1">fresh</a> firmware to get the ability to change the steps/mm.</p> <h1>EDIT2:</h1> <p>The 19x20x20mm cube sounds like the new belt did fix a lot of the dimensioning problem, but the steps/mm might be slightly off - or we have to trace down SOME mechanical error in the movement path. As a 140mm long test print also had a 1mm offset, a steps/mm error should be out.</p> <p>After examining the machine with jb <a href="https://chat.stackexchange.com/rooms/83007/ender-3-calibration-cube-fail">in chat</a>, the bearing on the X-belt seemed to stick a tiny bit on one side.</p> <p><a href="https://i.stack.imgur.com/qTjdg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qTjdg.jpg" alt="Ender3 X-tightener/bearing" /></a></p> <p>Turning the large bolt of the assembly in an attempt to disassemble it without a wrench to hold the self-securing nut on the far side seemed enough to lessen the pressure on the core of the bearing, allowing it to spin freely. In addition, the belt was a little loose.</p>
<p>First, check that the calibration part you have is actually a cube. Maybe you downloaded a trick 'calibration cube' model. Cura will show he overall dimensions of any model which it is slicing.</p> <p>Ignore any print quality issues first off. A hollow calibration cube is mainly used to check the X/Y/Z motion and so long as you print at a sensible (slow) speed), the other parameters shouldn't have much effect (so long as the first layer is OK, and you get within 30% of the right extrusion).</p> <p>If the calibration cube is within +/- 0.5mm on each side, it's probably good. Under/over extrusion, caliper technique, etc, can explain this sort of variation, and you might want to use a bigger test part like <a href="https://www.thingiverse.com/thing:2566871" rel="nofollow noreferrer">this star on my thingiverse account</a> once you think you're close.</p> <p>The 'steps per mm' setting is determined within the firmware, it is part of how your printer consumes G-code. For a delta printer, for example, there is some fancy maths to combine X/Y/Z into the motor movements. This means that you can't change steps/mm in Cura, you need to either change the firmware defaults and 'reset to factory settings', or modify the parameters in EEPROM by sending G-code.</p> <p>Seeing too small a calibration part (for a Cartesian printer) can easily be explained by problems in the printer's motion system:</p> <ul> <li>Stepper missing steps due to jerk or acceleration too high</li> <li>Stepper missing steps due to binding/friction in the bearings (Send <code>M84</code> to idle the stepper motor, and move X by hand)</li> <li>Teeth missing on the drive belt (may show up on a diagonal 'bar' print)</li> <li>Loose drive pinion (maybe backlash on the flat on the spindle means the problem is greater on small parts) - see below</li> <li>Flex in the drive mechanism (e.g. belt mount to traveller is loose)</li> </ul> <p>An annoying feature of a lot of these problems is that for any particular repetitive sequence of steps, you might see a very consistent result. Even thought to problem is something being badly adjusted, it gives the impression that the problem is calibration.</p> <p>The drive wheel is held in place with a grub screw, see this diagram from the Anet-A8 assembly diagram.</p> <p><a href="https://i.stack.imgur.com/1C3fcb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1C3fcb.png" alt="Anet X-drive"></a></p>
1,034
<p>So, I am a total beginner in any kind of <code>Windows</code> related programming. I have been playing around with the <code>Windows</code> <code>API</code> and came across a couple of examples on how to initialize create windows and such. </p> <p>One example creates a regular window (I abbreviated some of the code):</p> <pre><code>int WINAPI WinMain( [...] ) { [...] // Windows Class setup wndClass.cbSize = sizeof( wndClass ); wndClass.style = CS_HREDRAW | CS_VREDRAW; [...] // Register class RegisterClassEx( &amp;wndClass ); // Create window hWnd = CreateWindow( szAppName, "Win32 App", WS_OVERLAPPEDWINDOW, 0, 0, 512, 384, NULL, NULL, hInstance, NULL ); [...] } </code></pre> <p>The second example creates a dialog box (no abbreviations except the WinMain arguments):</p> <pre><code>int WINAPI WinMain( [...] ) { // Create dialog box DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, (DLGPROC)DialogProc); } </code></pre> <p>The second example does not contain any call to the register function. It just creates the DialogBox with its DialogProc process attached. </p> <p>This works fine, but I am wondering if there is a benefit of registering the window class and then creating the dialog box (if this is at all possible). </p>
<p>I would say exposing properties on your custom dialog is the idiomatic way to go because that is how standard dialogs (like the Select/OpenFileDialog) do it. Someone could argue it is more explicit and intention revealing to have a ShowBirthdayDialog() method that returns the result you're looking for, but following the framework's pattern is probably the wise way to go.</p>
<p>I've always done it exactly the way you're describing. I'm curious to see if there's a more accepted approach.</p>
5,761
<p>How to get the phone number of the device in Symbian?</p>
<p>According to the GSM specs, only the <a href="http://en.wikipedia.org/wiki/IMSI" rel="nofollow noreferrer">IMSI</a> is required to be available on the <a href="http://en.wikipedia.org/wiki/Subscriber_Identity_Module#Data" rel="nofollow noreferrer">SIM</a> card.</p> <p>The actual phone number <a href="http://en.wikipedia.org/wiki/MSISDN" rel="nofollow noreferrer">MSISDN</a> is stored on the <a href="http://en.wikipedia.org/wiki/GSM_core_network#Home_Location_Register_.28HLR.29" rel="nofollow noreferrer">HLR</a> database in the operator's network and does not need to be available on the SIM card or transmitted to the phone.</p> <p>So no matter what technology you are using (Symbina, Java ...) you can never count on being able to consistently get your own phone number from the device or SIM. You might be lucky if the operator stores it on the SIM or if the phone provides the user with a possibility to enter it manually, but it does not have to be this way.</p>
<p>You can't. Afaik.</p> <p>Check this discussion: <a href="http://discussion.forum.nokia.com/forum/showthread.php?t=65117" rel="nofollow noreferrer">http://discussion.forum.nokia.com/forum/showthread.php?t=65117</a></p>
8,534
<p>Many 3D printers employ a GT2 band for the <em>y</em>-axis plate and the printhead in the <em>x</em>-axis carriage.</p> <p>However, there seems to be the obvious disadvantages of:</p> <ul> <li>stretching (and need for adjustment) and;</li> <li>possibly slight inaccuracy, or &quot;wobble&quot; (for want of a better word (as wobble is often used in describing <em>z</em>-axis deviations)), due to the elasticity of the band.</li> </ul> <p>Is there any particular reason why GT2 is used over a straight forward rack and pinion system?</p> <p><a href="https://i.stack.imgur.com/EUTlt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EUTlt.jpg" alt="Rack and pinion" /></a></p> <p>In particular, for the <em>y</em>-axis plate, as a rack would appear to me, be:</p> <ul> <li>easy to install;</li> <li>more accurate, and;</li> <li>require a lot less adjustment<sup>1</sup>.</li> </ul> <p>If the rack is made from aluminium, surely <em>weight</em> can not be a major factor... or can it?</p> <p>Is <em>cost</em> a factor? A pinion seems to cost around \$10-\$15 (650 B\$, here in BKK, Thailand), which is obviously more than a reel of GT2 and a couple of GT2 pulleys.</p> <p>Would the <em>rigidity</em> of the rack be less forgiving of an imperfectly aligned axis, something which the GT2 band and pulleys combination would not be so affected by?</p> <hr /> <h3>TL;DR</h3> <p>Which of these factors cause designers to use GT2 en lieu of a rack?</p> <ul> <li>Accuracy</li> <li>Weight</li> <li>Cost</li> <li>Maintenance</li> <li>Tolerence of non-square axes, manufacturing errors.</li> </ul> <hr /> <p><sup>1</sup> Maybe constant adjustment is not required on an everyday basis, but the tension would still need to be checked now and again, whereas a pinion would not have this requirement.</p>
<p>With a belt system, the belt engages roughly half the pulley. This, and the tension in the belt, ensures the belt always engages the pulley tightly. A belt and pulley system is thus relatively forgiving.</p> <p>With a rack and pinion system, only a few teeth engage at any given time. To avoid backlash and get the same kind of "tight" engagement, both the gear and the rack need to be made with very high precision. The carriage also needs to be very well constrained, because any wobble of the rack relative to the gear introduces backlash (or binding). Moreover, you also need to keep the rack and pinion well lubricated lest they wear out prematurely.</p> <p>Given that belt and pulley work well enough, I don't see why you'd need to move to rack and pinion. The main advantage of rack and pinion is that the rack isn't elastic. The maximum length of a belt system is limited by its elasticity, but given we aren't building meter-long 3D printers anyway, that advantage of rack and pinion does not apply.</p>
<p>The answer so others can understand is that it's cheap and simple to run with a belt. Much of the 3D printers these days either stem from the sintering systems that were developed years ago and things that rose out of the RepRap community where a Lead Screw that had the precision needed to do proper 3D printing at decent speeds was out of reach for most of the community.</p> <p>It's a bit of, &quot;we've always used belts,&quot; and then people come up with all sorts of stories to validate the dubious take to begin with.</p> <p>At one point in time (to be specific...around a couple of years BEFORE the question was asked here...) the costs of a lead/belt-screw system for anything other than a Z axis solution for a Cartesian or a Core-XY was prohibitive for a hobbyist or a system bought off shelf or build by them.</p> <p>It was too hard and expensive to get straight enough parts with precision to actually make anything other than small toy systems with those. We wouldn't get into racks as they were even MORE expensive. With the precisions we were previously working on and with in the community at the time this question was originally posed, it was something that only made sense for select solutions.</p> <p>As you scale larger (Hey, we're now professionally making HUGE parts with this stuff) it makes much, much more sense. For certain classes of manufacturing...it actually makes sense with certain filaments to make short run parts for almost ANYTHING, including things in the automotive space. At that juncture, prototyping, fixing &quot;impossible&quot; to repair situations on older cars, etc. makes some sense to get more precision or vastly larger size. Desireable becomes the ability to make printers with volumes up to 2 meters in size. Professional space? Maybe. But telling people that a pinion isn't making any sense? Heh...hardly. Same goes for lead/ball-screws. Several have made incredible printers fairly cheaply that can print seemingly impossible print runs (Hung at a 45 degree angle in mid air and print...) with some of this stuff. Is it cheaper? No. Does it make sense? Possibly. Especially if one wants to DIY a massive print volume printer (<em><strong>waves hand</strong></em>). I want a meter and a half cubed on a side print volume that I can enclose to crank out ASA prints of Smart body panels, for example... You're not getting that with belts- too stretchy, even with PU steel core belts.</p> <p>Frame it in from a relative cost perspective (It's only going to be about 25% more costly on a DIY or commercial product with a speed upside and precision that might make it WORTH that...but understand that an Ender 3 designed that way will run 350 dollars instead of the 200 or thereabouts it currently runs) and you're going to be more realistic and honest on the question's answer. Saying it isn't practical...even from when the post originated isn't being exactly forthright in this day and age- and disregards that a person MIGHT just be willing to spend the more money for the precision, etc.</p>
509
<p>I want to print the following model on my Kobra Max using ABS.</p> <p>I have uploaded it <a href="https://drive.google.com/file/d/1XMasuTVzg3MCHDd3Txi7sb-pUqEzPtE0/view?usp=sharing" rel="nofollow noreferrer">here</a>.</p> <p><a href="https://i.stack.imgur.com/H0zNf.jpg" rel="nofollow noreferrer" title="Screenshot of the Cura preview for a 3D model"><img src="https://i.stack.imgur.com/H0zNf.jpg" alt="Screenshot of the Cura preview for a 3D model" title="Screenshot of the Cura preview for a 3D model" /></a></p> <p>I have tried it 3 times now, it always results in this:</p> <p><a href="https://i.stack.imgur.com/SoZMu.png" rel="nofollow noreferrer" title="Photo of the printed model on the build plate with corners curled up"><img src="https://i.stack.imgur.com/SoZMu.png" alt="Photo of the printed model on the build plate with corners curled up" title="Photo of the printed model on the build plate with corners curled up" /></a></p> <p>As you can see, one part managed to break free from the support and warped upwards. At this point, I had to stop the print process.</p> <p>The element which broke free really has a strong will to bend.</p> <p>What could I do in this case?</p> <p>These are my print settings; bed temperature is 80 °C, and nozzle temperature is 195 °C.</p> <p><a href="https://i.stack.imgur.com/7EaSA.png" rel="nofollow noreferrer" title="Screenshot of the Travel and Build Plate Adhesion settings in Cura"><img src="https://i.stack.imgur.com/7EaSA.png" alt="Screenshot of the Travel and Build Plate Adhesion settings in Cura" title="Screenshot of the Travel and Build Plate Adhesion settings in Cura" /></a></p>
<blockquote> <p>What is this called</p> </blockquote> <p>This is called <strong>warping</strong>.</p> <p>Warping of prints occurs frequently when you use a filament that shrinks. If the model would shrink uniformly, it will become smaller, like in a scaled version (unfortunately, the print is attached somewhere, which causes stresses in the first layers). But, if (due to the geometry of the print) some part of the model shrinks more, the model warps. It could then bend upwards from the build plate, deform at higher layers or sometimes even crack (e.g. in between layers).</p> <blockquote> <p>and how do I avoid it?</p> </blockquote> <ul> <li>A high(er) build plate temperature</li> <li>Not use a filament that is prone to shrink, e.g. ABS is frequently replaced by PETG/NGEN/some other Co-polymer nowadays</li> <li>Decent adhesion by using everything you can image to get the filament to stick to the build platform: <ul> <li>A rough build plate surface, like e.g. BuildTak or equivalent</li> <li>An adhesive like glue stick or specific sprays like Dimafix or equivalent</li> <li>A slurry of ABS and acetone</li> </ul> </li> <li>Use an enclosure to raise the temperature of the build volume</li> <li>If an enclosure is impossible, use a draft shied (basically a multi layer skirt which creates a sort of a mini enclosure)</li> <li>Use a raft</li> <li>Don't use part fan cooling</li> </ul>
<p>You are getting warping. It's unusual in this case, as your overall model is relatively low profile. It's the taller stuff that likes to warp.</p> <p>Consider to edit your post to include the layer heights and also the filament type and filament and bed temperatures. My first instinct is that your bed temperature is too low. There's little harm to be had by raising the temperature by ten degrees or so. Also if your slicer arbitrarily reduces the bed temperature after the first layers, disable that feature. There's no sense to set a good adhesion temperature on a print and later reduce it, yet I've seen slicer results that do just that.</p> <p>Too cold filament by a substantial amount can also reduce the adhesion in combination with a too low bed temperature.</p> <p>If you still run into adhesion problems, the Elmer's Purple Glue Stick works wonders.</p> <p>With the new information comes new responses:</p> <p>For ABS, 80 °C is on the low end for the bed, but may work. The extruder temp is really low for ABS. I run 250 °C for ABS. Also ensure some form of enclosure, even a cardboard box will help. I've accidentally fed ABS into a PLA profile. The results were surprisingly good, although warping was prevalent and some underextrusion was evident.</p> <p>If you have a glass bed, you will very much want to use glue stick, as a release agent, not as an adhesive. ABS sticks really well to clean glass, well enough that it will pull fragments of glass from the surface!</p>
2,205
<p>I'm in the process of weeding out all hardcoded values in a Java library and was wondering what framework would be the best (in terms of zero- or close-to-zero configuration) to handle run-time configuration? I would prefer XML-based configuration files, but it's not essential. </p> <p>Please do only reply if you have practical experience with a framework. I'm not looking for examples, but experience...</p>
<p>If your hardcoded values are just simple key-value pairs, you should look at <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html" rel="noreferrer">java.util.Properties</a>. It's a lot simpler than xml, easier to use, and mind-numbingly trivial to implement.</p> <p>If you are working with Java and the data you are storing or retrieving from disk is modeled as a key value pair (which it sounds like it is in your case), then I really can't imagine a better solution.</p> <p>I have used properties files for simple configuration of small packages in a bigger project, and as a more global configuration for a whole project, and I have never had problems with it.</p> <p>Of course this has the huge benefit of not requiring any 3rd party libraries to utilize.</p>
<p>Properties files a very simple, if you need something more functional, you could format some of your configuration files as Java classes. These can be placed in a different package/module and can be pre-compiled or loaded at runtime with a library like BeanShell.</p> <p>Note: In the simplest case (pre-compiled) you don't need any additional libraries.</p>
4,535
<p>We maintain a system that has over a million lines of COBOL code. Does someone have suggestions about how to migrate to a GUI (probably Windows based) without losing all the business logic we have written in COBOL? And yes, some of the business logic is buried inside the current user interface.</p>
<p>If it was me I would look into something like this:</p> <p><a href="http://www.adtools.com/products/windows/cobol.htm" rel="nofollow noreferrer">NetCobol for Windows</a></p> <p>It should be fairly easy to wrap your COBOL with an interface that exposes the functionality (if it isn't already written that way) and then call it from a .NET application.</p> <p>It took us about 15 years to get off of our mainframe, because we didn't do something like this.</p>
<p><a href="http://www.microfocus.com/" rel="nofollow noreferrer">Microfocus</a> provide a tool called Enterprise Server which allows COBOL to interact with web services.</p> <p>If you have a COBOL program A and another COBOL program B and A calls B via the interface section, the tool allows you to expose B's interface section as a web service.</p> <p>For program A, you then generate a client proxy and A can now call B via a web service.</p> <p>Of course, because B now has a web service any other type of program (command line, Windows application, Java, ASP etc.) can now also call it.</p> <p>Using this approach, you can "nibble away at the edges" to move the GUI to a modern, browser based approach using something like ASP while still utilising the COBOL business engine.</p> <p>And once you have a decent set of web services, these can be used for any new development which provides a way of moving away from COBOL in the longer term.</p>
6,931
<p>I like using "Vase Mode" (or single outline corkscrew printing mode) for quick nonfunctional prints, but it tends to leave gaps in horizontal or near horizontal surfaces. I understand why it does this, but is there a way (beyond printing with no infill*) to get a little more horizontal coverage out of it?</p> <p>*Is the answer to this literally just "Try to print without infill?"</p>
<p>Version 4 allows you to have multi-process vase mode prints -- do the vertical surfaces in vase mode, then switch over to normal mode for the horizontals. This lets you have the best of both worlds in the same print. :)</p>
<p>Vase mode is what it is... As it prints one perimeter there is just one extrusion. Try increasing extrusion rate to see if that will fix the gaps. </p> <p>but yes, printing without infill will do the job better than vase mode.</p>
684
<p>Occasionally while attempting to save a Crystal Report that I'm working on in VS2008, a dialog titled "File Save Failed" pops up saying "The document could not be saved in C:\Users\Phillip\AppData\Local\Temp{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}.rpt. It has been saved in C:\Users\Phillip\AppData\Local\Temp\~zzz{YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}.tmp."</p> <p>If I OK the dialog, I get a "Save File As" dialog. If I specify the correct location of the report file, I'm asked if I want to replace the existing file. If I say "Yes", I get an error message saying "The operation could not be completed. The system cannot find the file specified." Even if I specify a completely different filename, in a different folder (e.g. C:/test.rpt) I get the same "operation could not be completed" error.</p> <p>Sometimes if I wait a moment, then try to save again, it works fine. More frequently, however, I keep getting the "Save File As" dialog. My only option then is to close the report and discard my changes.</p> <p>This is an intermittent problem - much of the time, saving the report works just fine. Any ideas?</p>
<p>Copernic Desktop Search sometimes locks files so that they can't be written. Closing the program resolves the problem. Perhaps the same problem occurs with other search engines too.</p>
<p>sounds like a job for process moniter. you should be able use process moniter to see what's really hapening and why. </p> <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx</a></p> <p>Or you could install VS2008 sp1 and cross your fingers. (I'd do both)</p>
5,085
<p>I see many similar questions, however I want to find the Username of the currently logged in user using Java.</p> <p>Its probably something like:</p> <pre><code>System.getProperty(current.user); </code></pre> <p>But, I'm not quite sure.</p>
<p>You're actually really close. This is what you're looking for:</p> <pre><code>System.getProperty("user.name") </code></pre>
<p>As mentioned above (and linked for Java 6), to get the current user:</p> <pre><code>System.getProperty(&quot;user.name&quot;) </code></pre> <p>For Java 7: <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperties%28%29" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 8: <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getProperties--" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 9: <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/System.html#getProperties--" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 10: <a href="https://docs.oracle.com/javase/10/docs/api/java/lang/System.html#getProperties--" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 11: <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 12: <a href="https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 13: <a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 14: <a href="https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 15: <a href="https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 16: <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p> <p>For Java 17: <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/System.html" rel="nofollow noreferrer">System.getProperties()</a></p>
5,132
<p>I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. </p> <p>Does anyone know how to change the z index of Virtual Earth shape layers, or force a layer to the front?</p>
<p>I'll add my voice to the noise and take a stab at making things clear:</p> <h2>C# Generics allow you to declare something like this.</h2> <pre><code>List&lt;Person&gt; foo = new List&lt;Person&gt;(); </code></pre> <p>and then the compiler will prevent you from putting things that aren't <code>Person</code> into the list.<br /> Behind the scenes the C# compiler is just putting <code>List&lt;Person&gt;</code> into the .NET dll file, but at runtime the JIT compiler goes and builds a new set of code, as if you had written a special list class just for containing people - something like <code>ListOfPerson</code>.</p> <p>The benefit of this is that it makes it really fast. There's no casting or any other stuff, and because the dll contains the information that this is a List of <code>Person</code>, other code that looks at it later on using reflection can tell that it contains <code>Person</code> objects (so you get intellisense and so on).</p> <p>The downside of this is that old C# 1.0 and 1.1 code (before they added generics) doesn't understand these new <code>List&lt;something&gt;</code>, so you have to manually convert things back to plain old <code>List</code> to interoperate with them. This is not that big of a problem, because C# 2.0 binary code is not backwards compatible. The only time this will ever happen is if you're upgrading some old C# 1.0/1.1 code to C# 2.0</p> <h2>Java Generics allow you to declare something like this.</h2> <pre><code>ArrayList&lt;Person&gt; foo = new ArrayList&lt;Person&gt;(); </code></pre> <p>On the surface it looks the same, and it sort-of is. The compiler will also prevent you from putting things that aren't <code>Person</code> into the list.</p> <p>The difference is what happens behind the scenes. Unlike C#, Java does not go and build a special <code>ListOfPerson</code> - it just uses the plain old <code>ArrayList</code> which has always been in Java. When you get things out of the array, the usual <code>Person p = (Person)foo.get(1);</code> casting-dance still has to be done. The compiler is saving you the key-presses, but the speed hit/casting is still incurred just like it always was.<br /> When people mention &quot;Type Erasure&quot; this is what they're talking about. The compiler inserts the casts for you, and then 'erases' the fact that it's meant to be a list of <code>Person</code> not just <code>Object</code></p> <p>The benefit of this approach is that old code which doesn't understand generics doesn't have to care. It's still dealing with the same old <code>ArrayList</code> as it always has. This is more important in the java world because they wanted to support compiling code using Java 5 with generics, and having it run on old 1.4 or previous JVM's, which microsoft deliberately decided not to bother with.</p> <p>The downside is the speed hit I mentioned previously, and also because there is no <code>ListOfPerson</code> pseudo-class or anything like that going into the .class files, code that looks at it later on (with reflection, or if you pull it out of another collection where it's been converted into <code>Object</code> or so on) can't tell in any way that it's meant to be a list containing only <code>Person</code> and not just any other array list.</p> <h2>C++ Templates allow you to declare something like this</h2> <pre><code>std::list&lt;Person&gt;* foo = new std::list&lt;Person&gt;(); </code></pre> <p>It looks like C# and Java generics, and it will do what you think it should do, but behind the scenes different things are happening.</p> <p>It has the most in common with C# generics in that it builds special <code>pseudo-classes</code> rather than just throwing the type information away like java does, but it's a whole different kettle of fish.</p> <p>Both C# and Java produce output which is designed for virtual machines. If you write some code which has a <code>Person</code> class in it, in both cases some information about a <code>Person</code> class will go into the .dll or .class file, and the JVM/CLR will do stuff with this.</p> <p>C++ produces raw x86 binary code. Everything is <em>not</em> an object, and there's no underlying virtual machine which needs to know about a <code>Person</code> class. There's no boxing or unboxing, and functions don't have to belong to classes, or indeed anything.</p> <p>Because of this, the C++ compiler places no restrictions on what you can do with templates - basically any code you could write manually, you can get templates to write for you.<br /> The most obvious example is adding things:</p> <p>In C# and Java, the generics system needs to know what methods are available for a class, and it needs to pass this down to the virtual machine. The only way to tell it this is by either hard-coding the actual class in, or using interfaces. For example:</p> <pre><code>string addNames&lt;T&gt;( T first, T second ) { return first.Name() + second.Name(); } </code></pre> <p>That code won't compile in C# or Java, because it doesn't know that the type <code>T</code> actually provides a method called Name(). You have to tell it - in C# like this:</p> <pre><code>interface IHasName{ string Name(); }; string addNames&lt;T&gt;( T first, T second ) where T : IHasName { .... } </code></pre> <p>And then you have to make sure the things you pass to addNames implement the IHasName interface and so on. The java syntax is different (<code>&lt;T extends IHasName&gt;</code>), but it suffers from the same problems.</p> <p>The 'classic' case for this problem is trying to write a function which does this</p> <pre><code>string addNames&lt;T&gt;( T first, T second ) { return first + second; } </code></pre> <p>You can't actually write this code because there are no ways to declare an interface with the <code>+</code> method in it. You fail.</p> <p>C++ suffers from none of these problems. The compiler doesn't care about passing types down to any VM's - if both your objects have a .Name() function, it will compile. If they don't, it won't. Simple.</p> <p>So, there you have it :-)</p>
<p>NB: I don't have enough point to comment, so feel free to move this as a comment to appropriate answer.</p> <p>Contrary to popular believe, which I never understand where it came from, .net implemented true generics without breaking backward compatibility, and they spent explicit effort for that. You don't have to change your non-generic .net 1.0 code into generics just to be used in .net 2.0. Both the generic and non-generic lists are still available in .Net framework 2.0 even until 4.0, exactly for nothing else but backward compatibility reason. Therefore old codes that still used non-generic ArrayList will still work, and use the same ArrayList class as before. Backward code compatibility is always maintained since 1.0 till now... So even in .net 4.0, you still have to option to use any non-generics class from 1.0 BCL if you choose to do so.</p> <p>So I don't think java has to break backward compatibility to support true generics.</p>
5,163
<p>Could someone write-up a step by step guide to developing a C++ based plugin for FireFox on Windows? </p> <p>The links and examples on <a href="http://www.mozilla.org/projects/plugins/" rel="nofollow noreferrer">http://www.mozilla.org/projects/plugins/</a> are all old and inaccurate - the "NEW" link was added to the page in 2004.</p> <p>The example could be anything, but I was thinking a plugin that lets JavaScript set the name and then displays "Hello {Name}". To show 2-way communication, it could have a property that returns the full salutation.</p> <p>Though not as important, it would be nice if the plugin would work in Chrome too.</p>
<p>See also <a href="http://developer.mozilla.org/en/Plugins" rel="nofollow noreferrer">http://developer.mozilla.org/en/Plugins</a> . And yes, NPAPI plugins should work in Google Chrome as well.</p> <p>[edit 2015: Chrome removes support for NPAPI soon <a href="http://blog.chromium.org/2014/11/the-final-countdown-for-npapi.html" rel="nofollow noreferrer">http://blog.chromium.org/2014/11/the-final-countdown-for-npapi.html</a> ]</p>
<p>It's fairly simple to make a plugin using NPAPI. The key header files you'll need from the Gecko distribution are npapi.h and npupp.h. You'll export functions from your plugin DLL or shared library with the names NP_Initialize, NP_Shutdown, NP_GetMIMEDescription, and NP_GetValue, and you'll need to also fill in the symbol table given to you in the NP_Initialize call with handlers for all of the NPP functions.</p> <p>The key functions to implement from that set are NPP_New and NPP_Destroy. Those define the lifecycle of a plugin instance. If you're going to handle a media file linked from an &lt;object> or &lt;embed>, you'll need to also deal with NPP_NewStream, NPP_WriteReady, NPP_Write, and NPP_DestroyStream as a way for your plugin to get the file's data from the browser. There's plenty more in <a href="http://developer.mozilla.org/en/Gecko_Plugin_API_Reference" rel="nofollow noreferrer">the Gecko Plugin developer's guide</a>.</p>
8,850
<p>I'm using a device that's got GPRS media to connect to a PC running stunnel. On TCPIP connections, the number of sessions is limitless. However, when it comes to SSL connections, it could only go as far as 1062 successful sessions. I've tried it like 3 times but makes no difference. I've checked the OpenSSL codes and I couldn't seem to find any code block that limits SSL connection to 1062. On SSL's point of view, is there anything that limits the number of connections? </p> <hr> <p>Yes, I'm using a postpaid phone SIM, but there isn't any problem with TCPIP. It only happens with SSL connections. We've tried connecting to other PC's as well using same OpenSSL stunnel, but only ends up to 1062 connections. </p>
<p>Are you connecting via a phone provider - could that be the issue?</p>
<p>Are you connecting via a phone provider - could that be the issue?</p>
7,979
<p>Ok, this is bit of an obscure question, but hopefully someone can help me out with it.</p> <p>The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user generated data.</p> <p>So, for example, the string might look something like;</p> <pre><code>SELECT table1.Col1 AS "This is an alias" FROM table1 </code></pre> <p>This works fine. However, the value that is used for the alias can potentially contain a double quote character, which breaks the outer quotes. I thought that I could maybe escape double quotes inside the alias somehow, but I've had no luck figuring out how to do so. Backslash doesn't work, and using two double quotes in a row results in this error;</p> <pre><code>SQL Error: ORA-03001: unimplemented feature 03001. 00000 - "unimplemented feature" *Cause: This feature is not implemented. </code></pre> <p>Has anyone had any experience with this issue before? Cheers for any insight anyone has.</p> <p>p.s. the quotes are needed around the aliases because they can contain spaces.</p>
<p>Can you just put another character instead of double quotes and replace that with double quotes in the code?</p> <p>Something like this:</p> <pre><code>SELECT table1.Col1 AS "This is |not| an alias" FROM table1 </code></pre> <p>Then just replace | with ".</p> <p>I know it's a hack, but I can't think of any better solution... And what you are doing there is a hack anyway. The "nice" way would be to select the values and the column names separately and associate them in your code. That would make things much cleaner.</p>
<p>a possibly fruitful area of investigation would be to look into the quote method. <br></p> <p><strong>my $quotedString = $dbh->quote( $string );</strong> <br></p>
8,056
<p>What methods are there for automatically getting a stack trace on Unix systems? I don't mean just getting a core file or attaching interactively with GDB, but having a SIGSEGV handler that dumps a backtrace to a text file. </p> <p>Bonus points for the following optional features:</p> <ul> <li>Extra information gathering at crash time (eg. config files).</li> <li>Email a crash info bundle to the developers.</li> <li>Ability to add this in a <code>dlopen</code>ed shared library</li> <li>Not requiring a GUI</li> </ul>
<p>If you are on systems with the BSD <a href="http://linux.die.net/man/3/backtrace" rel="nofollow noreferrer"><code>backtrace</code></a> functionality available (Linux, OSX 1.5, BSD of course), you can do this programmatically in your signal handler.</p> <p>For example (<a href="http://www-128.ibm.com/developerworks/linux/library/l-cppexcep.html?ca=dgr-lnxw07ExceptionTricks" rel="nofollow noreferrer"><code>backtrace</code> code derived from IBM example</a>): </p> <pre class="lang-c prettyprint-override"><code>#include &lt;execinfo.h&gt; #include &lt;signal.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; void sig_handler(int sig) { void * array[25]; int nSize = backtrace(array, 25); char ** symbols = backtrace_symbols(array, nSize); for (int i = 0; i &lt; nSize; i++) { puts(symbols[i]);; } free(symbols); signal(sig, &amp;sig_handler); } void h() { kill(0, SIGSEGV); } void g() { h(); } void f() { g(); } int main(int argc, char ** argv) { signal(SIGSEGV, &amp;sig_handler); f(); } </code></pre> <p>Output:</p> <pre><code>0 a.out 0x00001f2d sig_handler + 35 1 libSystem.B.dylib 0x95f8f09b _sigtramp + 43 2 ??? 0xffffffff 0x0 + 4294967295 3 a.out 0x00001fb1 h + 26 4 a.out 0x00001fbe g + 11 5 a.out 0x00001fcb f + 11 6 a.out 0x00001ff5 main + 40 7 a.out 0x00001ede start + 54 </code></pre> <p>This doesn't get bonus points for the optional features (except not requiring a GUI), however, it does have the advantage of being very simple, and not requiring any additional libraries or programs.</p>
<p>Dereks solution is probably the best, but here's an alternative anyway:</p> <p>Recent Linux kernel version allow you to pipe core dumps to a script or program. You could write a script to catch the core dump, collect any extra information you need and mail everything back. This is a global setting though, so it'd apply to any crashing program on the system. It will also require root rights to set up. It can be configured through the /proc/sys/kernel/core_pattern file. Set that to something like ' | /home/myuser/bin/my-core-handler-script'.</p> <p>The Ubuntu people use this feature as well.</p>
3,886
<p><strong>A big shout out to all of us for a successful graduation into private beta. Let's make it a success now, and make sure we graduate into a full-fledged site. So, this is one post which every user of a private beta site should read and act accordingly.</strong></p> <p>This is a reproduction of a moderator's (Richard) <a href="https://hermeneutics.meta.stackexchange.com/questions/49">post on meta.hermeneutics.SE</a>; I believe it is very much applicable to this community as well. Richard wrote a post encouraging voting. I think this is a big issue because rep is the basis of our "economy", encourages (good) user activity, sorts out our content and makes the site look active. In particular <strong>Question Votes</strong> make the site look more active.</p> <blockquote> <p>I cannot state this strongly enough. Voting is <em>absolutely critical</em> to the formation of a healthy SE site. And this is never more true than in Private and early Public beta. </p> <h3>Vote on Questions</h3> <p>Voting allows the community to determine what topics are allowed and what are not. Voting shows what constitutes a well-formed question and what is unacceptable for this community.</p> <p>If you need help formulating better questions, the blog post <a href="http://blog.stackoverflow.com/2010/10/asking-better-questions/">Asking Better Questions</a> might help you out. (Admittedly, it's geared towards the Stackoverflow crowd, but the philosophies there will help). Also, <a href="https://stackoverflow.com/questions/how-to-ask">How to Ask</a> directly from StackOverflow is an excellent resource.</p> <p>Finally, I want to reiterate that <strong>Voting on questions is free!</strong> It doesn't cost you any reputation to to vote a question down. (Compared to answers:)</p> <h3>Vote on Answers</h3> <p>Voting on answers allows a dramatic increase in reputation. Like questions, it shows that you believe and support the answer provided. Also, vote answers up that you think are well worded and support the answer given. </p> <p><em>You don't have to agree with an answer to vote it up!</em></p> <p>To show that this is true, they've even created a <a href="https://3dprinting.stackexchange.com/help/badges/63/sportsmanship">badge for voting up competing answers (called "Sportsmanship")</a>.</p> <p>If you think an answer is <em>useful</em>, vote it up. If you think an answer is <em>not useful</em>, vote it down. Either way, <strong>vote</strong>!</p> <p>If you need help on writing answers, the meta post <a href="https://meta.stackexchange.com/questions/7656/how-do-i-write-a-good-answer-to-a-question">How do I write a good answer to a question?</a> will help you out.</p> <h3>Final thoughts</h3> <p>If people do not vote, there won't be enough reputation on this site for it to be promoted. Reputation is very important to a StackExchange site as it creates the groups of people capable of maintaining the site.</p> <p>To show how critical it is, Jeff Atwood posted a blog article regarding this topic: <a href="http://blog.stackoverflow.com/2010/10/vote-early-vote-often/">Vote Early, Vote Often</a></p> <h3>Encourage others to vote!</h3> <p>Quoting RobertCartaino from chat:</p> <blockquote> <p>Vote, vote, vote. Encourage others to vote, vote, vote. On good content, leave signposts ("If you like this, please vote it up. It's important for the community!")-- in both meta and the main site. Maybe a few meta posts informing the users of the important of that type of participation. You are empowered a lot more than you know.</p> </blockquote> </blockquote> <p>Don't upvote bad content (edit/suggest how to fix it instead) but make sure you remember to vote, especially for questions; if you learned something from an answer on a question, the question's probably worth an upvote too so others can find the good information.</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<img src="https://blog.stackexchange.com/images/wordpress/vote-here.jpg" alt="https://blog.stackexchange.com/images/wordpress/vote-here.jpg">]</p>
<p><strong>Yes!</strong></p> <p>Absolutely. We need to reward good answers, and raise rep levels so suers can get moderation privileges when they rise to the normal public beta levels.</p> <p>However, I think we should also downvote poor questions and answers. I haven't yet done so, partly because I've focused on rewarding the good posts. But downvoting is important, too.</p> <p>What happened to me yesterday:</p> <ol> <li>I posted an answer (my first) to a question.</li> <li>It was downvoted.</li> <li>A user who may/may not have been the downvoter pointed out something I was wrong about.</li> <li>There was a discussion in comments.</li> <li>I deleted my answer.</li> <li>I edited it.</li> <li>There was continued dialogue with the user and another. I improved my answer even further.</li> <li>Downvote was removed.</li> </ol> <p>I'm grateful to the downvoter, and to the comments. We need to establish what posts are good and bad in the site, and my original answer was not good. It was wrong in several points - and since the question was about <a href="https://3dprinting.stackexchange.com/questions/tagged/safety" class="post-tag" title="show questions tagged &#39;safety&#39;" rel="tag">safety</a>, it was even more important for it to be correct. The feedback helped me to fix my answer, but if I had not done so, the downvote would have ensured that better answers went to the top.</p> <p>We should definitely upvote. But downvoting is good, too. Downvoters don't have to comment - that's never the case - but comments certainly help. They helped me.</p>
<p>There are other considerations, as have already been noted on <a href="https://3dprinting.meta.stackexchange.com/questions/264/what-does-it-take-to-get-out-of-beta-stage">What does it take to get out of Beta stage?</a></p> <p>On fully graduated sites, we need:</p> <ul> <li><strong><em>users with > 10k</em></strong> who can access the moderation tools and;</li> <li><strong><em>users > 3k</em></strong> who can vote fully (close votes for example). </li> </ul> <hr> <p>For a full list of reputation against privileges on a <em>fully graduated site</em>, take a look at the <a href="https://raspberrypi.stackexchange.com/help/privileges">Raspberry Pi privileges page</a>:</p> <blockquote> <p><a href="https://i.stack.imgur.com/HkSHk.png" rel="nofollow noreferrer" title="Graduated privileges"><img src="https://i.stack.imgur.com/HkSHk.png" alt="Graduated privileges" title="Graduated privileges"></a></p> </blockquote> <p>As can be seen, the reputation differs greatly from the reputation required <em>when the site is in beta</em>, see <a href="https://3dprinting.stackexchange.com/help/privileges">our privileges</a>.</p> <blockquote> <p><a href="https://i.stack.imgur.com/aNWMB.png" rel="nofollow noreferrer" title="Beta Privileges"><img src="https://i.stack.imgur.com/aNWMB.png" alt="Beta Privileges" title="Beta Privileges"></a></p> </blockquote> <hr> <p>See <a href="https://robotics.meta.stackexchange.com/questions/1354/graduation-of-this-community#answer-1355">this answer</a> to the question <a href="https://robotics.meta.stackexchange.com/questions/1354/graduation-of-this-community">“Graduation” of this Community</a> for SE.Robotics.Meta, in particular this <em>very poignant</em> paragraph:</p> <blockquote> <p>Also, consider this, we don't have a single 10k user right now. If we were to graduate today, the only people who would have access to moderator tools would be ♦ moderators. The problems are even worse further down the reputation scale, we only have 6 users with 3k or more reputation, who aren't already ♦ moderators, so only these 6 people would be able to cast ordinary close votes.</p> </blockquote> <p>Our case is very similar. We have (click <a href="https://3dprinting.stackexchange.com/users?tab=Reputation&amp;filter=all">here</a>):</p> <ul> <li>One user who is <em>near</em> 10k, and that is, without wishing to name and shame (;-D) <a href="https://3dprinting.stackexchange.com/users/26/tom-van-der-zanden">Tom</a></li> <li>6 users over 3k</li> </ul>
9
<p>Let X be the set of all sets that do not contain themselves. Is X a member of X?</p>
<p>In <strong>ZFC</strong>, either the axiom of foundation [as mentioned] or the axiom (scheme) of comprehension will prohibit this. The first, for obvious reasons; the second, since it basically says that for given <em>z</em> and first-order property <em>P</em>, you can construct { <em>x</em> ∈ <em>z</em> : <em>P</em>(<em>x</em>) }, but to generate the Russell set, you would need <em>z</em> = <em>V</em> (the class of all sets), which is not a set (i.e. cannot be generated from any of the given axioms).</p> <p>In New Foundations (<strong>NF</strong>), "<em>x</em> ∉ <em>x</em>" is not a stratified formula, and so again we cannot define the Russell set. Somewhat amusingly, however, <em>V</em> <em>is</em> a set in <strong>NF</strong>.</p> <p>In von Neumann--Bernays--Gödel set theory (<strong>NBG</strong>), the class <em>R</em> = { <em>x</em> : <em>x</em> is a set and <em>x</em> ∉ <em>x</em> } is definable. We then ask whether <em>R</em> ∈ <em>R</em>; if so, then also <em>R</em> ∉ <em>R</em>, giving a contradiction. Thus we must have <em>R</em> ∉ <em>R</em>. But there is no contradiction here, since for any given class <em>A</em>, <em>A</em> ∉ <em>R</em> implies either <em>A</em> ∈ <em>A</em> or <em>A</em> is a proper class. Since <em>R</em> ∉ <em>R</em>, we must simply have that <em>R</em> is a proper class.</p> <p>Of course, the class <em>R</em> = { <em>x</em> : <em>x</em> ∉ <em>x</em> }, without the restriction, is simply not definable in <strong>NBG</strong>.</p> <p>Also of note is that the above procedure is formally constructable as a proof in <strong>NBG</strong>, whereas in <strong>ZFC</strong> one has to resort to meta-reasoning.</p>
<p>The question is ill-posed in the standard <a href="http://en.wikipedia.org/wiki/Zermelo-Fraenkel_set_theory" rel="nofollow noreferrer">ZFC</a> (Zermelo-Fraenkel + axiom of Choice) set theory because the object thus defined is not a set.</p> <p>Since (again, assuming standard ZFC) your <em>class</em> {x : x\not\in x} is not a set, the answer becomes no, it's not an element of itself (even as a class) since only sets can be elements of classes or sets.</p> <p>By the way, as soon as you agree to the <a href="http://en.wikipedia.org/wiki/Axiom_of_foundation" rel="nofollow noreferrer">axiom of foundation</a>, no set can be an element of itself.</p> <p>Of course the nice thing about math is you can choose whichever axioms you want :) but believing in paradoxes is just weird.</p>
5,580
<p>The command line interface to MySQL works perfectly well in itself, but when using my local copy I'm forced to interact with it using the old-fashioned DOS windows. Is there some way I can redirect it through a better shell?</p>
<p>Have you tried the <a href="http://www.mysql.com/products/tools/query-browser/" rel="nofollow noreferrer">MySQL Query Browser</a>? Works cross platform and is much nicer than the plain shell.</p>
<p>It sounds like a GUI is not really what you were after, but maybe <a href="http://en.wikipedia.org/wiki/HeidiSQL" rel="nofollow noreferrer">HeidiSQL</a> would be worth a look. It's a GUI frontend for MySQL which I wouldn't say I quite <em>enjoyed</em> using, but I've certainly come across worse ways to talk with a database.</p>
5,715
<p>Can it be done and if so, how? </p>
<p>You can use Merge Replication. Theres a tutorial here <a href="http://msdn.microsoft.com/en-us/sqlserver/bb219480.aspx" rel="nofollow noreferrer">SQL Server Compact 3.5 How-to Tutorials</a> (Number 5).</p>
<p>Because of budget constraints I think it will have to beta-tester's approch,i tried following the guide and cant seem to get it working. Before I spend time getting it to work, I just confrim, Replicating between SqlServer 2005 and Compact Edition is something that can be done?</p>
2,927
<p>I'm trying to develop specialized audio player for windows mobile devices (Professional ones). And I've ran into the problem an once.</p> <p>There no compressed audio APIs on WM or I was unable to found house in documentation. Yes there are WM6 Sound API but it cannot even pause playback or seek to specified position. There are allways Windows Media Player on WM device but I've not found it APIs documentation.</p> <p>So the question is:<br> Is there simple way to play, pause, forward, rewind, getting playback position and getting audio file length on <em>compressed</em> audio of several popular formats? Any library? platform APIs? Anything? </p>
<p>This might be of no help at all, but the (very good) podcast player <a href="http://www.codeplex.com/beyondpod" rel="nofollow noreferrer">BeyondPod</a> has a built in player, based on Windows Media Player, and it's open source - so you could have a look at what API they are using.</p> <p>Obviously if they've written their own custom player, you wont be able to just copy it if you're writing a commercial app. But you could use it for API documentation if they're just calling through to some Media Player API.</p>
<p>I've found quite a sufficient compressed audio playback library <a href="http://www.fmod.org/" rel="nofollow noreferrer">FMOD</a>. There are WM version of it. And I've found sample application on <a href="http://www.codeproject.com/KB/mobile/simple_mp3_player_for_ppc.aspx" rel="nofollow noreferrer">CodeProject</a> to start with.</p>
4,058
<p>I'm writing a CMS application in PHP and one of the requirements is that it must be able to interface with the customer's Exchange server. I've written up this functionality a few times before and have always used <a href="http://en.wikipedia.org/wiki/WebDAV" rel="noreferrer">WebDAV</a> to do it, but now I'm leaning away from that.</p> <p>I will be running the site on IIS OR Apache (no preference) on Windows server 2008. A few things I would need to do include adding contacts to a given user's address book, sending emails as a given user and running reports on contacts for a user.</p> <p>All of this is pretty easy to do with WebDAV, but if there is a better way that doesn't require any functionality that is likely to be deprecated any time soon.</p> <p>Any ideas?</p> <h3>Update:</h3> <p>Justin, I love the idea of using com objects, I just worry about maintaining a 3rd product to make everything work...</p> <p>John, I can write a web service in C# to interface with for these functions and access it with my PHP app, but it's also a little bit out of the way.</p> <p>So far, I'm not 100% convinced that either of these is better than WebDAV...</p> <p>Can anyone show me where I'm being silly?</p>
<p><strong>Update as of 2020:</strong><br /> Over a decade since this question and things have moved on. Microsft now has a <a href="https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/office-365-rest-apis-for-mail-calendars-and-contacts" rel="nofollow noreferrer">Rest API</a> that will allow you to easily access this data.</p> <hr /> <p><strong>Original Answer</strong></p> <p>I have not used PHP to do this but have experience in using C# to achieve the same thing.</p> <p>The Outlook API is a way of automating Outlook rather than connecting to Exchange directly. I have previously taken this approach in a C# application and it does work although can be buggy.</p> <p>If you wish to connect directly to the Exchange server you will need to research extended MAPI.</p> <p>In the past I used this wrapper <a href="http://www.codeproject.com/KB/IP/CMapiEx.aspx" rel="nofollow noreferrer">MAPIEx: Extended MAPI Wrapper</a>.</p> <p>It is a C# project but I believe you can use some .NET code on a PHP5 Windows server. Alternatively it has a C++ core DLL that you may be a able to use. I have found it to be very good and there are some good example applications.</p> <hr /> <p>Sorry for the delay no current way to keep track of posts yet.</p> <p>I do agree adding more layer on to your application and relying on 3rd party code can be scary (and rightfully so.)</p> <p>Today I read another <a href="https://stackoverflow.com/questions/4508/mapi-and-managed-code-experiences">interesting post</a> tagged up as MAPI that is on a different subject. The key thing here though is that it has linked to <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="nofollow noreferrer">this important MS article</a>. I have been unaware of the issues until now on using managed code to interface to MAPI although the C++ code in the component should be unaffected by this error as it is unmanaged.</p> <p>This blog entry also suggests other ways to connect to MAPI/Exchange server. In this case due to these new facts <a href="http://us3.php.net/imap" rel="nofollow noreferrer">http://us3.php.net/imap</a> may be the answer as suggested by the other user.</p>
<p>I'm not a PHP dev but Google says that PHP 5+ can instantiate COM components. If you can install Outlook on a box you could write a PHP web service around the COM component to handle the requests you need. </p> <pre><code>$outlook = COM("Outlook.Application") </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/aa193231.aspx" rel="noreferrer">Outlook API referance</a></p>
2,300
<p>I have been working at converting game files into 3d files that can be printed, but many of the models have very thin or walls. I was wondering if there was a way to increase the thickness of the walls using meshmixer or meshlab.</p>
<p>Only today, I learned of a solution for this sort of objective, but it uses Fusion 360 rather than Meshmixer or Meshlab. As your question does not include that program, I'll toss the Meshmixer method.</p> <p>This image is of the model prior to modification:</p> <p><a href="https://i.stack.imgur.com/XsIS5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XsIS5.jpg" alt="untouched model"></a></p> <p>When you load your STL file into MM, use Edit, Generate Face Groups. This will cause the surfaces to change color. Click Accept.</p> <p>With face groups created:</p> <p><a href="https://i.stack.imgur.com/W5gZL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W5gZL.jpg" alt="face groups created"></a></p> <p>If you can be assured of all one surface, use Select, then double click on the interior. This should turn the entire interior red. If you discover unselected surfaces, simply click on those surfaces until all is completed. If you select a surface in error, use Shift-Click to clear that one surface.</p> <p>Once selected, the select menu gives you a new edit menu. Use Edit, Offset for yet another menu. As you make changes in the menu settings, you'll see the results on the model. Ideally, you won't have an overly complex model with too many facets/triangles, as it can really bog a machine down.</p> <p>This particular model has a nearly uniform interior. Double clicking on the inside surface caused the full cylinder (not the bottom) to be selected (turning red).</p> <p>Low accuracy offset, with surfaces still selected:</p> <p><a href="https://i.stack.imgur.com/54Lv0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/54Lv0.jpg" alt="low accuracy"></a></p> <p>For smoothest results, keep the accuracy high. Any protruberance in the interior will give very strange results.</p> <p>High accuracy results, surfaces selected:</p> <p><a href="https://i.stack.imgur.com/vLrMk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vLrMk.jpg" alt="high accuracy"></a></p> <p>Experiment with the settings, aim for the best result and click accept. As long as you don't export the model over your original, all experimentation is a learning experience and not a destructive one.</p>
<p>Only today, I learned of a solution for this sort of objective, but it uses Fusion 360 rather than Meshmixer or Meshlab. As your question does not include that program, I'll toss the Meshmixer method.</p> <p>This image is of the model prior to modification:</p> <p><a href="https://i.stack.imgur.com/XsIS5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XsIS5.jpg" alt="untouched model"></a></p> <p>When you load your STL file into MM, use Edit, Generate Face Groups. This will cause the surfaces to change color. Click Accept.</p> <p>With face groups created:</p> <p><a href="https://i.stack.imgur.com/W5gZL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W5gZL.jpg" alt="face groups created"></a></p> <p>If you can be assured of all one surface, use Select, then double click on the interior. This should turn the entire interior red. If you discover unselected surfaces, simply click on those surfaces until all is completed. If you select a surface in error, use Shift-Click to clear that one surface.</p> <p>Once selected, the select menu gives you a new edit menu. Use Edit, Offset for yet another menu. As you make changes in the menu settings, you'll see the results on the model. Ideally, you won't have an overly complex model with too many facets/triangles, as it can really bog a machine down.</p> <p>This particular model has a nearly uniform interior. Double clicking on the inside surface caused the full cylinder (not the bottom) to be selected (turning red).</p> <p>Low accuracy offset, with surfaces still selected:</p> <p><a href="https://i.stack.imgur.com/54Lv0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/54Lv0.jpg" alt="low accuracy"></a></p> <p>For smoothest results, keep the accuracy high. Any protruberance in the interior will give very strange results.</p> <p>High accuracy results, surfaces selected:</p> <p><a href="https://i.stack.imgur.com/vLrMk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vLrMk.jpg" alt="high accuracy"></a></p> <p>Experiment with the settings, aim for the best result and click accept. As long as you don't export the model over your original, all experimentation is a learning experience and not a destructive one.</p>
756
<p>Can somebody point me to a resource that explains how to go about having 2+ IIS web server clustered (or Webfarm not sure what its called) ?</p> <p>All I need is something basic, an overview how and where to start. Can't seem to find anything...</p>
<p>This MSDN magazine article has a good overview of the technologies involved:</p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc500561.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc500561.aspx</a></p>
<p>A couple of good articles for those who are looking nowadays for information about <strong>Server Farms</strong> - <strong>Load Balancing</strong> and <strong>Application Request Rooting</strong> that I found and wanted to share are these: </p> <p>HTTP Load Balancing using Application Request Routing: <a href="https://learn.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/http-load-balancing-using-application-request-routing" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/http-load-balancing-using-application-request-routing</a>.</p> <p>Overview - Build a Web Farm with IIS Servers: <a href="https://learn.microsoft.com/en-us/iis/web-hosting/scenario-build-a-web-farm-with-iis-servers/overview-build-a-web-farm-with-iis-servers" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/iis/web-hosting/scenario-build-a-web-farm-with-iis-servers/overview-build-a-web-farm-with-iis-servers</a></p>
3,893
<p>Developer looking for best method to identify a deadlock on a specific transaction inside a specific thread. We are getting deadlock errors but these are very general in FB 2.0</p> <p>Deadlocks happening and they are leading to breakdowns in the DB connection between client and the DB. </p> <ul> <li>We send live ( once a second) data to the DB. </li> <li>We open a thread pool of around 30 threads and use them to ingest the data ( about 1-2 kB each second). </li> <li>Sometimes the DB can only take so much that we use the next thread in the pool to keep the stream current as possible. </li> </ul> <p>On occasion this produces a deadlock in addition to reaching the max thread count and breaking the connection. </p> <p>So we really need opinions on if this is the best method to ingest this amount of data every second. We have up to 100 on these clients hitting the DB at the same time.<br> Average transactions are about 1.5 to 1.8 million per day.</p>
<p>I don't know of a specific way to identify the particular thread or statement. I've had to deal with FB deadlocks many times. You probably have two theads that are trying to update the same row in some table but they are doing it in separate transactions.</p> <p>The best solution I've found is to design things so threads never have to update a row that any other thread might update. Sometimes that means having a thread that just exists to update a common table/row. The worker threads send a message to this thread. (The message could be done via another table.)</p> <p>We run FB in many systems in the field that generate transactions (not millions per day) and we have found FB to be rock solid once we get the design correct.</p>
<p>My suggestion would be to write a 3-tier application, serialize all access to database (inserting) to a single thread (other threads would just stack up data on the queue) and use Firebird embedded (which is much faster because it eliminates TCP/IP overhead). </p> <p>Beside avoiding deadlocks, this approach would also allow you to monitor the queue and see how is the system able to cope with the load.</p>
8,843
<p>I have noticed that <a href="http://slic3r.org/" rel="noreferrer">Slic3r</a> offers a speed setting called "<a href="http://slic3r.org/blog/new-stable-1.2.9" rel="noreferrer">auto speed</a>" meant to give a constant filament pressure at the extruder, which I believe could eliminate filament grinding issues at higher printing speeds. </p> <p>According to the tooltip in Slic3r, auto speed is calculated from two parameters:</p> <ul> <li>Maximum speed</li> <li>Maximum volumetric speed</li> </ul> <p>Maximum speed speaks for itself, but how can I calculate the maximum volumetric speed of my print?</p>
<p>Auto speed is calculated from maximum volumetric speed in mm<sup>3</sup> per second. If you normally print at 80 mm/s, your extrusion width is 0.5 mm and you are printing 0.2mm high layers, your volumetric speed would be 80 * 0.5 * 0.2 = 8 mm<sup>3</sup>/s, which is the volume of plastic extruded by your printer every second when printing at that speed (not accounting for any die swell).</p>
<p>There's no fixed maximum volumetric speed that works for everyone, there's simply too much variables to account for. By using @Ian Williams explanation you can convert from volumetric to regular speeds but you still need to test what speed works best for your setup.</p> <p>Just a few of the other variables affecting how fast material can come out consistently: temperature (nozzle &amp; heat brake), extruder motor power, path friction between extruder and hotend, material compressibility, fluidity and glass transition temperature, ..</p> <p>There are interesting topics on RepRap forums, like this one: </p> <p><a href="http://forums.reprap.org/read.php?262,654085" rel="nofollow noreferrer">http://forums.reprap.org/read.php?262,654085</a></p>
125
<p>I have a function in Python which is iterating over the attributes returned from <code>dir(obj)</code>, and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use <code>callable()</code> for this, but I don't want to include classes. The best I've come up with so far is:</p> <pre><code>isinstance(obj, (types.BuiltinFunctionType, types.FunctionType, types.MethodType)) </code></pre> <p>Is there a more future-proof way to do this check?</p> <p><strong>Edit:</strong> I misspoke before when I said: &quot;Normally you could use <code>callable()</code> for this, but I don't want to disqualify classes.&quot; I actually <em>do</em> want to disqualify classes. I want to match <em>only</em> functions, not classes.</p>
<p>The inspect module has exactly what you want:</p> <pre><code>inspect.isroutine( obj ) </code></pre> <p>FYI, the code is:</p> <pre><code>def isroutine(object): """Return true if the object is any kind of function or method.""" return (isbuiltin(object) or isfunction(object) or ismethod(object) or ismethoddescriptor(object)) </code></pre>
<p>Depending on what you mean by 'class':</p> <pre><code>callable( obj ) and not inspect.isclass( obj ) </code></pre> <p>or:</p> <pre><code>callable( obj ) and not isinstance( obj, types.ClassType ) </code></pre> <p>For example, results are different for 'dict':</p> <pre><code>&gt;&gt;&gt; callable( dict ) and not inspect.isclass( dict ) False &gt;&gt;&gt; callable( dict ) and not isinstance( dict, types.ClassType ) True </code></pre>
9,978
<p>The main web application of my company is crying out for a nifty set of libraries to make it in some way maintainable and scalable, and one of my colleagues has suggested CSLA. So I've bought the book but as :</p> <blockquote> <p><em>programmers don't read books anymore</em></p> </blockquote> <p>I wanted to gauge the SOFlow community's opinion of it.</p> <p>So here are my questions:</p> <ol> <li>How may people are using CSLA?</li> <li>What are the pros and cons?</li> <li>Does CSLA really not fit in with TDD?</li> <li>What are my alternatives?</li> <li>If you have stopped using it or decided against why?</li> </ol>
<p>Before I specifically answer your question, I'd like to put a few thoughts down. Is CSLA right for your project? It depends. I would personally consider CSLA for desktop based applications that does not value unit testing as a high priority. CSLA is great if you want to easily scale to an n-tier application. CSLA tends to get some flack because it does not allow pure unit testing. This is true, however like anything in technology, I believe that there is <em>No One True Way</em>. Unit testing may not be something you are undertaking for a specific project. What works for one team and one project may not work for another team or other project.<br /></p> <p>There are also many misconceptions in regards to CSLA. It is not an ORM. it is not a competitor to NHibernate (in fact using CLSA Business Objects &amp; NHibernate as data access fit really well together). It formalises the concept of a <em>Mobile Object</em>.</p> <p><strong>1. How many people are using CSLA?</strong><br /> Based on the <a href="http://forums.lhotka.net/forums/default.aspx" rel="noreferrer">CSLA Forums</a>, I would say there are quite a number of CSLA based projects out there. Honestly though, I have no idea how many people are actually using it. I have used it in the past on two projects.</p> <p><strong>2. What are the pros and cons?</strong><br /> While it is difficult to summarise in a short list, here is some of the pro/con's that come to mind.<br /> <em>Pros:</em></p> <ul> <li>It's easy to get new developers up to speed. The CSLA book and sample app are great resources to get up to speed.</li> <li>The Validation framework is truly world class - and has been "borrowed" for many many other non-CSLA projects and technologies.</li> <li>n-Level Undo within your business objects</li> <li>Config line change for n-Tier scalability (Note: not even a recompile is necessary)</li> <li>Key technologies are abstracted from the "real" code. When WCF was introduced, it had minimal impact on CSLA code.<br /></li> <li>It is possible to share your business objects between windows and web projects.</li> <li>CSLA promotes the normalization of <em>behaviour</em> rather than the normalization of <em>data</em> (leaving the database for data normalization).</li> </ul> <p><em>Cons:</em></p> <ul> <li>Difficulty in unit testing</li> <li>Lack of Separation of Concern (generally your business objects have data access code inside them).</li> <li>As CSLA promotes the normalization of <em>behavior</em>, rather than the normalization of <em>data</em>, and this can result in business objects that are named similarly, but have different purposes. This can cause some confusion and a feeling like you are not reusing objects appropriately. That said, once the physiological leap is taken, it more than makes sense - it seems inappropriate to structure objects the "old" way.</li> <li>It's not "in fashion" to build applications this way. You may struggle to get developers who are passionate about the technology.</li> </ul> <p><strong>3. After reading this does CSLA really not fit in with TDD?</strong><br /> I haven't found an effective way to do TDD with CSLA. That said, I am sure there are many smarter people out there than me that may have tried this with greater success.</p> <p><strong>4. What are my alternatives?</strong><br /> Domain-Driven-Design is getting big push at the moment (and rightfully so - it's fantastic for some applications). There are also a number of interesting patterns developing from the introduction of LINQ (and LINQ to SQL, Entity Framework, etc). Fowlers book <a href="https://rads.stackoverflow.com/amzn/click/com/0321127420" rel="noreferrer" rel="nofollow noreferrer">PoEAA</a>, details many patterns that may be suitable for your application. Note that some patterns are competing (i.e. Active Record and Repository), and thus are meant to be used for specific scenarios. While CSLA doesn't exactly match any of the patterns described in that book, it most closely resembles Active Record (although I feel it is short-sighted to claim an exact match for this pattern).</p> <p><strong>5. If you have stopped using it or decided against why?</strong><br /> I didn't fully recommend CSLA for my last project, because I believe the scope of the application is too large for the benefits CSLA provides. <br /> I would <em>not</em> use CSLA on a web project. I feel there are other technologies better suited to building applications in that environment.</p> <p>In summary, while CSLA is anything but a <em>silver bullet</em>, it is appropriate for some scenarios.</p> <p>Hope this helps!</p>
<p>CSLA is the best application framework that exists. Rocky LHotka is a very but very smart guy. He is writing the history of software development like Martin Fowler, David S Platt, but my favourites writers are Rod Stephens, Mathew mcDonalds Jeff Levinson thearon willis and Louis Davidson alias dr sql. :-) Pros: All design patterns are applied. Cons: Hard to learn, and few samples.</p>
3,605
<p>I have a script that retrieves objects from a remote server through an Ajax call. The server returns objects in JSON notation.­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p> <p>However, in Adobe AIR, there is a restriction on using <a href="http://labs.adobe.com/wiki/index.php/AIR:HTML_Security_FAQ#Why_restrict_eval.28.29_for_all_Application_content_if_there_are_legitimate_use_cases_for_using_it.3F" rel="nofollow noreferrer">eval()</a> for security reasons. So I'm able to get replies from the remote server, but can't turn them back into JavaScript objects. Is there any workaround for this issue? I would like to use JSON for my JavaScript objects, since it can be used almost immediately.</p> <p>Side-note : I do understand the security implications for forcing the issue, but I will be doing some rapid application development for a competition, so the program would only be a quick prototype, and not used for production purposes. Nevertheless, it would be great if there's a better alternative to what I'm trying to do now</p> <hr> <p><strong>Update:</strong></p> <p>Thanks to <a href="https://stackoverflow.com/a/24919/7750640">Theo</a> and <a href="https://stackoverflow.com/a/21716/7750640">jsight</a> for their answers; </p> <p>One important thing I learnt today is that I can actually make use of ActionScript libraries by using the <pre>&lt;script src="lib/myClasses.swf" type="application/x-shockwave-flash"&gt;&lt;/script&gt;</pre> tag extended by Adobe AIR. Check out <a href="https://stackoverflow.com/a/24919/7750640">Theo's</a> link for more details!</p>
<p>You can find a <a href="http://www.JSON.org/js.html" rel="noreferrer">JSON parser written in JavaScript here</a> (<a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="noreferrer">source code here</a>). You can also use the as3corelib JSON parser from JavaScript, there's <a href="http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ed9.html" rel="noreferrer">a description of how to access ActionScript libraries from JavaScript here</a>.</p>
<p>JSON is Javascript Object Notation, so if you are using Javascript you are already there! Have a look at these links, they give examples of how to create Javascript objects from JSON:</p> <p><a href="http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Object_Notation_)" rel="nofollow noreferrer">http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Object_Notation_)</a></p> <p><a href="http://betterexplained.com/articles/using-json-to-exchange-data/" rel="nofollow noreferrer">http://betterexplained.com/articles/using-json-to-exchange-data/</a></p> <p>If you decide to go the Flex / AS3 route, then as the jsight said, as3corelib is a good place to start.</p>
4,178
<p>I have a large legacy codebase with very complicated makefiles, with lots of variables. Sometimes I need to change them, and I find that it's very difficult to figure out why the change isn't working the way I expect. What I'd like to find is a tool that basically does step-through-debugging of the "make" process, where I would give it a directory, and I would be able to see the value of different variables at different points in the process. None of the debug flags to make seem to show me what I want, although it's possible that I'm missing something. Does anyone know of a way to do this?</p>
<p>Have you been looking at the output from running <code>make -n</code> and <code>make -np</code>, and the biggie <code>make -nd</code>?</p> <p>Are you using a fairly recent version of <code>gmake</code>?</p> <p>Have you looked at the free chapter on <a href="http://oreilly.com/catalog/make3/book/index.csp" rel="noreferrer">Debugging Makefiles</a> available on O'Reilly's site for their excellent book "Managing Projects with GNU Make" (<a href="https://rads.stackoverflow.com/amzn/click/com/0596006101" rel="noreferrer" rel="nofollow noreferrer">Amazon Link</a>).</p>
<p>There is a GNU make debugger project at <a href="http://gmd.sf.net" rel="nofollow">http://gmd.sf.net</a> which looks quite useful. The main feature supported by gmd is breakpointing, which may be more useful than stepping. To use this, you download gmd from <a href="http://gmd.sf.net" rel="nofollow">http://gmd.sf.net</a> and gmsl from <a href="http://gmsl.sf.net" rel="nofollow">http://gmsl.sf.net</a>, and do an 'include gmd' in your makefile.</p>
7,834
<p>I have a Prusa MK2.5 which runs at 12 V, the Prusa MK3 runs at 24 V.</p> <p>I noticed that on <a href="https://www.prusa3d.com/product/stepper-motors-set/" rel="nofollow noreferrer">Prusa's webpage</a>, they list the stepper motors as being compatible with both the MK2 <em>and</em> the MK3 even though they run at different voltages.</p> <p>My question is: are stepper motors typically tuned for specific voltages (like most fans are), or are these stepper motors compatible with <em>both</em> 12 and 24 V systems?</p>
<p>The steppers have two voltages in the specifications: nominal voltage and maximum voltage for the electrical insulation between windings.</p> <p>The nominal voltage is basically never that high. The motors from Prusa are likely rated at 4-5 V operating voltage: the voltage you apply from the control board is higher, but as soon as the current reaches the value you set, the chip starts cutting intermittently the voltage, so 12-0-12-0-12... and the average value never goes above those 4-5 V.</p> <p>The second value, the insulation, is the one you must NEVER exceed, even when operating intermittently, but it is likely 30 V or more.</p>
<p>Without having the exact model number of the motor to check the data sheet, this can't be answered. Glancing at the link you supplied, I didn't see either a data sheet or a model number I could use to get a data sheet.</p> <p>Typically stepper motors overheat when they are run at too high of a voltage. However, the advertised voltage for the motor could be the lowest voltage at which it works.</p> <p>For a real answer, you'd have to look at the manufacturer's datasheet for the motor, which should include minimum and maximum voltages and graphs showing current vs. voltage vs. force graphs, and possibly duty cycle graphs.</p> <p>Also, in some cases, if you run a motor at a higher voltage than it is rated for, it may produce back EMF that is larger than the motor controller is prepared for, and it could burn out the controller. However, if the controller is designed for 24v, this is less likely of a problem.</p> <p>Note also that there are conversion kits, where you place a small board between the controller and the motor that fixes the voltage for the motor.</p>
2,076
<p>In this <a href="https://stackoverflow.com/questions/32877/how-to-remove-vsdebuggercausalitydata-data-from-soap-message">question</a> the answer was to flip on a switch that is picked up by the debugger disabling the extraneous header that was causing the problem. The Microsoft help implies these switched are user generated and does not list any switches.</p> <pre><code>&lt;configuration&gt; &lt;system.diagnostics&gt; &lt;switches&gt; &lt;add name="Remote.Disable" value="1" /&gt; &lt;/switches&gt; &lt;/system.diagnostics&gt; &lt;/configuration&gt; </code></pre> <p>What I would like to know is where the value "Remote.Disable" comes from and how find out what other things can be switched on or off. Currently it is just some config magic, and I don't like magic.</p>
<p>As you suspected, Remote.Disable stops the app from attaching debug info to remote requests. It's defined inside the .NET framework methods that make the SOAP request.</p> <p>The basic situation is that these switches can be defined anywhere in code, you just need to create a new System.Diagnostics.BooleanSwitch with the name given and the config file can control them.</p> <p>This particular one is defined in System.ComponentModel.CompModSwitches.DisableRemoteDebugging:</p> <pre><code>public static BooleanSwitch DisableRemoteDebugging { get { if (disableRemoteDebugging == null) { disableRemoteDebugging = new BooleanSwitch("Remote.Disable", "Disable remote debugging for web methods."); } return disableRemoteDebugging; } } </code></pre> <p>In your case it's probably being called from <em>System.Web.Services.Protocols.RemoteDebugger.IsClientCallOutEnabled()</em>, which is being called by <em>System.Web.Services.Protocols.WebClientProtocol.NotifyClientCallOut</em> which is in turn being called by the Invoke method of <em>System.Web.Services.Protocols.SoapHttpClientProtocol</em></p> <p>Unfortunately, to my knowledge, short of decompiling the framework &amp; seaching for </p> <pre><code>new BooleanSwitch </code></pre> <p>or any of the other inheritors of the <em>System.Diagnostics.Switch</em> class, there's no easy way to know what switches are defined. It seems to be a case of searching msdn/google/stack overflow for the specific case</p> <p>In this case I just used Reflector &amp; searched for the Remote.Disable string</p>
<p>You can use Reflector to search for uses of the Switch class and its subclasss (BooleanSwitch, TraceSwitch, etc). The various switches are hardcoded by name, so AFAIK there's no master list somewhere. </p>
5,336
<p>What's the best value for money c# code protection? Some just use obfuscation, others add win32 wrapping, some cost a fortune. So far I've come up with <a href="http://www.eziriz.com/" rel="nofollow noreferrer">http://www.eziriz.com/</a> who's Intellilock looks promising. Any other suggestions? Any reasons why this is not a good idea?</p> <p>I know its impossible to completely protect but I'd prefer the ability to protect my code so that it would require a lot of effort in order to recover it. I do hope to sell my products eventually, while also releasing some for free.</p>
<p><a href="http://www.smartassembly.com/product/editions.aspx" rel="nofollow noreferrer">Smartassembly</a> does very decent job. It's very very good, and easy to use. It even makes it harder to look at obfuscated file since it even makes it harder to decompile.</p> <blockquote> <p>Why choose {smartassembly}?</p> <p>{smartassembly} is a first-rate .NET Obfuscator, and will thus protect your .NET Intellectual Property. But, beyond that, {smartassembly} additionally offers you, and every .NET developer, the most efficient and easiest way to: Further secure your .NET application (Strings Encoding, Anti-disassembler &amp; Anti-decompiler options, Strong Name signature...) Deploy your .NET application in one file (Dependencies Merging, Compression and Embedding) Remove all non-useful code and metadata (Pruning) Perform other code optimizations (Memory Management, Automatic Sealing of Classes...) And debug your obfuscated and deployed assembly (automatic unhandled exception reporting via 24x7x365 managed Web Service).</p> <p>This comprehensive feature-set to efficiently produce better software, protected, optimized, and improved, definitely distinguishes {smartassembly} of all other .NET "protection and/or optimization solutions" available on the market.</p> <p>And its user-friendliness, which allows every .NET developer, whatever his level of competence or expertise, to easily take advantage of all these capabilities, advantageously completes this uniqueness, to your benefit.</p> <p>By efficiently enabling every .NET developer to deliver a smart version of his .NET application, in no time, and with unmatched ease, {smartassembly} definitely takes the Improvement and Protection of .NET software forward!</p> <p>With {smartassembly}, you’ll take your valued .NET application to the next level! </p> </blockquote> <p>Price range is also affordable:</p> <p>Product Name Product ID Price in Euros Price in US$</p> <p>{smartassembly} Standard Edition – Single User #300056706 € 349.00 $ 499.00</p> <p>{smartassembly} Professional Edition – Single User #300056708 € 499.00 $ 699.00</p> <p>{smartassembly} Enterprise Edition – Single User #300072534 € 649.00 $ 899.0</p>
<p>Our <a href="http://www.ssware.com/cryptoobfuscator/obfuscator-net.htm" rel="nofollow noreferrer">Crypto Obfuscator</a> product is affordable - license does not cost thousands of dollars - and provides strong obfuscation to your assemblies.</p>
9,658
<p>I want to create cursor rsrc files on the Mac from png files. The application that uses the cursors requires it to be in a .rsrc format and I cannot change that. Does anybody know of any way I can create the cursor .rsrc files from png images.</p>
<p>You can use <a href="http://www.versiontracker.com/dyn/moreinfo/macosx/23349" rel="nofollow noreferrer" title="Rezilla">Rezilla</a> to edit resource files on Mac OS X, it has a CURS (and crsr) editor among others. It's a PowerPC binary but it runs well under rosetta on intel.</p> <p>Also, you don't create a CURS resource file, you create a resource file and add as many CURS resources to it as you need. Resource forks are generic and can contain any number/kind of resources.</p>
<p>Its been a long time since I've thought about MacOS resource forks. Are you using the classic MacOS (i.e. before MacOS X)?</p> <p>As I recall, <A HREF="http://developer.apple.com/documentation/macos8/DevTools/ResEditReference/reseditreference.html" rel="nofollow noreferrer">ResEdit</A> was the application most often used to manipulate the resource fork of a classic Mac application. I know it can edit cursor resources, but I don't recall if it can read PNG files. You may need to convert the files to GIF.</p> <p>ResEdit is a Classic MacOS application. MacOS X prior to 10.5 could run Classic apps in emulation, but in 10.5 this support has been removed. You'd need to find a system either running the classic MacOS directly, or running 10.4 with Classic installed.</p>
9,760
<p>I am trying to print a model that has (at the start of the print) several small parts attached to the bed. Some of these parts have bed contact 2.5mm x 20mm.</p> <p>After a few layers, if there are any imperfections in the previous layer, the hotend is bumping the imperfection and knocking the part loose.</p> <p>I am using a genuine Prusa i3 Mk2s with Filaform PLA. I am slicing with PrusaControl and using the "Generic PLA" settings, which is giving me 215/210 degree hot end (first/other layers), and 55 degree bed. I have the fan enabled. The print bed is clean and dust free</p> <p>How can I improve bed adhesion for these small parts, ideally without adding brims etc? </p> <p>Thanks</p>
<p>One technique is to add your own custom brims to the model. A couple of "Mickey Mouse ears", attached to each end of the piece, may be enough to keep it in place (and will also be easy to remove).</p>
<p>My low-tech solution is to smear on some school/craft glue-stick. This is so quick and so easy yet it has saved me so many times from going any further troubleshooting adhesion problems.</p> <p>My <a href="https://3dprinting.stackexchange.com/a/5781/9719">answer to a similar question</a> describes this in full.</p>
703
<p>I have adjusted my z axis end stop via the paper test. However when I press to home all the axis the z axis hits the print bed moves it down slightly then goes to the postion I describe. Is this how its supose to be if not what do I need to do?</p>
<p>According to the RepRap.org <a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">list of G-Code commands</a>, see <strong><a href="http://reprap.org/wiki/G-code#G0_.26_G1:_Move" rel="nofollow noreferrer">G0 &amp; G1: Move</a></strong>:</p> <blockquote> <p>The <code>Ennn</code> command is <em>The amount to extrude between the starting point and ending point</em>. </p> </blockquote> <p>However, according to <strike><a href="https://github.com/daid/Cura/issues/385" rel="nofollow noreferrer">this</a></strike> a discussion, that is now deleted from GitHub, about the Cura slicing engine:</p> <p>The <strong>E</strong> values are in <em>absolute mode</em>, so perhaps the firmware is attempting to move the stepper motor to the absolute position (which is almost 50% through your print). This may lead to clogging or skipping depending on how hot your extruder is at that point.</p> <p>As a last resort, you can perform a Boolean subtract on your model of the section that's already printed and re-slice the model to print the remaining bit. Then glue, or ABS weld, the remaining piece to the main print. I've done this in the past, it's not super glamorous, but it gets the job done if the part doesn't require a lot of structural integrity.</p> <p><strong>I was incorrect with the following statements with regard to the Cura slicing engine:</strong> </p> <p><s>It's been a while since I've looked at 3D printer G-Code, but from what I remember, <strong>E</strong> values can be the bane of any manually written G-Code. Usually the slicing engine generates the <strong>E</strong> value as an incremental step value throughout the G-Code (at least this was true for Skeinforge and early MakerWare, please verify this). So, if the value is incremental and depending on the controller, this value could be lost or corrupt if a new print is initialized.</p> <p>I would hope, that if you're using a slicing engine's <em>custom G-Code</em> input, that the software would be able to compensate situations like this and reformat your provided G-Code to match the value of <strong>E</strong> or any similar command.</s></p>
<p>Is the hotend temperature set correctly? If you only preheat the hotend but then turn it off, it will behave exactly as you described (while you're above <code>EXTRUDE_MINTEMP</code> it will behave normally, but once the temperature drops too low it will continue doing the XYZ-moves, but stop extruding). Perhaps you need to add a <code>M109</code> command to set the temperature properly.</p> <p><a href="https://3dprinting.stackexchange.com/questions/850/no-extrusion-when-trying-to-resume-failed-print-with-manually-edited-gcode/851#851">In his answer</a>, tbm0115 mentions absolute and relative coordinates. Whether absolute or relative coordinates are used is set using the <code>G90</code>/<code>G91</code> commands and will always be the same for all axes (XYZ and E). He also mentions that:</p> <blockquote> <p>so perhaps the firmware is attempting to move the stepper motor to the absolute position (which is almost 50% thru your print). This may lead to clogging or skipping depending on how hot your extruder is at that point.</p> </blockquote> <p>This shouldn't happen, as extremely long extrude moves are ignored by Marlin. When the printer encounters</p> <pre><code>G1 F3600 X210.390 Y105.771 E4104.65185 </code></pre> <p>it performs only the XYZ-part of the move, but doesn't move the extruder (assuming the printer was reset and the current extruder position is 0). However, it does update the internal value for the extruder position, so the next move happens normally. Perhaps missing the initial extrude segment isn't a big deal, but if you want the print to resume perfectly where you left off, you should add a <code>G92</code> command to the beginning to initialize the extruder position correctly, for example:</p> <pre><code>G92 E4104.4 </code></pre> <p>(but the exact value depends on the last extruder position in the previous layer).</p>
231
<p>I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.</p> <p>The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.</p> <p>I was wondering if the more experienced ones among us (remember, I'm just a beginner) could point out the benefits and caveats of using Glade as opposed to creating everything in the code itself (assuming that learning the correct gtk bindings wouldn't exactly be a problem).</p>
<p>I would say that it depends: if you find that using Glade you can build the apps you want or need to make than that's absolutely fine. If however you actually want to learn how GTK works or you have some non-standard UI requirements you will <strong>have</strong> to dig into GTK internals (which are not that complicated).</p> <p>Personally I'm usually about 5 minutes into a rich client when I need some feature or customization that is simply impossible through a designer such as Glade or <a href="http://www.mono-project.com/Stetic" rel="noreferrer">Stetic</a>. Perhaps it's just me. Nevertheless it is still useful for me to bootstrap window design using a graphical tool.</p> <p>My recommendation: if making rich clients using GTK is going to be a significant part of your job/hobby then learn GTK as well since you <strong>will</strong> need to write that code someday.</p> <p>P.S. I personally find <a href="http://www.mono-project.com/Stetic" rel="noreferrer">Stetic</a> to be superior to Glade for design work, if a little bit more unstable.</p>
<p>You may use glade-2 to design, and use <a href="https://gist.github.com/shellexy/0ad0864b7e4e99a0a95d" rel="nofollow">glade2py.py</a> to generating the pure pygtk code, it use pygtkcompat to support gtk3</p>
7,048
<p>I've got a bunch of FoxPro (VFP9) DBF files on my Ubuntu system, is there a library to open these in Python? I only need to read them, and would preferably have access to the memo fields too.</p> <p><strong>Update</strong>: Thanks @cnu, I used Yusdi Santoso's <a href="http://www.physics.ox.ac.uk/users/santoso/dbf.py.src" rel="noreferrer"><code>dbf.py</code></a> and it works nicely. One gotcha: The memo file name extension must be lower case, i.e. <code>.fpt</code>, not <code>.FPT</code> which was how the filename came over from Windows.</p>
<p>You can try this <a href="http://code.activestate.com/recipes/362715/" rel="nofollow noreferrer">recipe on Active State</a>. </p> <p>There is also a <a href="http://code.google.com/p/lino/source/browse/lino/utils/dbfreader.py" rel="nofollow noreferrer">DBFReader module</a> which you can try.</p> <p>For support for <a href="http://www.physics.ox.ac.uk/users/santoso/dbf.py.src" rel="nofollow noreferrer">memo fields</a>.</p>
<p>If you're still checking this, I have a GPL FoxPro-to-PostgreSQL converter at <a href="https://github.com/kstrauser/pgdbf" rel="noreferrer">https://github.com/kstrauser/pgdbf</a> . We use it to routinely copy our tables into PostgreSQL for fast reporting.</p>
5,827
<p>Is it possible, in Java, to make a <code>JPanel</code> skip drawing its background thus being transparent except for the components on it?</p>
<p><code>setOpaque(false)</code></p> <p>It'll pass off painting the background to its parent, which may draw its own background.</p> <p>You can do a screen capture and then use that to paint the background of the panel.</p>
<pre><code>class TransparentJPanel extends JPanel { TransparentJPanel() { super() ; this.setOpaque( false ) ; // this will make the JPanel transparent // but not its components (JLabel, TextField etc.) this.setLayout( null ) ; } } </code></pre>
7,858
<p>I have an idea for a 3D printed project, but I'm a total noob in this area and need someone to reality check it for me.</p> <p>Basically what I want to do is a tricopter frame made of a <a href="https://en.wikipedia.org/wiki/Tetragonal_disphenoid_honeycomb" rel="nofollow noreferrer">tetrahedral honeycomb</a>.</p> <p>The whole model would be within 30 * 30 * 10 cm, the honeycomb edges would be approximately 1mm thick and about 15mm long and it would be printed out of nylon with SLS.</p> <p>I have found Shapeways' design guidelines and my idea seems to fit it, but still it feels slightly more extreme use than what they had in mind.</p> <p>Is this doable? Does anyone else use a similar method? Is there some software that I can use to generate honeycombs like this, or do I have to write it myself?</p> <p>Edit:</p> <p>This is how two layers of the honeycomb look like: <a href="https://i.stack.imgur.com/ttIZ6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ttIZ6.jpg" alt="honeycomb"></a></p> <p>In the actual model there would be several layer of this on top of each other and the shape would be kind of carved out of the honeycomb (+ some finishing to avoid spiky surface)</p>
<p>For designing your part, especially considering the repetitive mathematics involved, I would consider to learn to use OpenSCAD. I've learned the program and it fits your modeling requirement quite well. I feel it's easy to learn and is somewhat easier for folks who have a programming background. I don't have one, but it's still a logical progression to learn this program.</p> <p>Regarding the SLS aspect, that also jumped out at me as a suitable answer. Solid shapes require to have "drain holes" to reduce the amount of powder consumed by the process.</p> <p>I am assembling a Sintratec SLS printer and your model is the sort of thing I would enjoy to create with the printer. I've not yet listed my Sintratec printer on 3dhubs to solicit business, simply because it's not yet a fully assembled printer!</p> <p>I did a quick Google search for "openscad tetrahedral honeycomb" and found this link:</p> <p><a href="http://forum.openscad.org/Beginner-Honeycomb-advice-needed-td4556.html" rel="nofollow noreferrer">http://forum.openscad.org/Beginner-Honeycomb-advice-needed-td4556.html</a></p> <p>The result is more a polygonal honeycomb, not a true 3d tetrahedron, but it's a start. The file that created it is fewer than a few dozen lines of code.</p> <p>The post is old enough that the internal links no longer work but the OP posted his module code and that does work:</p> <p><a href="https://i.stack.imgur.com/rO5Je.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rO5Je.png" alt="enter image description here"></a></p> <p>I'm not sure how personal contact works in stackexchange, but I'd be willing to work with you regarding creating your code and if the printer ever gets assembled, printing out your part.</p> <p><a href="https://i.stack.imgur.com/hohRb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hohRb.png" alt="enter image description here"></a></p> <p>Adding a picture again, to show the latest revision, based on the updated information:</p> <p><a href="https://i.stack.imgur.com/Gna6W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gna6W.png" alt="enter image description here"></a></p>
<p>In short, I don't think printing the full tetrahedral honeycomb design is a good approach considering the application of the part. Here are few things to note when attempting to 3D print the tetrahedral honeycomb:</p> <p>I wouldn't recommend trying to 3D print this with a an FDM/FFF printer as you will most likely need supports and there would not be enough strength laterally. You may be able to <em>print</em> the design using SLA, but handling would be very difficult before post-processing as the part is very brittle post-print until a heat treat or curing process is done to chemically solidify. The post-process of the SLA could determine how strong the part is (ie. stainless steel powder, infused with bronze in a heat treat process would be good for such a part).</p> <p>While SLS may be the best method for 3D printing this type of design, for that size part (30x30x10cm) you're looking at an expensive print regardless of whether or not you print it yourself.</p> <p>Instead, I would highly recommend finding (or designing your own) a joint connector that would allow you to join wood/plastic dowels in the tetrahedral honeycomb shape. Not only will this be cheaper for you in the long run (easier to replace a few broken segments than an entire 3D printed model), but it could provide more structural strength for something that could potentially get banged around, like a tricopter.</p> <p>For example, <a href="http://www.thingiverse.com/thing:176263" rel="nofollow noreferrer">this model</a> on Thingiverse (not my model) shows an example of how you can utilize 3D printing complex or custom joints that allow you to connect dowels in the shape you're looking for. It'd kind of be like building with <a href="https://www.google.com/search?q=k&#39;nex&amp;hl=en&amp;biw=1920&amp;bih=918&amp;site=webhp&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ved=0ahUKEwjurNmd2fzLAhVL1mMKHZ9RA44Q_AUIBygC" rel="nofollow noreferrer">K'Nex</a>.</p> <p>As far as designing said joint, you could model a single "inner" joint that has 18 connectors (8 on XY plane, 6 on YZ plane, and 4 on XZ plane). Below is a crude example of what I mean drawn in Google SketchUp: <a href="https://i.stack.imgur.com/dlTMG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dlTMG.png" alt="enter image description here"></a></p>
246
<p>Sure, we can use a simple bulleted list or a mindmap. But, there must be a better, more interactive way. What do you use when starting your website architecture?</p>
<p>From a physical and logical architecture standpoint, nothing beats the whiteboard, drawing up the layers/tiers of the application in boxes. Then create an electronic copy using Visio.</p> <p>After that, iteratively dive into each layer and design it using appropriate tools and techniques. Here are what I commonly use:</p> <ol> <li>Database: ERD</li> <li>Business Objects (and Service Contracts): UML class diagrams</li> <li>UI: prototypes &amp; wireframes</li> <li>Workflows and asynchronous operations: flowcharts and sequence diagrams</li> </ol>
<p>By "architecture", do you mean the initial site map? If not, please post a clarification and I'll edit my response.</p> <p>Our tech team starts development after our creative department has done their stuff. Part of what we get is output from the information architect. He passes off a graphical sitemap, a detailed sitemap as an Excel sheet, and a set of wireframes in a PDF.</p>
7,791
<p>(y/N)</p> <p>Edit: Read-only access is fine.</p>
<p>I haven't tried this yet, but I think I've found a workaround.</p> <p>Adobe AIR cannot write to Windows Registry, but you can, however, launch a native process in AIR 2. Here's a blog post that shows how to do that: <a href="http://www.adobe.com/devnet/air/flex/quickstart/articles/interacting_with_native_process.html" rel="noreferrer">http://www.adobe.com/devnet/air/flex/quickstart/articles/interacting_with_native_process.html</a></p> <p>Now, on Windows, you are able to modify the Windows registry with .reg files. .reg files are just plain text files that's read by regedit.exe. So in theory, you can write a .reg file to the file system, then launch regedit.exe with the .reg file passed in and...TADA! You just modified Windows registry from your AIR app!</p> <p>To read value, you can use regedit's export function to write to a reg file and read from the reg file. Details to regedit's options: <a href="http://www.robvanderwoude.com/regedit.php" rel="noreferrer">http://www.robvanderwoude.com/regedit.php</a></p> <p>Here are some additional resources:<br/> .reg file syntax: <a href="http://support.microsoft.com/kb/310516" rel="noreferrer">http://support.microsoft.com/kb/310516</a><br/> write to file with AIR: <a href="http://www.adobe.com/devnet/air/flex/articles/exploring_file_capabilities.html" rel="noreferrer">http://www.adobe.com/devnet/air/flex/articles/exploring_file_capabilities.html</a></p>
<p>You could theoretically modify the actual registry files, but I would highly discourage that idea.</p>
2,573
<p>I've got a C# class with a <code>Dispose</code> function via <code>IDisposable</code>. It's intended to be used inside a <code>using</code> block so the expensive resource it handles can be released right away.</p> <p>The problem is that a bug occurred when an exception was thrown before <code>Dispose</code> was called, and the programmer neglected to use <code>using</code> or <code>finally</code>.</p> <p>In C++, I never had to worry about this. The call to a class's destructor would be automatically inserted at the end of the object's scope. The only way to avoid that happening would be to use the new operator and hold the object behind a pointer, but that required extra work for the programmer isn't something they would do by accident, like forgetting to use <code>using</code>.</p> <p>Is there any way to for a <code>using</code> block to be automatically used in C#?</p> <p>Many thanks.</p> <p>UPDATE:</p> <p>I'd like to explain why I'm not accepting the finalizer answers. Those answers are technically correct in themselves, but they are not C++ style destructors.</p> <p>Here's the bug I found, reduced to the essentials...</p> <pre><code>try { PleaseDisposeMe a = new PleaseDisposeMe(); throw new Exception(); a.Dispose(); } catch (Exception ex) { Log(ex); } // This next call will throw a time-out exception unless the GC // runs a.Dispose in time. PleaseDisposeMe b = new PleaseDisposeMe(); </code></pre> <p>Using <code>FXCop</code> is an excellent suggestion, but if that's my only answer, my question would have to become a plea to the C# people, or use C++. Twenty nested using statements anyone?</p>
<p>Unfortunately there isn't any way to do this directly in the code. If this is an issue in house, there are various code analysis solutions that could catch these sort of problems. Have you looked into FxCop? I think that this will catch these situations and in all cases where IDisposable objects might be left hanging. If it is a component that people are using outside of your organization and you can't require FxCop, then documentation is really your only recourse :).</p> <p>Edit: In the case of finalizers, this doesn't really guarantee when the finalization will happen. So this may be a solution for you but it depends on the situation.</p>
<p>This is no different from a programmer forgetting to use <em>delete</em> in C++, except that at least here the garbage collector will still eventually catch up with it.</p> <p>And you never need to use IDisposable if the only resource you're worried about is memory. The framework will handle that on it's own. IDisposable is only for unmanaged resources like database connections, filestreams, sockets, and the like.</p>
6,988
<p>Let's say I'm building a data access layer for an application. Typically I have a class definition for a each kind of object that is stored in the database. Of course, the actual data access retrieves data in the form of a datareader, typed or untyped dataset, or similar, usually with the data needed to create one object per row in the results.</p> <p>How would you go about creating your object instances in the data layer? Would have a constructor that accepts a datarow? If so, how would you make that type-safe? Or would you have your constructor list out one parameter for each field you want to instantiate, even if there could be many fields? Would you mark this constructor 'internal'?</p>
<p>If you aren't content with DataRow or SqlDataReader, you should look at an ORM system like Linq to Sql or nHibernate, instead of re-inventing the wheel yourself.</p> <p>(By the way, this is called the "ActiveRecord" pattern)</p>
<p>@Joel (re: complex queries, joins, etc)</p> <p>The NHibernate and Castle ActiveRecord tool can handle very complex queries and joins via class relationships and a thorough 'Expression' class (which you can add to the query methods) or the use of the 'Hibernate Query Language' (HQL).</p> <p>You can Google any of these details, check the official <a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/" rel="nofollow noreferrer">documentation</a>, or see the awesome <a href="http://www.summerofnhibernate.com/" rel="nofollow noreferrer">Summer of NHibernate</a> screencasts.</p>
6,151
<p>My Tevo Flash works well. Right now, I'm trying to print a thin, disc-like part on supports. The 3 perimeters at the edge of the disc are OK. The dense fill zigzag pattern makes many U-turns near the perimeter. It all looks OK in Simplify3D. But in the printed part, in several spots, the zigzag pattern doesn't reach the perimeters, leaving a ~1 mm gap.</p> <p>My guess: in those spots, the filament has nothing to grab onto underneath, so the U-turn region is dragged back by the nozzle a bit (away from the perimeters) and/or it droops. I'm using the smallest support res in Simplify 3D: 1 mm. Any options I can try?</p> <p><a href="https://i.stack.imgur.com/nxpz1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nxpz1.jpg" alt="enter image description here" /></a></p>
<p><em>Posted as a wiki answer from a comment from the OP to a different <a href="https://3dprinting.stackexchange.com/a/16584">answer</a>.</em></p> <hr /> <p>The <a href="https://3dprinting.stackexchange.com/a/16584"><code>Zig Zag</code> vs <code>Lines</code> patterns</a> was only a part of the problem. The 2<sup>nd</sup> part was that this layer rested on supports only, so the fill, whatever its pattern, didn't have enough surface to &quot;grab on&quot; near the perimeters. If I had switched from <code>Zig Zag</code> to <code>Lines</code>, the air gap would've diminished a bit, but I would've gotten drooping. I solved it with wider, underlying perimeters.</p>
<p>The zig-zag pattern are known for this kind of fluke...</p> <p>I will use Cura to demonstrate, but it's gonna happen on the majority of slicers.</p> <p>See this example: <a href="https://i.stack.imgur.com/uK0sk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uK0sk.png" alt="Image showing air gaps when using zig-zag fill for top/bottom layers" /></a></p> <p>Because nothing is really a circle on a cartesian plane and there's resolution limitations on the real world, the slicer has to account for these and, assuming you are using zig-zag to save time, they are doing what is expected. The Zig-zag pattern is a continuous, fast way to fill the top/bottom layers.</p> <p>Now, see this lines pattern top layer: <a href="https://i.stack.imgur.com/3CzgP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3CzgP.png" alt="Image showing smaller air gaps when using lines fill for top/bottom layers" /></a></p> <p>It has much smaller air gaps. Every time the nozzle finishes a line, it has the chance to reposition itself to make a much smaller gap, just because isn't continuous.</p> <p>So yeah, the air-gaps are a &quot;feature&quot; for zig-zag patterns, but you can mitigate this effect reducing the line width on top/botton layers.</p> <p><a href="https://i.stack.imgur.com/V4zXp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V4zXp.png" alt="Image showing kinda-smaller air gaps with zig-zag patterns when reducing the line withd" /></a></p> <p>It seems that increasing &quot;Skin Overlap Percentage&quot; on cura mitigates this effect too, but i really haven't seen the effects of this setting on a real life object</p>
1,962
<p>If I have a 3D cylindrical extrusion (in Onshape), how can I scoop, carve, or indent a concave/parabolic curve in one of the ends?</p> <p>The yellow surface is the target. <a href="https://i.stack.imgur.com/80wQB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/80wQB.jpg" alt="Object"></a> Here is the basic shape I'm trying to bore out (like a satellite dish, parabolic antenna, or even a contact lens.. You get the idea). <a href="https://i.stack.imgur.com/cbthB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cbthB.jpg" alt="Void"></a></p>
<p>As is typical with many CAD type programs, a feature in Onshape known as revolve may be your solution. As you have a clear formula for the cross-section, half of the work is complete. </p> <p>You would generate a sketch representing the curve, then use the Revolve feature with the axis oriented to vertical. According to the <a href="https://www.onshape.com/videos/revolve" rel="nofollow noreferrer">Onshape video</a>, you can generate a solid or a surface from the options that appear when selecting that feature.</p> <p><a href="https://i.stack.imgur.com/HscXP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HscXP.png" alt="sketch before revolve"></a></p> <p><a href="https://i.stack.imgur.com/YCvNK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YCvNK.png" alt="sketch after revolve"></a></p> <p>As you can see in the images above, the axis selected in the tutorial video is horizontal. Other features of revolve are covered in the video. Your post suggests it will also be necessary to perform a subtraction action on the assembly in order to get the scoop/concave result.</p>
<p>Create a midplane going through it, and then sketch half if a profile for what you want yo carve out on it that plane, and in the spot where you need it to carve out. Now revolve that profile around it's Central axis and this should cut wlthe piece you want out.</p>
732
<p>I'm trying to use <code>strtotime()</code> to respond to a button click to advance -1 and +1 days (two buttons) relative to the day advanced to on the previous click. </p> <p><strong>Example:</strong> </p> <ul> <li>It's the 10th of the month, I click "-1 day" button, and now the date reads as the 9th. </li> <li>I click the "-1 day" button again and now the readout states the 8th day. </li> <li>I click the "+1 day" button and now the readout states it's the 9th. </li> </ul> <p>I understand the buttons and the displaying the date and using <code>$_GET</code> and PHP to pass info, but how do I get <code>strtotime()</code> to work on the relative date from the last time the time travel script was called?</p> <p>My work so far has let me show yesterday and today relative to <em>now</em> but not relative to, for example, the <em>day before yesterday</em>, or the <em>day after tomorrow</em>. Or if I use my <strong>"last monday"</strong> button, the day before or after whatever that day is.</p>
<p>Working from previous calls to the same script isn't really a good idea for this type of thing.</p> <p>What you want to do is always pass two values to your script, the date, and the movement. (the below example is simplified so that you only pass the date, and it will always add one day to it)</p> <p>Example</p> <p><a href="http://www.site.com/addOneDay.php?date=1999-12-31" rel="noreferrer">http://www.site.com/addOneDay.php?date=1999-12-31</a></p> <pre><code>&lt;?php echo Date("Y-m-d",(strtoTime($_GET[date])+86400)); ?&gt; </code></pre> <p>Please note that you should check to make sure that isset($_GET[date]) before as well</p> <p>If you really want to work from previous calls to the same script, you're going to have to do it with sessions, so please specify if that is the case.</p>
<p>After a moment of inspiration, the solution to my question became apparent to me (I was riding my bike). The '$now' part of </p> <pre><code>strtottime( string $time {,int $now ]) </code></pre> <p>needs to be set as the current date. Not "$time()-now", but "the current date I'm concerned with / I'm looking at my log for.</p> <p>ie: if I'm looking at the timesheet summary for 8/10/2008, then that is "now" according to strtotime(); yesterday is 8/09 and tomorrow is 8/11. Once I creep up one day, "now" is 8/11, yesterday is 8/10, and tomorrow is 8/12.</p> <p>Here's the code example:</p> <pre><code>&lt;?php //catch variable $givendate=$_GET['given']; //convert given date to unix timestamp $date=strtotime($givendate); echo "Date Set As...: ".date('m/d/Y',$date)."&lt;br /&gt;"; //use given date to show day before $yesterday=strtotime('-1 day',$date); echo "Day Before: ".date('m/d/Y',$yesterday)."&lt;br /&gt;"; //same for next day $tomorrow=strtotime('+1 day',$date); echo "Next Day: ".date('m/d/Y',$tomorrow)."&lt;br /&gt;"; $lastmonday=strtotime('last monday, 1 week ago',$date); echo "Last Moday: ".date('D m/d/Y',$lastmonday)."&lt;br /&gt;"; //form echo "&lt;form method=\"get\" action=\"{$_SERVER['PHP_SELF']}\"&gt;"; //link to subtract a day echo "&lt;a href=\"newtimetravel.php?given=".date('m/d/Y',$yesterday)."\"&gt;&lt;&lt; &lt;/a&gt;"; //show current day echo "&lt;input type=\"text\" name=\"given\" value=\"$givendate\"&gt;"; //link to add a day echo "&lt;a href=\"newtimetravel.php?given=".date('m/d/Y',$tomorrow)."\"&gt; &gt;&gt;&lt;/a&gt;&lt;br /&gt;"; //submit manually entered day echo "&lt;input type=\"submit\" name=\"changetime\" value=\"Set Current Date\"&gt;"; //close form echo "&lt;form&gt;&lt;br /&gt;"; ?&gt; </code></pre> <p>Clicking on the "&lt;&lt;" and ">>" advances and retreats the day in question</p>
3,015
<p>just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview 5 preferably.</p>
<p>Check out the mvccontrib project at <a href="http://www.mvccontrib.org" rel="nofollow noreferrer">http://www.mvccontrib.org</a>. In the source code a restful implementation has been added and it is current up to Preview 5. Check out the source code here - <a href="http://mvccontrib.googlecode.com/svn/trunk/src/MVCContrib/SimplyRestful" rel="nofollow noreferrer">http://mvccontrib.googlecode.com/svn/trunk/src/MVCContrib/SimplyRestful</a></p>
<p>I don't know of one off the top of my head, but you might look into the way that Rails handles it if you don't find anything else, and try porting it over. Rails utilizes POST, GET, PUT, and DELETE, but it apparently has to do some fakery for PUT. Could be worth looking into if you come up dry here.</p>
6,881
<p>I'm printing a ring that's a replacement for the non-slip base of a mixing bowl. The ring is about 130mm in diameter, with a rectangular cross section, like this:</p> <p><a href="https://i.stack.imgur.com/9cx9Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9cx9Y.png" alt="rubber ring" /></a></p> <p>I'm using Cura as the slicer, and I've set the infill to 100% and <code>concentric</code>, but after slicing it looks like Cura used <code>lines</code> instead; the ring is filled with parallel straight lines:</p> <p><a href="https://i.stack.imgur.com/LEfXF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LEfXF.png" alt="lines infill" /></a></p> <p>Is this a problem with Cura? Is there something I can do to encourage it to use concentric infill? I don't really care what the infill pattern is, but I think <code>concentric</code> would print a lot faster since the head wouldn't have to switch directions all the time.</p>
<p>This is <a href="https://github.com/Ultimaker/Cura/issues/11568" rel="nofollow noreferrer">a known issue</a>. Cura's profile variable logic sets the number of bottom layers to 999999 if infill is set to 100%, overriding infill by replacing it with additional bottom layers. If you go find the setting for number of bottom layers and set it back to the number you actually want, overriding this, infill should work as expected.</p> <p>Alternatively, setting top/bottom pattern to concentric should also fix it, and you probably want that anyway so that you don't have distinct bottom layers that are printed as lines.</p>
<blockquote> <p>Is this a problem with Cura?</p> </blockquote> <p>I don't know if the good folks at Ultimaker consider this a bug or a feature, but it appears that Cura uses the <code>Lines</code> option regardless of the <em>Infill Pattern</em> setting when <em>Infill Density</em> is set to <code>100%</code>. There may well be some reason for that; for example, the fact that the <code>Lines</code> option alternates the direction of the lines from one layer to the next probably makes for stronger parts.</p> <blockquote> <p>Is there something I can do to encourage it to use concentric infill?</p> </blockquote> <p><strong>Yes!</strong> It turns out that setting <em>Infill Density</em> to anything less than <code>100%</code> gives the expected concentric infill (provided <em>Infill Pattern</em> is set to <code>Concentric</code>, of course). When I changed the setting to <code>99.99%</code> and re-sliced, I got concentric infill in the Preview panel. I haven't tried printing yet, but I have no doubt that I'll get the same thing in the actual print.</p> <blockquote> <p>I don't really care what the infill pattern is, but I think concentric would print a lot faster</p> </blockquote> <p>With <em>Infill Density</em> set to <code>99.99%</code> and <em>Infill Pattern</em> set to <code>Concentric</code>, the estimated time to print my part drops from 4 hours 50 minutes to 2 hours 44 minutes, <strong>a 44% time savings compared to 100% infill</strong>. That's probably a lot more savings than you'd get on a part that wasn't so narrow, but it's worth knowing that at least some parts can print much faster with concentric infill.</p>
2,185
<p>I am a web-developer working in PHP. I have some limited experience with using Test Driven Development in C# desktop applications. In that case we used nUnit for the unit testing framework.</p> <p>I would like to start using TDD in new projects but I'm really not sure where to begin. </p> <p>What recommendations do you have for a PHP-based unit testing framework and what are some good resources for someone who is pretty new to the TDD concept?</p>
<p>I've used both PHPUnit &amp; <strong><a href="http://simpletest.org/" rel="noreferrer">SimpleTest</a></strong> and I found <strong>SimpleTest</strong> to be easier to use.</p> <p>As far as TDD goes, I haven't had much luck with it in the purest sense. I think that's mainly a time/discipline issue on my part though.</p> <p>Adding tests after the fact has been somewhat useful but my favorite things to do is use write SimpleTest tests that test for specific bugs that I have to fix. That makes it very easy to verify that things are actually fixed and stay fixed.</p>
<p>Test driven development is an approach where tests are always written before code. You should learn to <a href="https://phpunit.de/" rel="nofollow noreferrer">PHPUNIT</a> first in order to start TDD Development. Then while making your function you should always think how function can fail and write test case in phpunit and in the end you should write code in order to pass your test. Its will be a new approach so it will be little difficult in the beginning but once you get use to it, you will find it very useful specially for after development bugs and coding style. You can go through this <a href="http://vihasverma.blogspot.com/" rel="nofollow noreferrer">Step By Step</a> guide for understanding this concept. </p> <p>Always Remember if test are written after development they are useless. So TDD is must if you are thinking to write unit tesst </p>
6,831
<p>I would like to do the equivalent of:</p> <pre><code>object result = Eval("1 + 3"); string now = Eval("System.DateTime.Now().ToString()") as string </code></pre> <p>Following Biri s <a href="http://www.codeproject.com/KB/cs/evalcscode.aspx" rel="noreferrer">link</a>, I got this snippet (modified to remove obsolete method <code>ICodeCompiler.CreateCompiler()</code>:</p> <pre><code>private object Eval(string sExpression) { CSharpCodeProvider c = new CSharpCodeProvider(); CompilerParameters cp = new CompilerParameters(); cp.ReferencedAssemblies.Add("system.dll"); cp.CompilerOptions = "/t:library"; cp.GenerateInMemory = true; StringBuilder sb = new StringBuilder(""); sb.Append("using System;\n"); sb.Append("namespace CSCodeEvaler{ \n"); sb.Append("public class CSCodeEvaler{ \n"); sb.Append("public object EvalCode(){\n"); sb.Append("return " + sExpression + "; \n"); sb.Append("} \n"); sb.Append("} \n"); sb.Append("}\n"); CompilerResults cr = c.CompileAssemblyFromSource(cp, sb.ToString()); if (cr.Errors.Count &gt; 0) { throw new InvalidExpressionException( string.Format("Error ({0}) evaluating: {1}", cr.Errors[0].ErrorText, sExpression)); } System.Reflection.Assembly a = cr.CompiledAssembly; object o = a.CreateInstance("CSCodeEvaler.CSCodeEvaler"); Type t = o.GetType(); MethodInfo mi = t.GetMethod("EvalCode"); object s = mi.Invoke(o, null); return s; } </code></pre>
<p>I have written an open source project, <a href="https://github.com/davideicardi/DynamicExpresso/" rel="noreferrer">Dynamic Expresso</a>, that can convert text expression written using a C# syntax into delegates (or expression tree). Text expressions are parsed and transformed into <a href="http://msdn.microsoft.com/en-us/library/bb397951.aspx" rel="noreferrer">Expression Trees</a> without using compilation or reflection.</p> <p>You can write something like:</p> <pre><code>var interpreter = new Interpreter(); var result = interpreter.Eval("8 / 2 + 2"); </code></pre> <p>or</p> <pre><code>var interpreter = new Interpreter() .SetVariable("service", new ServiceExample()); string expression = "x &gt; 4 ? service.aMethod() : service.AnotherMethod()"; Lambda parsedExpression = interpreter.Parse(expression, new Parameter("x", typeof(int))); parsedExpression.Invoke(5); </code></pre> <p>My work is based on Scott Gu article <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx</a> .</p>
<p>Looks like there is also a way of doing it using RegEx and XPathNavigator to evaluate the expression. I did not have the chance to test it yet but I kind of liked it because it did not require to compile code at runtime or use libraries that could not be available.</p> <p><a href="http://www.webtips.co.in/c/evaluate-function-in-c-net-as-eval-function-in-javascript.aspx" rel="nofollow noreferrer">http://www.webtips.co.in/c/evaluate-function-in-c-net-as-eval-function-in-javascript.aspx</a></p> <p>I'll try it and tell later if it worked. I also intend to try it in Silverlight, but it is too late and I'm almost asleep to do it now.</p>
7,744
<p>I've only recently started working with asp.net and c#. Is there a standard practice set of web.config settings for a live final website? There seem to be a ton of options available and I'm looking to streamline performance, close possible security holes and other unnecessary options. </p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx" rel="nofollow noreferrer">Tip/Trick: Automating Dev, QA, Staging, and Production Web.Config Settings with VS 2005</a> </p>
<p>An empty web.config (or at least an absent <em><code>&lt;</code>system.web></em> element) would mean that all of the framework's recommended defaults would take effect. You would then just need to be concerned with the host (e.g., IIS) set-up.</p>
7,936
<p>We have an Apache ANT script to build our application, then check in the resulting JAR file into version control (VSS in this case). However, now we have a change that requires us to build 2 JAR files for this project, then check both into VSS.</p> <p>The current target that checks the original JAR file into VSS discovers the name of the JAR file through some property. Is there an easy way to "generalize" this target so that I can reuse it to check in a JAR file with any name? In a normal language this would obviously call for a function parameter but, to my knowledge, there really isn't an equivalent concept in ANT.</p>
<p>I would suggest to work with <a href="http://ant.apache.org/manual/Tasks/macrodef.html" rel="nofollow noreferrer">macros</a> over subant/antcall because the main advantage I found with macros is that you're in complete control over the properties that are passed to the macro (especially if you want to add new properties).</p> <p>You simply refactor your Ant script starting with your target:</p> <pre><code>&lt;target name="vss.check"&gt; &lt;vssadd localpath="D:\build\build.00012.zip" comment="Added by automatic build"/&gt; &lt;/target&gt; </code></pre> <p>creating a macro (notice the copy/paste and replacement with the @{file}):</p> <pre><code>&lt;macrodef name="private-vssadd"&gt; &lt;attribute name="file"/&gt; &lt;sequential&gt; &lt;vssadd localpath="@{file}" comment="Added by automatic build"/&gt; &lt;/sequential&gt; &lt;/macrodef&gt; </code></pre> <p>and invoke the macros with your files:</p> <pre><code>&lt;target name="vss.check"&gt; &lt;private-vssadd file="D:\build\File1.zip"/&gt; &lt;private-vssadd file="D:\build\File2.zip"/&gt; &lt;/target&gt; </code></pre> <p>Refactoring, "the Ant way"</p>
<p>You can use <a href="http://gant.codehaus.org/" rel="nofollow noreferrer">Gant</a> to script your build with <a href="http://groovy.codehaus.org" rel="nofollow noreferrer">groovy</a> to do what you want or have a look at the <a href="http://groovy.codehaus.org/The+groovy+Ant+Task" rel="nofollow noreferrer">groovy ant task</a>.</p>
7,249
<p>The ReSharper reformat code feature is very handy and flexible, particularly with the new code layout templating flexibility JetBrains have added in version 3.0.</p> <p>Is there a standard set of code style settings for ReSharper which match the rules enforced by <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="noreferrer">Microsoft StyleCop</a>, so that StyleCop compliance can be as easy as running the ReSharper "reformat code" feature?</p>
<p>Try the ReSharper StyleCop plugin at: <a href="http://www.codeplex.com/StyleCopForReSharper" rel="noreferrer">http://www.codeplex.com/StyleCopForReSharper</a></p>
<p>I am looking for the same things.</p> <p>Here is a Custom Type member layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns"&gt; &lt;!--Do not reorder COM interfaces and structs marked by StructLayout attribute--&gt; &lt;Pattern&gt; &lt;Match&gt; &lt;Or Weight="100"&gt; &lt;And&gt; &lt;Kind Is="interface"/&gt; &lt;HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/&gt; &lt;/And&gt; &lt;HasAttribute CLRName="System.Runtime.InteropServices.StructLayoutAttribute"/&gt; &lt;/Or&gt; &lt;/Match&gt; &lt;/Pattern&gt; &lt;!--Special formatting of NUnit test fixture--&gt; &lt;Pattern RemoveAllRegions="true"&gt; &lt;Match&gt; &lt;And Weight="100"&gt; &lt;Kind Is="class"/&gt; &lt;HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" Inherit="true"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;!--Setup/Teardow--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And&gt; &lt;Kind Is="method"/&gt; &lt;Or&gt; &lt;HasAttribute CLRName="NUnit.Framework.SetUpAttribute" Inherit="true"/&gt; &lt;HasAttribute CLRName="NUnit.Framework.TearDownAttribute" Inherit="true"/&gt; &lt;HasAttribute CLRName="NUnit.Framework.FixtureSetUpAttribute" Inherit="true"/&gt; &lt;HasAttribute CLRName="NUnit.Framework.FixtureTearDownAttribute" Inherit="true"/&gt; &lt;/Or&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Group Region="Setup/Teardown"/&gt; &lt;/Entry&gt; &lt;!--All other members--&gt; &lt;Entry/&gt; &lt;!--Test methods--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And Weight="100"&gt; &lt;Kind Is="method"/&gt; &lt;HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;/Entry&gt; &lt;/Pattern&gt; &lt;!--Default pattern--&gt; &lt;Pattern&gt; &lt;!--public delegate--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And Weight="100"&gt; &lt;Access Is="public"/&gt; &lt;Kind Is="delegate"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group Region="Delegates"/&gt; &lt;/Entry&gt; &lt;!--public enum--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And Weight="100"&gt; &lt;Access Is="public"/&gt; &lt;Kind Is="enum"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;Name Region="${Name} enum"/&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!--fields and constants--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;Or&gt; &lt;Kind Is="constant"/&gt; &lt;Kind Is="field"/&gt; &lt;/Or&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Kind Order="constant field"/&gt; &lt;Readonly/&gt; &lt;Static/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group Region="Fields"/&gt; &lt;/Entry&gt; &lt;!-- Events--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;Kind Is="event"/&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group Region="Events"/&gt; &lt;/Entry&gt; &lt;!--Constructors. Place static one first--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;Kind Is="constructor"/&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Static/&gt; &lt;/Sort&gt; &lt;Group Region="Constructors"/&gt; &lt;/Entry&gt; &lt;!--properties, indexers--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;Or&gt; &lt;Kind Is="property"/&gt; &lt;Kind Is="indexer"/&gt; &lt;/Or&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group Region="Properties"/&gt; &lt;/Entry&gt; &lt;!--interface implementations--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And Weight="100"&gt; &lt;Kind Is="member"/&gt; &lt;ImplementsInterface/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;ImplementsInterface Immediate="true"/&gt; &lt;Kind Order="property"/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;ImplementsInterface Immediate="true" Region="${ImplementsInterface} Members"/&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!-- public Methods --&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And&gt; &lt;Kind Is="method"/&gt; &lt;Access Is="public"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Static/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!-- internal Methods --&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And&gt; &lt;Kind Is="method"/&gt; &lt;Access Is="internal"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Static/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!--protected internal Methods --&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And&gt; &lt;Kind Is="method"/&gt; &lt;Access Is="protected-internal"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Static/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!-- protected Methods --&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And&gt; &lt;Kind Is="method"/&gt; &lt;Access Is="protected"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Static/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!-- private Methods --&gt; &lt;Entry&gt; &lt;Match&gt; &lt;And&gt; &lt;Kind Is="method"/&gt; &lt;Access Is="private"/&gt; &lt;/And&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Static/&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;!--all other members--&gt; &lt;Entry/&gt; &lt;!--nested types--&gt; &lt;Entry&gt; &lt;Match&gt; &lt;Kind Is="type"/&gt; &lt;/Match&gt; &lt;Sort&gt; &lt;Name/&gt; &lt;/Sort&gt; &lt;Group&gt; &lt;Name Region="Nested type: ${Name}"/&gt; &lt;/Group&gt; &lt;/Entry&gt; &lt;/Pattern&gt; &lt;/Patterns&gt; &lt;!-- I. Overall I.1 Each pattern can have &lt;Match&gt;....&lt;/Match&gt; element. For the given type declaration, the pattern with the match, evaluated to 'true' with the largest weight, will be used I.2 Each pattern consists of the sequence of &lt;Entry&gt;...&lt;/Entry&gt; elements. Type member declarations are distributed between entries I.3 If pattern has RemoveAllRegions="true" attribute, then all regions will be cleared prior to reordering. Otherwise, only auto-generated regions will be cleared I.4 The contents of each entry is sorted by given keys (First key is primary, next key is secondary, etc). Then the declarations are grouped and en-regioned by given property II. Available match operands Each operand may have Weight="..." attribute. This weight will be added to the match weight if the operand is evaluated to 'true'.The default weight is 1 II.1 Boolean functions: II.1.1 &lt;And&gt;....&lt;/And&gt; II.1.2 &lt;Or&gt;....&lt;/Or&gt; II.1.3 &lt;Not&gt;....&lt;/Not&gt; II.2 Operands II.2.1 &lt;Kind Is="..."/&gt;. Kinds are: class, struct, interface, enum, delegate, type, constructor, destructor, property, indexer, method, operator, field, constant, event, member II.2.2 &lt;Name Is="..." [IgnoreCase="true/false"] /&gt;. The 'Is' attribute contains regular expression II.2.3 &lt;HasAttribute CLRName="..." [Inherit="true/false"] /&gt;. The 'CLRName' attribute contains regular expression II.2.4 &lt;Access Is="..."/&gt;. The 'Is' values are: public, protected, internal, protected internal, private II.2.5 &lt;Static/&gt; II.2.6 &lt;Abstract/&gt; II.2.7 &lt;Virtual/&gt; II.2.8 &lt;Override/&gt; II.2.9 &lt;Sealed/&gt; II.2.10 &lt;Readonly/&gt; II.2.11 &lt;ImplementsInterface CLRName="..."/&gt;. The 'CLRName' attribute contains regular expression II.2.12 &lt;HandlesEvent /&gt; --&gt; </code></pre> <p>based on this one, that did not do the trick for me but who deserves the credit: <a href="http://www.clydesdalesoftware.net/blogs/jluif/CommentView,guid,1875594b-0d23-401f-8e22-f1cbf87beefe.aspx" rel="nofollow noreferrer">http://www.clydesdalesoftware.net/blogs/jluif/CommentView,guid,1875594b-0d23-401f-8e22-f1cbf87beefe.aspx</a></p> <p>This is a header snippet that complies to stylecop:</p> <pre><code>// &lt;copyright file="$FileName$" company="$Company$"&gt; // Copyright (c) 2008 All Right Reserved // &lt;/copyright&gt; // &lt;author&gt;$author$&lt;/author&gt; // &lt;email&gt;$email$&lt;/email&gt; // &lt;date&gt;$date$&lt;/date&gt; // &lt;summary&gt;$summary$&lt;/summary&gt; </code></pre> <p>Still not quite there but it is a start.</p> <p>Since this answer the Custom type member layout has been put in the StyleCop for resharper plugin. See <a href="http://1succeeded0failed0skipped.com/blogs/howardvanrooijen/archive/2008/12/07/stylecop-for-resharper-v0-0-14220-released.aspx" rel="nofollow noreferrer">here</a></p>
8,229