instruction stringlengths 27 22.5k | chosen stringlengths 27 28.2k | rejected stringlengths 19 24.9k | __index_level_0__ int64 0 10k |
|---|---|---|---|
<p>I'm looking for a c# snippet which I can insert in a Windows service. The code must empty the recycle bin for all users on the computer.</p>
<p>I have previously tried using <code>SHEmptyRecycleBin</code> (ref <a href="http://www.codeproject.com/KB/cs/Empty_Recycle_Bin.aspx" rel="nofollow noreferrer">http://www.cod... | <p>I think doing something like this is against Microsoft recommended practices. What are you trying to do that requires emptying the Recycle Bin from a Windows service?</p>
| <p>First, have you tried running the service on an interactive user account? Maybe SHEmptyRecycleBin requires an interactive user even though it doesn't necessarily display a Window.</p>
<p>Second, I'm not sure it's a good idea to delete other users' stuff but I guess you have a very good reason?</p>
| 3,009 |
<p>How do I detect if the system has a default recording device installed?
I bet this can be done through some calls to the Win32 API, anyone has any experience with this?</p>
<p>I'm talking about doing this through code, not by opening the control panel and taking a look under sound options.</p>
| <p>Using the <a href="https://www.microsoft.com/en-in/download/details.aspx?id=6812" rel="nofollow noreferrer">DirectX SDK</a>, you can call DirectSoundCaptureEnumerate, which will call your DSEnumCallback function for each DirectSoundCapture device on the system. The first parameter passed to your DSEnumCallback is a... | <p>There is an Open Source Audio API called <a href="http://www.portaudio.com/" rel="nofollow noreferrer">PortAudio</a> that has a method you could use. I think the method is called Pa_GetDeviceInfo() or something.</p>
| 6,263 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/30170/avoiding-repeated-constants-in-css">Avoiding repeated constants in CSS</a> </p>
</blockquote>
<p>We have some "theme colors" that are reused in our CSS sheet.</p>
<p>Is there a way to set a variable and ... | <p>There's no requirement that all styles for a selector reside in a single rule, and a single rule can apply to multiple selectors... so <em>flip it around</em>:</p>
<pre><code>/* Theme color: text */
H1, P, TABLE, UL
{ color: blue; }
/* Theme color: emphasis */
B, I, STRONG, EM
{ color: #00006F; }
/* ... */
/* Th... | <p>CSS does not (yet) employ variables, which is understandable for its age and it being a declarative language.</p>
<p>Here are two major approaches to achieve more dynamic style handling:</p>
<ul>
<li>Server-side variables in inline css<br>
Example (using PHP):
<blockquote>
<p><code><style> .myclass{colo... | 6,976 |
<p>Does anyone know a method to programmatically close the CD tray on Windows 2000 or higher?
Open CD tray exists, but I can't seem to make it close especially under W2k. </p>
<p>I am especially looking for a method to do this from a batch file, if possible, but API calls would be OK.</p>
| <p>Here is an easy way using the Win32 API:</p>
<pre><code>
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]
protected static extern int mciSendString(string lpstrCommand,StringBuilder lpstrReturnString,int uReturnLength,IntPtr hwndCallback);
public void OpenCloseCD(bool Open)
... | <p>To close the drive tray do as described <a href="https://stackoverflow.com/a/30512979/3969362">here</a> but instead of using DeviceIoControl with IOCTL_STORAGE_EJECT_MEDIA you need to call DeviceIoControl with IOCTL_STORAGE_LOAD_MEDIA.</p>
| 8,308 |
<p>This problem started <a href="http://forums.asp.net/t/1304033.aspx" rel="nofollow noreferrer">on a different board</a>, but <a href="https://stackoverflow.com/users/60/dave-ward">Dave Ward</a>, who was very prompt and helpful there is also here, so I'd like to pick up here for hopefully the last remaining piece of t... | <p>Hey, Jason. Sorry you're still having trouble with this.</p>
<p>What I would do is set up a simple page like:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
Response.Write(i + "<br />");
Response.Flush();
Thread.Sleep(1000);
}
}
<... | <p>I don't know that you can force buffering - but a reverse proxy server between you and the server would affect buffering (since the buffer then affects the proxy's connection - not your browser's).</p>
| 4,446 |
<p>How do you create SQL Server 2005 stored procedure templates in SQL Server 2005 Management Studio?</p>
| <p>Another little nugget that I think will help people developing and being more productive in their database development. I am a fan of stored procedures and functions when I develop software solutions. I like my actual CRUD methods to be implemented at the database level. It allows me to balance out my work betwee... | <p>You bring up <em>Template Explorer</em> using Ctrl+Alt+T or trough <em>View > Template Explorer</em>. Then you can right click tree nodes to add new Templates or new folders to organize your new templates.</p>
| 9,064 |
<p>I have a simple printer bot metal with a heated bed, the heated bed I am not using. I am using conductive pla by protopasta </p>
<p>The conductive pla is not that strong, so when I take my pieces off the board, sometimes they break. The only time it appears to be invincibly strong is when it sticks to the bed plate... | <p>I have no experience with your printer model nor with protopasta conductive PLA but since your problem is "too much adhesion" I would simply suggest to <strong>follow in reverse all the usual advices on how to make the first layer adhere better</strong> (a far more common problem). The list of suggestion could be:<... | <p>Based on your description "it is very thin" about the skirt, and by the other characteristics you've provided, I suggest that your z-height for the first layer is suspect of being too small, too close to the bed.</p>
<p>If you have calibration specific to z-height only, re-calibrate and make a test print with skir... | 865 |
<p>We have a Java listener that reads text messages off of a queue in JBossMQ. If we have to reboot JBoss, the listener will not reconnect and start reading messages again. We just get messages in the listener's log file every 2 minutes saying it can't connect. Is there something we're not setting in our code or in JBo... | <p>You should implement in your client code javax.jms.ExceptionListener. You will need a method called onException. When the client's connection is lost, you should get a JMSException, and this method will be called automatically. The only thing you have to look out for is if you are intentionally disconnecting from... | <p>Piece of advice from personal experience. <strong>Upgrade to <a href="http://www.jboss.org/jbossmessaging/" rel="nofollow noreferrer">JBoss Messaging</a>.</strong> I've seen it in production for 4 months without problems. It has fully transparent failover - amongst many other features.</p>
<p>Also, if you do go ... | 6,993 |
<p>I infrequently (monthly/quarterly) generate hundreds of Crystal Reports reports using Microsoft SQL Server 2005 database views. Are those views wasting CPU cycles and RAM during all the time that I am not reading from them? Should I instead use stored procedures, temporary tables, or short-lived normal tables sinc... | <p>For the most part, it doesn't matter. Yes, SQL Server will have more choices when it parses SELECT * FROM table (it'll have to look in the system catalogs for 'table') but it's highly optimized for that, and provided you have sufficient RAM (most servers nowadays do), you won't notice a difference between 0 and 1,00... | <p>The views are only going to take up cpu/memory resources when they are called.</p>
<p>Anyhow, best practice would be to consolidate what can be consolidated, remove what can be removed, and if it's literally only used by your reports, choose a consistent naming standard for the views so they can easily be grouped t... | 6,140 |
<p>I'd like to know what's the way to actually set the icon of a <code>.bat</code> file to an arbitrary icon.
How would I go about doing that programmatically, independently of the language I may be using.</p>
| <p>Assuming you're referring to MS-DOS batch files: as it is simply a text file with a special extension, a <code>.bat</code> file doesn't store an icon of its own.</p>
<p>You can, however, create a shortcut in the <code>.lnk</code> format that stores an icon.</p>
| <p>i recommand to use BAT to EXE converter for your desires </p>
| 3,626 |
<p>There are many posts on the internet about the ReadDirectoryChangesW API function missing files when there is a lot of file activity. Most blame the speed at which the ReadDirectoryChangesW function loop is called. This is an incorrect assumption. The best explanation I have seen is in the following post, the com... | <p>If the API is unreliable, then a workaround may be your only option. That of course likely involves keeping track of lastmodified and filenames. <s>What this doesn't mean is that you need to poll when looking for changes, rather, you can use the FileSystemWatcher as a means to trigger checking. </s></p>
<p>So ... | <p>I met same problem. But, I didn't find a solution that guarantee to get all of events. In several tests, I could know that ReadDirectoryChangesW function should be called again as fast as possible after GetQueuedCompletionStatus function returned. I guess if a processing speed of filesystem is very faster than my ap... | 8,147 |
<p>So, I did search google and SO prior to asking this question. Basically I have a DLL that has a form compiled into it. The form will be used to display information to the screen. Eventually it will be asynchronous and expose a lot of customization in the dll. For now I just want it to display properly. The problem t... | <p>I also had trouble activating and bringing a window to the foreground. Here is the code that eventually worked for me. I'm not sure if it will solve your problem.</p>
<p>Basically, call ShowWindow() then SetForegroundWindow().</p>
<pre><code>using System.Diagnostics;
using System.Runtime.InteropServices;
// Sets ... | <p>You shouldn't need to import any win32 functions for this. If .Focus() isn't enough the form should also have a .BringToFront() method you can use. If that fails, you can set it's .TopMost property to true. You don't want to <em>leave</em> it true forever, so then call Application.DoEvents so the form can process... | 6,807 |
<p>If you use the standard tab control in .NET for your tab pages and you try to change the look and feel a little bit then you are able to change the back color of the tab pages but not for the tab control. The property is available, you could set it but it has no effect. If you change the back color of the pages and ... | <p>The solution in Rajesh's blog is really useful, but it colours the tab part of the control only. In my case I had a tabcontrol on a different coloured background. The tabs themselves were grey which wasn't a problem, but the area to the right of the tabs was displaying as a grey strip. </p>
<p>To change this colour... | <p>Thanks, LauraM. You helped get me on the right track. I had already found the link Oskar provided but that didn't do anything for the strip at the end.</p>
<p>In the end, I had to change quite a bit because I needed a background image on the form to bleed through or if the parent was something without a backgroun... | 9,287 |
<p>What is a good complete <a href="http://en.wikipedia.org/wiki/Regular_expression" rel="noreferrer">regular expression</a> or some other process that would take the title:</p>
<blockquote>
<p>How do you change a title to be part of the URL like Stack Overflow?</p>
</blockquote>
<p>and turn it into </p>
<pre clas... | <p>Here's how we do it. Note that there are probably more edge conditions than you realize at first glance.</p>
<p>This is the second version, unrolled for 5x more performance (and yes, I benchmarked it). I figured I'd optimize it because this function can be called hundreds of times per page.</p>
<pre><code>/// <... | <p>Rewrite of Jeff's code to be more concise</p>
<pre><code> public static string RemapInternationalCharToAscii(char c)
{
var s = c.ToString().ToLowerInvariant();
var mappings = new Dictionary<string, string>
{
{ "a", "àåáâäãåą" },
{ &quo... | 4,490 |
<p>I created a view on a machine using the <em>substring</em> function from Firebird, and it worked. When I copied the database to a different machine, the view was broken. This is the way I used it:</p>
<pre><code>SELECT SUBSTRING(field FROM 5 FOR 15) FROM table;
</code></pre>
<p>And this is the output on the mach... | <ol>
<li><p>Make sure Firebird engine is 1.5 and there's no InterBase server running on this same box on the port you expected Firebird 1.5.</p>
</li>
<li><p>Make sure you don't have any UDF called 'substring' registered inside this DB so that Firebird is expecting different parameters.</p>
</li>
</ol>
| <p>Different engine versions?</p>
<p>Have you tried naming that expression in the result?</p>
<pre><code>SELECT SUBSTRING(field FROM 5 FOR 15) AS x FROM table;
</code></pre>
| 2,713 |
<p>In C++, I'm trying to catch all types of exceptions in one catch (like <code>catch(Exception)</code> in C#). How is it done? And what's more, how can one catch divide-by-zero exceptions?</p>
| <pre><code>catch (...)
{
// Handle exceptions not covered.
}
</code></pre>
<p>Important considerations:</p>
<ul>
<li>A better approach is to catch specific types of exception that you can actually recover from as opposed to all possible exceptions.</li>
<li>catch(...) will also catch certain serious system level e... | <p>If I recall correctly (it's been a while since I've looked at C++), I think the following should do the trick</p>
<pre><code>try
{
// some code
}
catch(...)
{
// catch anything
}
</code></pre>
<p>and a quick google(<a href="http://www.oreillynet.com/pub/a/network/2003/05/05/cpluspocketref.html" rel="nofollow nor... | 7,969 |
<p>I noticed that Google maps is providing directions in my local language (hungarian) when I am using google chrome, but English language directions when I am using it from IE. </p>
<p>I would like to know how chrome figures this out and how can I write code that is always returning directions on the user's language.... | <p><code>HTTP</code>requests` include an <strong>Accept-Language header</strong> which is set according to your locale preferences on most OS/browser combinations. Google uses a combination of that, the local domain you use (eg 'google.it', 'google.hu') and any preferences you set with the Preferences link in the home ... | <p>I could be way off but I think it's fairly safe to assume that google, is using gears.</p>
| 9,261 |
<p>I need to implement a Diff algorithm in VB.NET to find the changes between two different versions of a piece of text. I've had a scout around the web and have found a couple of different algorithms.</p>
<p>Does anybody here know of a 'best' algorithm that I could implement?</p>
| <p>Well I've used the c# version on codeproject and its really good for what I wanted...</p>
<p><a href="http://www.codeproject.com/KB/recipes/diffengine.aspx" rel="noreferrer">http://www.codeproject.com/KB/recipes/diffengine.aspx</a></p>
<p>You can probably get this translated into VB.net via an <a href="http://labs... | <p>I don't know for sure if it's the best diff algorithms but you might want to check out those links that talks about SOCT4 and SOCT6</p>
<p><a href="http://dev.libresource.org/home/doc/so6-user-manual/concepts" rel="nofollow noreferrer">http://dev.libresource.org/home/doc/so6-user-manual/concepts</a></p>
<p>and als... | 2,530 |
<p>I wrote a simple web service in C# using SharpDevelop (which I just got and I love).</p>
<p>The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, so I may seem a little old-fashioned.)</p>
... | <p>In VB.NET, namespace declarations are relative to the default namespace of the project. So if the default namespace for the project is set to X.Y, everithyng between <code>Namespace Z</code> and <code>End Namespace</code> will be in the X.Y.Z namespace.
In C# you have to provide the full namespace name, regardless o... | <pre><code><%@ WebService Class="flightinfo.Soap,flightinfo" %>
</code></pre>
<p>What is the name of your class?</p>
| 8,490 |
<p>I'm trying to call an Antlr task in my Ant build.xml as follows:</p>
<pre><code><path id="classpath.build">
<fileset dir="${dir.lib.build}" includes="**/*.jar" />
</path>
...
<target name="generate-lexer" depends="init">
<antlr target="${file.antlr.lexer}">
<classpath refi... | <p>The current Antlr-task jar is available at <a href="http://www.antlr.org/share/1169924912745/antlr3-task.zip" rel="nofollow noreferrer">http://www.antlr.org/share/1169924912745/antlr3-task.zip</a></p>
<p>It can be found on the <a href="http://antlr.org" rel="nofollow noreferrer">antlr.org</a> website under the "Fil... | <p>On Ubuntu this should make it available:</p>
<p><code>sudo apt-get install ant-optional</code></p>
| 4,512 |
<p>How do I get the latest version of my solution recursively like its done in the solution explorer context menu of Visual Studio? I want to do this from the command line or via a macro. I'm trying to automate a part of my daily routine by using a set of batch files. I am sure a lot of developers would love to have so... | <p>TFS has a <a href="http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx" rel="nofollow noreferrer">.Net SDK</a> that allows you to create your own custom programs that interact with a TFS Server. You could write a small program that performs the task you need:</p>
<pre><code>TeamFoundationServer tfs = Team... | <p>I know you mentioned batch files, but let me throw something else out for you.</p>
<p>I'm going to guess that you are using the 2005 version of TFS. 2008 has all of the scheduling stuff built in. </p>
<p>However, you could also use <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+Cruis... | 5,439 |
<p>Suppose I have the following CSS rule in my page:</p>
<pre class="lang-css prettyprint-override"><code>body {
font-family: Calibri, Trebuchet MS, Helvetica, sans-serif;
}
</code></pre>
<p>How could I detect which one of the defined fonts were used in the user's browser?</p>
<p>For people wondering why I want to ... | <p>I've seen it done in a kind of iffy, but pretty reliable way. Basically, an element is set to use a specific font and a string is set to that element. If the font set for the element does not exist, it takes the font of the parent element. So, what they do is measure the width of the rendered string. If it matche... | <p>You can use this website :</p>
<p><a href="http://website-font-analyzer.com/" rel="nofollow noreferrer">http://website-font-analyzer.com/</a></p>
<p>It does exactly what you want...</p>
| 2,328 |
<p>I'm trying to get good-quality thin wall prints with PLA on my Creality CR10s Pro V2 using Cura. After hours of calibration and testing, I'm getting quite good results. However, there is one issue I can't figure out. It seems that I'm getting uneven extrusion and blobs when the printer deaccelerates or accelerates. ... | <p>Look at the gcode for those curves either manually in a text editor, or with a gcode analyzer tool (e.g. <a href="https://gcode.ws" rel="nofollow noreferrer">gcode.ws</a>) and see if there's anything strange about them. Cura is notorious for numeric instability problems with high resolution curves, where it will end... | <p>If you haven't already, try rotating the object about the Z-axis to give a different orientation with respect to X and Y. May not correct the problem but if the effect changes it may shed some light on the cause.</p>
| 2,101 |
<p>Is it possible to extract all of the VBA code from a Word 2007 "docm" document using the API?</p>
<p>I have found how to insert VBA code at runtime, and how to delete all VBA code, but not pull the actual code out into a stream or string that I can store (and insert into other documents in the future).</p>
<p>Any ... | <p>You'll have to add a reference to Microsoft Visual Basic for Applications Extensibility 5.3 (or whatever version you have). I have the VBA SDK and such on my box - so this may not be exactly what office ships with.</p>
<p>Also you have to enable access to the VBA Object Model specifically - see the "Trust Center" i... | <p>You'll have to add a reference to Microsoft Visual Basic for Applications Extensibility 5.3 (or whatever version you have). I have the VBA SDK and such on my box - so this may not be exactly what office ships with.</p>
<p>Also you have to enable access to the VBA Object Model specifically - see the "Trust Center" i... | 7,233 |
<p>I'm creating an installer for a website that uses a custom event log source. I would like our WiX based installer to create that event log source during installation.</p>
<p>Does anyone know the best way to do this using the WiX framework.</p>
| <p>Wix has out-of-the-box support for creating event log sources.</p>
<p>Assuming you use Wix 3, you first need to add a reference to WixUtilExtension to either your Votive project or the command line. You can then add an EventSource element under a component :</p>
<pre><code><Wix xmlns="http://schemas.microsoft.c... | <p>Just to save people some time - if you are trying to use the Application log and the .NET messages you can cut paste the below code:</p>
<pre><code><Util:EventSource
xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
Name="ROOT Builder"
Log="Application"
EventMessageFile="%SystemRoot%\Microsoft.NET\... | 8,289 |
<p>Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:</p>
<pre><code>Array.CreateInstance(typeof(Object), new int[] {2}, new int[] {9});
</code></pre>
<p>Produces the desired results (an array of objects with a lower boun... | <p>The reason why you can't cast from one to the other is that this is evil.</p>
<p>Lets say you create an array of object[5..9] and you pass it to a function F as an object[].</p>
<p>How would the function knows that this is a 5..9 ? F is expecting a general array but it's getting a constrained one. You could say it... | <p>Know it's old question, but to fully explain it.</p>
<p>If type (in this case a single-dimension array with lower bound > 0) can't be created by typed code, simply reflected type instance can't be consumed by typed code then.</p>
<p>What you have noticed is already in documentation:</p>
<p><a href="https://learn.... | 8,040 |
<p>I'm reading lines of text that can come in any order. The problem is that the output can actually be indentical to the previous output. How can I detect this, without sorting the output first?</p>
<p>Is there some kind of hash function that can take identical input, but in any order, and still produce the same resu... | <p>The easiest way would seem to be to hash each line on the way in, storing the hash and the original data, and then compare each new hash with your collection of existing hashes. If you get a positive, you could compare the actual data, to make sure it's not a false positive - though this would be extremely rare, you... | <p>So you have input like</p>
<pre><code>A B C D
D E F G
C B A D
</code></pre>
<p>and you need to detect that the first and third lines are identical?</p>
| 8,972 |
<p>What CSS should I use to make a cell's border appear even if the cell is empty?</p>
<p>IE 7 specifically.</p>
| <p>If I recall, the cell dosn't exist in some IE's unless it's filled with something...</p>
<p>If you can put a <code>&nbsp;</code> (non-breaking space) to fill the void, that will usually work. Or do you require a pure CSS solution?</p>
<p>Apparently, IE8 shows the cells by default, and you have to hide it with ... | <p>"IE" isn't a useful term in this context anymore now that IE8 is out.</p>
<p>IE7 always does "empty-cells:show" (or so I'm told ... Vista).
IE8 in any of its "Quirks" or "IE7 Standards" modes always does "empty-cells:hide".
IE8 in "Standards" mode defaults to "empty-cells:show" and supports the attribute via CSS.</... | 8,119 |
<p>I have some code like this in a winforms app I was writing to query a user's mail box Storage Quota.</p>
<pre><code>DirectoryEntry mbstore = new DirectoryEntry(
@"LDAP://" + strhome,
m_serviceaccount,
[m_pwd],
AuthenticationTypes.Secure);
</code></pre>
<p>No matter what approach I tried ... | <p>The sanctified method is to use CryptoAPI and the Data Protection APIs.</p>
<p>To encrypt, use something like this (C++):</p>
<pre><code>DATA_BLOB blobIn, blobOut;
blobIn.pbData=(BYTE*)data;
blobIn.cbData=wcslen(data)*sizeof(WCHAR);
CryptProtectData(&blobIn, description, NULL, NULL, NULL, CRYPTPROTECT_LOCAL_M... | <p>If you store it as a secure string and save the secure string to a file (possibly using <a href="http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.aspx" rel="nofollow noreferrer">Isolated Storage</a>, the only time you will have a plain text password is when you decrypt it to create your mbstore. Un... | 6,212 |
<p>What are some strategies that people have had success with for maintaining a change history for data in a fairly complex database. One of the applications that I frequently use and develop for could really benefit from a more comprehensive way of tracking how records have changed over time. For instance, right now r... | <p>In the past I have used triggers to construct db update/insert/delete logging. </p>
<p>You could insert a record each time one of the above actions is done on a specific table into a logging table that keeps track of the action, what db user did it, timestamp, table it was performed on, and previous value. </p>
<p... | <p>The only problem with using Triggers is that it adds to performance overhead of any insert/update/delete. For higher scalability and performance, you would like to keep the database transaction to a minimum. Auditing via triggers increase the time required to do the transaction and depending on the volume may cause ... | 4,363 |
<p>Is there any difference between:</p>
<pre><code>if foo is None: pass
</code></pre>
<p>and</p>
<pre><code>if foo == None: pass
</code></pre>
<p>The convention that I've seen in most Python code (and the code I myself write) is the former, but I recently came across code which uses the latter. None is an instance... | <p><code>is</code> always returns <code>True</code> if it compares the same object instance</p>
<p>Whereas <code>==</code> is ultimately determined by the <code>__eq__()</code> method</p>
<p>i.e.</p>
<pre><code>
>>> class Foo(object):
def __eq__(self, other):
return True
>>> f = Foo()
>>> f == Non... | <pre><code>a is b # returns true if they a and b are true alias
a == b # returns true if they are true alias or they have values that are deemed equivalence
a = [1,3,4]
b = a[:] #creating copy of list
a is b # if gives false
False
a == b # gives true
True
</code></pre>
| 4,616 |
<p>I have an Ender 3 with a removeable build surface. The build surface backing has become warped - the center is at least 0.3 mm higher than the corners. I'm not sure what the material of this plate is - it's the part behind the BuildTak-clone surface that sits on the aluminum heat bed and is clipped to it. This makes... | <p>I measured mine with a thread gauge and it says the pitch is <strong>0.7 mm</strong>.</p>
<p>So, as the stock adjustment wheels have 14 bumps around their circumference, turning by one of those is an adjustment of exactly 0.05 mm (assuming no backlash).</p>
<p>I can't speak for anyone else's, but due to the availabi... | <p>I don't know what the value is, but there are a few ways to find out. It is very hard to measure this with a caliper, but it can be done, mark the upper and bottom of e.g. 10 windings and measure this with a caliper. Alternatively measure how much the screw drops after 10 full turns. </p>
<p>There are special tools... | 1,571 |
<p>I've got an MDI application written in Delphi 2006 which runs XP with the default theme. </p>
<p>Is there a way of controlling the appearance of the MDI Children to avoid the large XP-style title bar on each window? </p>
<p>I've tried setting the <code>BorderStyle</code> of the <code>MDIChildren</code> to <code>bs... | <p>All your need - overload procedure CreateWindowHandle, like this:</p>
<pre><code>unit CHILDWIN;
interface
uses Windows, Classes, Graphics, Forms, Controls, StdCtrls;
type
TMDIChild = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure CreateWindowHandle(const Pa... | <p>I don't think there is; in my experience, MDI in Delphi is very strictly limited and controlled by its implementation in the VCL (and perhaps also by the Windows API?). For example, don't try hiding an MDI child (you'll get an exception if you try, and you'll have to jump through a couple of API hoops to work around... | 3,022 |
<p>I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?</p>
<p>It appears that the general solution is to create a hidden iframe and throw the contents of the strin... | <p>Ajaxian actually had a <a href="http://ajaxian.com/archives/introducing-html-into-an-iframe-and-getting-it-back" rel="noreferrer">post on inserting / retrieving html from an iframe</a> today. You can probably use the js snippet they have posted there.</p>
<p>As for handling closing of a browser / tab, you can attac... | <p>So you want to download a webpage as an XML object using javascript, but you don't want to use a webpage? Since you have no control over what the user will do (closing tabs or windows or whatnot) you would need to do this in like a OSX Dashboard widget or some separate application. A Firefox extension would also wor... | 2,592 |
<p>So I am trying to fix a custom built 3D printer for my institute and am running into a problem I can't wrap my head around.</p>
<p>So the limit switches for Y-axis and Z-Axis work just fine, but the X-Axis does not. </p>
<p>All three switches are Makerbot (3-pin), and all three light up the LED when they get press... | <p>Considering you're having issues with the board, and the limit switches appear to be registering, but the board isn't doing anything about it, a first good step would be to update the firmware to 1.1.9 as @0scar states. If the update in the firmware doesn't do the trick, then move on to doing as he suggests with cha... | <p>To rule out problem with the switches itself, you can change the Z-min and swap it with the Y- or Z-min. Once you found out that you get the same issues you know that your X endstop module is working (unless they both are faulty, but the odds are small for that), but the signal change is not registered by the board.... | 1,153 |
<p>People,</p>
<p>We have 4 or 5 utilities that work in conjunction with our application. These utilities are either .bat files, or VB apps, PowerBuilder, etc. I am trying to manage these utils in source control, and am trying to figure out a better way to assign versions to them. Right now, the developers use the ver... | <p>PowerBuilder in particular has a nice trick you can do to incorporate the build number from an ini file into the compiled application.</p>
<p>Details here: <a href="http://www.pbdr.com/pbtips/ex/autorev.htm" rel="nofollow noreferrer">http://www.pbdr.com/pbtips/ex/autorev.htm</a></p>
<p>We have ini file inside sour... | <p>I managed our build system at my last job, which seemed to have some parallels to what you're asking.</p>
<p>There were ~30 C++ projects which needed compiling, and various .NET/Java things, and the odd perl script.</p>
<p>This was all built on our build machine using NAnt - If I were doing it today I'd use <a hre... | 3,857 |
<p>After changing the output directory of a visual studio project it started to fail to build with an error very much like: </p>
<pre><code>C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\sgen.exe /assembly:C:\p4root\Zantaz\trunk\EASDiscovery\EASDiscoveryCaseManagement\obj\Release\EASDiscoveryCaseManagement.... | <p>If you are having this problem while building your VS.NET project in Release mode here is the solution:</p>
<p>Go to the project properties and click on the Build tab and set the value of the "Generate Serialization Assembly" dropdown to "Off".</p>
<p>Sgen.exe is "The XML Serializer Generator creates an XML serial... | <p>I've not seen this particular problem, but recently for us a "C1001: An internal error has occurred in the compiler" type crash from cl.exe was fixed after installing some random and unrelated (or so we thought) Windows security updates.</p>
<p>We knew the code didn't crash the compiler on other machines using the ... | 2,834 |
<p>I have a ASP.NET page with an asp:button that is not visible. I can't turn it visible with JavaScript because it is not rendered to the page.</p>
<p>What can I do to resolve this?</p>
| <p>If you need to manipulate it on the client side, you can't use the Visible property on the server side. Instead, set its CSS display style to "none". For example:</p>
<pre><code><asp:Label runat="server" id="Label1" style="display: none;" />
</code></pre>
<p>Then, you could make it visible on the client si... | <p>If you wait until the page is loaded, and then set the button's display to none, that should work. Then you can make it visible at a later point.</p>
| 2,937 |
<p>I'm trying to refer to a drive whose letter may change. I'd like to refer to it by its label (e.g., MyLabel (v:) within a Batch File. It can be referred to by V:\ . I'd like to refer to it by MyLabel.</p>
<p>(This was posted on Experts Echange for a month with no answer. Let's see how fast SO answers it )</p>
| <p>The previous answers seem either overly complicated, and/or not particularly suited to a batch file.</p>
<p>This simple one liner should place the desired drive letter in variable myDrive. Obviously change "My Label" to your actual label.</p>
<pre><code>for /f %%D in ('wmic volume get DriveLetter^, Label ^| find "... | <p>You can use the WMI query language for that.
Take a look at <a href="http://msdn.microsoft.com/en-us/library/aa394592(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa394592(VS.85).aspx</a> for examples.
The information you are looking for is available e.g. through the property Volume... | 7,014 |
<p>[We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right i... | <p>I think the best approach for this is to combine </p>
<ol>
<li><a href="https://stackoverflow.com/q/460483/1366033">Converting Markdown to HTML</a> &</li>
<li><a href="https://stackoverflow.com/a/12724381/1366033">Displaying HTML in WinForms</a></li>
</ol>
<p>The most up to date Markdown Library seems to be <a... | <p>Can't you just use the same control I'm Stack Overflow uses (that we're all typing into)---WMD, and just store the Markdown in the VARCHAR. Then use the .NET Markdown to HTML converter, as you mentioned, to display the HTML as needed. Jeff talks about this in more detail in a StackOverflow podcast (don't know the ep... | 5,077 |
<p>For various reasons calling <code>System.exit</code> is frowned upon when writing <strong>Java Applications</strong>, so how can I notify the calling process that not everything is going according to plan?</p>
<p><strong>Edit:</strong> The 1 is a <code>standin</code> for any non-zero exit code.</p>
| <p>The use of <code>System.exit</code> is frowned upon when the 'application' is really a sub-application (e.g. servlet, applet) of a larger Java application (server): in this case the <code>System.exit</code> could stop the JVM and hence also all other sub-applications. In this situation, throwing an appropriate excep... | <p>It's frowned upon for <em>normal</em> exits. If "not everything is going according to plan", then System.exit is fine.</p>
<p>Update: I should add that I assume your '1' has meaning that is documented somewhere.</p>
| 5,279 |
<p>What are the real overhang limits? I see a lot online about 45 %, then up to 60 %, but I'm routinely doing them at up to 90 % for "shortish" distances and 80%+ for several centimeters at a time. I haven't tried to see how far I can do it, since I don't have filament to waste on that sort of thing.</p>
<p>I... | <p>It is very difficult to determine a definitive number/value for the overhang angle, this is very dependent on the temperature, speed, material, nr. of walls amount of cooling fan percentage and the effectivity of the fan duct and your object geometry. Probably more settings are applicable.</p>
<p>You could find out ... | <p>From my limited experience there is very little in the way of overhangs that won't print for a short distance. Depending what you're printing and what it's end use will be.</p>
<p>In this case it needs to be robust enough for daily use holding napkins and toothpicks and cutlery at a restaurant.</p>
<p>The model in t... | 2,127 |
<p>I am considering log-shipping of <a href="http://www.postgresql.org/docs/8.2/static/runtime-config-wal.html" rel="noreferrer">Write Ahead Logs (WAL)</a> in PostgreSQL to create a warm-standby database. However I have one table in the database that receives a huge amount of INSERT/DELETEs each day, but which I don't ... | <p>Unfortunately, I don't believe there is. The WAL logging operates on the page level, which is much lower than the table level and doesn't even know which page holds data from which table. In fact, the WAL files don't even know which pages belong to which <em>database</em>.</p>
<p>You might consider moving your high... | <p>I'd consider <a href="http://www.danga.com/memcached/" rel="nofollow noreferrer">memcached</a> for use-cases like this. You can even spread the load over a bunch of cheap machines too.</p>
| 5,903 |
<p>How do I get the id of my Java process? </p>
<p>I know there are several platform-dependent hacks, but I would prefer a more generic solution.</p>
| <p>There exists no platform-independent way that can be guaranteed to work in all jvm implementations.
<code>ManagementFactory.getRuntimeMXBean().getName()</code> looks like the best (closest) solution, and typically includes the PID. It's short, and <em>probably</em> works in every implementation in wide use.</p>
<p>O... | <p>This is what I used when I had similar requirement. This determines the PID of the Java process correctly. Let your java code spawn a server on a pre-defined port number and then execute OS commands to find out the PID listening on the port. For Linux</p>
<pre><code>netstat -tupln | grep portNumber
</code></pre>
| 5,642 |
<p>I'm trying to design a camera handle, which will be around 8" long and will have a brass camera thread insert in the end, where the camera will be mounted. (That way, I don't have to screw the camera thread into plastic which will wear out faster.)</p>
<p>If I print the handle normally, the end of the handle won't... | <p>I think you are approaching this wrong. Sounds like you need to design it to have a hollow wall. That said to answer your question no you cannot have your slicer modify prints like that. But it bears mentioning you can set all shells to what ever you want have have a very sparse infill. To you can set vertical shell... | <p>I believe the solution is to use more walls in Cura.</p>
<p>Here is a 50mm cylinder with a 20mm hole. I specified 10 walls in Cura.</p>
<p>This should give extra plastic for the screw to bit into, but not take all day to print!</p>
<p><a href="https://i.stack.imgur.com/cItxw.png" rel="nofollow noreferrer"><img s... | 464 |
<p>I had filament on my 3D45 coming out of threads on the nozzle.</p>
<p>To fix this I removed the nozzle to find the PTFE Liner in really bad shape. It looked crushed and deformed. Now the tough part, how do I replace the PTFE Liner. You can't seem to buy the liner and getting a replacement nozzle assembly from Dremel... | <p>The initial problem you had with filament coming out of the threads at the nozzle is caused by improper seating of the heat break to the nozzle. In a "from the ground up" installation, you'd have an empty heat block, containing your heater core and your thermistor. Threaded into the "bottom" of t... | <p>Capricorn sells 3x2mm ptfe heat break tube. Havnt used it long enough to know if it will hold up to its claims of withstanding temps up to 275c and beyond for any length of time; but I do know the generic ptfe I had in it before lived up to its reputation of going funny at 240c even though they sell it as rated for ... | 1,707 |
<p>Current main problem is that at various points during a print, one layer doesn’t attach well to the layer below it. That is what appears to be causing the artifacts in the second picture below, but the picture may not show it clearly.</p>
<h2>Background</h2>
<p>I have a Makerbot Replicator 5th generation printer. Th... | <p>Your printer is improperly leveled with respect to the distance of the nozzle to the bed. This, and a high raft to print part distance, causes consecutive layers to not adhere well. </p>
<p>PLA should not need that high temperatures to print nor does it need a raft. Rafts are interesting when printing filaments tha... | <p>Reading your print settings, I noticed some oddities:</p>
<ul>
<li>215 °C</li>
<li>raft</li>
</ul>
<p>These are settings one does not expect for PLA but seem reasonable for ABS. The 215 °C could be reasonable if</p>
<ul>
<li>the melt zone is extremely short and partially insulated (Makerbot Mk 10 style)</li>
<li>the... | 1,144 |
<p>I am wondering if making an hermetic box is feasible using 3D printer. The box would be a cube with a front face removable, with screw and sealing joint to close it.<br>
I searched for different materials, however, none talks about hermiticity. (However, I found a product that seems to improve water resistance of 3D... | <p>A few thoughts that might help...</p>
<p><strong>Material:</strong></p>
<ul>
<li>ABS can be vapor smoothed with Acetone which results in the layers sort of "melting" together to form a smoother, and less porous surface.</li>
<li>Other plastics can be smoothed with compatible solvents, but I've not tried solvent sm... | <p>I believe this can be achieved using o-rings. That's what they use for scuba diving lights. The component doesn't need to be circular, but the o-ring needs to be slightly smaller than the component so that it is held in place via tension. Additionally, you'll want to create a groove for the o-ring to set it in an... | 392 |
<p>I'm trying to implement something like this:</p>
<pre><code><div>
<table>
<thead>
<tr>
<td>Port name</td>
<td>Current port version</td>
<td>New port version</td>
<td... | <p>You don't want to use a Webforms button in ASP.NET MVC. MVC is a completely different way of working, and you no longer have the WebForms abstraction. </p>
<p>You have 2 different options you can either replace your asp:Button with an input tag or use a standard hyperlink instead. If you use the input option then y... | <p>I think you have to enclose your block in Form tags ans runat=server.</p>
| 3,767 |
<p>I want to get the base 10 logarithm of a Fixnum using Ruby, but found that n.log or n.log10 are not defined. Math::log is defined but uses a different base than 10.</p>
<p>What is the easiest way to get the base 10 logarithm of a Fixnum?</p>
| <p>There is </p>
<pre><code>Math::log10 (n)
</code></pre>
<p>And there is also a property of logarithms that <code>logx(y) = log(y)/log(x)</code></p>
| <p><a href="http://www.ruby-doc.org/core-1.8.7/classes/Math.html#M001197" rel="nofollow noreferrer">Math.log10</a>(numeric) => float
returns base 10 log</p>
| 7,447 |
<p>I recently bought a Creality Ender 3 V2. I have heard that it is best to use a raft when printing. I have tried to use a raft a few different times using PLA, with different settings each time. When I try to peel the raft off of the print, it will snap around the bottom of the print. Are there any recommended slicer... | <blockquote>
<p>I have heard that it is best to use a raft</p>
</blockquote>
<p>Actually, it is not best to use a raft, a raft is an aid that can best be used in special cases, e.g. for filaments that shrink reasonably (PLA is not such a filament).</p>
<p>A raft always caused a rough bottom of your print and is frequen... | <p>Rafts fuse with models because the filament gets overheated. To avoid this, keep the temperature in the room between between 23 and 28 °C. Malfunctioning extruder fans, a heater & thermocouple, extruder printed circuit board (PCB), extruder cable, and motherboard can be also to blame.</p>
| 2,161 |
<p>Compare</p>
<pre><code>String.Format("Hello {0}", "World");
</code></pre>
<p>with</p>
<pre><code>"Hello {0}".Format("World");
</code></pre>
<p>Why did the .Net designers choose a static method over an instance method? What do you think?</p>
| <blockquote>
<p>Because the Format method has nothing to do with a string's current value.</p>
</blockquote>
<p>That's true for <em>all</em> string methods because .NET strings are immutable.</p>
<blockquote>
<p>If it was non-static, you would need a string to begin with.</p>
</blockquote>
<p>It does: the format... | <p><code>String.Format</code> takes at least one String and returns a different String. It doesn't need to modify the format string in order to return another string, so it makes little sense to do that (ignoring your formatting of it). On the other hand, it wouldn't be that much of a stretch to make <code>String.Forma... | 4,324 |
<p>I would like to monitor the following system information in Java:</p>
<ul>
<li>Current CPU usage** (percent)</li>
<li>Available memory* (free/total)</li>
<li><p>Available disk space (free/total)</p>
<p>*Note that I mean overall memory available to the whole system, not just the JVM.</p></li>
</ul>
<p>I'm looking ... | <p>Along the lines of what I mentioned <a href="https://stackoverflow.com/questions/25552/using-java-to-get-os-level-system-information#25583">in this post</a>. I recommend you use the <a href="https://github.com/hyperic/sigar" rel="noreferrer">SIGAR API</a>. I use the SIGAR API in one of my own applications and it is... | <pre><code> OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
System.out.println((osBean.getCpuLoad() * 100) + "%");
</code></pre>
<p>import <code>com.sun.management.OperatingSystemMXBean</code></p>
<p>It only starts working after the second call so save t... | 6,937 |
<p>I've been curious about the various UV/Laser printers in (or coming into) market that use liquid resin. I've seen the samples of the <a href="https://fslaser.com/Products/View/1" rel="noreferrer">Pegasus Touch</a>, <a href="http://formlabs.com/products/materials/" rel="noreferrer">Form1</a>, and the <a href="http://... | <p>Taken in order your questions:</p>
<p>Maintenance for a resin printer means keeping the vat or tray clean, using appropriate methods to remove the unused resin (or leaving it in the vat per manufacturer's directions). Cleaning the tray should be done also per manufacturer's spec, although each printer's user forum ... | <p>Despite how many vendors make it appear, resin-curing SLA/DLP printers are industrial or commercial tools that are really not suitable for home desktop use. Here are the major downsides:</p>
<ul>
<li>Significantly more expensive to operate than FDM printers, in most cases. </li>
<li>The resin is seriously toxic unt... | 229 |
<p>I understand about race conditions and how with multiple threads accessing the same variable, updates made by one can be ignored and overwritten by others, but what if each thread is writing the same value (not different values) to the same variable; can even this cause problems? Could this code:</p>
<p>GlobalVar.p... | <p>The problem comes when you read that state back, and do something about it. Writing is a red herring - it is true that as long as this is a single word most environments guarantee the write will be atomic, but that doesn't mean that a larger piece of code that includes this fragment is thread-safe. Firstly, presumab... | <p>If the operation is atomic, you <em>should</em> be able to get by just fine. But I wouldn't do that in practice. It is better just to acquire a lock on the object and write the value.</p>
| 9,769 |
<p>I am working on an application for college music majors. A feature i am considering is slowing down music playback without changing its pitch. I have seen this done in commercial software, but cannot find any libraries or open source apps that do anything like this. </p>
<ol>
<li>Are there libraries out there?</li... | <p>Timestretching is quite hard. The more you slow down or speed up the sound the more artifacts you get. If you want to know what they sound like listen to "The Rockafeller Skank" by Fat Boy Slim. There are a lot of ways to do it that all have their own strengths and weaknesses. The math can get really complex. That's... | <p>audacity does it out of the box and it's free. THere are several plug ins for mp3 players as well that are free. Apparently it's pretty easy to do with an mp3 since it's already coded in the frequency domain.</p>
| 8,470 |
<p>I'm trying to retrieve a file from a server using SFTP (as opposed to FTPS) using Java. How can I do this?</p>
| <p>Another option is to consider looking at the <a href="http://www.jcraft.com/jsch/" rel="noreferrer" title="JSch library">JSch library</a>. JSch seems to be the preferred library for a few large open source projects, including Eclipse, Ant and Apache Commons HttpClient, amongst others.</p>
<p>It supports both user/p... | <p>The best solution I've found is <a href="http://www.lag.net/paramiko/" rel="nofollow noreferrer">Paramiko</a>. There's a Java version.</p>
| 3,542 |
<p>I have an Ender 3 pro. In my country electricity outage is an issue, though it comes back pretty instantaneously, when I hit the resume button on the Ender 3 pro after heating the hot end and the bed when the hot end lifts the Y-axis or X-axis shifts a little bit, I do not understand why as when there is no power ou... | <p>Not sure on your exact firmware, but it could be that it is using a <a href="https://marlinfw.org/docs/gcode/M413.html" rel="nofollow noreferrer">M413 power loss recovery</a> rather than a power loss interrupt pin. Possible you might be able to change this with your current firmware, but worst case you could install... | <p>you'll need a UPS with EMI filter. I had this same issue and I opt to a regular desktop UPS and the problem was still there. So, I connected a EMI filter and it worked.</p>
| 2,095 |
<p>I've asked a question before on the extruder gear clicking on my CR-10, but I'm certain its because of the nozzle getting clogged for some reason. I'm using a standard 0.4 mm nozzle with white PLA and randomly during the print the extruder gear starts clicking on the fast parts and then under extrudes the rest ... | <p>Turns out the filament was the problem, I tried printing a model with a high quality sample PLA filament I had and it printed perfectly; one of the cleanest prints I've had. Never skimp on filament.</p>
<p><img src="https://i.stack.imgur.com/AT3cW.jpg" alt="enter image description here"></p>
| <p>White PLA is usually some of the worst stuff to print with, generally avoid it. I would say. I myself are having a lot of problems with it as well.</p>
| 1,457 |
<p>In Windows, is there an easy way to tell if a folder has a subfile that has changed?</p>
<p>I verified, and the last modified date on the folder does not get updated when a subfile changes.</p>
<p>Is there a registry entry I can set that will modify this behavior?</p>
<p>If it matters, I am using an NTFS volume. ... | <p>This <a href="http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx" rel="nofollow noreferrer">article</a> should help. Basically, you create one or more notification object such as:</p>
<pre>
HANDLE dwChangeHandles[2];
dwChangeHandles[0] = FindFirstChangeNotification(
lpDir, ... | <p>If you are not opposed to using .NET the <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx" rel="nofollow noreferrer">FileSystemWatcher</a> class will handle this for you fairly easily.</p>
| 8,071 |
<p>When you roll out changes to a live web site, how do you go about checking that the <em>live</em> system is working correctly? Which tools do you use? Who does it? Do you block access to the site for the testing period? What amount of downtime is acceptable?</p>
| <p>I tend to do all of my testing in another environment (not the live one!). This allows me to push the updates to the live site knowing that the code should be working ok, and I just do sanity testing on the live data - make sure I didn't forget a file somewhere, or had something weird go wrong.</p>
<p>So proper te... | <p>Run your main server on a port other than 80. Stick a lightweight server (e.g. nginx) in front of it on port 80. When you update your site, start another instance on a new port. Test. When you are satisfied that it has been deployed correctly, edit your proxy config file, and restart it. In nginx's case, this r... | 9,292 |
<p>I'd like to have a java.utils.Timer with a resettable time in java.I need to set a once off event to occur in X seconds. If nothing happens in between the time the timer was created and X seconds, then the event occurs as normal. </p>
<p>If, however, before X seconds has elapsed, I decide that the event should occu... | <p>According to the <a href="http://java.sun.com/javase/6/docs/api/java/util/Timer.html" rel="noreferrer"><code>Timer</code></a> documentation, in Java 1.5 onwards, you should prefer the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html" rel="noreferrer"><code>Schedule... | <p>Here is the example for Resetable Timer . Try to change it for your convinence...</p>
<pre><code>package com.tps.ProjectTasks.TimeThread;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
im... | 5,193 |
<p>Im planning on building an enclosure for my CR-10S and am debating whether to use MDF walls lined with an insulation foam that reduces noise and keeps the heat in or going with double pane glass walls.</p>
<p>My main concern is not necessarily keeping the enclosure hot as it is for noise reduction. Obviously the wo... | <p>First you should check if the bed still works when applying 12V directly. You can then also check the voltage over the 12V output terminals to measure the power supply unit while it is powering the bed. It is unclear whether you measured the voltage of the PSU while it was powering a large load.</p>
<p>It is also a... | <p>you can swap pins in Marlin firmware.
When you download it from GitHub, there is a file called <a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/pins.h" rel="nofollow noreferrer">pins.h</a> (please be aware that this file is an example), and you can play with your setup to skip the broken mosfet.<... | 931 |
<p>I'm using a CraftBot original to print PLA, but some of the filament has become stuck in the teeth of the <a href="https://craftunique.com/item/craftbot-extruder-gear" rel="nofollow">extruder gear</a> on its way into the hot end. I'm having issues with the gear becoming stuck and "clicking" instead of turning, and ... | <p>I mostly use a tooth brush for that kind of problem</p>
| <p>If you are able to remove the gear, as I suspect you can, a useful tool is the file card. It resembles a flat hair brush but the bristles are short wire, very stiff. In traditional use, it removes metal shavings from conventional metal files. It will easily remove plastic from between the gear teeth. If you are unab... | 322 |
<p>I have any ASP.NET control. I want the HTML string how to do I get the HTML string of the control?</p>
| <p>This appears to work.</p>
<pre><code>public string RenderControlToHtml(Control ControlToRender)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter stWriter = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(s... | <p>If your control is a web user control, this is how you can get to the HTML it emits from another page or handler:</p>
<pre><code>public void GetHtmlFromMySweetControl(HttpContext context)
{
HttpRequest httpRequest = context.Request;
HttpResponse httpResponse = context.Response;
string foo = httpRequest... | 8,337 |
<p>I am having trouble with my Visual Studio 2005 IntelliSense for some time now.<br><br>
It used to work fine, but for some reason the 'Updating IntelliSense...' does no longer seem to be able to complete for the solution I'm working on currenly- it simply gets stuck somewhere at about 3-bars of progress and blocks on... | <p>I have found that the best fix for Intellisense in VS2005 is to install SP1, and then this hotfix: <a href="http://support.microsoft.com/kb/947315" rel="noreferrer">947315</a>. It has the added benefit of fixing most of the multi-core build issues.</p>
<p>This hotfix also includes the ability to control Intellise... | <p>Intellsense is problematic. Very problematic. When it works, it's great, but more often than not it will cause more problems than it's worth. It will hang up, it will parse through files while you are trying to compile code and will generally make VC 2005 sometimes run like a dog. As a previous poster suggested,... | 9,511 |
<p>What is the best way to do per-user database connections in <code>Rails</code>? </p>
<p>I realize this is a poor Rails design practice, but we're gradually replacing an existing web application that uses one database per user. A complete redesign/rewrite is not feasible.</p>
| <p>Put something like this in your application controller. I'm using the subdomain plus "_clientdb" to pick the name of the database. I have all the databases using the same username and password, so I can grab that from the db config file.</p>
<p>Hope this helps!</p>
<pre><code>class ApplicationController < Actio... | <p>Take a look at <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001397" rel="nofollow noreferrer">ActiveRecord::Base.establish_connection</a>. That's how you connect to a different database server. I can't be of much more help since I don't know how you recognize the user or map it to it's databas... | 8,320 |
<p>What can be reasons to prevent a class from being inherited? (e.g. using sealed on a c# class)
Right now I can't think of any.</p>
| <p>Because writing classes to be substitutably extended is <em>damn hard</em> and requires you to make accurate predictions of how future users will want to extend what you've written.</p>
<p>Sealing your class forces them to use composition, which is much more robust.</p>
| <p>Because you always want to be handed a reference to the class and not to a derived one for various reasons:<br>
i. invariants that you have in some other part of your code<br>
ii. security<br>
etc</p>
<p>Also, because it's a safe bet with regards to backward compatibility - you'll never be able to close that class ... | 4,426 |
<p>Each cell contains some text and a background color. So I have some cells that are blue and some that are red. What function do I use to count the number of red cells?</p>
<p>I have tried <code>=COUNTIF(D3:D9,CELL("color",D3))</code> with no success (Where <code>D3</code> is red).</p>
| <p>Excel has no way of gathering that attribute with it's built-in functions. If you're willing to use some VB, all your color-related questions are answered here:</p>
<p><a href="http://www.cpearson.com/excel/colors.aspx" rel="nofollow noreferrer">http://www.cpearson.com/excel/colors.aspx</a></p>
<p>Example form the... | <p>Yes VBA is the way to go.</p>
<p>But, if you don't need to have a cell with formula that auto-counts/updates the number of cells with a particular colour, an alternative is simply to use the 'Find and Replace' function and format the cell to have the appropriate colour fill.</p>
<p>Hitting 'Find All' will give you... | 7,259 |
<p>I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.</p>
<p>On the Mac I am spawning <a href="http://web.archive.org/web/20090309234215/http://developer.apple.com:80/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="noreferrer">sips</a>. Is th... | <p>ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the <code>ps:alpha</code> delegate in ImageMagick, just adjusted to use JPEG as output):</p>
<pre><code>gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \
-dM... | <p>Is the PC likely to have Acrobat installed? I think Acrobat installs a shell extension so previews of the first page of a PDF document appear in Windows Explorer's thumbnail view. You can get thumbnails yourself via the IExtractImage COM API, which you'll need to wrap. <a href="http://www.vbaccelerator.com/home/net/... | 2,293 |
<p>What's the easiest way to add a header and footer to a .Net PrintDocument object, either pragmatically or at design-time?</p>
<p>Specifically I'm trying to print a 3rd party grid control (Infragistics GridEx v4.3), which takes a PrintDocument object and draws itself into it.</p>
<p>The resulting page just contains... | <p>The printdocument object fires the printpage event for each page to be printed. You can draw text/lines/etc into the print queue using the printpageeventargs event parameter: </p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx" rel="nofollow noreferrer">http://msdn.mi... | <p>The printdocument object fires the printpage event for each page to be printed. You can draw text/lines/etc into the print queue using the printpageeventargs event parameter: </p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx" rel="nofollow noreferrer">http://msdn.mi... | 8,375 |
<p>What is the dependency inversion principle and why is it important?</p>
| <p>Check this document out: <a href="https://drive.google.com/file/d/0BwhCYaYDn8EgMjdlMWIzNGUtZTQ0NC00ZjQ5LTkwYzQtZjRhMDRlNTQ3ZGMz/view" rel="noreferrer">The Dependency Inversion Principle</a>.</p>
<p>It basically says:</p>
<ul>
<li>High level modules should not depend upon low-level modules. Both should depend upon ... | <p>Dependency Inversion Principle (DIP) says that </p>
<p>i) High level modules should not depend upon low-level modules. Both should depend upon abstractions.</p>
<p>ii) Abstractions should never depend upon details. Details should depend upon abstractions.</p>
<p>Example: </p>
<pre><code> public interface ICus... | 8,803 |
<p>How can I figure out the size of a file, in bytes?</p>
<pre><code>#include <stdio.h>
unsigned int fsize(char* file){
//what goes here?
}
</code></pre>
| <p>On Unix-like systems, you can use POSIX system calls: <a href="https://en.wikipedia.org/wiki/Stat_(system_call)" rel="noreferrer"><code>stat</code> on a path</a>, or <code>fstat</code> on an already-open file descriptor (POSIX <a href="https://man7.org/linux/man-pages/man3/fstat.3p.html" rel="noreferrer">man page</a... | <p>You can open the file, go to 0 offset relative from the bottom of the file with </p>
<pre><code>#define SEEKBOTTOM 2
fseek(handle, 0, SEEKBOTTOM)
</code></pre>
<p>the value returned from fseek is the size of the file.</p>
<p>I didn't code in C for a long time, but I think it should work.</p>
| 2,971 |
<p>I'd like to be able to pass a SecureString (a cached passphrase) to a child process in C# (.Net 3.5), but I don't know what the most secure way is to do it. If I were to convert the SecureString back to a regular string and pass it as a command-line argument, for example, then I <em>think</em> the value may be prone... | <p>In general you should define your threat model before worrying about more exotic attacks. In this case: are you worried that somebody shuts down the computer and does a forensic analysis of the harddrive? Application memory can also be swapped out, so the simple fact that <em>one</em> process has it in memory, makes... | <p>Unless your child process also understands how to work with SecureString I don't think there is a way to pass it directly. For example, the Process.Start() method has two overloads that take a SecureString so the risk of the actual string value being sniffed is minimized (it's still possible since somewhere along th... | 6,886 |
<p>Most 3 mm (mostly are actually 2.85 mm) filament extruders have some kind of gear reduction. Many 1.75 mm extruders are direct-drive / ungeared but some do use gears. What kind of reduction ratios are suitable or optimal?</p>
| <p>I'm not sure if it's possible, but on github is code for setting CuraEngine up. Maybe you'll find this link, <a href="https://github.com/Ultimaker/CuraEngine/blob/master/src/settings/settings.cpp" rel="nofollow noreferrer"> CuraEngine/src/settings/settings.cpp</a> helpful. </p>
<p>The latest release has more speed ... | <p>I'm not sure if it's possible, but on github is code for setting CuraEngine up. Maybe you'll find this link, <a href="https://github.com/Ultimaker/CuraEngine/blob/master/src/settings/settings.cpp" rel="nofollow noreferrer"> CuraEngine/src/settings/settings.cpp</a> helpful. </p>
<p>The latest release has more speed ... | 214 |
<p>I am working on a project that requires the parsing of log files. I am looking for a fast algorithm that would take groups messages like this:</p>
<blockquote>
<p>The temperature at P1 is 35F.</p>
<p>The temperature at P1 is 40F.</p>
<p>The temperature at P3 is 35F.</p>
<p>Logger stopped.</p>
<p>Logger started.</p>
... | <p>I think you might be overlooking and missed fscanf() and sscanf(). Which are the opposite of fprintf() and sprintf().</p>
| <p>@John: I think that the question relates to an algorithm that actually recognises patterns in log files and automatically "guesses" appropriate format strings and data for it. The <code>*scanf</code> family can't do that on its own, it can only be of help once the patterns have been recognised in the first place.</p... | 3,121 |
<p>Why do we need to use:</p>
<pre><code>extern "C" {
#include <foo.h>
}
</code></pre>
<p><strong>Specifically:</strong> </p>
<ul>
<li><p>When should we use it?</p></li>
<li><p>What is happening at the compiler/linker level that requires us to use it? </p></li>
<li><p>How in terms of compilation/linking does... | <p>C and C++ are superficially similar, but each compiles into a very different set of code. When you include a header file with a C++ compiler, the compiler is expecting C++ code. If, however, it is a C header, then the compiler expects the data contained in the header file to be compiled to a certain format—the C++ '... | <p><strong>Decompile a <code>g++</code> generated binary to see what is going on</strong></p>
<p>To understand why <code>extern</code> is necessary, the best thing to do is to understand what is going on in detail in the object files with an example:</p>
<p>main.cpp</p>
<pre><code>void f() {}
void g();
extern "C" {... | 9,345 |
<p>I'm looking for a good tool to profile a java webapp. I'd like to get performance information and memory usage if possible. </p>
<p>Any suggestions?</p>
| <p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html" rel="nofollow noreferrer">JProfiler</a> is a really good one. It integrates with all the major IDEs and application servers.</p>
| <p><a href="http://www.gurock.com/products/smartinspect/" rel="nofollow noreferrer">SmartInspect</a> is a profiler and logger. Not specific to memory, but you might want to take a look. It works with a variety of languages too, including Delphi, Java and .NET. Includes other more advanced features.</p>
<p><img src=... | 6,880 |
<p>How do you redirect HTTPS to HTTP?. That is, the opposite of what (seemingly) everyone teaches.</p>
<p>I have a server on HTTPS for which I paid an SSL certification for and a mirror for which I haven't and keep around for just for emergencies so it doesn't merit getting a certification for.</p>
<p>On my client's ... | <p>This has not been tested but I think this should work using mod_rewrite</p>
<pre><code>RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
</code></pre>
| <p>As far as I'm aware of a simple meta refresh also works without causing errors:</p>
<pre><code><meta http-equiv="refresh" content="0;URL='http://www.yourdomain.com/path'">
</code></pre>
| 2,980 |
<p>Prints are generally successful, but I always get a herringbone pattern on the top and bottom surfaces and striations on the sides. The herringbone is finer with finer print qualities, but it is always there. Ditto the sides. See photos.</p>
<p>Always there, regardless of temperature (using a heat tower), speed (eve... | <p>The top image looks as if the (top) layer(s) are <strong>under-extruding</strong>, the walls don't appear to be suffering from the same problem.</p>
<p>The following image from a recent PETG print is typical for an FDM product. The deposited lines need to touch (actually, slightly overlapping, but the slicer will ta... | <p>With a replaced Bowden tube and better PLA, the herringbone is a little better, and the layering on the sides is more regular, but still there. So, based on this and photos from others here (especially @Oscar), I think the answer to my question is YES: These ARE normal surfaces from this printer.</p>
| 2,022 |
<p>For some reason I never see this done. Is there a reason why not? For instance I like _blah for private variables, and at least in Windows Forms controls are by default private member variables, but I can't remember ever seeing them named that way. In the case that I am creating/storing control objects in local v... | <p>This might be counter-intuitive for some, but we use the dreaded Hungarian notation for UI elements.</p>
<p>The logic is simple: for any given data object you may have two or more controls associated with it. For example, you have a control that indicates a birth date on a text box, you will have:</p>
<ul>
<li>the... | <p>I use m_ for member variables, but I'm increasingly becoming tempted to just using lowerCamelCase like I do for method parameters and local variables. Public stuff is in UpperCamelCase.</p>
<p>This seems to be more or less accepted convention across the .NET community.</p>
| 3,084 |
<p>Can you suggest some light weight fuzzy text search library?</p>
<p>What I want to do is to allow users to find correct data for search terms with typos.</p>
<p>I could use full-text search engines like Lucene, but I think it's an overkill.</p>
<p><strong>Edit:</strong><br>
To make question more clear here is a m... | <p>Lucene is very scalable—which means its good for little applications too. You can create an index in memory very quickly if that's all you need.</p>
<p>For fuzzy searching, you really need to decide what algorithm you'd like to use. With information retrieval, I use an <a href="http://en.wikipedia.org/wiki/N-... | <p>@aku - links to working soundex libraries are right there at the bottom of the page.</p>
<p>As for Levenshtein distance, the <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="nofollow noreferrer">Wikipedia article on that</a> also has implementations listed at the bottom.</p>
| 6,339 |
<p>I've had a FTP server (Mac OS X, but not the server version) set up for a while where the users are virtual, i.e. they are not actual user accounts in the server's OS, but accounts handled by the FTP server software -- to the OS they all look like the <code>ftp</code> user account. I'd like to retire the FTP server ... | <p>The usual generic Unix answer to this is 'PAM'. If you want plain old OpenSSH SSHD to handle your SFTP, you need something plugged in to SSHD's PAM stack (/etc/pam.d/sshd) that does what you need and leaves out what you don't need. This might be a general-purpose directory server (probably LDAP) that maps all your v... | <p>If you're open to commercial products, VShell Server from Van Dyke Software is available on Unix/Linux/Windows, supports virtual users (multiple backends) with SSH and SFTP protocols:</p>
<p><a href="http://www.vandyke.com/products/vshell/index.html" rel="nofollow">VShell Server</a></p>
| 6,023 |
<p>How can you obtain the Type (the name as a string is sufficient) of an Object in VB6 at runtime?</p>
<p>i.e. something like:</p>
<pre><code>If Typeof(foobar) = "CommandButton" Then ...
</code></pre>
<p><strong>/EDIT:</strong> to clarify, I need to check on Dynamically Typed objects. An example:</p>
<pre><code>Di... | <p>I think what you are looking for is TypeName rather than TypeOf.</p>
<pre><code>If TypeName(foobar) = "CommandButton" Then
DoSomething
End If
</code></pre>
<p>Edit: What do you mean Dynamic Objects? Do you mean objects created with
CreateObject(""), cause that should still work.</p>
<p>Edit: </p>
<pre><code>... | <p>This should prove difficult, since in VB6 all objects are COM (<code>IDispatch</code>) things. Thus they are only an interface.</p>
<p><code>TypeOf(object) is class</code> probably only does a COM get_interface call (I forgot the exact method name, sorry).</p>
| 7,540 |
<p>I'm trying to work out if I have an open relay on my server. How do I do that?</p>
<p>I've tried <a href="http://www.abuse.net/relay.html" rel="nofollow noreferrer">http://www.abuse.net/relay.html</a></p>
<p>and it reports:</p>
<p>Hmmn, at first glance, host appeared to accept a message for relay.
THIS MAY OR MAY... | <p>Eh? As your link tells you, register for the site and it will give you an address @abuse.net, valid for 24 hours. Enter that address into the testing form. If your abuse.net account receives the test email, you have an open relay.</p>
| <p>This depends on your MTA and how you've configured it. Ultimately there is only one thing you must do to prevent relaying. Restrict relaying to authenticated users and/or restrict relaying to specific IPs. I prefer to restrict all IPs except localhost on my mail server and require authentication from everyone else.<... | 8,557 |
<p>I am trying to build a function in C/C++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but can't get it down. O... | <p>You're close. You're referencing the address of the array items when you swap, which isn't necessary. The items in the array are pointers, and that's what needs to be swapped.</p>
<p>See below:</p>
<pre><code>void SortArray( int ** pArray, int ArrayLength )
{
int i, j, flag = 1; // set flag to 1 to begin in... | <p>To complete Brian Ensink's post, you'll find the STL full of surprises. For example, the std::sort algorithm:</p>
<pre><code>#include <iostream>
#include <vector>
#include <algorithm>
void printArray(const std::vector<int *> & p_aInt)
{
for(std::vector<int *>::size_type i = 0, ... | 3,798 |
<p>Is it possible to modify the title of the message box the confirm() function opens in JavaScript? </p>
<p>I could create a modal popup box, but I would like to do this as minimalistic as possible.
I would like to do something like this:</p>
<pre><code>confirm("This is the content of the message box", "Modified tit... | <p>This is not possible, as you say, from a security stand point. The only way you could simulate it, is by creating a modeless dialog window.</p>
<p>There are many third-party javascript-plugins that you could use to fake this effect so you do not have to write all that code.</p>
| <p>You can't unfortunately. The only way is to simulate this with a window.open call.</p>
| 6,558 |
<p>I got my ender 3 about a month ago, it was working fine. Tried a new brand, overture, this is when I started experiencing problems. First, I was clogging nozzles left and right, then I went back to hatchbox, and my layers are messed up...
<a href="https://i.stack.imgur.com/TXuzX.jpg" rel="nofollow noreferrer"><img ... | <p>I wonder if this problem is unrelated to your material or printer, and purely a matter of slicer breakage. Have you tried printing gcode files you created before the problem appeared? If you use Cura and upgraded it, you might have hit one of the bugs where it assumes by default you have 2.85 mm filament, even thoug... | <p>Seems like in Movement without displaycement in x and y it seems to fit (neck-area).
I also would check your belts. There may be a bit too much friction.
Otherwise have you made some Testprints (calibration cube, boat)?</p>
<p>Especially the base looks bad. But it is not a cylinder or?</p>
<p>If you want, you may ... | 1,458 |
<p>I want to get started doing some game development using Microsoft's XNA. Part of that is Shader development, but I have no idea how to get started. I know that <a href="http://developer.nvidia.com/object/fx_composer_home.html" rel="noreferrer">nVidia's FX Composer</a> is a great tool to develop shaders, but I did no... | <p>Development of shaders in XNA (which obviously uses DirectX) requires knowledge of <a href="http://msdn.microsoft.com/en-us/library/bb509561(VS.85).aspx" rel="noreferrer">HLSL</a> or shader assembly. I'd recommend getting familiar with the former before diving into the latter.</p>
<p>Before writing any shaders, it'... | <p>SAMS's <a href="https://rads.stackoverflow.com/amzn/click/com/0672329646" rel="nofollow noreferrer" rel="nofollow noreferrer">XNA Unleashed</a> by Chad Carter is a great starting point for XNA and assumes little knowledge of game development practices or hard maths before you start. It has two chapters on basic and ... | 2,861 |
<p><a href="https://3dprinting.stackexchange.com/questions/3586/adding-custom-m-codes-to-marlin">Adding custom M Codes to Marlin</a> doesn't work for Marlin 2.0</p>
<p>How would one go about adding custom G codes or M Codes to Marlin 2.0? The Marlin_main.cpp file does not exist. </p>
<p>In general for Marlin 2.0, thi... | <p>The code in 2.0.x is similar to the old branch 1.1.x, G-code is parsed in <a href="https://github.com/MarlinFirmware/Marlin/blob/2.0.x/Marlin/src/gcode/gcode.cpp" rel="nofollow noreferrer"><code>gcode.cpp</code></a>, specifically in <code>process_parsed_command</code>:</p>
<pre><code>void GcodeSuite::process_parsed... | <ol start="0">
<li>Choose a code in the >10,000 in case new codes are added. But in this example I will choose 13</li>
<li>Navigate to 'src' folder of Marlin</li>
<li>Edit the file <code>gcode.cpp</code> around line 223 to have a new unused number. For example, this will create a new G code function for the label <... | 1,669 |
<p>One thing I never understood is the so-called <strong>Extrusion Multiplier (EM)</strong> or <strong>Flow</strong> setting in slicers like Simplify3D (S3D) or CURA.</p>
<p>The description for this setting reads...</p>
<ul>
<li>S3D: <em>Multiplier for all extrusion movements (...)</em></li>
<li>CURA: <em>The amount ... | <p>No, the Flow rate or Extrusion multiplier is to compensate for different materials and temperature ranges.</p>
<h2>Where does the factor come from?</h2>
<p>Let's say we calibrated our nozzle for work at 200°C with PLA, so 100 mm extrusion are correct and want to print ABS. ABS behaves differently and we get bad prin... | <p>The extrusion multiplier is just to compensate for amounts of flow. A material like PLA is very fluid when at 190-200C, so to extrude slightly less then 100% would reduce zits on the print, slightly increase tolerance, reduce stringing and also reduce risk of heatcreep. Materials like ABS and Nylon aren't as liquid ... | 1,237 |
<p>I recently discovered the notify extension in Mercurial which allows me quickly send out emails whenever I push changes, but I'm pretty sure I'm still missing out on a lot of functionality which could make my life a lot easier. </p>
<ul>
<li>notify-extension: <a href="https://www.mercurial-scm.org/wiki/NotifyExtens... | <p>I really enjoy what I did with my custom hook. I have it post a message to my campfire account (campfire is a group based app). It worked out really well. Because I had my clients in there and it could show him my progress.</p>
| <p>Take a look at the hgweb stuff. You can set up RSS feeds and see all the revisions, et cetera.</p>
| 8,894 |
<p>In TFS whats the easiest way of linking a backlog item to a large number of other backlog items, without doing them one at a time?</p>
<p>I do not have access to the underlying database so am unable to write a query to do it.</p>
| <p>I'd stay away from the SQL Query. Instead, I'd either use the API or Web Services. Here's an example API call to retrieve and edit a work item:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb130323.aspx" rel="nofollow noreferrer"><a href="http://msdn.microsoft.com/en-us/library/bb130323.aspx" rel="nofoll... | <p>Depends on your definition of easy, but you could write a SQL Update linking the backlog item(s) to the correct backlog items.</p>
<p>(If there is no field in the backlog item to connect it to another backlog item, you would have to extend backlog item and the views showing them yourself)</p>
| 6,077 |
<p>Is there a way, when I parse an XML document using lxml, to validate that document against its DTD using an external catalog file? I need to be able to work the fixed attributes defined in a document’s DTD.</p>
| <p>You can add the catalog to the <code>XML_CATALOG_FILES</code> environment variable:</p>
<pre><code>os.environ['XML_CATALOG_FILES'] = 'file:///to/my/catalog.xml'
</code></pre>
<p>See <a href="http://thread.gmane.org/gmane.comp.python.lxml.devel/5907" rel="noreferrer">this thread</a>. Note that entries in <code>XML_... | <p>It seems that lxml does not expose this libxml2 feature, grepping the source only turns up some #defines for the error handling:</p>
<pre><code>C:\Dev>grep -ir --include=*.px[id] catalog lxml-2.1.1/src | sed -r "s/\s+/ /g"
lxml-2.1.1/src/lxml/dtd.pxi: catalog.
lxml-2.1.1/src/lxml/xmlerror.pxd: XML_FROM_CATALOG =... | 3,362 |
<p>This is how I wanted to do it which would work in PHP 5.3.0+</p>
<pre><code><?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo $classname::CONSTANT; // As of PHP 5.3.0
?>
</code></pre>
<p>But I'm restricted to using PHP 5.2.6. Can anyone th... | <p>You can accomplish this without using <a href="http://php.net/manual/en/function.eval.php" rel="nofollow noreferrer"><code>eval</code></a> in pre-5.3 code. Just use the <a href="http://php.net/manual/en/function.constant.php" rel="nofollow noreferrer"><code>constant</code></a> function:</p>
<pre><code><?php
cla... | <p>If you absolutly need to access a constant like that, you can do this:</p>
<pre><code><?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo eval( 'return '.$classname.'::CONSTANT;' );
?>
</code></pre>
<p>But, if i were you, I'd try not to use eval.</p>
| 2,735 |
<p>I am currently adding a fillet to the base of an object (the plane that's touching the bed) and I was curious if the radius of the filet contributed to any mis-prints. I've had luck so far but was wondering if the intensity of the radius had mattered.</p>
<p>I am using the Ender3 Pro.</p>
<hr />
<p><em>I may do some... | <p>You can print a fillet without support as support material causes other issues like problems with removing supports and ugly scarring on you print. However, a fillet will cause an overhang when you slice the object</p>
<p><a href="https://i.stack.imgur.com/mXpkz.png" rel="nofollow noreferrer"><img src="https://i.sta... | <blockquote>
<p>wondering if the intensity of the radius had mattered.</p>
</blockquote>
<p>Yes it does if it's an overhang.</p>
| 2,160 |
<p>I've upgraded my stepper drivers.</p>
<p>I'm looking to understand why my stepper motors made noise in the first place.</p>
| <p>Stepper motors contain two distinct sets of coils. The current in these coils is governed by your stepper motor driver.</p>
<p><a href="https://i.stack.imgur.com/RaDxb.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RaDxb.gif" alt="Stepper motor diagram (WikiForU.com)"></a></p>
<p>To move the mo... | <p>To make a stepper perform a step, block signals are send to energize the coils to position the rotor. Such a block signal causes abrupt motion and triggers harmonic frequencies. This is audible as stepper noise. If the block signal is smoothed, the motion is more fluent and less noise will be observed. A similar eff... | 1,388 |
<p>Take the following string as an example: </p>
<p>"The quick brown fox" </p>
<p>Right now the q in quick is at index 4 of the string (starting at 0) and the f in fox is at index 16. Now lets say the user enters some more text into this string.</p>
<p>"The very quick dark brown fox"</p>
<p>Now the q is at index ... | <p>Let's say that you have a string and some of its letters are <i>interesting</i>. To make things easier let's say that the letter at index 0 is always interesting and you never add something before it—a sentinel. Write down pairs of (interesting letter, distance to the previous interesting letter). If the strin... | <p>The standard trick that usually helps in similar situations is to keep the characters of the string as leaves in a balanced binary tree. Additionally, internal nodes of the tree should keep sets of letters (if the alphabet is small and fixed, they could be bitmaps) that occur in the subtree rooted at a particular no... | 5,680 |
<p>I was wondering if there are any alternatives to Microsoft's SQL Server Management Studio?</p>
<p>Not there's anything wrong with SSMS, but sometimes it just seem too big an application where all I want todo is browse/edit tables and run queries.</p>
| <p>I've started using <a href="http://www.linqpad.net/" rel="noreferrer" title="Linq Pad">LinqPad</a>. In addition to being more lightweight than SSMS, you can also practice writing LINQ queries- way more fun than boring old TSQL!</p>
| <p>You can still install and use Query Analyzer from previous SQL Server versions.</p>
| 2,714 |
<p>I'm using JavaScript to hide an image and show some text thats hidden under it. But, when the text is shown if you scroll over it, it fires the mouseout event on the container, that then hides the text and shows the image again, and it just goes into a weird loop.</p>
<p>The html looks like this:</p>
<pre><code>&l... | <p>I'd give the container div:</p>
<pre><code>position: relative;
</code></pre>
<p>and add a third div in the container (should be the last child of the container) with:</p>
<pre><code>position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
</code></pre>
<p>and catch the mouseover and mouseout events on this div ... | <p>This may not be the best solution but you could set a global boolean variable that would be accessible to both methods that would just specify if the last action was HoverIn or HoverOut. You could use this boolean variable to determine if the code should run or not. </p>
<pre><code>if (bWasHoverIn){
...
}
</code... | 7,226 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.