instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I have an array of numbers that potentially have up to 8 decimal places and I need to find the smallest common number I can multiply them by so that they are all whole numbers. I need this so all the original numbers can all be multiplied out to the same scale and be processed by a sealed system that will only deal with whole numbers, then I can retrieve the results and divide them by the common multiplier to get my relative results.</p> <p>Currently we do a few checks on the numbers and multiply by 100 or 1,000,000, but the processing done by the *sealed system can get quite expensive when dealing with large numbers so multiplying everything by a million just for the sake of it isn’t really a great option. As an approximation lets say that the sealed algorithm gets 10 times more expensive every time you multiply by a factor of 10.</p> <p>What is the most efficient algorithm, that will also give the best possible result, to accomplish what I need and is there a mathematical name and/or formula for what I’m need?</p> <p>*The sealed system isn’t really sealed. I own/maintain the source code for it but its 100,000 odd lines of proprietary magic and it has been thoroughly bug and performance tested, altering it to deal with floats is not an option for many reasons. It is a system that creates a grid of X by Y cells, then rects that are X by Y are dropped into the grid, “proprietary magic” occurs and results are spat out – obviously this is an extremely simplified version of reality, but it’s a good enough approximation.</p> <p>So far there are quiet a few good answers and I wondered how I should go about choosing the ‘correct’ one. To begin with I figured the only fair way was to create each solution and performance test it, but I later realised that pure speed wasn’t the only relevant factor – an more accurate solution is also very relevant. I wrote the performance tests anyway, but currently the I’m choosing the correct answer based on speed as well accuracy using a ‘gut feel’ formula.</p> <p>My performance tests process 1000 different sets of 100 randomly generated numbers. Each algorithm is tested using the same set of random numbers. Algorithms are written in .Net 3.5 (although thus far would be 2.0 compatible) I tried pretty hard to make the tests as fair as possible.</p> <ul> <li>Greg – Multiply by large number and then divide by GCD – 63 milliseconds</li> <li>Andy – String Parsing – 199 milliseconds </li> <li>Eric – Decimal.GetBits – 160 milliseconds</li> <li>Eric – Binary search – 32 milliseconds </li> <li>Ima – sorry I couldn’t figure out a how to implement your solution easily in .Net (I didn’t want to spend too long on it) </li> <li>Bill – I figure your answer was pretty close to Greg’s so didn’t implement it. I’m sure it’d be a smidge faster but potentially less accurate.</li> </ul> <p>So Greg’s Multiply by large number and then divide by GCD” solution was the second fastest algorithm and it gave the most accurate results so for now I’m calling it correct.</p> <p>I really wanted the Decimal.GetBits solution to be the fastest, but it was very slow, I’m unsure if this is due to the conversion of a Double to a Decimal or the Bit masking and shifting. There should be a similar usable solution for a straight Double using the BitConverter.GetBytes and some knowledge contained here: <a href="http://blogs.msdn.com/bclteam/archive/2007/05/29/bcl-refresher-floating-point-types-the-good-the-bad-and-the-ugly-inbar-gazit-matthew-greig.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/bclteam/archive/2007/05/29/bcl-refresher-floating-point-types-the-good-the-bad-and-the-ugly-inbar-gazit-matthew-greig.aspx</a> but my eyes just kept glazing over every time I read that article and I eventually ran out of time to try to implement a solution.</p> <p>I’m always open to other solutions if anyone can think of something better.</p>
<p>I'd multiply by something sufficiently large (100,000,000 for 8 decimal places), then divide by the <a href="http://en.wikipedia.org/wiki/Greatest_common_divisor" rel="nofollow noreferrer">GCD</a> of the resulting numbers. You'll end up with a pile of smallest integers that you can feed to the other algorithm. After getting the result, reverse the process to recover your original range.</p>
<p>What language are you programming in? Something like</p> <pre><code>myNumber.ToString().Substring(myNumber.ToString().IndexOf(".")+1).Length </code></pre> <p>would give you the number of decimal places for a double in C#. You could run each number through that and find the largest number of decimal places(x), then multiply each number by 10 to the power of x.</p> <p>Edit: Out of curiosity, what is this sealed system which you can pass only integers to?</p>
8,284
<p>I am writing a little application to download files over http (as, for example, described <a href="https://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python#22776">here</a>).</p> <p>I also want to include a little download progress indicator showing the percentage of the download progress.</p> <p>Here is what I came up with:</p> <pre> sys.stdout.write(rem_file + "...") urllib.urlretrieve(rem_file, loc_file, reporthook=dlProgress) def dlProgress(count, blockSize, totalSize): percent = int(count*blockSize*100/totalSize) sys.stdout.write("%2d%%" % percent) sys.stdout.write("\b\b\b") sys.stdout.flush() </pre> <p>Output: MyFileName... 9%</p> <p>Any other ideas or recommendations to do this? </p> <p>One thing that's somewhat annoying is the blinking cursor in the terminal on the first digit of the percentage. Is there a way to prevent this? Is there a way to hide the cursor?</p> <p><strong>EDIT:</strong></p> <p>Here a better alternative using a global variable for the filename in dlProgress and the '\r' code:</p> <pre> global rem_file # global variable to be used in dlProgress urllib.urlretrieve(rem_file, loc_file, reporthook=dlProgress) def dlProgress(count, blockSize, totalSize): percent = int(count*blockSize*100/totalSize) sys.stdout.write("\r" + rem_file + "...%d%%" % percent) sys.stdout.flush() </pre> <p>Output: MyFileName...9% </p> <p>And the cursor shows up at the END of the line. Much better.</p>
<p>There's a text progress bar library for python at <a href="http://pypi.python.org/pypi/progressbar/2.2" rel="noreferrer">http://pypi.python.org/pypi/progressbar/2.2</a> that you might find useful:</p> <blockquote> <p>This library provides a text mode progressbar. This is tipically used to display the progress of a long running operation, providing a visual clue that processing is underway.</p> <p>The ProgressBar class manages the progress, and the format of the line is given by a number of widgets. A widget is an object that may display diferently depending on the state of the progress. There are three types of widget: - a string, which always shows itself; - a ProgressBarWidget, which may return a diferent value every time it's update method is called; and - a ProgressBarWidgetHFill, which is like ProgressBarWidget, except it expands to fill the remaining width of the line.</p> <p>The progressbar module is very easy to use, yet very powerful. And automatically supports features like auto-resizing when available.</p> </blockquote>
<p>For small files you may need to had this lines in order to avoid crazy percentages:</p> <p>sys.stdout.write("\r%2d%%" % percent)</p> <p>sys.stdout.flush()</p> <p>Cheers</p>
7,420
<p>With an ABS or PLA extrusion 3D printer, are there any potentially negative quality differences that could occur if I try to print at a higher resolution?</p> <p>I am not concerned about print time as the equipment is not under high demand. I am, however, worried the device may be more prone to fracture, likely to have defects, or have other issues I cannot currently imagine.</p>
<p>The biggest effect I've see on resolution is due to plastic stress due to thermal gradients.</p> <p>The higher resolution prints build up more layers of material, and each layer has a cumulative effect on thermal stress. The upper layers pulling up more as they cool, and the lower layers curling up more strongly as the layer count is increased.</p> <p>To counteract this, a heated (or even just a draft free) enclosure makes a big difference. Having a heated print bed helps significantly, as long as the bed itself resists deformation (a sheet metal or PCB bed will bend more than glass under the same tension, for instance).</p> <p>The actual plastic strength, however, appears increased. Laying down thinner layers of material appears to increase the bond strength between layers.</p>
<p>In my experience building with smaller layers also makes bridging and overhangs more pronounced and less likely to fail. </p> <p>The smaller layers allow gradual changes for overhangs that are more abrupt with thicker layer. </p>
90
<p>I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it.</p> <p>So, can someone give me a quick overview of how to track merges in a branch with Subversion 1.5? Are there any pitfalls with using this support? Do I need to ensure all the team upgrades to 1.5 before using this support?</p>
<h3>Usage</h3> <p>Merge tracking is managed by the client and stored in a property (<a href="http://subversion.tigris.org/merge-tracking/design.html" rel="nofollow noreferrer">svn:mergeinfo</a>).</p> <p>To use merge tracking you just merge as usual but without the revision range:</p> <pre><code>svn merge trunkURL </code></pre> <p>The client will take care of reading the properties to see what revision(s) need to be merged in and then update the properties with the newly-merged revision(s).</p> <p><a href="http://blog.red-bean.com/sussman/?p=92" rel="nofollow noreferrer">Here</a> is a pretty basic overview of the process.</p> <h3>Pitfalls, etc.</h3> <p>I personally haven't run into any problems with merge tracking, but my usage of the feature has been pretty light.</p> <h3>Upgrading</h3> <p>There are two upgrades you'll need to do to get merge tracking:</p> <ol> <li>Server: Your server <strong>must</strong> be running 1.5 to get merge tracking support.</li> <li>Client: You can use a 1.x client against a 1.5 server, <strong>but you won't get merge tracking.</strong></li> </ol> <p>Just upgrade everyone.</p>
<p>If you've built your repository with the ~ svn-merge.py command you can upgrade your repository to use svn native merge tracking with the XXX command.</p>
6,795
<p>Suppose I have a COM object which users can access via a call such as:</p> <pre><code>Set s = CreateObject("Server") </code></pre> <p>What I'd like to be able to do is allow the user to specify an event handler for the object, like so:</p> <pre><code>Function ServerEvent MsgBox "Event handled" End Function s.OnDoSomething = ServerEvent </code></pre> <p>Is this possible and, if so, how do I expose this in my type library in C++ (specifically BCB 2007)?</p>
<p>This is how I did it just recently. Add an interface that implements IDispatch and a coclass for that interface to your IDL:</p> <pre><code>[ object, uuid(6EDA5438-0915-4183-841D-D3F0AEDFA466), nonextensible, oleautomation, pointer_default(unique) ] interface IServerEvents : IDispatch { [id(1)] HRESULT OnServerEvent(); } //... [ uuid(FA8F24B3-1751-4D44-8258-D649B6529494), ] coclass ServerEvents { [default] interface IServerEvents; [default, source] dispinterface IServerEvents; }; </code></pre> <p>This is the declaration of the CServerEvents class:</p> <pre><code>class ATL_NO_VTABLE CServerEvents : public CComObjectRootEx&lt;CComSingleThreadModel&gt;, public CComCoClass&lt;CServerEvents, &amp;CLSID_ServerEvents&gt;, public IDispatchImpl&lt;IServerEvents, &amp;IID_IServerEvents , &amp;LIBID_YourLibrary, -1, -1&gt;, public IConnectionPointContainerImpl&lt;CServerEvents&gt;, public IConnectionPointImpl&lt;CServerEvents,&amp;__uuidof(IServerEvents)&gt; { public: CServerEvents() { } // ... BEGIN_COM_MAP(CServerEvents) COM_INTERFACE_ENTRY(IServerEvents) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IConnectionPointContainer) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CServerEvents) CONNECTION_POINT_ENTRY(__uuidof(IServerEvents)) END_CONNECTION_POINT_MAP() // .. // IServerEvents STDMETHOD(OnServerEvent)(); private: CRITICAL_SECTION m_csLock; }; </code></pre> <p>The key here is the implementation of the IConnectionPointImpl and IConnectionPointContainerImpl interfaces and the connection point map. The definition of the OnServerEvent method looks like this:</p> <pre><code>STDMETHODIMP CServerEvents::OnServerEvent() { ::EnterCriticalSection( &amp;m_csLock ); IUnknown* pUnknown; for ( unsigned i = 0; ( pUnknown = m_vec.GetAt( i ) ) != NULL; ++i ) { CComPtr&lt;IDispatch&gt; spDisp; pUnknown-&gt;QueryInterface( &amp;spDisp ); if ( spDisp ) { spDisp.Invoke0( CComBSTR( L"OnServerEvent" ) ); } } ::LeaveCriticalSection( &amp;m_csLock ); return S_OK; } </code></pre> <p>You need to provide a way for your client to specify their handler for your events. You can do this with a dedicated method like "SetHandler" or something, but I prefer to make the handler an argument to the method that is called asynchronously. This way, the user only has to call one method:</p> <pre><code>STDMETHOD(DoSomethingAsynchronous)( IServerEvents *pCallback ); </code></pre> <p>Store the pointer to the IServerEvents, and then when you want to fire your event, just call the method:</p> <pre><code>m_pCallback-&gt;OnServerEvent(); </code></pre> <p>As for the VB code, the syntax for dealing with events is a little different than what you suggested:</p> <pre><code>Private m_server As Server Private WithEvents m_serverEvents As ServerEvents Private Sub MainMethod() Set s = CreateObject("Server") Set m_serverEvents = New ServerEvents Call m_searchService.DoSomethingAsynchronous(m_serverEvents) End Sub Private Sub m_serverEvents_OnServerEvent() MsgBox "Event handled" End Sub </code></pre> <p>I hope this helps.</p>
<p>I ended up following the technique described <a href="http://www.mp3car.com/vbulletin/digitalmods-scripts-api/81425-how-create-c-com-object-streetdeck.html" rel="nofollow noreferrer">here</a>.</p>
8,691
<p>I do a lot of work in the grid and HPC space and one of the biggest challenges we have with a system distributed across hundreds (or in some case thousands) of servers is analysing the log files. </p> <p>Currently log files are written locally to the disk on each blade but we could also consider publishing logging information using for example a UDP Appender and collect it centally.</p> <p>Given that the objective is to be able to identify problems in as close to real time as possible, what should we do?</p>
<p>First, synchronize all clocks in the system using NTP.</p> <p>Second, if you are collecting the logs in a single location (like the UDP appender you mention) make sure the logs have enough information to actually help. I would include at least the server that generated the log, the time it happened, and the message. If there is any sort of transaction id, or job id type concept, include that also. </p> <p>Since you mentioned a UDP Appender I am guessing you are using log4j (or one of it's siblings). Log4j has an MDC class that allows extra information to be passed along through a processing thread. it can help collect some of the extra information and pass it along. </p>
<p>Are you using Apache? If so you could have a look at <a href="http://www.schlossnagle.org/~george/mod_log_spread/" rel="nofollow noreferrer">mod_log_spread</a> Though you may have too big an infrastructure to make it maintainable. The other option is to look at "broadcasting" or "multicasting" your log messages and having dedicated logging servers subscribing to those feeds and collating them</p>
5,573
<p>What I want is lots of nodes which can expand making a mind map.</p> <p>I'd ideally like to expand and collapse nodes. I would like to be able to navigate by either dragging around the page, or by following expanded nodes.</p>
<p>I have a colleague who needed that kind of functionalities to graph Maven dependencies between projects. He ended up using <a href="http://freemind.sourceforge.net/" rel="nofollow noreferrer">FreeMind</a> to do the visualization. He just had to write an XML file conforming to the FreeMind format. I even think you can just use <a href="http://www.opml.org/" rel="nofollow noreferrer">OPML</a> as the file format and find a ready to use XSLT to transform it to the FreeMind format. Maybe FreeMind actually supports OPML directly (I havent used it for a long time).</p> <p>Once you have your data in FreeMind, you can either export them, or use the <a href="http://freemind.sourceforge.net/docs/Serving%20Freemind%20maps%20in%20a%20browser/freemind%20applet.html" rel="nofollow noreferrer">FreeMind applet</a> to display an interactive MindMap on your website.</p>
<p>I think you are asking for a component that does what Visio can do, except that it can be displayed on a web page. Most likely you would have to create one from scratch, because mind mapping tools are always released as products per se and not customizable components. I suggest looking for a basic drawing/illustration component, and then putting your mind-mapping logic in it.</p>
8,750
<p>I have a non-.Net executable file that is included in my .net assembly as an embedded resource. Is there a way to run this executable that does not involve writing it out to disk and launching it?</p> <p>This is .Net 2.0.</p>
<p>You can load a .NET assembly from a byte array using an overload of <a href="http://msdn.microsoft.com/en-us/library/twt16z2x.aspx" rel="nofollow noreferrer">Assembly.Load</a>.</p> <p>However, there are implications for the security model that need to be considered which make things more complex. See the discussion <a href="http://blogs.msdn.com/shawnfa/archive/2007/04/18/loading-an-assembly-as-a-byte-array.aspx" rel="nofollow noreferrer">here</a>, and also this <a href="https://web.archive.org/web/20160513112857/http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.clr/2006-08/msg00069.html" rel="nofollow noreferrer">thread</a>.</p> <p>If your embedded executable is not .NET then I think you will have to write it out to disk first.</p>
<p>You might try injecting your exe into a suspended process and then awakening the hijacked process, but this seems like a recipe for disaster.</p>
9,823
<p>I inherited a Windows Forms app written in VB.Net. Certain parts of the app run dreadfully slow. What's the easiest way to find which parts of the code are holding things up? I'm looking for a way to quickly find the slowest subroutines and tackle them first in an attempt to speed up the app.</p> <p>I know that there are several code profiler products available for purchase which will show how long each subroutine takes, but I was hoping to find a <strong>free</strong> solution.</p>
<p>I appreciate the desire to find free software. However, in this case, I would strongly recommend looking at all options, including commercial products. I tried to play with nProf (which is at version 0.1 I think) and didn't have much luck. Even so, performance profiling an application is a subtle business and is best approached using a powerful, flexible tool. Unless you are working for free, I strongly believe the time you will save using a professional product will far outweigh the cost of a license. And of course, if you are only wanting to profile a single application, each commercial package has a 15 or 30 day trial, more than enough time to pinpoint any issues in an existing application. And if you need profiling support for more than just the one-off project, you're better buying a full strength tool anyway. </p> <p>We use the <a href="http://www.red-gate.com/products/ants_profiler/index.htm" rel="nofollow noreferrer">ANTS profiler</a> from RedGate and have been very happy with it. I have also used <a href="http://memprofiler.com/features.aspx" rel="nofollow noreferrer">.NET Memory Profiler</a> with excellent results. The cool thing about .NET Memory Profiler is that it can attach to and profile running production applications, which really saved our butts when we had a memory leak in production we couldn't reproduce in our test lab.</p> <p>The JetBrains folks <a href="http://www.jetbrains.com/profiler/" rel="nofollow noreferrer">have a profiler as well called dotTrace</a> which I haven't tried, but I have to believe that if it comes from the JetBrains shop it is probably top notch as well.</p> <p>Anyway, my advice is this: try to fix your app within the free trial window of one or an aggregated combination of the three of them (minimum of 45 days free use) and if that isn't enough time, pick your favorite and spring for one of them. You won't be sorry.</p>
<p>Visual Studio also comes with a performance profiler which is pretty good. it doesn't come with all versions - for VS2008, I think it is the Developer Edition you need.</p>
2,597
<p>I have a database table and one of the fields (not the primary key) is having a unique index on it. Now I want to swap values under this column for two rows. How could this be done? Two hacks I know are:</p> <ol> <li>Delete both rows and re-insert them.</li> <li>Update rows with some other value and swap and then update to actual value.</li> </ol> <p>But I don't want to go for these as they do not seem to be the appropriate solution to the problem. Could anyone help me out?</p>
<p>I think you should go for solution 2. There is no 'swap' function in any SQL variant I know of.</p> <p>If you need to do this regularly, I suggest solution 1, depending on how other parts of the software are using this data. You can have locking issues if you're not careful.</p> <p>But in short: there is no other solution than the ones you provided.</p>
<p>Oracle has deferred integrity checking which solves exactly this, but it is not available in either SQL Server or MySQL.</p>
2,306
<p>I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:</p> <pre><code>sun.util.calendar.ZoneInfo[id="GMT-08:00", offset=-28800000, dstSavings=0, useDaylight=false, transitions=0, lastRule=null] </code></pre> <p>Rather than the Pacific time zone. This is further indicated when I try to print the default time zone's <a href="http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getDisplayName()" rel="noreferrer">display name</a>, and it comes up "GMT-08:00", which seems to indicate to me that it is not correctly set to the US Pacific time zone. I am running on Ubuntu Hardy Heron, upgraded from Gutsy Gibbon.</p> <p>Is there a configuration file I can update to tell the JRE to use Pacific with all the associated daylight savings time information? The time on my machine shows correctly, so it doesn't seem to be an OS-wide misconfiguration.</p> <hr> <p>Ok, here's an update. A coworker suggested I update JAVA_OPTS in my /etc/profile to include "-Duser.timezone=US/Pacific", which worked (I also saw CATALINA_OPTS, which I updated as well). Actually, I just exported the change into the variables rather than use the new /etc/profile (a reboot later will pick up the changes and I will be golden).</p> <p>However, I still think there is a better solution... there should be a configuration for Java somewhere that says what timezone it is using, or how it is grabbing the timezone. If someone knows such a setting, that would be awesome, but for now this is a decent workaround.</p> <hr> <p>I am using 1.5, and it is most definitely a DST problem. As you can see, the time zone is set to not use daylight savings. My belief is it is generically set to -8 offset rather than the specific Pacific timezone. Since the generic -8 offset has no daylight savings info, it's of course not using it, but the question is, where do I tell Java to use Pacific time zone when it starts up? I'm NOT looking for a programmatic solution, it should be a configuration solution.</p>
<p>It's a "quirk" in the way the JVM looks up the zoneinfo file. See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6456628" rel="noreferrer">Bug ID 6456628</a>.</p> <p>The easiest workaround is to make /etc/localtime a symlink to the correct zoneinfo file. For Pacific time, the following commands should work:</p> <pre><code># sudo cp /etc/localtime /etc/localtime.dist # sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime </code></pre> <p>I haven't had any problems with the symlink approach.</p> <p>Edit: Added "sudo" to the commands.</p>
<p>It may help to double-check the timezone rules your OS is using.</p> <pre><code>/usr/bin/zdump -v /etc/localtime | less </code></pre> <p>This file should contain your daylight savings rules, like this one for the year 2080:</p> <pre><code>/etc/localtime Sun Mar 31 01:00:00 2080 UTC = Sun Mar 31 02:00:00 2080 BST isdst=1 gmtoff=3600 </code></pre> <p>You can compare this with the timezone rules you think you should be using. They can be found in <strong>/usr/share/zoneinfo/</strong>.</p>
2,814
<p>I'm new to NAnt but have some experience with Ant and CruiseControl.</p> <p>What I want to do is have my SVN project include all tools needed (like NUnit and Mocks etc) so I can check out onto a fresh machine and build. This strategy is outlined by J.P Boodhoo <a href="http://blog.jpboodhoo.com/NAntStarterSeries.aspx" rel="noreferrer">here.</a></p> <p>So far so good if I only want to run on Windows, but I want to be able to check out onto Linux and build/test/run against Mono too. I want no dependencies external to the SVN project. I don't mind having two sets of tools in the project but want only one NAnt build file</p> <p>This must be possible - but how? what are the tricks / 'traps for young players' </p>
<p>This shouldn't be a particularly difficult excercise. We do some fairly similar stuff on one of my projects since half of it runs on Java using Ant to run relevant targets, and the other half is .Net (C#) for the UI. The projects get run on windows machines for development, but the servers (Java) run linux, but in the UAT environment (linux) we need to run the nunits (integration tests). The real trick (not really a difficult trick) behind this is having a NAnt build file that can run in both environments which seems to be the same thing you're trying to do here.</p> <p>Of course you realise you'll need to install NAnt on Mono first:</p> <pre><code>$ export MONO_NO_UNLOAD=1 $ make clean $ make $ mono bin/NAnt.exe clean build </code></pre> <p>And then your build file needs to be written in such a way that it seperates concerns. Some parts of the build file written for windows will not work in linux for example. So you really just need to divide it up ito specific targets in the build file. After that, there are a number of ways you can run a specific targets from the command line. An example might look like this:</p> <pre><code>&lt;project name="DualBuild"&gt; &lt;property name="windowsDotNetPath" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5" /&gt; &lt;property name="windowsSolutionPath" value="D:\WorkingDirectory\branches\1234\source" /&gt; &lt;property name="windowsNUnitPath" value="C:\Program Files\NUnit-Net-2.0 2.2.8\bin" /&gt; &lt;property name="monoPath" value="You get the idea..." /&gt; &lt;target name="BuildAndTestOnWindows" depends="WinUpdateRevision, WinBuild, WinTest" /&gt; &lt;target name="BuildAndTestOnLinux" depends="MonoUpdateRevision, MonoBuild, MonoTest" /&gt; &lt;target name="WinUpdateRevision"&gt; &lt;delete file="${windowsSolutionPath}\Properties\AssemblyInfo.cs" /&gt; &lt;exec program="subwcrev.exe" basedir="C:\Program Files\TortoiseSVN\bin\" workingdir="${windowsSolutionPath}\Properties" commandline="${windowsSolutionPath} .\AssemblyInfoTemplate.cs .\AssemblyInfo.cs" /&gt; &lt;delete file="${windowsSolutionPath}\Properties\AssemblyInfo.cs" /&gt; &lt;exec program="subwcrev.exe" basedir="C:\Program Files\TortoiseSVN\bin\" workingdir="${windowsSolutionPath}\Properties" commandline="${windowsSolutionPath} .\AssemblyInfoTemplate.cs .\AssemblyInfo.cs" /&gt; &lt;/target&gt; &lt;target name="WinBuild"&gt; &lt;exec program="msbuild.exe" basedir="${windowsDotNetPath}" workingdir="${windowsSolutionPath}" commandline="MySolution.sln /logger:ThoughtWorks.CruiseControl.MsBuild.XmlLogger, ThoughtWorks.CruiseControl.MsBuild.dll;msbuild-output.xml /nologo /verbosity:normal /noconsolelogger /p:Configuration=Debug /target:Rebuild" /&gt; &lt;/target&gt; &lt;target name="WinTest"&gt; &lt;exec program="NCover.Console.exe" basedir="C:\Program Files\NCover" workingdir="${windowsSolutionPath}"&gt; &lt;arg value="//x &amp;quot;ClientCoverage.xml&amp;quot;" /&gt; &lt;arg value="&amp;quot;C:\Program Files\NUnit-Net-2.0 2.2.8\bin \nunit-console.exe&amp;quot; MySolution.nunit /xml=nunit-output.xml /nologo" /&gt; &lt;/exec&gt; &lt;/target&gt; &lt;target name="MonoUpdateRevision"&gt; You get the idea... &lt;/target&gt; &lt;target name="MonoBuild"&gt; You get the idea... &lt;/target&gt; &lt;target name="MonoTest"&gt; You get the idea... &lt;/target&gt; &lt;/project&gt; </code></pre> <p>For brevity, I've left both sides out. The neat thing is you can use NUnit as well as NAnt on both environments and that makes things really easy from a dependency point of view. And for each executable you can swap out for others that work in that environment, for example (xBuild for MSBuild, and svn for tortoise etc)</p> <p>For more help on Nunit etc on Mono, check out <a href="http://blog.coryfoy.com/2006/02/nunitnant-and-mono-on-linux/" rel="nofollow noreferrer">this fantastic post</a>.</p> <p>Hope that helps,</p> <p>Cheers,</p> <p>Rob G</p>
<p>I use the following template. It allows simple building on any platform (<code>build</code> on Win or <code>./build.sh</code> on linux) and minimises duplication in the build scripts.</p> <hr> <p>The NAnt executable is stored with the project in <code>tools\nant</code>.</p> <p>The build config file determines which build tool to use, either MSBuild or xbuild (in this case, for Windows I require the VS2015 MSBuild version, change the path as required).</p> <p>The <code>build-csproj</code> build target can be reused for when you have multiple projects within a solution.</p> <p>The <code>test-project</code> target would need to be expanded upon for your needs.</p> <p><strong>build.bat</strong></p> <pre><code>@tools\nant\nant.exe %* </code></pre> <p><strong>build.sh</strong></p> <pre><code>#!/bin/sh /usr/bin/cli tools/nant/NAnt.exe "$@" </code></pre> <p><strong>default.build</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;project name="MyProject" default="all"&gt; &lt;if test="${not property::exists('configuration')}"&gt; &lt;property name="configuration" value="release" readonly="true" /&gt; &lt;/if&gt; &lt;if test="${platform::is-windows()}"&gt; &lt;property name="BuildTool" value="C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" readonly="true"/&gt; &lt;/if&gt; &lt;if test="${platform::is-unix()}"&gt; &lt;property name="BuildTool" value="xbuild" readonly="true"/&gt; &lt;/if&gt; &lt;property name="TestTool" value="tools/mytesttool.exe"/&gt; &lt;target name="all" depends="myproject myprojectlib" /&gt; &lt;target name="build-csproj" description="Build a given csproj"&gt; &lt;!-- Must not be called standalone as it requires some properties set. --&gt; &lt;exec program="${BuildTool}"&gt; &lt;arg path="src/${ProjectName}/${ProjectName}.csproj" /&gt; &lt;arg line="/property:Configuration=${configuration}" /&gt; &lt;arg value="/target:Rebuild" /&gt; &lt;arg value="/verbosity:normal" /&gt; &lt;arg value="/nologo" /&gt; &lt;/exec&gt; &lt;/target&gt; &lt;target name="test-project"&gt; &lt;!-- Must not be called standalone as it requires some properties set. --&gt; &lt;exec program="${TestTool}"&gt; &lt;arg path="my/${ProjectName}/tests/path/for/tool" /&gt; &lt;arg value="/aproperty=value" /&gt; &lt;/exec&gt; &lt;/target&gt; &lt;target name="myproject" description="Build the project"&gt; &lt;property name="ProjectName" value="MyProject"/&gt; &lt;call target="build-csproj" /&gt; &lt;call target="test-project" /&gt; &lt;/target&gt; &lt;target name="myprojectlib" description="Build the project's library dll"&gt; &lt;property name="ProjectName" value="MyProjectLib"/&gt; &lt;call target="build-csproj" /&gt; &lt;call target="test-project" /&gt; &lt;/target&gt; &lt;/project&gt; </code></pre>
5,197
<p>It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.</p> <pre><code>List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = sl; </code></pre> <p>results in Cannot implicitly convert type <code>System.Collections.Generic.List&lt;string&gt;</code> to <code>System.Collections.Generic.List&lt;object&gt;</code></p> <p>And then...</p> <pre><code>List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = (List&lt;object&gt;)sl; </code></pre> <p>results in Cannot convert type <code>System.Collections.Generic.List&lt;string&gt;</code> to <code>System.Collections.Generic.List&lt;object&gt;</code></p> <p>Of course, you can do it by pulling everything out of the string list and putting it back in one at a time, but it is a rather convoluted solution.</p>
<p>Think of it this way, if you were to do such a cast, and then add an object of type Foo to the list, the list of strings is no longer consistent. If you were to iterate the first reference, you would get a class cast exception because once you hit the Foo instance, the Foo could not be converted to string!</p> <p>As a side note, I think it would be more significant whether or not you can do the reverse cast:</p> <pre><code>List&lt;object&gt; ol = new List&lt;object&gt;(); List&lt;string&gt; sl; sl = (List&lt;string&gt;)ol; </code></pre> <p>I haven't used C# in a while, so I don't know if that is legal, but that sort of cast is actually (potentially) useful. In this case, you are going from a more general class (object) to a more specific class (string) that extends from the general one. In this way, if you add to the list of strings, you are not violating the list of objects.</p> <p>Does anybody know or can test if such a cast is legal in C#?</p>
<p>Here is another pre-.NET 3.5 solution for any IList whose contents can be cast implicitly.</p> <pre><code>public IList&lt;B&gt; ConvertIList&lt;D, B&gt;(IList&lt;D&gt; list) where D : B { List&lt;B&gt; newList = new List&lt;B&gt;(); foreach (D item in list) { newList.Add(item); } return newList; } </code></pre> <p>(Based on Zooba's example)</p>
2,827
<p>I know this isn't strictly a programming question but y'all must have experienced this. </p> <p>So...you have four or five RDP sessions open over the corp VPN, you're bashing away inside your favourite IDE, your VPN to the data centre bounces briefly then recovers, all your RDP sessions start re-establishing their connections and whilst doing so sequentially keep grabbing focus, one after the other. Pretty bloody annoying and downright rude.</p> <p>Any idea how to prevent this behaviour and just make the RDP client flash it's taskbar button instead of totally grabbing focus away from whatever you were doing?</p> <p>@<a href="https://stackoverflow.com/questions/22903/how-do-i-stop-the-windows-rdp-client-grabbing-focus-after-a-reconnect#22911">Jason</a> - thanks for the reply, I'm running 64 bit Vista and 64 Bit Windows 2008. Any ideas how well it plays?</p> <p>@<a href="https://stackoverflow.com/questions/22903/how-do-i-stop-the-windows-rdp-client-grabbing-focus-after-a-reconnect#23049">Jason</a> - good idea. Done.</p> <p>@<a href="https://stackoverflow.com/questions/22903/how-do-i-stop-the-windows-rdp-client-grabbing-focus-after-a-reconnect#23139">Ryan</a> - thanks also for the answer. I tried <a href="http://www.codeplex.com/Terminals" rel="nofollow noreferrer">Terminals</a> a few times before, but quite often I need to see two or three sessions side by side which the tabbing doesn't really facilitate too well, would've been nice to have a 'pop out in own window' button. I did once grab the source code to fix stuff like that, but never got the time. I also found it behaved oddly whenever there was a brief network disconnect (e.g. xDSL flapping) and it would reconnect to the wrong session (usually a new one) and leave the session I had opened in a disconnected state on the server. Otherwise Terminals would've been really cool, we have 200+ windows servers, and organising all those .rdp files can be a pain.</p>
<p>I use <a href="http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx" rel="nofollow noreferrer">Tweak UI</a> to configure explorer so that apps don't steal focus; you can also configure how many times they flash in the taskbar as well.</p> <p>EDIT: Once you are within Tweak UI, these options are found under General > Focus.</p> <p>EDIT: @Kev, apparently there is <a href="http://www.softpedia.com/get/Tweak/System-Tweak/TweakUI-64-Bit-Edition.shtml" rel="nofollow noreferrer">a 64-bit version</a> (not MS approved, apparently, I would scan it for viruses of course) that works successfully with the 64-bit version of XP. From what I understand, you download that and then run it in XP compatibility mode as administrator and it will do the trick. Tweak UI is basically a nice wrapper around a collection of registry hacks, so I imagine you could find the hacks themselves if you didn't care for running Tweak UI in this manner. Hope that works for you!</p>
<p>As an alternative, you could try using something like <a href="http://www.codeplex.com/Terminals" rel="nofollow noreferrer">Terminals</a>. It allows you to have multiple remote desktop windows open at once all as tabs in the same window. Quite cool. Also, it is open source so you can change its behavior if needed (although I don't believe it steals focus like a normal RDP session does). </p> <p><img src="https://i.stack.imgur.com/aLRB4.jpg" alt="Terminals Screenshot"></p>
4,292
<p>Can you use windows hooks or other methods to do code injection with c#? I've seen lots of things about code injection but all of them are done in C/C++. I don't know either of those languages and have a really hard time translating. Does anyone have any ideas on how to do this?</p>
<p>Kevin, it is possible. You can create library with window hook proc using managed C++. All you need to do is to inject this hook into some application using standard WinAPI (SetWindowsHookEx etc.). Inside this hook you can call System::AppDomain::CurrentDomain->Load method to load your assembly into target application's AppDomain. Then you can call methods defined in your assembly using reflection. For example, <a href="https://web.archive.org/web/20081228210203/http://blois.us/Snoop/" rel="nofollow noreferrer">Snoop</a> uses this method.</p>
<p>Mike Stall has <a href="http://blogs.msdn.com/jmstall/archive/2006/09/28/managed-create-remote-thread.aspx" rel="nofollow noreferrer">this sample</a>, that uses CreateRemoteThread. It has the advantage of not requiring any C++. </p>
4,397
<p>There are numerous topics found on first layers that do not adhere properly causing prints to fail or cause print quality defects.</p> <p>The advice is often to properly level or tram the build surface. How does one tram the build surface?</p>
<h3>Definition of leveling</h3> <p>Tramming, often referred to as &quot;leveling&quot; in the 3D printer world (&quot;tramming&quot; and &quot;leveling&quot; is used interchangeably, but &quot;tramming&quot; is the correct nomenclature), is the process of creating a 2D <a href="https://en.wikipedia.org/wiki/Plane_(geometry)" rel="nofollow noreferrer">plane</a> of the build surface that is parallel to the nozzle at the whole print area (usually the X-Y plane).</p> <h3>Why tramming?</h3> <p>In order to adhere the hot filament from the nozzle it is essential that the distance between the nozzle and the build surface is as constant as possible. Increase of the gap may cause the filament to not be squished enough and it may be dragged instead of deposited or create an insufficient bond to cause problems later in the print job when e.g. shrinkage of the object comes in play.</p> <h3>How to tram the surface?</h3> <p>To tram the build surface (a build surface comes in many shapes and forms, sheet of glass, bare aluminum plate, some sort of coated heated surface, etc.) most printers are equipped with at least three so-called &quot;leveling screws&quot;. Why at least three? It takes a minimum of three screws to fixate a plane in space, more screws cause the bed to be over-defined or indeterminate, but with a flexible build surface it is quite common to have 4 screws although it is causing a <a href="https://en.wikipedia.org/wiki/Statically_indeterminate" rel="nofollow noreferrer">statically indeterminate system</a>. So, these screws need to be adjusted as such that the build surface if parallel to the nozzle.</p> <p>First step is to home (<a href="https://3dprinting.stackexchange.com/questions/18453/what-is-homing-what-is-the-purpose-of-homing">What is homing? What is the purpose of homing?</a>) the printer, <a href="/questions/tagged/homing" class="post-tag" title="show questions tagged &#39;homing&#39;" rel="tag">homing</a> from the <a href="https://3dprinting.stackexchange.com/tags/homing/info">tag wiki</a> reads:</p> <blockquote> <p>The process of determining the location of a 3D printer nozzle in three dimensions using a reference point (home location) is referred to as &quot;homing&quot;. Homing should occur before every print and involves bringing the X, Y and Z-Axis motors to pre-defined limit locations (usually these are endstops). Pre-recorded homing data offset values determine the position of the build plate origin with respect to the endstop locations.</p> </blockquote> <p>Once homed (with G-code <a href="https://reprap.org/wiki/G-code#G28:_Move_to_Origin_.28Home.29" rel="nofollow noreferrer"><code>G28</code></a> or through the graphical user interface of the printer display) , the origin (0, 0, 0) of the printer is known, from this origin you can determine the level. Note that the X and Y is usually correct (if not, see <a href="https://3dprinting.stackexchange.com/questions/6375/how-to-center-my-prints-on-the-build-platform-re-calibrate-homing-offset">How to center my prints on the build platform? (Re-calibrate homing offset)</a>) the Z offset depends on the height of the Z endstop and the leveling screws. For a surface that uses a sensor as endstop (see e.g. <a href="https://3dprinting.stackexchange.com/questions/16604/automatic-bed-leveling-abl-with-a-sensor-bltouch-inductive-capacitive-how">Automatic Bed Leveling (ABL) with a sensor (BLTouch, inductive, capacitive), how does it work?</a>) the offset is defined by G-code (<code>M851</code>) or through the user interface of the printer display. Note that automatic bed leveling (ABL) is not magic, you still need to provide a trammed bed that is as level as possible, the sensor merely scans the surface and adjusts for larger imperfections of the build surface. After homing, move the nozzle at a certain Z value to the corner of the origin, which is usually the front left) (0, 0, Z) or close to this corner (10, 10, Z), put a piece of paper (A4/Letter) on the build surface and lower the Z to 0 (or if you hit the build surface before you reach zero height, then lower the build surface) raise the build surface until you can feel the the paper drag slightly when pulled between the nozzle and build surface (alternatively you can use a feeler gauge, A4 paper is 0.08 to 0.11 mm thick, so a 0.1 mm gauge will do fine). To be sure that the carriage hasn't been moved by the tramming, issue a homing command and move to the corner to the right and repeat the process to crete a slight drag of the paper when pulled between the nozzle and build surface. Note that tramming this point may have influenced the first point. Now repeat the homing and moving (for corners back right and back left) to start over again at the front left corner and repeating the whole process at least one to two times. This iterative process will deliver a trammed bed, the bed should now be parallel to the nozzle.</p> <h3>Trammed, but filament not adhering...</h3> <p>Once trammed the build surface should be parallel to the nozzle, if the distance (usually paper thickness) is too far or too close, adhesion or first layer deposition may fail or cause surface defects like <a href="/q/7229">ripples</a>. If not adhering the initial gap between the nozzle and the build surface (paper thickness) might be too big, making this smaller may help squish the filament more so that it adheres better to the build surface. Alternatively use an adhesive in between the build surface and the first layer, nowadays there are multiple dedicated sprays and liquids available, but some house hold product like wood glue, glue sticks and <a href="/a/11183">hair sprays</a> could be used.</p> <h3>Build surface cannot or is difficult to tram</h3> <p>When the build surface isn't perfectly flat, tramming is a challenge, or doesn't provide a 2D plane at a fixed distance of the nozzle. In such cases, scanning the build surface and adjusting during printing might help to get the filament to adhere properly; this process is called automatic bed leveling or ABL (see <a href="https://3dprinting.stackexchange.com/questions/16604/automatic-bed-leveling-abl-with-a-sensor-bltouch-inductive-capacitive-how">Automatic Bed Leveling (ABL) with a sensor (BLTouch, inductive, capacitive), how does it work?</a>). An alternative is UBL (see <a href="https://3dprinting.stackexchange.com/questions/18451/what-is-abl-or-ubl-is-this-the-same">What is ABL or UBL? Is this the same?</a>).</p> <h3>Tramming frequently?</h3> <p>The frequency of tramming depends on the quality and (mis)use of the printer to maintain the 2D plane parallel to the nozzle. For good quality printers the tramming is performed very seldom.</p>
<p>For fine tuning I get good results by loading a model of any object with a rectangular footprint and scaling it to a size close to the printer's limits.</p> <p>With the skirt set to around 10 passes, start the print job, let the skirt print then kill the job.</p> <p>Peel the skirt from the bed and measure its thickness near the leveling screw locations with digital calipers or a micrometer and adjust the leveling screws as indicated.</p>
2,115
<p>For some reason the only the top layers keep failing or underextruding on my prints, for no clear reason. Here are my settings:</p> <ul> <li>Slicer: Simplify3D</li> <li>Filament: 1.75 mm Black PLA from Filamentive</li> <li>Resolution: 0.1 mm on a 0.4 mm nozzle</li> <li>Temperature: 200 °C nozzle and 50 °C bed</li> <li>Speed: 45 mm/s and 50% outline speed</li> <li>Infill: 15%</li> </ul> <p>The prints were going perfectly fine on a 0.2 mm resolution and only seemed to fail when I changed to 0.1 mm; which is strange considering the rest of the print goes fine, apart from the top layers (which I have 3 of).</p> <p>My only thought is that it could be a bridging issue and is somehow underextruding, and getting caught on the infill as that it where it is centred around. I wouldn't know how to fix this.</p> <p>If anyone could give me any information or tips I would be very appreciative, thanks.</p> <p>The pictures are taken after some light sanding.</p> <p><a href="https://i.stack.imgur.com/wnhbn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wnhbn.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/PyVoc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PyVoc.jpg" alt="enter image description here"></a></p>
<p>If you decrease layer thickness, you should increase bottom and top layer amount, or set it to a fixed shell thickness. The thinner the layers the more difficult to span over the infill (there is much less filament extruded). </p> <p>You could try extra part cooling, higher percentage infill, reduced hotend temperature and slower top layer printing. But, best results are reached with more top layers and higher infill percentage.</p> <p>See e.g. <a href="https://groups.google.com/forum/m/#!topic/wanhao-printer-3d/tulE2ATbClA" rel="nofollow noreferrer">this answer</a> by user "dnewman":</p> <blockquote> <p>That said, with very low layer heights (e.g., 0.1&nbsp;mm), there's a tendency to use very sparse infill to speed up printing time. However, very low layer heights bridge over voids very, very poorly. So poorly that you can have the print nearly finished only to find that the top won't close up. Thus, don't make the infill too sparse when doing low layer heights. MOREVER, you definitely need more top layers to get the final finished top to look acceptable. The thin layer heights will take many more layers (many more in physical height, not just layer count) to give a nice top. At issue (again) is how poorly low layer heights will bridge voids. With 0.2&nbsp;mm on up, you generally get a nice, thin strand extruded which can stretch across voids. But at 0.1&nbsp;mm layer heights the printer is just doing tiny, discrete squirts of plastic which it spreads like cake icing across the lower layer. There's not a single, fine strand extruded and instead tiny little beads. When there's a solid layer below, these squirts have something to be spread against by the extruder nozzle. But when there's a void, the squirts just build up on the nozzle and then come off in a big blob when the nozzle next brushes over a non-void space.</p> </blockquote>
<p>The holes in your part tops are the result of a combination of poor bridging and too few top layers.</p> <p>What's happening is that when the printer tries to lay down the first layer of the top/roof, it has to "bridge" over the top layer of the infill. If you are trying to lay down that layer too quickly, with too hot a filament temperature, over too sparse an infill, the lines won't go down properly, and then the next layer over that has to try to bridge this same gap with very little support (and very often with up-curled broken strands of filament in the way).</p> <p>The printer can <em>eventually</em> lay down a smooth layer, if you give it enough tries to smooth over the rougher, broken layers underneath. How many you need depends on how badly the first one failed to bridge the infill gaps. If you're only printing 2 layers, try 4. If you're printing 4, try 6.</p> <p>Also, look at your infill percentage and pattern. The top lines have to be drawn over the top of whatever the layer of infill looks like as of when the slicer calculates that the first layer of top needs to go down. Virtually all slicers provide a "preview" of the sliced layers, with some like Cura allowing you to trace through the extruder's "tool path" over each layer. This can be a very useful tool to diagnose potential issues with what the slicer will expect the printer to do.</p> <p>As for how to change it, it really depends on what you need out of the part in terms of material strength (different patterns have advantages and disadvantages in how much force can be applied in what directions), weight (more infill means heavier), and print time (higher percentages and more complex infill patterns increase print time). Cubic infill has the best overall strength-for-weight, and it slices and prints pretty fast as each layer is just straight lines. However, it's among the worst in terms of the grid it provides under the top layer. Isolinear/Triangle fill provides one of the better support structures, and is near the top in Z-axis compressive strength, but compressive strength other than in the Z-axis tends to be low. Gyroid infill has among the best combinations of strength, weight and required bridging distances, but slicing and printing the complex curved structure takes more time, and some slicers don't offer it (I'm still kicking around with an old MakerBot that's only fully supported by MakerBot Desktop, which doesn't offer any "fully 3D" fills like cubic or gyroid at all).</p> <p>Lastly, if you absolutely need the model at a light weight or fast print time that precludes increasing the infill or slowing print head speed, try printing a bridging test, especially something like a "temperature tower" that allows you to see the effects of varying extrusion temperature all in one model, and make sure you're printing at the exact temperature giving you the best results for the other configuration settings you're using. Your model may not require externally-visible bridging or overhangs, but the ability to draw a long line of filament literally into thin air without sagging or snapping is a useful trick even in "solid" object prints, because as you've found out, these solid shapes are up to 90% air inside.</p>
1,550
<p>TFS2008. I'd like to track task points on a Task work item, but there isn't anywhere (other than the description) to record this. I'd like to add a dropdown with 0, 1, 2, 3, 5, 8, etc, so these task points can be exported in reports.</p>
<p>Use the process template editor, available as part of the <a href="http://msdn.microsoft.com/en-ca/tfs2008/bb980963.aspx" rel="nofollow noreferrer">Visual Studio Team System 2008 Team Foundation Server Power Tools</a>.</p>
<p>I created a web cast awhile ago that demonstrates this tool. it covers a couple of really basic scenarios. It can be accessed <a href="http://homepage.mac.com/stevevrporter/blog/Ta.html#vyk233532924" rel="nofollow noreferrer">here</a>.</p> <p>Ta.</p> <p>Steve Porter</p>
7,628
<p>I'm looking for a profiler in order to find the bottleneck in my C++ code. I'd like to find a free, non-intrusive, and good profiling tool. I'm a game developer, and I use PIX for Xbox&nbsp;360 and found it very good, but it's not free. I know the Intel <a href="https://en.wikipedia.org/wiki/VTune" rel="noreferrer">VTune</a>, but it's not free either.</p>
<p><a href="https://gpuopen.com/archived/legacy-codexl/" rel="nofollow noreferrer">CodeXL</a> has now superseded the End Of Line'd <a href="https://web.archive.org/web/20120607044224/http://developer.amd.com/tools/CodeAnalyst/Pages/default.aspx" rel="nofollow noreferrer">AMD Code Analyst</a> and both are free, but not as advanced as VTune.</p> <p>There's also <a href="http://www.codersnotes.com/sleepy/" rel="nofollow noreferrer">Sleepy</a>, which is very simple, but does the job in many cases.</p> <p>Note: <strong>All three of the tools above are unmaintained since several years.</strong></p>
<p>I've used "TrueTime - part of Compuware's DevPartner suite for years. There's a [free version](you could try Compuware DevPartner Performance Analysis Community Edition.) available.</p>
9,308
<p>If I issue the <a href="https://en.wikipedia.org/wiki/Find_(Unix)" rel="noreferrer">find</a> command as follows:</p> <pre><code>find . -name *.ear </code></pre> <p>It prints out:</p> <pre><code>./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear </code></pre> <p>I want to 'print' the name and the size to the command line:</p> <pre><code>./dir1/dir2/earFile1.ear 5000 KB ./dir1/dir2/earFile2.ear 5400 KB ./dir1/dir3/earFile1.ear 5400 KB </code></pre>
<pre><code>find . -name '*.ear' -exec ls -lh {} \; </code></pre> <p>just the h extra from jer.drab.org's reply. saves time converting to MB mentally ;)</p>
<p>You could try for loop:</p> <pre><code>for i in `find . -iname &quot;*.ear&quot;`; do ls -lh $i; done </code></pre>
9,025
<p>I think the file that is produced is an .asm file, any idea how to produce this in Visual Studio when you do a build?</p>
<ol> <li>Open the Properties page for a project </li> <li>Select the <code>Configuration Properties -&gt; C/C++ -&gt; Output Files</code> branch </li> <li>Change the Assembler Output option to something other than <code>No Listing</code> </li> <li>Make sure ASM List Location is set to a valid path or sub-path</li> <li>Build.</li> </ol>
<p>Or if using the Visual Studio command line, </p> <p>cl.exe /Fa[assembler code filename]</p> <p>If you just want to view the assembler code in the IDE you can start the debugger and then select the Go To Dissassembly choice on the right click menu.</p>
5,494
<p>Here is a sample from Kernighan &amp; Ritchie's "The C Programming Language":</p> <pre><code>int getline(char s[], int lim) { int c, i = 0; while (--lim &gt; 0; &amp;&amp; (c=getchar()) !=EOF &amp;&amp; c !='\n') { s[i++] = c; } if (c =='\n') { s[i++] = c; } s[i] = '\0'; return i; } </code></pre> <p>Why do we should check if <code>c != '\n'</code>, despite we use <code>s[i++] = c</code> after that?</p>
<p>The functions reads characters from the standard input until either EOF or a newline characters is found. </p> <p>The second check ensures that the only newline character is put into the char array. EOF shouldn't occur in a proper c-string. Also, if the character isn't newline that means that we might have filled up our c-string, in which case we shouldn't put any more characters into it. </p> <p>Notice we still append the '\0'. We've ensured that theres still room for one more character in our c-string, as we use the pre-fix decrementor, which evaluates before the comparison.</p>
<p>You do that just to exit the while loop on new line. Else you would have to check it in while body and use break.</p>
9,746
<p>We have a website that uses <code>#include file</code> command to roll info into some web pages. The authors can access the text files to update things like the occasional class or contact information for the department.</p> <p>My question is this, I don't <em>see</em> anyone using this method and wonder if it is a good idea to keep using it. If not, what method should I transition to instead?</p>
<p>I've had to interview people for a few C# positions and this is my general advice for VB.Net developers interviewing for a C# position:</p> <ul> <li>Make sure you are clear that you have been working VB.Net. This seems obvious but is something that apparently isn't (in my experience).</li> <li>Try to give a code sample, if possible. I've seen some horrible VB.Net (and C#) written by VB programmers who didn't seem to learn much in the transition to .Net.</li> <li>Be able to write in C# during the interview, if asked. I know there aren't many real differences between the two, but I don't want to pay you to learn the new syntax.</li> </ul> <p>For your specific question: I've asked that type of question before and what I wanted to hear about was how the underlying system and framework were the same. If possible, talk about garbage collection, IDisposable, finalizers, the dangers of unsafe code blocks, stack vs heap, etc. All the kind of stuff to show that you really understand the intricacies of the .Net framework. Right or wrong, the heritage of VB brings with it an expectation of a lack of understand of lower level programming and windows in general (which, ironically enough, a c++ developer would have of a c# developer... and so on). </p> <p>Lastly, how you frame your experience can make a world of difference. If you position yourself as a .Net developer, rather than VB.Net or C#, the stupid, pseudo-religious, banter may not enter the conversation. This of course requires that you actually know both VB.Net and C# at the time of the interview, but that's a good policy regardless.</p> <p>The truth of the matter is that if you find that the person interviewing you writes you off simply because you've previously been developing in VB.Net, it's likely not going to be a place you want to work at anyway.</p>
<p>VB or C# both are syntax only diffrent but if you are applying way of logic is same.</p>
3,558
<p><a href="https://i.stack.imgur.com/WwWuN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/WwWuN.jpg" alt="3D printing problem stringing"></a></p> <p>So these past few days I have been 3D printing again with my Ender 3 with PETG and 0.4&nbsp;mm nozzle and while I have been using the same setting as usual I am seeing an unusual amount of stringing between the prints. Does anyone know why? If you're wondering regarding the settings here they are, I'm using Cura for slicing, see options:</p> <p><a href="https://i.stack.imgur.com/ialqzm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ialqzm.png" alt="Quality"></a> <a href="https://i.stack.imgur.com/Tc2Blm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Tc2Blm.png" alt="Shell"></a> <a href="https://i.stack.imgur.com/3SpNZm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3SpNZm.png" alt="Temperature"></a> <a href="https://i.stack.imgur.com/6H1M6m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6H1M6m.png" alt="Retraction"></a> <a href="https://i.stack.imgur.com/0KMAQm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0KMAQm.png" alt="Speed"></a> <a href="https://i.stack.imgur.com/xWib6m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xWib6m.png" alt="Cooling"></a></p>
<p>The travel speed of 160 mm/s is a big red flag. PETG is not tolerant of a hot nozzle moving over it at high speeds, especially unretracted (combing). The nozzle will drag material in a stuttering pattern, every so often, marring the surface and pulling what it dug up into strings.</p> <p>Lower the travel speed to the same as the print speed, and then experiment with whether you can increase it without problems. I would not try going over 80 mm/s and probably not even over 60.</p> <p>For what it's worth, this <em>sounds like</em> softened/molten PETG is a non-newtonian fluid, where at low stress (slow moving nozzle pushing/pulling) it deforms gracefully, but at high stress (fast moving nozzle) it strongly resists deformation and has a discontinuous breaking point. A quick Googling turned up this article, <a href="https://link.springer.com/article/10.1007/s10924-019-01544-6" rel="nofollow noreferrer">Thermal, Rheological and Mechanical Properties of PETG/rPETG Blends</a>, which might explain what's happening.</p>
<p>Petg it stringy material, all I can do is keep it dry to prevent blob. but I live in hot country with high moisture so I decide to keep filament in heat dryer box while print. It help a lot. </p>
1,615
<p>When I have two mysql servers that have different jobs (holding different databases) but want to be able to use one of them to slip in when the other one fails, what would you suggest how I keep the data on both of them equal "close to realtime"? </p> <p>Obviously it's not possible to make a full database dump every x minutes.</p> <p>I've read about the <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-log.html" rel="noreferrer">Binary Log</a>, is that the way that I need to go? Will that not slow down the fallback server a lot? Is there a way to not include some tables in the binary log - where it doesn't matter that the data has changed?</p>
<p>Binary log is definitely the way to go. However, you should be aware that with <strong>MySQL</strong> you can't just flip back and forth between servers like that.</p> <p>One server will be the <strong>master</strong> and the other will be the slave. You write/read to the master, but can only read from the slave server. If you ever write to the slave, they'll be out of sync and there's no easy way to get them to sync up again (basically, you have to swap them so the master is the new slave, but this is a tedious manual process).</p> <p>If you need true hot-swappable backup databases you might have to go to a system other than <strong>MySQL</strong>. If all you want is a read-only live backup that you can use instantly in the worst-case scenario (master is permanently destroyed), Binary Log will suit you just fine.</p>
<p>You may want to consider the <strong>master-master</strong> replication scenario, but with a slight twist. You can specify which databases to replicate and limit the replication for each server.</p> <p>For server1 I would add <code>--replicate-do-db=server_2_db</code> and on server2 <code>--replicate-do-db=server_1_db</code> to your my.cnf (or my.ini on Windows). This would mean that only statements for the server_1_db would be replicated to server2 and vice verse. </p> <p>Please also make sure that you perform full backups on a regular basis and not just rely on replication as it does not provide safety from accidental <code>DROP DATABASE</code> statements or their like.</p>
2,958
<p>I have an Ender 3, currently in stock Bowden extruder configuration.</p> <p>I want to be able to print nylon and TPU, both of which require temperature too high for the tolerance of the PTFE Bowden tube (as well as the issues with the flexible filament in the tube).</p> <p>Therefore, I've considered converting my printer to direct drive. However, the conversions I've seen, both DIY/print the parts type and commercial, seem to include a short length of the same PTFE tube between the extruder (now mounted on the hot end carriage) and the actual hot end. This same material ought to have the same temperature limit (about 250 C) as it would have in a Bowden configuration -- and for nylon, at the least, this is a problem, since the PTFE would start to soften from contact with the heat break.</p> <p>Am I missing something in these conversions, or is the PTFE's glass transition not the limiting factor in printing hotter with a direct drive conversion?</p>
<p>Direct Drive v.s. Bowden has no relation to the maximum print temperature. What determines the maximum print temperature is the design of the hotend itself. There are &quot;all-metal&quot; designs, where the PTFE tube (Bowden or not) stops in the cold zone and the heatbreak and all other components that get hot are fully made of metal. Other hotend designs have the PTFE tube run all the way down into the hot zone and this limits the maximum printing temperature. It has nothing to do with whether the hotend is Bowden or not.</p>
<p>Bowden tubes extending to the nozzle to make a seal will damage the Teflon (PTFE) tube if exceeding 250°C for an extended time. An all-metal hotend for a Bowden would have either the nozzle sealed against the heatbreak or an integrated nozzle and heatbreak. Then the Bowden tube would attach with a minimum gape with either the heatbreak or heatsink.</p> <p>Note: The heater block needs to be at the maximum operating temperature When making a seal between the nozzle and heatbreak.</p>
1,959
<p>I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File.</p>
<p>I found a possible answer here: <a href="http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63" rel="noreferrer">http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63</a></p> <p>From the article:</p> <pre><code>XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ; XslTransform myXslTrans = new XslTransform() ; myXslTrans.Load(myStyleSheet); XmlTextWriter myWriter = new XmlTextWriter("result.html",null) ; myXslTrans.Transform(myXPathDoc,null,myWriter) ; </code></pre> <p><strong>Edit:</strong></p> <p>But my trusty compiler says, <code>XslTransform</code> is obsolete: Use <code>XslCompiledTransform</code> instead:</p> <pre><code>XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ; XslCompiledTransform myXslTrans = new XslCompiledTransform(); myXslTrans.Load(myStyleSheet); XmlTextWriter myWriter = new XmlTextWriter("result.html",null); myXslTrans.Transform(myXPathDoc,null,myWriter); </code></pre>
<p>I would like to share this small piece of code which reads from Database and transforms using XSLT. On the top I also have used <code>xslt-extensions</code> which makes it little different than others.</p> <p>Note: <em>This is just a draft code and may need cleanup before using in production.</em></p> <pre><code>var schema = XDocument.Load(XsltPath); using (var connection = new SqlConnection(ConnectionString)) { connection.Open(); using (var command = new SqlCommand(Sql, connection)) { var reader = command.ExecuteReader(); var dt = new DataTable(SourceNode); dt.Load(reader); string xml = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;&quot; + Environment.NewLine; using (var stringWriter = new StringWriter()) { dt.WriteXml(stringWriter, true); xml += stringWriter.GetStringBuilder().ToString(); } XDocument transformedXml = new XDocument(); var xsltArgumentList = new XsltArgumentList(); xsltArgumentList.AddExtensionObject(&quot;urn:xslt-extensions&quot;, new XsltExtensions()); using (XmlWriter writer = transformedXml.CreateWriter()) { XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(schema.CreateReader()); xslt.Transform(XmlReader.Create(new StringReader(xml)), xsltArgumentList, writer); } var result = transformedXml.ToString(); } } </code></pre> <p><code>XsltPath</code> is path to your xslt file.<br /> <code>ConnectionString</code> constant is pointing to your database.<br /> <code>Sql</code> is your query.<br /> <code>SourceNode</code> is node of each record in source xml.</p> <p>Now the interesting part, please note the use of <code>urn:xslt-extensions</code> and <code>new XsltExtensions()</code> in above code. You can use this if need some complex computation which may not be possible in xslt. Following is a simple method to format date.</p> <pre><code>public class XsltExtensions { public string FormatDate(string dateString, string format) { DateTime date; if (DateTime.TryParse(dateString, out date)) return date.ToString(format); return dateString; } } </code></pre> <p>In XSLT file you can use it as below;</p> <pre><code>&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:ext=&quot;urn:xslt-extensions&quot;&gt; ... &lt;myTag&gt;&lt;xsl:value-of select=&quot;ext:FormatDate(record_date, 'yyyy-MM-dd')&quot;/&gt;&lt;/myTag&gt; ... &lt;/xsl:stylesheet&gt; </code></pre>
5,426
<p>I'm using subclipse in Flex Builder 3, and recently received this error when trying to commit:</p> <p><code>svn: Checksum mismatch for '/Users/redacted/Documents/Flex Builder 3/path/to/my/file.mxml'; expected: 'f8cb275de72776657406154dd3c10348', actual: 'null'</code></p> <p>I worked around it by:</p> <ol> <li>Committing all the other changed files, omitting the troublesome one.</li> <li>Copying the contents of the trouble file to a TextMate window</li> <li>Deleting my project in FlexBuilder/Eclipse</li> <li>Checking my project out fresh from SVN</li> <li>Copying the text of the trouble file back in from the TextMate Window</li> <li>Committing the changes.</li> </ol> <p>It worked, but I can't help but think there's a better way. What's actaully happening to cause the svn:checksum error, and what's the best fix.</p> <p>Maybe more important -- is this a symptom of a greater problem?</p>
<p>The file in the .svn directory that keeps track of what you have checked out, when, what revision, and from where, has gotten corrupted somehow, for that particular file.</p> <p>This is no more dangerous or critical than the normal odd file problem, and can be because of various problems, like a subversion program dying mid-change, power-disruption, etc.</p> <p>Unless it happens more I wouldn't make much out of it.</p> <p>It can be fixed by doing what you did, make a copy of your work-files, check out a fresh copy, and add the modified files back in.</p> <p>Note that this might cause problems if you have a busy project where you would normally have to merge in changes.</p> <p>For instance, you and a collegue both check out a fresh copy, and start working on the same file. At some point, your collegue checks in his modifications. When you attempt to do the same, you get the checksum problem you have. If you now make copies of your changed files, do a fresh checkout, then subversion will lose track of how your changes should be merged back in.</p> <p>If you didn't get the problem in this case, when you got around to checkin in your modifications, you would need to update your working copy first, and possibly handle a conflict with your file.</p> <p>However, if you do a fresh checkout, complete with your collegues changes, it now looks like you removed his changes and substituted with your own. No conflicts, and no indications from subversion that something is amiss.</p>
<p>here's how i fixed the issue - v simple, but as per jsh above, need to be sure your copy is the best one.</p> <p>simply</p> <ol> <li>make a copy all problem files, in the same folder.</li> <li>delete the old ones with svn rm</li> <li>commit. </li> <li>then rename the copies back to the original file names.</li> <li>commit again.</li> </ol> <p>suspect this probably kills all sorts of revision history on that file, so it's a pretty ugly way to go about it...</p>
2,794
<p>The <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/DataInput.html#skipBytes(int)" rel="noreferrer">Sun Documentation for DataInput.skipBytes</a> states that it "makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. However, it may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility."</p> <ol> <li><p>Other than reaching end of file, why might <code>skipBytes()</code> not skip the right number of bytes? (The <code>DataInputStream</code> I am using will either be wrapping a <code>FileInputStream</code> or a <code>PipedInputStream</code>.)</p></li> <li><p>If I definitely want to skip n bytes and throw an <code>EOFException</code> if this causes me to go to the end of the file, should I use <code>readFully()</code> and ignore the resulting byte array? Or is there a better way?</p></li> </ol>
<p>1) There might not be that much data available to read (the other end of the pipe might not have sent that much data yet), and the implementing class might be non-blocking (i.e. it will just return what it can, rather than waiting for enough data to fulfil the request).</p> <p>I don't know if any implementations actually behave in this way, however, but the interface is designed to permit it.</p> <p>Another option is simply that the file gets closed part-way through the read.</p> <p>2) Either readFully() (which will always wait for enough input or else fail) or call skipBytes() in a loop. I think the former is probably better, unless the array is truly vast.</p>
<p>According to the docs, <code>readFully()</code> is the only way that both works and <em>guaranteed</em> to work.</p> <p>The actual Oracle implementation is... confusing:</p> <pre><code>public final int skipBytes(int n) throws IOException { int total = 0; int cur = 0; while ((total&lt;n) &amp;&amp; ((cur = (int) in.skip(n-total)) &gt; 0)) { total += cur; } return total; } </code></pre> <p>Why call <code>skip()</code> in a loop when <code>skipBytes()</code> has essentially the same contract as <code>skip()</code>? It would make perfect sense to implement it this way if both of the following were true: <code>skipBytes()</code> guaranteed to skip less than requested <em>only</em> on EOF, <em>and</em> <code>skip()</code> guaranteed to skip at least one byte if at all possible (just like <code>read()</code> does).</p> <p>What's even worse, is that <code>skip()</code> is actually implemented using <code>read()</code>, which means it actually <em>does</em> the job. It just doesn't <em>promise</em> to do it, which means other implementations may fail to do so (and even Oracle one may potentially fail in the future if changed in future releases).</p> <p>To be completely safe: call <code>readBytes()</code>, and if it doesn't do the job, allocate a temp buffer and call <code>readFully()</code> (use a loop here if the ability to skip over arbitrarily large amounts of data is needed).</p> <p>On the other hand, calling <code>skipBytes()</code> in a loop is pointless. At least with Oracle implementation, because it's already a loop.</p>
7,443
<p>I'm the second dev and a recent hire here at a PHP/MySQL shop. I was hired mostly due to my experience in wrangling some sort of process out of a chaotic mess. At least, that's what I did at my last company. ;)</p> <p>Since I've been here (a few months now), I've brought on board my boss, my product manager and several other key figures (But mostly chickens, if you pardon the Scrum-based stereotyping). I've also helped bring in some visibility to the development cycle of a major product that has been lagging for over a year. People are loving it! </p> <p>However, my coworker (the only other dev here for now) is not into it. She prefers to close her door and focus on her work and be left alone. Me? I'm into the whole Agile approach of collaboration, cooperation and openness. Without her input, I started the Scrum practices (daily scrums, burndown charts and other things I've found that worked for me and my previous teams (ala H. Kniberg's cool wall chart). During our daily stand up she slinks by and ignores us as if we actually weren't standing right outside her door (we are actually). It's pretty amazing. I've never seen such resistance.</p> <p>Question... how do I get her onboard? Peer pressure is not working. </p> <p>Thanks from fellow Scrum-borg,</p> <p>beaudetious</p>
<p>While Scrum other agile methodologies like it embody a lot of good practices, sometimes giving it a name and making it (as many bloggers have commented on) a "religion" that must be adopted in the workplace is rather offputting to a lot of people, including myself.</p> <p>It depends on what your options and commitments are, but I know I'd be a lot more keen on accepting ideas because they are good ideas, not because they are a bandwagon. Try implementing/drawing her in to the practices one at a time, by showing her how they can improve her life and workflow as well.</p> <p>Programmers love cool things that help them get stuff done. They hate being preached at or being asked to board what they see as a bandwagon. Present it as the former rather than the latter. (It goes without saying, make sure it actually IS the former)</p> <p><strong>Edit: another question</strong></p> <p>I've never actually worked for a place that used a specific agile methodology, though I'm pretty happy where I'm at now in that we incorporate a lot of agile practices without the hype and the dogma (best of both worlds, IMHO). </p> <p>But I was just reading about Scrum and, is a system like that even beneficial for a 2 person team? Scrum does add a certain amount of overhead to a project, it seems, and that might outweigh the benefits when you have a very small team where communication and planning is already easy.</p>
<p>Continue your efforts to involve the other developer. Remember you are the one who wants to make this change. Ask for help with problems you have. Invite them to the daily stand up meeting. I currently do the planning for the daily stand up and I make sure all the pigs and chickens are invited. If you are the lead on the project it is up to you to address the situation and take a risk. Put yourself out there.</p>
5,539
<p>As part of a larger project, i'm trying to print a translucent green dome. I set it up as follows:</p> <ul> <li>In Blender, create an icosphere of the maximum allowed complexity. Cut it in half and throw away one of the hemispheres.</li> <li>Duplicate the hemisphere. Move the second one down slightly and use Subtract, to hollow it out. Clean up the vertex garbage left behind.</li> <li>Export the model. Import it in the slicer, scale to the proper size, and export as gcode.</li> <li>Print the model with <a href="https://rads.stackoverflow.com/amzn/click/com/B00ZB48IZE" rel="nofollow noreferrer" rel="nofollow noreferrer">translucent green filament</a> at 100% solid infill.</li> </ul> <p>I ended up with a beautifully rounded dome that doesn't feel at all like a polyhedron, so that worked out fine. The only problem is, it's solid green. The filament seems to lose its translucency past a certain thickness, and the fact that my "solid" print is actually made up of thousands of tiny strings pressed up against each other probably doesn't help.</p> <p>I tried reprinting it in Spiral Vase mode, and while the print turned out to be transparent, it was also extremely thin and fragile, and it failed anyway because of lack of support once the dome's angle got bad enough.</p> <p>I've been trying to think of how to print this properly, but nothing I think of will work:</p> <ul> <li>Scaling can make the walls thinner, but only by reducing the size of the model. Its basic dimensions need to remain unchanged.</li> <li>Doing the same trick again that I used to create the dome, subtracting a copy of itself moved down slightly, would lead to non-uniform thickness in the model. (Which I already have some of. But when the thickness is directly correlated to the degree of transparency, this is problematic.)</li> </ul> <p>Does anyone know of any tricks I can use to get it to come out properly? For reference, I'm using Blender as my 3D software, IdeaMaker as my slicer, and printing on a Raise3D N2 Plus printer.</p>
<blockquote> <p>The filament seems to lose its translucency past a certain thickness</p> </blockquote> <p>That's exactly the point. Think of translucency as a percentage of light being allowed through, per amount of material. 2x the material means 1/2 the light. You need either less material (which becomes brittle as you saw), or a more translucent material. I think it has little to do with the model itself.</p> <p>Also - check out OnShape. One of the features it has is a "shell" function, that does what you're describing - takes a single 3D feature and creates a shell out of it of consistent thickness.</p>
<p>For the modeling, I suggest to change to a proper CAD software, design a half sidecut and create the model by rotating it around Z. That way you'd create an evenly thick part.</p> <p>As for loosing transparency, that has several reasons:</p> <ul> <li>light loss into printed materials is mainly due to air being captured in the model. To get the air out as much as possible and generate an almost entirely transparent print, I have printed some lens-tests with extra heat and deliberately overextruding to fill all the cavities and voids.</li> <li>light loss in materials is also dependant on the material factor and thickness.</li> </ul> <p>If you go away from FDM and look into resin-based SLA/DLP systems, you can get almost fully transparent prints with very low colored resins.</p>
1,215
<p>Is here any performance benefit to using multiple threads on a computer with a single CPU that does not having hyperthreading? </p>
<p>In terms of speed of computation, No. In fact things will slow down due to the overhead of managing the threads.</p> <p>In terms of responsiveness, yes. You can for example have one thread wait on an IO operation and have another run a GUI at the same time.</p>
<p>Regardless of the number of CPUs available, if you require preemptive multitasking and/or applications with asynchronous components (i.e. pretty much anything that combines a responsive GUI with a non-trivial amount of computation or continuous I/O processing), multithreading performs much better than the alternative, which is to use multiple processes for each application.</p> <p>This is because threads in the same process can exchange data much more efficiently than can multiple processes, because they share the same memory context.</p> <p>See <a href="http://en.wikipedia.org/wiki/Computer_multitasking" rel="nofollow noreferrer">this Wikipedia article on computer multitasking</a> for a fairly concise discussion of these issues.</p>
6,997
<p>Can anyone point to any websites or web applications that are using the <a href="http://www.dossier-andreas.net/software_architecture/pac.html" rel="noreferrer">Presentation-Abstraction-Control</a> design pattern rather than MVC? Desktop applications are easy to find like this (e.g.; GIMP) but I'm looking for something on the web.</p>
<p>There are more sites using PAC than, I think, people realize. For example, <a href="http://drupal.org" rel="noreferrer">drupal</a> uses the PAC pattern and there are a lot of sites (and a lot of big sites) built with drupal. Many people confuse <a href="http://www.dossier-andreas.net/software_architecture/mvc.html" rel="noreferrer">MVC</a> and <a href="http://www.dossier-andreas.net/software_architecture/pac.html" rel="noreferrer">PAC</a>. <a href="http://www.garfieldtech.com/blog/mvc-vs-pac" rel="noreferrer">Larry Garfield does a good job explaining the difference and how drupal uses PAC</a>.</p> <p>In my research on this topic I found more than one open source app/framework that called themselves a MVC architecture when they more accurately fit the PAC pattern. Specifically in the way the model/abstraction, presentation/view, and controller interacted with each other.</p>
<p>The only example I've seen is in <a href="https://rads.stackoverflow.com/amzn/click/com/0471958697" rel="nofollow noreferrer" rel="nofollow noreferrer">Pattern-Oriented Software Architecture Volume 1: A System Of Patterns</a>.</p>
9,928
<p>I'm starting a new web project and I am considering two presentation frameworks. I am thinking either about ASP.NET MVC or Silverlight. I would tend toward Silverlight since I'm quite experienced .NET developer while I have just a basic knowledge of ASP.NET controls.</p>
<blockquote> <p>It is mainly going to be an iternal product so browsers are not an issue.</p> </blockquote> <p>You still have not written a <em>proper</em> description about the nature of your application. It is difficult to assess which technology is a good fit without first knowing well enough the domain the application is being applied to, and the problems it is designed to solve.</p> <p>In general, Microsoft is positioning these array of presentation technologies on the "<strong>Reach vs Rich</strong>" continuum. You have "plain old" HTML and Javascript on one end, acceptable by the most number of client machines out there, and the ultimate full-blown WPF on the other side where limited number of machines can handle. You did mention this to be an internal app, so WPF via XBAP or ClickOnce are also possible.</p> <p>So the scale would align this way: (reach) ASP.NET, AJAX, Silverlight, WPF (rich).</p> <p>So the question is just how rich you want/need it to be for the users until it hurts the deployment base? Frankly if all you fetch are forms and tabular data and statistics then regular ASP.NET web forms are just fine. If you want on-the-fly resizable graphs and client-side interactive with back-end WCF web services Silverlight can do that. If you want even more powerful graphical rendering than WPF via the remote deployment options is your bet.</p>
<p>It's hard to recommend one over the other without knowing what your application is. Whatever you do decide, make sure you keep your target audience in mind; not everyone is going to have Silverlight installed on their computers.</p> <p>Personally, unless I was designing an incredibly interactive and beautiful web app, I would go with ASP.NET (with or without the MVC framework) if only for the fact that there is a <em>ton</em> of reference material for it while Silverlight is still relatively new territory.</p>
5,358
<p>Every time I try melting a scrap piece of plastic it ends up turning brown, smelling, and smoking before even melting down completely. My entire home ends up filled with cancerous fumes and there's no way I'm baking any food in my oven ever again. I've tried different types of Nylon, ASA, and PLA and all of them turned brown before properly melting. I placed the scraps inside a glass jar inside an oven and tried both slowly increasing the temperature, and placing it into the preheated oven.</p> <p>Absolutely disgusting.</p> <p><a href="https://i.stack.imgur.com/TaFHz.jpg" rel="nofollow noreferrer" title="Glass jar with burnt melted plastic"><img src="https://i.stack.imgur.com/TaFHz.jpg" alt="Glass jar with burnt melted plastic" title="Glass jar with burnt melted plastic" /></a></p> <p><a href="https://i.stack.imgur.com/0QNUQ.jpg" rel="nofollow noreferrer" title="Baking pan with burnt melted plastic"><img src="https://i.stack.imgur.com/0QNUQ.jpg" alt="Baking pan with burnt melted plastic" title="Baking pan with burnt melted plastic" /></a></p> <p>I would like to melt it into blocks or cylinders or planes and further process it with my lathe, my CNC mill, bandsaw... whatever, like this guy: <div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/G-HWrDMr0ks?start=0"></iframe> </div></div></p>
<p>Plastic in general and 3d printer plastic specifically doesn't really melt so much as get softer in a range of temperatures (in a state refered to as &quot;plastic&quot; rather than liquid). Below that range, it is a solid. Above that range, it decomposes and ultimately burns.</p> <p>If you want to make a solid block, you need to not only heat it to a specific temperature (which varies by plastic formulation), but also press it into a new shape.</p>
<p>Your kitchen oven is for food. I'd strongly recommend using a different heating device for this. Your oven probably has oils in it that are contaminating the plastic, and the plastic will make your later cooked-food contaminated. I suggest cleaning your oven before cooking food, too.</p> <p>Personally I've had good luck <strong>softening</strong> PLA with a hot air gun, essentially a workshop version of a hairdryer. I've not tried forming it into shapes though.</p> <p>I've been putting all my offcuts, bad prints, brims etc into a 2L icecream tub, and when its full of spidery bits, a 20 second heat with hot air shrivels it all down to 1/4 of the volume.</p> <p>However I've not tried to make use of the resulting lump for anything.</p>
2,082
<p>I am trying to lay out a table-like page with two columns. I want the rightmost column to dock to the right of the page, and this column should have a distinct background color. The content in the right side is almost always going to be smaller than that on the left. I would like the div on the right to always be tall enough to reach the separator for the row below it. How can I make my background color fill that space?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.rightfloat { color: red; background-color: #BBBBBB; float: right; width: 200px; } .left { font-size: 20pt; } .separator { clear: both; width: 100%; border-top: 1px solid black; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="separator"&gt; &lt;div class="rightfloat"&gt; Some really short content. &lt;/div&gt; &lt;div class="left"&gt; Some really really really really really really really really really really big content &lt;/div&gt; &lt;/div&gt; &lt;div class="separator"&gt; &lt;div class="rightfloat"&gt; Some more short content. &lt;/div&gt; &lt;div class="left"&gt; Some really really really really really really really really really really big content &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <hr> <p>Edit: I agree that this example is very table-like and an actual table would be a fine choice. But my "real" page will eventually be less table-like, and I'd just like to first master this task!</p> <p>Also, for some reason, when I create/edit my posts in IE7, the code shows up correctly in the preview view, but when I actually post the message, the formatting gets removed. Editing my post in Firefox 2 seems to have worked, FWIW.</p> <hr> <p>Another edit: Yeah, I unaccepted GateKiller's answer. It does indeed work nicely on my simple page, but not in my actual heavier page. I'll investigate some of the links y'all have pointed me to.</p>
<p>Ahem...</p> <blockquote> <p>The short answer to your question is that you must set the height of 100% to the body and html tag, then set the height to 100% on each div element you want to make 100% the height of the page.</p> </blockquote> <p>Actually, 100% height will not work in most design situations - this may be short but it is not a good answer. Google "any column longest" layouts. The best way is to put the left and right cols inside a wrapper <code>div</code>, float the left and right cols and then float the wrapper - this makes it stretch to the height of the inner containers - then set background image on the outer wrapper. But watch for any horizontal margins on the floated elements in case you get the IE "double margin float bug".</p>
<p>Just trying to help out here so the code is more readable.<br> Remember that you can insert code snippets by clicking on the button at the top with "101010". Just enter your code then highlight it and click the button.</p> <p>Here is an example:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;style type="text/css"&gt; .rightfloat { color: red; background-color: #BBBBBB; float: right; width: 200px; } .left { font-size: 20pt; } .separator { clear: both; width: 100%; border-top: 1px solid black; } &lt;/style&gt; </code></pre>
2,696
<p>What advantage, if any, is provided by formatting C code as follows:</p> <pre><code>while(lock_file(lockdir)==0) { count++; if(count==20) { fprintf(stderr,"Can't lock dir %s\n",lockdir); exit(1); } sleep(3); } if(rmdir(serverdir)!=0) { switch(errno) { case EEXIST: fprintf(stderr,"Server dir %s not empty\n",serverdir); break; default: fprintf(stderr,"Can't delete dir %s\n",serverdir); } exit(1); } unlock_file(lockdir); </code></pre> <p>versus something more typical such as</p> <pre><code>while(lock_file(lockdir)==0) { count++; if(count==20) { fprintf(stderr,"Can't lock dir %s\n",lockdir); exit(1); } sleep(3); } if(rmdir(serverdir)!=0) { switch(errno) { case EEXIST: fprintf(stderr,"Server dir %s not empty\n",serverdir); break; default: fprintf(stderr,"Can't delete dir %s\n",serverdir); } exit(1); } unlock_file(lockdir); </code></pre> <p>I just find the top version difficult to read and to get the indenting level correct for statements outside of a long block, especially for longs blocks containing several nested blocks.</p> <p>Only advantage I can see is just to be different and leave your fingerprints on code that you've written.</p> <p>I notice vim formatting would have to be hand-rolled to handle the top case.</p>
<p>The top example is know as "Whitesmiths style". <a href="http://en.wikipedia.org/wiki/Indent_style" rel="noreferrer">Wikipedia's entry on Indent Styles</a> explains several styles along with their advantages and disadvantages.</p>
<p>Its just another style--people code how they like to code, and that is one accepted style (though not my preferred). I don't think it has much of a disadvantage or advantage over the more common style in which brackets are not indented but the code within them is. Perhaps one could justify it by saying that it more clearly delimits code blocks.</p>
9,633
<p>Is it possible to change how <kbd>Ctrl</kbd> + <kbd>Tab</kbd> and <kbd>Shift</kbd> + <kbd>Ctrl</kbd> + <kbd>Tab</kbd> work in Visual Studio? I have disabled the popup navigator window, because I only want to switch between items in the tab control. My problem is the inconsistency of what switching to the next and previous document do.</p> <p>Every other program that uses a tab control for open document I have seen uses <kbd>Ctrl</kbd> + <kbd>Tab</kbd> to move from left to right and <kbd>Shift</kbd> + <kbd>Ctrl</kbd> + <kbd>Tab</kbd> to go right to left. Visual Studio breaks this with its jump to the last tab selected. You can never know what document you will end up on, and it is never the same way twice. </p> <p>It is very counterintuitive. Is this a subtle way to encourage everyone to only ever have two document open at once?</p> <hr> <p>Let's say I have a few files open. I am working in one, and I need to see what is in the next tab to the right. In every other single application on the face of the Earth, <kbd>Ctrl</kbd> + <kbd>Tab</kbd> will get me there. But in Visual Studio, I have no idea which of the other tabs it will take me to. If I only ever have two documents open, this works great. As soon as you go to three or more, all bets are off as to what tab Visual Studio has decided to send you to. </p> <p>The problem with this is that I shouldn't have to think about the tool, it should fade into the background, and I should be thinking about the task. The current tab behavior keeps pulling me out of the task and makes me have to pay attention to the tool.</p>
<p>In Visual Studio 2015 (as well as previous versions of VS, but you must install <a href="https://visualstudiogallery.msdn.microsoft.com/dbcb8670-889e-4a54-a226-a48a15e4cace">Productivity Power Tools</a> if you're using VS2013 or below), there are two new commands in Visual Studio:</p> <p><em>Window.NextTab</em> and <em>Window.PreviousTab</em> </p> <p>Just go remap them from <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PageUp</kbd>/<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PageDown</kbd> to <kbd>Ctrl</kbd>+<kbd>Tab</kbd>/<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd> in:</p> <p>Menu <em>Tools</em> -> <em>Options</em> -> <em>Environment</em> -> <em>Keyboard</em></p> <p>Note: In earlier versions such as Visual Studio 2010, Window.NextTab and Window.PreviousTab were named <em>Window.NextDocumentWellTab</em> and <em>Window.PreviousDocumentWellTab</em>.</p>
<p>I don't use Visual Studio (<em>yes, really, I don't use it</em>), but <a href="http://en.wikipedia.org/wiki/AutoHotkey" rel="nofollow noreferrer">AutoHotkey</a> can remap any hotkey globally or in a particular application:</p> <pre><code>#IfWinActive Microsoft Excel (application specific remapping) ; Printing area in Excel (@ Ctrl+Alt+A) ^!a:: Send !ade return #IfWinActive $f4:: ; Closes the active window (make double tapping F4 works like ALT+F4) if f4_cnt &gt; 0 { f4_cnt += 1 return } f4_cnt = 1 SetTimer, f4_Handler, 250 return f4_Handler: SetTimer, f4_Handler, off if (f4_cnt &gt;= 2) ; Pressed more than two times { SendInput !{f4} } else { ; Resend f4 to the application Send {f4} } f4_cnt = 0 return </code></pre> <p>These are two remappings of my main AutoHotKey script. I think it's an excellent tool for this type of tasks.</p>
4,137
<p>I'm building a webapp that contains an IFrame in design mode so my user's can "tart" their content up and paste in content to be displayed on their page. Like the WYSIWYG editor on most blog engines or forums.</p> <p>I'm trying to think of all potential security holes I need to plug, one of which is a user pasting in Javascript:</p> <pre><code>&lt;script type="text/javascript"&gt; // Do some nasty stuff &lt;/script&gt; </code></pre> <p>Now I know I can strip this out at the server end, before saving it and/or serving it back, but I'm worried about the possibility of someone being able to paste some script in and run it there and then, without even sending it back to the server for processing.</p> <p>Am I worrying over nothing?</p> <p>Any advice would be great, couldn't find much searching Google.</p> <p>Anthony</p>
<blockquote> <p>...I'm worried about the possibility of someone being able to paste some script in and run it there and then, without even sending it back to the server for processing. </p> <p>Am I worrying over nothing?</p> </blockquote> <p>Firefox has a plug-in called Greasemonkey that allows users to arbitrarily run JavaScript against any page that loads into their browser, and there is nothing you can do about it. Firebug allows you to modify web pages as well as run arbitrary JavaScript.</p> <p>AFAIK, you really only need to worry once it gets to your server, and then potentially hits other users.</p>
<p>As Jason said, I would focus more on cleaning the data on the server side. You don't really have any real control on the client side unless you're using Silverlight / Flex and even then you'd need to check the server.</p> <p>That said, Here are some tips from <em>"A List Apart"</em> you may find helpful regarding server side data cleaning.</p> <p><a href="http://www.alistapart.com/articles/secureyourcode" rel="nofollow noreferrer">http://www.alistapart.com/articles/secureyourcode</a></p>
7,326
<p>How do I have a Python script that a) can accept user input and how do I make it b) read in arguments if run from the command line?</p>
<p>To read user input you can try <a href="https://docs.python.org/dev/library/cmd.html" rel="noreferrer">the <code>cmd</code> module</a> for easily creating a mini-command line interpreter (with help texts and autocompletion) and <a href="https://docs.python.org/2/library/functions.html#raw_input" rel="noreferrer"><code>raw_input</code></a> (<a href="https://docs.python.org/dev/library/functions.html#input" rel="noreferrer"><code>input</code></a> for Python 3+) for reading a line of text from the user.</p> <pre><code>text = raw_input("prompt") # Python 2 text = input("prompt") # Python 3 </code></pre> <p>Command line inputs are in <code>sys.argv</code>. Try this in your script:</p> <pre><code>import sys print (sys.argv) </code></pre> <p>There are two modules for parsing command line options: <a href="https://docs.python.org/dev/library/optparse.html" rel="noreferrer"><s><code>optparse</code></s></a> (deprecated since Python 2.7, use <a href="https://docs.python.org/dev/library/argparse.html" rel="noreferrer"><code>argparse</code></a> instead) and <a href="https://docs.python.org/dev/library/getopt.html" rel="noreferrer"><code>getopt</code></a>. If you just want to input files to your script, behold the power of <a href="https://docs.python.org/dev/library/fileinput.html" rel="noreferrer"><code>fileinput</code></a>.</p> <p>The <a href="https://docs.python.org/dev/library/" rel="noreferrer">Python library reference</a> is your friend.</p>
<p>In Python 2:</p> <pre><code>data = raw_input('Enter something: ') print data </code></pre> <p>In Python 3:</p> <pre><code>data = input('Enter something: ') print(data) </code></pre>
9,629
<p>I've just inherited a java application that needs to be installed as a service on XP and vista. It's been about 8 years since I've used windows in any form and I've never had to create a service, let alone from something like a java app (I've got a jar for the app and a single dependency jar - log4j). What is the magic necessary to make this run as a service? I've got the source, so code modifications, though preferably avoided, are possible.</p>
<p>I've had some luck with <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html" rel="noreferrer">the Java Service Wrapper</a></p>
<p>It's possible to implement a Windows service in 100% Java code by combining the use of <a href="https://jdk.java.net/panama/" rel="nofollow noreferrer">Foreign Memory and Linker API</a> (previewing from JDK16 upwards) with <a href="https://github.com/openjdk/jextract" rel="nofollow noreferrer">OpenJDK jextract project</a> to handle the Windows Service callbacks, and then use <a href="https://docs.oracle.com/en/java/javase/18/jpackage/packaging-overview.html" rel="nofollow noreferrer">jpackage</a> to produce a Windows EXE which can then be registered as a Windows Service.</p> <p>See this example which outlines the work needed to implement a <a href="https://learn.microsoft.com/en-gb/windows/win32/services/svc-cpp" rel="nofollow noreferrer">Windows service</a>. All Windows service EXE must provide callbacks for the main entrypoint <a href="https://learn.microsoft.com/en-gb/windows/win32/api/winsvc/nc-winsvc-lpservice_main_functionw" rel="nofollow noreferrer">ServiceMain</a> and <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nc-winsvc-lphandler_function" rel="nofollow noreferrer">Service Control Handler</a>, and use API calls <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatcherw" rel="nofollow noreferrer">StartServiceCtrlDispatcherW</a>, <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-registerservicectrlhandlerw" rel="nofollow noreferrer">RegisterServiceCtrlHandlerExW</a> and <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-setservicestatus" rel="nofollow noreferrer">SetServiceStatus</a> in <code>Advapi.DLL</code>.</p> <p>The flow of above callbacks in Java with Foreign Memory structures are:</p> <pre><code>main() Must register ServiceMain using StartServiceCtrlDispatcherW Above call blocks until ServiceMain exits void ServiceMain(int dwNumServicesArgs, MemoryAddress lpServiceArgVectors) Must register SvcCtrlHandler using RegisterServiceCtrlHandlerExW Use SetServiceStatus(SERVICE_START_PENDING) Initialise app Use SetServiceStatus(SERVICE_RUNNING) wait for app shutdown notification Use SetServiceStatus(SERVICE_STOPPED) int SvcCtrlHandler(int dwControl, int dwEventType, MemoryAddress lpEventData, MemoryAddress lpContext) Must respond to service control events and report back using SetServiceStatus On receiving SERVICE_CONTROL_STOP reports SetServiceStatus(SERVICE_STOP_PENDING) then set app shutdown notification </code></pre> <p>Once finished the Java application, jpackage can create runtime+EXE which can then be installed and registered as a Windows Service. Run as Adminstrator (spaces after = are important):</p> <pre><code> sc create YourJavaServiceName type= own binpath= &quot;c:\Program Files\Your Release Dir\yourjavaservice.exe&quot; </code></pre>
9,362
<p>Back in the days of Unix, you couldn't even <a href="http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Exiting" rel="noreferrer">close a software</a> without reading the man page first. Then came Mac and Windows with consistent menu layout and keyboard shortcuts, but you still saw paper user manuals shipped in the shrinkwrap box, which described each and every single operation possible in the app. After the Internet, help files became html documents.</p> <p>Nowadays with <em>Web 2.0</em> applications, you hardly see the Help. Even <a href="http://mail.google.com/support/" rel="noreferrer">if it's there</a>, they simply describe some specific tasks. In other words, the apps are relying more on the <em>common sense</em> or <a href="http://www.sensible.com/" rel="noreferrer"><em>don't-make-me-think</em></a> factor of the user base.</p> <p>Years ago Microsoft came up with a concept called <a href="http://msdn.microsoft.com/en-us/library/ms997506.aspx" rel="noreferrer">Inductive User Interface</a>, which basically tells programmers to put in instructions on the apps itself, but I am not sure how popular that idea is.</p> <p>Are help files, user manuals, and context sensitive online help with F1 key dead? Have I failed if user could not find out what to do from the UI? If not, what degree of help should I provide? (both for desktop and web app)</p> <p>EDIT: How does documentation/help file mesh with agile development methods? For example, should the developers think twice before UI changes that may obsolete a bunch of screenshots?</p>
<h3>Three notes on help:</h3> <ol> <li>F1 / stand-alone context-sensitive help was always doomed. It was hidden by default, and so the people who most needed it were least likely to read it. There was hope at one time that we would be able to train users to always hit F1 when they ran into trouble, but too many applications without useful context-sensitive help... combined with too many bizarre help interfaces... pretty much killed this.</li> <li>Manuals are as important now as they ever were. Not so many printed manuals anymore, but online manuals are better than ever. The proliferation of wiki-as-a-manual systems has helped here, reducing the up-front cost of creating good online documentation. Of course, plenty of people <em>just don't read</em>...</li> <li>The beauty of using web pages as an application interface is that you <em>can</em> combine useful context-sensitive help with the UI, removing the barrier for novices and others who otherwise couldn't be bothered to look for relevant information when they get stuck.</li> </ol> <p>Of course, there are still plenty of apps, even online apps, designed with obtuse interfaces and a tiny little help icon in a corner somewhere, presumably hoping that the latter mitigates the former. Pity them.</p>
<p>The Idiot/Dummy books must be doing quite well. Imagine if the standard application help was as good as those books. The standard F1 help for a lot of apps is just awful.</p> <p>Is help dead? No, but some of it should be taken out and shot.</p>
8,578
<p>Is is possible to construct a regular expression that rejects all input strings?</p>
<p>Probably this:</p> <pre><code>[^\w\W] </code></pre> <p>\w - word character (letter, digit, etc)<br> \W - opposite of \w</p> <p>[^\w\W] - should always fail, because any character should belong to one of the character classes - \w or \W</p> <p>Another snippets:</p> <pre><code>$.^ </code></pre> <p>$ - assert position at the end of the string<br> ^ - assert position at the start of the line<br> . - any char </p> <pre><code>(?#it's just a comment inside of empty regex) </code></pre> <p>Empty lookahead/behind should work:</p> <pre><code>(?&lt;!) </code></pre>
<p>EDIT: [^\n\r\w\s]</p>
8,784
<p>Is it possible to access an element on a Master page from the page loaded within the <code>ContentPlaceHolder</code> for the master?</p> <p>I have a ListView that lists people's names in a navigation area on the Master page. I would like to update the ListView after a person has been added to the table that the ListView is data bound to. The <code>ListView</code> currently does not update it's values until the cache is reloaded. We have found that just re-running the <code>ListView.DataBind()</code> will update a listview's contents. We have not been able to run the <code>ListView.DataBind()</code> on a page that uses the Master page. </p> <p>Below is a sample of what I wanted to do but a compiler error says </p> <blockquote> <p>"PeopleListView does not exist in the current context"</p> </blockquote> <p>GIS.master - Where ListView resides</p> <pre><code>...&lt;asp:ListView ID="PeopleListView"... </code></pre> <p>GISInput_People.aspx - Uses GIS.master as it's master page</p> <p>GISInput_People.aspx.cs</p> <pre><code>AddNewPerson() { // Add person to table .... // Update Person List PeopleListView.DataBind(); ... } </code></pre> <p>What would be the best way to resolve an issue like this in C# .Net?</p>
<p>I believe you <em>could</em> do this by using this.Master.FindControl or something similar, but you probably shouldn't - it requires the content page to know too much about the structure of the master page.</p> <p>I would suggest another method, such as firing an event in the content area that the master could listen for and re-bind when fired.</p>
<p>Assuming your master page was named MyMaster:</p> <pre><code>(Master as MyMaster).PeopleListView.DataBind(); </code></pre> <p><strong>Edit:</strong> since PeopleListView will be declared protected by default, you will either need to change this to public, or create a public property wrapper so that you can access it from your page.</p>
2,815
<p>I've been handed a table with about 18000 rows. Each record describes the location of one customer. The issue is, that when the person created the table, they did not add a field for "Company Name", only "Location Name," and one company can have many locations.</p> <p>For example, here are some records that describe the same customer:</p> <p><strong>Location Table</strong></p> <pre><code> ID Location_Name 1 TownShop#1 2 Town Shop - Loc 2 3 The Town Shop 4 TTS - Someplace 5 Town Shop,the 3 6 Toen Shop4 </code></pre> <p>My goal is to make it look like:</p> <p><strong>Location Table</strong></p> <pre><code> ID Company_ID Location_Name 1 1 Town Shop#1 2 1 Town Shop - Loc 2 3 1 The Town Shop 4 1 TTS - Someplace 5 1 Town Shop,the 3 6 1 Toen Shop4 </code></pre> <p><strong>Company Table</strong></p> <pre><code> Company_ID Company_Name 1 The Town Shop </code></pre> <p>There is no "Company" table, I will have to generate the Company Name list from the most descriptive or best Location Name that represents the multiple locations.</p> <p>Currently I am thinking I need to generate a list of Location Names that are similar, and then and go through that list by hand.</p> <p>Any suggestions on how I can approach this is appreciated.</p> <p><strong>@Neall, Thank you for your statement, but unfortunately, each location name is distinct, there are no duplicate location names, only similar. So in the results from your statement "repcount" is 1 in each row.</strong></p> <p><strong>@yukondude, Your step 4 is the heart of my question.</strong></p>
<p>Please update the question, do you have a list of CompanyNames available to you? I ask because you maybe able to use Levenshtein algo to find a relationship between your list of CompanyNames and LocationNames.</p> <hr> <p><strong>Update</strong></p> <blockquote> <p>There is not a list of Company Names, I will have to generate the company name from the most descriptive or best Location Name that represents the multiple locations.</p> </blockquote> <p>Okay... try this:</p> <ol> <li>Build a list of candidate CompanyNames by finding LocationNames made up of mostly or all alphabetic characters. You can use <a href="http://us2.php.net/manual/en/book.pcre.php" rel="nofollow noreferrer">regular expressions</a> for this. Store this list in a separate table.</li> <li>Sort that list alphabetically and (manually) determine which entries should be CompanyNames.</li> <li>Compare each CompanyName to each LocationName and come up with a match score (use <a href="http://us2.php.net/manual/en/function.levenshtein.php" rel="nofollow noreferrer">Levenshtein</a> or some other string matching algo). Store the result in a separate table.</li> <li>Set a threshold score such that any MatchScore &lt; Threshold will not be considered a match for a given CompanyName.</li> <li>Manually vet through the LocationNames by CompanyName | LocationName | MatchScore, and figure out which ones actually match. Ordering by MatchScore should make the process less painful.</li> </ol> <p>The whole purpose of the above actions is to automate parts and limit the scope of your problem. It's far from perfect, but will hopefully save you the trouble of going through 18K records by hand.</p>
<p>I was going to recommend some complicated token matching algorithm but it's really tricky to get right and if you're data does not have a lot of correlation (typos, etc) then it's not going to give very good results.</p> <p>I would recommend you submit a job to the <a href="http://www.mturk.com/mturk/welcome" rel="nofollow noreferrer">Amazon Mechanical Turk</a> and let a human sort it out.</p>
2,791
<p>I want to use SQL Profiler to trace the queries executed agains my database, track performance, etc. However it seems that the SQL Profiler is only available in the Enterprise edition of SQL Server 2005. Is this the case indeed, and can I do something about it?</p>
<p>You don't need <strong>any</strong> SQL license to run the client tools (Management Studio, Profiler, etc). If your organization has a copy of the installation media for Developer, Standard, or Enterprise, you can install the client tools on your local machine under the same license.</p> <p>If you're working solo, I would recommend <a href="http://www.microsoft.com/products/info/product.aspx?view=22&amp;pcid=f544888c-2638-48ed-9f0f-d814e8b93ca0&amp;crumb=catpage&amp;catid=cd1daedd-9465-4aef-a7bf-8f5cf09a4dc0#HowToBuy" rel="nofollow noreferrer">purchasing</a> SQL Developer edition, it's only $50.</p>
<p>The SQL Profiler tool is only available with the Standard and Enterprise version of SQL Server, however, all version can be profiled using the tool.</p> <p>Source: <a href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx" rel="nofollow noreferrer">http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx</a></p>
6,530
<p>Questions like this are <em><strong>usually</strong></em> not allowed but since the price of a brass nozzle in Switzerland is 15.90 and the average price of a nozzle from Alibaba or AliExpress is less than 0.10, and nozzles are something you exchange frequently the issue becomes of such magnitude that we <em><strong>need</strong></em> to have a simple answer to the very straightforward question:</p> <p>Do nozzles from China offer the same quality and results?</p>
<p>I use cheap brass nozzles through the &quot;A&quot; place and they are almost certainly Chinese.</p> <p>When installing a new nozzle I use a drill bit in a pin vise in the large counter-drilled hole on the top side, pressing pretty hard to assure there are no drill chips in there, either loose or still attached. I follow that with a nozzle cleaning pin of the appropriate size, then a good blast of Dust-Off or the equivalent from the &quot;W&quot; place.</p> <p>I get reasonable nozzle life and performance.</p> <p>In my case nozzle replacement is nearly always from blockage, almost never from wear so I've never considered it worthwhile to use premium nozzles with better wear resistance.</p>
<p>Up until this year, I used the cheap nozzles - the original that came with my Ender 3, and both the ones that were supposedly by Creality and appeared identical to it, and similarly cheap ones off Amazon. I never had any problem with them that I attributed to nozzle quality, but I went through them fairly quickly since they were so cheap, just swapping one out if it got a lot of buildup that was hard to clean off rather than bothering to clean it well. I would say they are perfectly usable.</p> <p>However, if you're already used to paying more for a nozzle, I would <strong>strongly</strong> recommend ditching plain nozzles and going with the Bondtech CHT. The performance and quality improvement from it is <strong>drastic</strong>. It gives more improvement to flow than going from a standard size block to a volcano size block (see <a href="https://www.youtube.com/watch?v=UNJdv5bFGOg&amp;ab_channel=CNCKitchen" rel="nofollow noreferrer">Stefan's tests on CNC Kitchen</a>), and a lot less backpressure, so you can get by with lower values for Pressure Advance/Linear Advance, which put less stress on the extruder and get more consistent extrusion. In terms of ratio of printing performance boost to price (not to mention ease of installation), it's probably the single best upgrade you can make to a printer. And while it's not a special durable material, it is coated, which makes it a little bit better than plain brass.</p>
2,130
<p>I generally use a manual process:</p> <ol> <li>Look at the page, figure out the semantic elements, and build the HTML</li> <li>Slice up the images I think I'll need</li> <li>Start writing CSS</li> <li>Tweak and repeat different steps as necessary</li> </ol> <p>Got a better approach, or a tool?</p>
<p>I have a fairly natural way of coding. The key is to treat the page like a document or an article. If you think of it like this the following becomes logically clear:</p> <ol> <li><p>The page title is a top level heading </p> <ul> <li>Whether you make the site title or actual page title the h1 is up to you - personally I'd make About Us the h1 rather than Stack Overflow.</li> </ul></li> <li><p>The navigation is a table of contents, and thus an <strong>ordered list</strong> - you may as well use an ol over a ul.</p></li> <li><p>Section headers are h2, sections within those sections are h3s etc. Stack them up.</p></li> <li><p>Use blockquotes and quotes where possible. Don't just surround it with ".</p></li> <li><p>Don't use b and i. Use strong and em. This is because HTML is structural rather than presentational markup. <strong>Strong</strong> and <strong>em</strong>phasis tags should be used where you'd put emphasis on the word.</p></li> <li><p><code>&lt;label&gt;</code> your form elements.</p></li> <li><p>Use <code>&lt;acronym&gt;</code>s and <code>&lt;abbr&gt;</code>s where possible, but only in the first instance.</p></li> <li><p>The easiest: always, <em>always</em> give your images some alternate text.</p></li> <li><p>There's lots of HTML tags you could use that you probably haven't - address for postal addresses, screen code output. Have a look at <a href="http://www.htmldog.com/" rel="noreferrer">HTML Dog</a> for some, it's my favourite reference.</p></li> </ol> <p>That's just a few pointers, I'm sure I could think of more.</p> <p>Oh, and if you want a challenge write your XHTML first, then write the CSS. When CSS-ing you aren't allowed to touch the HTML. It's actually harder than you think (but I've found it's made me quicker).</p>
<p>Some of the designers i know, usually uses Illustrator to make the design elements.</p>
3,997
<p>The code that I want to write is like this:</p> <pre><code>void MethodOnThreadA() { for (;;) { // Do stuff if (ErrorConditionMet) ThrowOnThread(threadB, new MyException(...)); } } void MethodOnThreadB() { try { for (;;) { // Do stuff } } catch (MyException ex) { // Do the right thing for this exception. } } </code></pre> <p>I know I can have thread B periodically check, in thread safe way, to see if a flag has been set by thread A, but that makes the code more complicated. Is there a better mechanism that I can use?</p> <p>Here is a more fleshed out example of periodically checking:</p> <pre><code>Dictionary&lt;Thread, Exception&gt; exceptionDictionary = new Dictionary&lt;Thread, Exception&gt;(); void ThrowOnThread(Thread thread, Exception ex) { // the exception passed in is going to be handed off to another thread, // so it needs to be thread safe. lock (exceptionDictionary) { exceptionDictionary[thread] = ex; } } void ExceptionCheck() { lock (exceptionDictionary) { Exception ex; if (exceptionDictionary.TryGetValue(Thread.CurrentThread, out ex)) throw ex; } } void MethodOnThreadA() { for (;;) { // Do stuff if (ErrorConditionMet) ThrowOnThread(threadB, new MyException(...)); } } void MethodOnThreadB() { try { for (;;) { // Do stuff ExceptionCheck(); } } catch (MyException ex) { // Do the right thing for this exception. } } </code></pre>
<p>This is NOT a good idea</p> <p><a href="http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html" rel="noreferrer">This article talks about ruby's timeout library.</a> which throws exceptions across threads.</p> <p>It explains how doing such a thing is fundamentally broken. It's not just broken in ruby, it's broken anywhere that throws exceptions across threads.</p> <p>In a nutshell, what can (and does) happen is this:</p> <p>ThreadA: </p> <pre><code>At some random time, throw an exception on thread B: </code></pre> <p>ThreadB:</p> <pre><code>try { //do stuff } finally { CloseResourceOne(); // ThreadA's exception gets thrown NOW, in the middle // of our finally block and resource two NEVER gets closed. // Obviously this is BAD, and the only way to stop is to NOT throw // exceptions across threads CloseResourceTwo(); } </code></pre> <p>Your 'periodic checking' example is fine, as you're not actually throwing exceptions across threads.<br> You're just setting a flag which says "throw an exception the next time you look at this flag", which is fine as it doesn't suffer from the "can be thrown in the middle of your catch or finally block" problem.<br> However, if you're going to do that, you may as well just be setting an "exitnow" flag, and using that and save yourself the hassle of creating the exception object. A volatile bool will work just fine for that.</p>
<p>I'm interested to know why you would want to do this. There's not an easy way to do it, because it's not a good practice. You should probably go back to your design and figure out a cleaner way to accomplish the end goal.</p>
6,642
<p>As a follow up to this question: <a href="https://stackoverflow.com/questions/46873/developing-a-online-exam-application-how-do-i-prevent-cheaters">Developing a online exam application, how do I prevent cheaters?</a></p> <p>Can I detect when Flex application looses its focus? that is if a user has clicked onto another application or opened a browser tab?</p> <p>I read this: <a href="http://blog.flexmonkeypatches.com/2007/12/07/detecting-when-a-flex-application-loses-focus/" rel="nofollow noreferrer">Detecting when a Flex application loses focus</a> but was not very clear...</p>
<p>The key part of the code at that link is the </p> <pre><code>systemManager.stage.addEventListener(Event.DEACTIVATE,deactivate); </code></pre> <p>The Flash player send outs activate and deactivate events when the focus enters and leaves the player. All you need to do is create a listenr for them and react appropriately.</p> <p>A more clear example of how to use to the activate and deactivate events can be seen at <a href="http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/" rel="noreferrer">blog.flexaxamples.com</a>. </p> <p>Also, it looks like the activate and deactivate events have trouble in some browsers. <a href="http://www.moock.org/blog/archives/000252.html" rel="noreferrer">Colin Moock has more info on that here.</a></p>
<p>This will work to detect when the Flex windows loses focus, but to detect when the window regains focus without having to actually click on the flex app requires an update in the HTML wrapper, correct? Something like:</p> <pre><code>&lt;script language="JavaScript" type="text/javascript"&gt; &lt;!-- // ----------------------------------------------------------------------------- // Globals // Major version of Flash required var requiredMajorVersion = ${version_major}; // Minor version of Flash required var requiredMinorVersion = ${version_minor}; // Minor version of Flash required var requiredRevision = ${version_revision}; // ----------------------------------------------------------------------------- // --&gt; function onAppFocusIn() { ${application}.onAppFocusIn(); alert("onAppFocusIn"); } &lt;/script&gt; &lt;body scroll="no" onFocus="onAppFocusIn()"&gt; </code></pre> <p>I am trying to implement this but the onAppFocusIn() function is not executing once I move back to the flex app window. When I view the source, the code is there. Does anyone know why??</p> <p>Thanks, Annie</p>
6,909
<p>I have built a 3D printer from salvaged/purchased parts. I am using an Arduino Uno and three easy driver stepper drivers with 3 CD-ROMs drives and a PC power unit. I ordered a 3D pen and have it mounted with a transistor to switch it on/off. Everything works but when I try to run code that I got from makercam.com it seems like it wants to fill in the shape rather than build up. </p> <p>I followed this tutorial <a href="https://youtu.be/anIy6eb1fW0" rel="nofollow noreferrer">YouTube - How To Make A Cheap 3D Printer</a> and after modifying the G-code I am unable to get any successful prints.</p> <p><a href="https://i.stack.imgur.com/LgHI1.jpg" rel="nofollow noreferrer" title="Bad prints"><img src="https://i.stack.imgur.com/LgHI1.jpg" alt="Bad prints" title="Bad prints"></a></p>
<p>Download an stl file from Thingiverse.com </p> <p>Put your .stl file in a slicer program like cura</p> <p>It will output gcode for 3d objects rather than 2d.</p>
<p>I would typically shy away from downloading gcode and printing it directly. Always slice it yourself since, inevitably, every printer is different. What happens if the gcode is setup for ABS (higher temps) and you are printing with PLA? If it's setup for a build platform larger than yours and you just hit endstops?</p> <p>Definitely go with Aaron's idea, download a model (Thingiverse is great, but there are SO many sites where you can get files), configure a slicer for your print settings (I prefer slic3r to Cura, but both are great), slice it and print away.</p>
712
<p>I'm running a stock Ender 5 pro with the filament that came with it, and using Creality Slicer 4.8.2, but I'm only able to get reliable bed adhesion if I increase the bed temperature from 50 to 60 °C for the bottom layer and decrease the print head speed by about 75 % from the default profile for the Ender 5.</p> <p>The machine is absolutely stock, and is fresh out of the box except for bed levelling.</p> <p>I used the default bed leveling print and that came out well, so I'm reasonably certain that it's not a bed leveling issue. The problem seems to be with models that I've made myself in blender and exported as STL files.</p> <p>In all cases the raft that was generated by the Creality software has printed out perfectly, but the print has only partially gone down when it came to the model itself. <img src="https://i.stack.imgur.com/sdXA1.jpg" alt="enter image description here" /></p>
<p>Your bed is too low - raise it by turning the knobs underneath.</p> <p>The first layer should not look like strings sitting on the bed as per your photo. Instead it should be a wider strip that looks somewhat like an electronic circuit trace, or like someone has pushed wet paint out of a tube that is being wiped across the surface.</p> <p>My method is to head the bed with &quot;preheat&quot; in the menu, and let it sit at printing temp for at least 5 minutes. This avoids the heater being at temp but the top of the glass bed being cool.</p> <p>Then start your job. As the brim or skirt is printed, actively watch it in person and twiddle the height knobs a quarter turn at a time. You want the &quot;end view&quot; or cross sectional view of the printed filament to be like this:</p> <pre><code> _____&lt;==&gt;_____ </code></pre> <p>and not like this</p> <pre><code> ______0______ </code></pre> <p>and definitely not like this</p> <pre><code> 0 _______________ </code></pre> <p>If the head starts scratching the bed, you've gone too far so lower the bed back down again (effectively raising the print head a little)</p> <hr /> <p>Here's a print in progress trying to show a better brim. Notice eachgstrand is ovalised and mushed down. That brim will come off in one piece afterward.</p> <p><a href="https://i.stack.imgur.com/Vis5Z.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vis5Z.jpg" alt="enter image description here" /></a></p>
<p>Assuming Creality's stock firmware still doesn't have Linear Advance enabled, there's a fairly hard requirement to go slow on the first layer. This is because, as the toolhead accelerates up to higher speed without advancing the extruder extra to compensate for the backpressure in the filament-path/nozzle, you'll have an interval of underextrusion, giving less contact area for the extruded material to cling to the bed at the same time there's added force pulling it in a direction parallel to the bed surface. This becomes less critical to adhesion starting with the second layer, since the new material is bonding to itself rather than just trying to stick to a bed.</p> <p>Having the bed hot will help it stick better and maybe even help reduce the pressure at the nozzle by reducing the heat loss, so it might work around the problem. But in general, you don't want to be in a situation where a few degrees of temperature difference are the cutoff between a failed print and a successful one.</p> <p>Anyway, do all the usual stuff to improve bed adhesion, and especially make sure your bed height is as close to perfect as you can get it, if you want moderately fast printing to work. But don't be surprised if you need to upgrade to a version of Marlin with Linear Advance (or to Klipper) to get successful high-speed first layers.</p>
2,090
<p>We're living in a golden age of databases, with numerous high quality commercial and free databases. This is great, but the downside is there's not a simple obvious choice for someone who needs a database for his next project.</p> <ul> <li>What are the constraints/criteria you use for selecting a database?</li> <li>How well do the various databases you've used meet those constraints/criteria?</li> <li>What special features do the databases have?</li> <li>Which databases do you feel comfortable recommending to others? </li> </ul> <p>etc...</p>
<p>I would think first on what the system requirements are for data access, data security, scalability, performance, disconnected scenarios, data transformation, data sizing. </p> <p>On the other side, consider also the experience and background of developers, operators, platform administrators.</p> <p>You should also think on what constraints you have regarding programming languages, operating systems, memory footprint, network bandwidth, hardware.</p> <p>Last, but not least, you have to think about business issues like budget for licences, support, operation.</p> <p>After all those considerations you should end up with just a couple of options and the selection should be easier.</p> <p>In other words, select the technology that suits the best the constraints and needs of your organization and project. </p> <p>I certainly think that you are right on saying that it is not an obvious choice given the wide number of alternatives, but this is the only way I think you can narrow them to the ones that are really feasible for your project.</p>
<ul> <li>Linux, Web Hosted - MySQL (PostreSQL maybe)</li> <li>Mainstream SME - MS SQL</li> <li>Big Iron (banking etc) - Oracle</li> </ul> <p>Thinking about anything other than those three is masturbation - any of the other databases becomes a discussion about niche products to solve particular problems that you probably haven't encountered yet. If you choose anything other than the three above you will -</p> <ol> <li>Struggle to find people to work on the project or keep the database going</li> <li>Struggle to motivate your decision without an academic discussion</li> <li>Someone will curse you, your ancestors and your lineage a few years down the line - and replace your choice anyway.</li> </ol> <p>Niche databases are not where architectural strides are made - it is technologies like middleware, messaging, cloud services etc where you can afford to (and should) go out on a limb to find good products.</p>
4,949
<p>Say you've got a credit card number with an expiration date of 05/08 - i.e. May 2008.</p> <p>Does that mean the card expires on the morning of the 1st of May 2008, or the night of the 31st of May 2008?</p>
<p>It took me a couple of minutes to find a site that I could source for this.</p> <blockquote> <p>The card is valid until the last day of the month indicated, after the last [sic]<sup>1</sup> day of the next month; the card cannot be used to make a purchase if the merchant attempts to obtain an authorization. - <a href="http://web.archive.org/web/20081003052424/http://cumemberscard.com/noda/CreditCardGlossary.asp" rel="noreferrer">Source</a></p> </blockquote> <p>Also, while looking this up, I found an interesting article on Microsoft's website using an example like this, exec summary: <a href="https://web.archive.org/web/20150113060002/http://support.microsoft.com/kb/210534" rel="noreferrer">Access 2000 for a month/year defaults to the first day of the month, here's how to override that to calculate the end of the month like you'd want for a credit card</a>.</p> <p>Additionally, this page has <a href="http://euro.ecom.cmu.edu/resources/elibrary/everycc.htm" rel="noreferrer">everything you ever wanted to know about credit cards</a>.</p> <hr> <ol> <li>This is assumed to be a typo and that it should read "..., after the first day of the next month; ..."</li> </ol>
<p>In your example a credit card is expired on 6/2008.</p> <p>Without knowing what you are doing I cannot say definitively you should not be validating ahead of time but be aware that sometimes business rules defy all logic.</p> <p>For example, where I used to work they often did not process a card at all or would continue on transaction failure simply so they could contact the customer and get a different card.</p>
7,761
<p>Is it possible to embed an audio object (mp3, wma, whatever) in a web-enabled InfoPath form ? </p> <p>If it is, how do you do it ?</p>
<p>It looks like you can't embed <code>&lt;object&gt;</code> tags in a richtext field. I'm getting nothing when I do it. </p>
<p>Edit: My apologies, I missed that the question was about Web forms - for which the below does not work. Must learn to read the question fully!</p> <ol> <li>Go to menu View</li> <li>Click on Design Tasks</li> <li>Select Controls in the 'Design Tasks' Task pane</li> <li>Click on the 'add or remove custom controls' button to install your custom control</li> <li>Click on the Add button and select ActiveX Control</li> <li>Select the Windows Media Player control</li> <li>Select the necessary properties for databinding and finish the wizard.</li> </ol> <p>After you have added the control, you can drag and drop the control on your screen. Right-Click on the control and select the 'Windows Media Player properties' Fill in the URL to automatically embed the file to play.</p>
5,507
<p>Should I use a dedicated network channel between the database and the application server?</p> <p>...or... </p> <p>Connecting both in the switch along with all other computer nodes makes no diference at all?</p> <p>The matter is <strong>performance!</strong></p>
<p>Declare it like this:</p> <pre><code>&lt;bean id="doubleValue" class="java.lang.Double"&gt; &lt;constructor-arg index="0" value="3.7"/&gt; &lt;/bean&gt; </code></pre> <p>And use like this:</p> <pre><code>&lt;bean id="someOtherBean" ...&gt; &lt;property name="value" ref="doubleValue"/&gt; &lt;/bean&gt; </code></pre>
<p>Why don't you just use a <strong>Double</strong>? any reason?</p>
8,462
<p>So you know a lot of Mac apps use "bundles": It looks like a single file to your application, but it's actually a folder with many files inside.</p> <p>For a version control system to handle this, it needs to:</p> <ul> <li>check out all the files in a directory, so the app can modify them as necessary</li> <li>at checkin, <ul> <li>commit files which have been modified</li> <li>add new files which the application has created</li> <li>mark as deleted files which are no longer there (since the app deleted them)</li> <li>manage this as one atomic change</li> </ul></li> </ul> <p>Any ideas on the best way to handle this with existing version control systems? Are any of the versioning systems more adept in this area? </p>
<p>Mercurial in particular versions based on file, not directory structure. Therefore, your working tree, which is a fully-fledged repository, doesn't spit out .svn folders at each level.</p> <p>It also means that a directory that is replaced, like an Application or other Bundle, will still find it's contents with particular file names under revision control. File names are monitored, not inodes or anything fancy like that!</p> <p>Obviously, if a new file is added to the Bundle, you'll need to explicitly add this to your repository. Similarly, removing a file from a Bundle should be done with an 'hg rm'.</p> <p>There aren't any decent Mercurial GUIs for OS X yet, but if all you do is add/commit/merge, it isn't that hard to use a command line.</p>
<p>An update from the future:</p> <p>If I recall, the problem with managing bundles in SVN was all the .svn folders getting cleared each time you made a bundle. This shouldn't be a problem any more, now that SVN stores everything in a single .svn folder at the root.</p>
4,666
<p>I'm trying to gear down a servo even further. I notice that the majority of the gears are made of nylon, and I want to create new gears that come close to the resolution and strength of the existing gears. I have a Replicator 2, but the resolution does not seem to come close to what I need. Any suggestions on how I can create nylon or other hard material parts that might work?</p>
<p>I looked at the current Marlin code and the P24 command should work as you expect it unless the pin you are trying to use in listed as the "SENSITIVE_PINS" list:</p> <pre><code>#define SENSITIVE_PINS { 0, 1, \ X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, \ Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, \ Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, Z_MIN_PROBE_PIN, \ PS_ON_PIN, HEATER_BED_PIN, FAN_PIN, FAN1_PIN, FAN2_PIN, CONTROLLER_FAN_PIN, \ _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS BED_PINS \ _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS \ _X2_PINS _Y2_PINS _Z2_PINS \ X_MS1_PIN, X_MS2_PIN, Y_MS1_PIN, Y_MS2_PIN, Z_MS1_PIN, Z_MS2_PIN \ } </code></pre> <p>These pins are printer specific; so, without access to your Marlin build, I can't see if pin 4 corresponds to one of these. If this is the problem, the command should be returning an error. If there is no error, I would look closely at the hardware.</p>
<p>Might be because servo pins are not connected to 5V. use Jumper as shown</p> <p><a href="https://i.stack.imgur.com/ycegg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ycegg.png" alt="enter image description here"></a></p>
486
<p>Does anyone use Accurev for Source Control Management? We are switching (eventually) from StarTeam to Accurev.</p> <p>My initial impression is that the GUI tool is severely lacking, however the underlying engine, and the branches as streams concept is incredible.</p> <p>The biggest difficulty we are facing is assessing our own DIY tools that interfaced with starteam, and either replacing them with DIY new tools, or finding and purchasing appropriate replacements.</p> <p>Additionally, is anyone using the AccuWork component for Issue management? Starteam had a very nice change request system, and AccuWork does not come close to matching it. We are evaluating either using Accuwork, or buying a 3rd party package such as JIRA.</p> <p>Opinions?</p>
<p>Honestly, I feel like I need to double check to see if I'm using the same tool as these folks that seem to like Accurev. I used Subversion in my previous job and liked it a lot. We never had any issues with it to speak of, and of course the price is right. My biggest problem with Accurev is that it seems they felt the need to be different for different's sake. It uses a completely different vocabulary to express versioning concepts, that even after using it for almost 6 months, feels very foreign to me. It has no fewer than 8 or 9 states any given file can be in, compared to about around 1/2 as many for Subversion. The GUI is crappy and slow, and the IDE integration plugins are sub-par. I had assumed that at some point I would "get" Accurev and see why it's so much better, but that has yet to happen. My advice is to stay away.</p>
<p>I've just come across this discussion and thought I would share our experiences with AccuRev.</p> <p>We have been using the Dimensions SCM from Serena for around 8 years. Two years ago we had a major problem integrating our India based Development team with our UK Dev team. It was clear that we were not going to meet our needs with the current system and hence we set about evaluating a number of options. I discuss all of this in this article <a href="http://blog.accurev.com/2008/07/18/how-we-integrated-our-offshore-development-team/" rel="nofollow noreferrer">How We Integrated Our Offshore Dev Team.</a></p> <p>Our experience of using AccuRev has so far been very positive. </p> <ul> <li>It is easy to setup and administer. </li> <li>Users are able to get going very very quickly (especially important for the India dev team)</li> <li>We've never had a problem with speed (in fact this is one of the main plus points for us)</li> <li>The replication works like a dream</li> <li>I do agree that the UI can be a bit clunky (especially the Unix client). I am hoping that it will be better in the latest version when we update to that next month.</li> </ul> <p>All in all I would say that this was one of the best decisions and purchases we have made.</p>
3,968
<p>I am interested in moving a number of my projects from Visual Studio and Access/Office Basic with a SQL back-end to the Linux world. </p> <p>Are there any utilities available to move code over to a similar platform on Linux?</p>
<p>Here's a link to the <a href="http://www.mono-project.com/MoMA" rel="nofollow noreferrer">Mono Migration Analyzer</a> to get started. It will help you pinpoint Microsoft specific calls, but you'll probably have to do the db conversion and data access layer manually. You may be surprised - mono does have a System.Data.SqlClient namespace so you may not have much work to do.</p>
<p>There are some flavours of OpenOffice that include native support for VBA. The version included with Ubuntu is one example, and the <a href="http://www.novell.com/products/openworkgroupsuite/product_evals.html" rel="nofollow noreferrer">Novell version for Windows</a> is another. For more details and a list of versions with this feature, see <a href="http://www.linux.com/archive/articles/58348" rel="nofollow noreferrer">this article on linux.com</a>.</p> <p>They don't support all features of VBA, but they will reduce your conversion effort.</p>
5,364
<p>My product has several components: ASP.NET, Windows Forms App and Windows Service. 95% or so of the code is written in VB.NET.</p> <p>For Intellectual Property reasons, I need to obfuscate the code, and until now I have been using a version of dotfuscator which is now over 5 years old. I'm thinking it is time to move to a new generation tool. What I'm looking for is a list of requirements which I should consider when searching for a new obfuscator.</p> <p>What I know I should look for so far:</p> <ul> <li><strong><em>Serialization/De-serialization</em></strong>. In my current solution, I simply tell the tool <strong>not</strong> to obfuscate any class data members because the pain of not being able to load data which was previously serialized is simply too big.</li> <li><strong><em>Integration with Build Process</em></strong></li> <li><strong><em>Working with ASP.NET</em></strong>. In the past, I have found this problematic due to changing .dll names (you often have one per page) - which not all tools handle well.</li> </ul>
<p>Back with .Net 1.1 obfuscation was essential: decompiling code was easy, and you could go from assembly, to IL, to C# code and have it compiled again with very little effort.</p> <p>Now with .Net 3.5 I'm not at all sure. Try decompiling a 3.5 assembly; what you get is a long long way from compiling.</p> <p>Add the optimisations from 3.5 (far better than 1.1) and the way anonymous types, delegates and so on are handled by reflection (they are a nightmare to recompile). Add lambda expressions, compiler 'magic' like Linq-syntax and <code>var</code>, and C#2 functions like <code>yield</code> (which results in new classes with unreadable names). Your decompiled code ends up a long long way from compilable. </p> <p>A professional team with lots of time could still reverse engineer it back again, but then the same is true of any obfuscated code. What code they got out of that would be unmaintainable and highly likely to be very buggy.</p> <p>I would recommend key-signing your assemblies (meaning if hackers can recompile one they have to recompile all) but I don't think obfuscation's worth it.</p>
<p>I tried Eziriz demo version....I liked it. But never brought the software.</p>
2,464
<p>In Java, what would the best way be to have a constantly listening port open, and still send upon receipt of a packet. I am not particularly savvy with network programming at the moment, so the tutorials I have found on the net aren't particularly helpful.</p> <p>Would it make sense to have the listening socket as a serversocket and run it in a separate thread to the socket I'm using to send data to the server?</p> <p>In a loosely related question. Does anyone know if programming simply for java, in netbeans then exporting it for use on a blackberry (using a plugin) the sockets would still work ?</p>
<p>If you can afford the threading, try this (keep in mind I've left out some details like exception handling and playing nice with threads). You may want to look into <code>SocketChannels</code> and/or NIO async sockets / selectors. This should get you started.</p> <pre><code>boolean finished = false; int port = 10000; ServerSocket server = new ServerSocket(port); while (!finished) { // This will block until a connection is made Socket s = server.accept(); // Spawn off some thread (or use a thread pool) to handle this socket // Server will continue to listen } </code></pre>
<p>I'd need to go back to the basics for this one too. I'd recommend O'Reilly's excellent <em>Java in a Nutshell</em> that includes code examples for just such a case (available <a href="http://oreilly.com/catalog/javanut/examples/" rel="nofollow noreferrer">online</a> as well). See Chapter 7 for a pretty good overview of the decisions you'd want to make early on.</p>
6,757
<p>I'm developing a site in Visual Web Dev Express, and when I run/debug, I'd like to be able to set my application's document root so that I can use safer paths, like "/css/style.css' instead of "css/style.css". How would I accomplish this?</p>
<ul> <li>Click on the web site node in the solution explorer.</li> <li>Press F4 to see the properties window.</li> <li>Change the virtual path from <strong>/projectname</strong> to <strong>/</strong></li> </ul> <p>Bear in mind that this has an impact on how you expect the application/web site to be deployed. If it is ever used outside the root of a web server, the URL paths will be incorrect.</p>
<p>I have been looking for the virtual path field in the properties window but haven't been able to find it... it only shows me the following options</p> <ul> <li>aperture directory URL</li> <li>complete access route</li> <li>policy file</li> <li>port</li> <li>use dynamic port</li> </ul> <p>Do you know of some place else where I could find the Virtual Path field?</p>
4,147
<p>How can I create rounded corners using CSS?</p>
<p>Since CSS3 was introduced, the best way to add rounded corners using CSS is by using the <code>border-radius</code> property. You can <a href="http://www.w3.org/TR/css3-background/#the-border-radius" rel="noreferrer">read the spec</a> on the property, or get some <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius" rel="noreferrer">useful implementation information on MDN</a>:</p> <p>If you are using a browser that <a href="http://fmbip.com/litmus/" rel="noreferrer">doesn't</a> <a href="http://css3test.com/" rel="noreferrer">implement</a> <code>border-radius</code> (Chrome pre-v4, Firefox pre-v4, IE8, Opera pre-v10.5, Safari pre-v5), then the links below detail a whole bunch of different approaches. Find one that suits your site and coding style, and go with it.</p> <ol> <li><a href="http://www.alistapart.com/articles/customcorners/" rel="noreferrer">CSS Design: Creating Custom Corners &amp; Borders</a></li> <li><a href="http://www.smileycat.com/miaow/archives/000044.php" rel="noreferrer">CSS Rounded Corners 'Roundup'</a></li> <li><a href="http://www.cssjuice.com/25-rounded-corners-techniques-with-css/" rel="noreferrer">25 Rounded Corners Techniques with CSS</a></li> </ol>
<p>Opera does not support border-radius yet (apparently it will be in the release after version 10). In the meantime, you can <a href="http://dev.opera.com/articles/view/new-development-techniques-using-opera-k/" rel="nofollow noreferrer">use CSS to set an SVG background to create a similar effect</a>.</p>
2,873
<p>Does anyone have a technique for generating SQL table create (and data insert) commands pragmatically from a CSV (or sheet in a .xls) file? </p> <p>I've got a third party database system which I'd like to populate with data from a csv file (or sheet in a xls file) but the importer supplied can't create the table structure automatically as it does the import. My csv file has lots of tables with lots of columns so I'd like to automate the table creation process as well as the data importing if possible but I'm unsure about how to go about generating the create statement...</p>
<p>In SQL server it is as easy as</p> <pre><code>SELECT * INTO NewTablenNmeHere FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\testing.xls','SELECT * FROM [Sheet1$]') </code></pre>
<p>Unfortunately I'm using an SQLEngine for embedded systems so it does not support BULK INSERT or OLEDB datasources, which is why I was thinking of taking the sql statement generation approach.</p>
4,295
<p>Sorry for this not being a "real" question, but Sometime back i remember seeing a post here about randomizing a randomizer randomly to generate truly random numbers, not just pseudo random. I dont see it if i search for it.</p> <p>Does anybody know about that article?</p>
<p>I believe that was on <a href="http://thedailywtf.com/Articles/Random-Stupidity.aspx" rel="noreferrer">thedailywtf.com</a> - ie. not something that you want to do.</p> <p>It is not possible to get a truly random number from pseudorandom numbers, no matter how many times you call randomize().</p> <p>You <em>can</em> get "true" random numbers from special <a href="http://en.wikipedia.org/wiki/Hardware_random_number_generator" rel="noreferrer">hardware</a>. You could also collect entropy from mouse movements and things like that.</p>
<p>One of the best method to generate a random number is through <a href="http://en.wikipedia.org/wiki/Hardware_random_number_generator#Clock_drift" rel="nofollow noreferrer">Clock Drift</a>. This primarily works with two oscillators.</p> <p>An analogy of how this works is imagine a race car on a simple oval circuit with a while line at the start of the lap and also a while line on one of the tyres. When the car completes a lap, a number will be generated based on the difference between the position of the white line on the road and on the tyre.</p> <p>Very easy to generate and impossible to predict.</p>
5,850
<p><strong>Background</strong>:</p> <p>I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly with Acrobat Reader 4 :-(. Installing a newer version of Acrobat Reader breaks this application, making the users very unhappy.</p> <p>I want to re-architect this app so that it will send the data to be merged to a PDF output generation server. This server will merge the data passed to it onto the form, generate a PDF image of this, and store it, so that any user wishing to view the final result can then simply get the PDF (it is generated just once). If the underlying data is changed, the PDF will be deleted and regenerated next time it is requested. The client program can then have any version of Acrobat Reader they wish, as it will be used exclusively for displaying PDF files (as it was intended). The server will most likely be written in .NET (C#) with Visual Studio 2005, probably as a Web Service... </p> <p><strong>Question</strong>:</p> <p>How would others recommend I go about this? Should I use Adobe's Acrobat 9 at the server to do this, puting the data into FDF or Adobe's XML format, and letting Acrobat do the merge? Are there great competitors in the "merge data onto form and output a PDF" space? How do others do this? It has to be API based, no GUI at the server, of course...</p> <p>While some output is generated via FDF/PDF, another part of the application actually sends lines, graphics, and text to the printer (or a form for preview purposes) one page at a time, giving the proper x/y coordinates, font, size, etc. for each, knowing when it is at the end of a page, etc. This code is currently in the program that displays this for the user to review, and it is also in the program that prints the final form to the printer. For consistency between reviewer and printer, I'd like to move this output generation logic to a server as well, either using a good PDF generation API tool or use the code as is and generate a PDF with a PDF printer... and saving this PDF for display by the clients.</p> <p>Googling "Form software" or "fill form software" or similar searches returns sooooooooo much unrelated material, mostly related to UI for users to fill in forms, I just don't know how to properly narrow down my search. This site seems the perfect place to ask such a question, as other programmers must also need to generate similar outputs, and have tried out some great tools.</p> <p><strong>EDIT:</strong> </p> <p>I've added PDF tag as well as PDF-generation. Also, my current customer insists on PDF output, but I appreciate the alternative suggestions.</p>
<p>can't help with VB6 solution, can help with .net or java solution on the server.<br> Get iText or iTextSharp from <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">http://www.lowagie.com/iText/</a>.<br> It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate FDF files, get field names out of PDF files, etc... </p>
<p>Take my advice. Ditch PDF for XPS. I am working on two apps, both server based. One displays image-based documents as PDFs in a browser. The second uses FixedPage templates to construct XPS documents bound to data sources. </p> <p>My conclusion after working on both projects is that PDFs suck; XPS documents less so. You have to pay cash money for a decent PDF library, whereas XPS comes with the framework. PDF document generation is a memory hog, has lots of potholes and isn't very server friendly. XPS docs have a much smaller footprint and less chances of shooting yourself in the foot. </p>
7,844
<p>What does the expression "Turing Complete" mean? </p> <p>Can you give a simple explanation, without going into too many theoretical details?</p>
<p>Here's the briefest explanation:</p> <p>A Turing Complete system means a system in which a program can be written that will find an answer (although with no guarantees regarding runtime or memory).</p> <p>So, if somebody says &quot;my new thing is Turing Complete&quot; that means in principle (although often not in practice) it could be used to solve any computation problem.</p> <p>Sometimes it's a joke... a guy wrote a Turing Machine simulator in vi, so it's possible to say that vi is the only computational engine ever needed in the world.</p>
<p>As <a href="https://stackoverflow.com/questions/7284/what-is-turing-complete/878771#878771">Waylon Flinn said</a>:</p> <blockquote> <p>Turing Complete means that it is at least as powerful as a Turing Machine.</p> </blockquote> <p>I believe this is incorrect, a system is Turing complete if it's exactly as powerful as the Turing Machine, i.e. every computation done by the machine can be done by the system, but also every computation done by the system can be done by the Turing machine.</p>
2,893
<p>Anyone know uf there's a dll/runner anywhere that returns TAP output from an NUnit test suite?</p>
<p>Seems unlikely to me, since there is an impedance mismatch. TAP has no concept for what NUnit calls a test, and what TAP calls a test usually corresponds to an NUnit assertion, but not precisely. So I’m not sure how the thing you’re looking for would work at all. (But maybe a heuristic could work well enough.)</p>
<p>At the very least, a simple pass/fail for each TestFixture run would allow the output to be sucked into other TAP results for aggregating results/reports. Maybe it's as simple as a xslt to transform the xml report into TAP</p>
9,741
<p>How do you return 1 value per row of the max of several columns:</p> <p><strong>TableName</strong></p> <pre><code>[Number, Date1, Date2, Date3, Cost] </code></pre> <p>I need to return something like this:</p> <pre><code>[Number, Most_Recent_Date, Cost] </code></pre> <p>Query?</p>
<p>Here is another nice solution for the <code>Max</code> functionality using T-SQL and SQL Server</p> <pre><code>SELECT [Other Fields], (SELECT Max(v) FROM (VALUES (date1), (date2), (date3),...) AS value(v)) as [MaxDate] FROM [YourTableName] </code></pre> <p>Values is the <a href="https://learn.microsoft.com/en-us/sql/t-sql/queries/table-value-constructor-transact-sql?view=sql-server-ver15" rel="noreferrer">Table Value Constructor</a>.</p> <p>&quot;Specifies a set of row value expressions to be constructed into a table. The Transact-SQL table value constructor allows multiple rows of data to be specified in a single DML statement. The table value constructor can be specified either as the VALUES clause of an INSERT ... VALUES statement, or as a derived table in either the USING clause of the MERGE statement or the FROM clause.&quot;</p>
<p>here is a good solution:</p> <pre><code>CREATE function [dbo].[inLineMax] (@v1 float,@v2 float,@v3 float,@v4 float) returns float as begin declare @val float set @val = 0 declare @TableVal table (value float ) insert into @TableVal select @v1 insert into @TableVal select @v2 insert into @TableVal select @v3 insert into @TableVal select @v4 select @val= max(value) from @TableVal return @val end </code></pre>
9,644
<p>I would like to have an <code>iframe</code> take as much vertical space as it needs to display its content and not display a scrollbar. Is it at all possible ?</p> <p>Are there any workarounds?</p>
<p>This should set the <code>IFRAME</code> height to its content's height:</p> <pre><code>&lt;script type="text/javascript"&gt; the_height = document.getElementById('the_iframe').contentWindow.document.body.scrollHeight; document.getElementById('the_iframe').height = the_height; &lt;/script&gt; </code></pre> <p>You may want to add <code>scrolling="no"</code> to your <code>IFRAME</code> to turn off the scrollbars.</p> <p><em>edit:</em> Oops, forgot to declare <code>the_height</code>.</p>
<p>This CSS snippet should remove the vertical scrollbar:</p> <pre class="lang-css prettyprint-override"><code>body { overflow-x: hidden; overflow-y: hidden; } </code></pre> <p>I'm not sure yet about having it take up as much vertical space as it needs, but I'll see if I can't figure it out.</p>
5,496
<p>It seems that everybody is jumping on the dynamic, non-compiled bandwagon lately. I've mostly only worked in compiled, static typed languages (C, Java, .Net). The experience I have with dynamic languages is stuff like ASP (Vb Script), JavaScript, and PHP. Using these technologies has left a bad taste in my mouth when thinking about dynamic languages. Things that usually would have been caught by the compiler such as misspelled variable names and assigning an value of the wrong type to a variable don't occur until runtime. And even then, you may not notice an error, as it just creates a new variable, and assigns some default value. I've also never seen intellisense work well in a dynamic language, since, well, variables don't have any explicit type.</p> <p>What I want to know is, what people find so appealing about dynamic languages? What are the main advantages in terms of things that dynamic languages allow you to do that can't be done, or are difficult to do in compiled languages. It seems to me that we decided a long time ago, that things like uncompiled asp pages throwing runtime exceptions was a bad idea. Why is there is a resurgence of this type of code? And why does it seem to me at least, that Ruby on Rails doesn't really look like anything you couldn't have done with ASP 10 years ago?</p>
<p>I think the reason is that people are used to statically typed languages that have very limited and inexpressive type systems. These are languages like Java, C++, Pascal, etc. Instead of going in the direction of more expressive type systems and better type inference, (as in Haskell, for example, and even SQL to some extent), some people like to just keep all the "type" information in their head (and in their tests) and do away with static typechecking altogether.</p> <p>What this buys you in the end is unclear. There are many misconceived notions about typechecking, the ones I most commonly come across are these two.</p> <p><strong>Fallacy: Dynamic languages are less verbose.</strong> The misconception is that type information equals type annotation. This is totally untrue. We all know that type annotation is annoying. The machine should be able to figure that stuff out. And in fact, it does in modern compilers. Here is a statically typed QuickSort in two lines of Haskell (from <a href="http://haskell.org" rel="nofollow noreferrer">haskell.org</a>):</p> <pre><code>qsort [] = [] qsort (x:xs) = qsort (filter (&lt; x) xs) ++ [x] ++ qsort (filter (&gt;= x) xs) </code></pre> <p>And here is a dynamically typed QuickSort in LISP (from <a href="http://swisspig.net/r/post/blog-200603301157" rel="nofollow noreferrer">swisspig.net</a>):</p> <pre><code>(defun quicksort (lis) (if (null lis) nil (let* ((x (car lis)) (r (cdr lis)) (fn (lambda (a) (&lt; a x)))) (append (quicksort (remove-if-not fn r)) (list x) (quicksort (remove-if fn r)))))) </code></pre> <p>The Haskell example falsifies the hypothesis <em>statically typed, therefore verbose</em>. The LISP example falsifies the hypothesis <em>verbose, therefore statically typed</em>. There is no implication in either direction between typing and verbosity. You can safely put that out of your mind.</p> <p><strong>Fallacy: Statically typed languages have to be compiled, not interpreted.</strong> Again, not true. Many statically typed languages have interpreters. There's the Scala interpreter, The GHCi and Hugs interpreters for Haskell, and of course SQL has been both statically typed and interpreted for longer than I've been alive.</p> <p>You know, maybe the dynamic crowd just wants freedom to not have to think as carefully about what they're doing. The software might not be correct or robust, but maybe it doesn't have to be.</p> <p>Personally, I think that those who would give up type safety to purchase a little temporary liberty, deserve neither liberty nor type safety.</p>
<p>Because it's fun fun fun. It's fun to not worry about memory allocation, for one. It's fun not waiting for compilation. etc etc etc</p>
6,453
<p>If I select from a table group by the month, day, year, it only returns rows with records and leaves out combinations without any records, making it appear at a glance that every day or month has activity, you have to look at the date column actively for gaps. How can I get a row for every day/month/year, even when no data is present, in T-SQL?</p>
<p>Create a calendar table and outer join on that table</p>
<p>Look into using a <a href="http://andre-silva-cardoso.blogspot.com/2007/11/sql-trickspatterns-1-numbers-table.html" rel="nofollow noreferrer">numbers table</a>. While it can be hackish, it's the best method I've come by to quickly query missing data, or show all dates, or anything where you want to examine values within a range, regardless of whether all values in that range are used.</p>
6,168
<p>I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.</p> <p>I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in. Does P4 have the equivalent of Subversion's 'ignore file' feature? </p>
<p>As of version 2012.1, Perforce supports the <code>P4IGNORE</code> environment variable. I updated my answer to <a href="https://stackoverflow.com/a/3103898/4228">this question about ignoring directories</a> with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess.</p> <hr> <p>Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this:</p> <pre> -//depot/foo/*.dll //CLIENT/foo/*.dll -//depot/foo/.../*.dll //CLIENT/foo/.../*.dll </pre> <p>The first line removes them from the directory "foo" and the second line removes them from all sub directories. Now, when you 'Reconcile Offline Work...', all the .dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to.</p> <p>You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won't be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn't matter).</p> <pre> -//depot/foo.../*.dll //CLIENT/foo.../*.dll </pre>
<p>If you are using the Eclipse Perforce plugin, then <a href="http://perforce.com/perforce/doc.091/manuals/p4wsad/topics/adding.html" rel="nofollow noreferrer">the plugin documentation</a> lists several ways to ignore files.</p>
7,923
<p>I have a large resistor that goes in my J-Head extruder. It's grey, and it came with the extruder. I'm uncertain as to what grade of wire I need to solder to it. It being one of the elements of the system that heats the hottest, I would think that it would be important to find out what sort of wire is the correct kind to use on it, since heating elements require a lot of electricity.</p> <p>Also does the solder type I use matter? </p>
<p>There are a number of things to consider:</p> <ul> <li><p>Wire Gauge: a typical 40W, 12V heater draws around 3A. 24 AWG or lower would be appropriate (copper wire, CCA will require thicker gauge).</p></li> <li><p>Insulation: the part of the wire close to the resistor leads might get too hot for conventional PVC installation. Consider using silicone, teflon or glass fiber insulation instead, especially near the heating element. If the resistor's leads are long enough they might stay cool enough for regular PVC insulation, but make sure you insulate the part of the leads closer to the resistor appropriately.</p></li> <li><p>Solder: if close to the heater itself, the solder might melt. Consider using silver solder, or using a mechanical connection (ferrule/crimp) instead. Again, this might not be a concern if the leads of the resistor are long enough.</p></li> <li><p>Flexibility: given that the extruder (probably) moves a lot, use flexible wire (stranded, not solid core) and provide strain relief (especially near the connections, and avoid creating too sharp bends).</p></li> </ul> <p>Finally, resistors have fallen out of favor compared to ceramic heating elements. Since they are inexpensive and solve all of the above problems (the leads are already attached and appropriately insulated) consider using a ceramic heater instead.</p>
<p>The physical size of the resistor is irrelevant. What matters is the total power (and in particular, current) the head will draw. Once you know that, there are plenty of tables on the web that'll list max amperage vs. wire gauge. When in doubt, use a larger wire :-) since we're only talking about a couple of feet length; cost is minimal.</p> <p>As to solder: so long as you're not selling the printer, you don't need to meet any RoHs requirements. Use whatever you want.</p>
438
<p>My office has a central Source Safe 2005 install that we use for source control. I can't change what the office uses on the server. </p> <p>I develop on a laptop and would like to have a different local source control repository that can sync with the central server (when available) regardless of the what that central provider is. The reason for the request is so I can maintain a local stable branch/build for client presentations while continuing to develop without having to jump through flaming hoops. Also, as a consultant, my clients may request that I use their source control provider and flexibility here would make life easier.</p> <p>Can any of the existing distributed source control clients handle that?</p>
<p>Well... KernelTrap has <a href="http://kerneltrap.org/mailarchive/git/2008/5/27/1952124" rel="nofollow noreferrer">something on this</a>. Looks like you can use <a href="http://www.pumacode.org/projects/vss2svn/wiki/RunningTheMigration" rel="nofollow noreferrer">vss2svn</a> to pipe the Source Safe repo into a Subversion repository, then use the very nice git-svn to pull into a local git repo.</p> <p>I would assume the commits back to VSS would not be a smooth, automatic process using this method.</p>
<p>some day I work in a company that use VSS (and in other companies that use other less unknow <a href="http://en.wikipedia.org/wiki/Source_Code_Management" rel="nofollow noreferrer">SCM</a>) but i prefer use SVN (someday I'll try GIT) for active development, for me and my group.</p> <p>First of all, this situation it's only good idea, if commit to VSS are few over month, because working with other SCM (than VSS) give you more flexibility, but commint to VSS from SVN is expensive in time.</p> <p>My solution was:</p> <p>VSS -&gt; SVN: I have linux script (or ant script, or XXX script) that copy from currrent update directory work of VSS to current SVN, then refresh SVN client and update/merge/commit to SVN. With this, you are update from changes of the rest of company that use VSS.</p> <p>SVN -&gt; VSS: In this way, you need a checkout of all your modify files to VSS, then you can simply use the reverse script to copy from current update SVN directory (ignore .svn directories) and copy to current update VSS directory, update and commit.</p> <p>But remember, in a few case does worth your time to do this.</p>
2,387
<p>The log4j network adapter sends events as a serialised java object. I would like to be able to capture this object and deserialise it in a different language (python). Is this possible?</p> <p><em>NOTE</em> The network capturing is easy; its just a TCP socket and reading in a stream. The difficulty is the deserialising part</p>
<p>Generally, no.</p> <p>The stream format for Java serialization is defined <a href="http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf" rel="nofollow noreferrer">in this document</a>, but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into something approaching the original objects. For example, classes may define writeObject() and readObject() methods to customise their own serialized form.</p> <p>(<strong>edit:</strong> lubos hasko suggests having a little java program to deserialize the objects in front of Python, but the problem is that for this to work, your "little java program" needs to load the same versions of all the same classes that it might deserialize. Which is tricky if you're receiving log messages from one app, and really tricky if you're multiplexing more than one log stream. Either way, it's not going to be a little program any more. <strong>edit2:</strong> I could be wrong here, I don't know what gets serialized. If it's just log4j classes you should be fine. On the other hand, it's possible to log arbitrary exceptions, and if they get put in the stream as well my point stands.)</p> <p>It would be much easier to customise the log4j network adapter and replace the raw serialization with some more easily-deserialized form (for example you could use XStream to turn the object into an XML representation)</p>
<p>If you can have a JVM on the receiving side and the class definitions for the serialized data, and you only want to use Python and no other language, then you may use Jython:</p> <ul> <li>you would deserialize what you received using the correct Java methods</li> <li>and then you process what you get with you Python code</li> </ul>
4,916
<p>I have a class property exposing an internal IList&lt;> through</p> <pre><code>System.Collections.ObjectModel.ReadOnlyCollection&lt;&gt; </code></pre> <p>How can I pass a part of this <code>ReadOnlyCollection&lt;&gt;</code> without copying elements into a new array (I need a live view, and the target device is short on memory)? I'm targetting Compact Framework 2.0.</p>
<p>Try a method that returns an enumeration using yield:</p> <pre><code>IEnumerable&lt;T&gt; FilterCollection&lt;T&gt;( ReadOnlyCollection&lt;T&gt; input ) { foreach ( T item in input ) if ( /* criterion is met */ ) yield return item; } </code></pre>
<p>How do the filtered elements need to be accessed? If it's through an Iterator then maybe you could write a custom iterator that skips the elements you don't want publicly visible?</p> <p>If you need to provide a Collection then you might need to write your own Collection class, which just proxies to the underlying Collection, but prevents access to the elements you don't want publicly visible.</p> <p>(Disclaimer: I'm not very familiar with C#, so these are general answers. There may be more specific answers to C# that work better)</p>
6,049
<p>I'm using MediaTemple's Grid Server (shared/grid hosting) to run some MySQL/PHP sites I'm writing and noticed that I wasn't closing one of my MySQL connections, which caused my site to error out: </p> <pre><code>"Too Many Connections" </code></pre> <p>I can't log in anywhere to close the connections manually. </p> <p><strong>Is that any way to close open connections using a script or other type of command?.</strong> </p> <p>Should I just wait?</p>
<p>If you can't log into MySQL at all, you will probably have to contact your hosting provider to kill the connections.</p> <p>If you can use the MySQL shell, you can use the <a href="http://dev.mysql.com/doc/refman/5.0/en/show-processlist.html" rel="nofollow noreferrer">show processlist</a> command to view connections, then use the <a href="http://dev.mysql.com/doc/refman/5.0/en/kill.html" rel="nofollow noreferrer">kill</a> command to remove the connections.</p> <p>It's been my experience that hung SQL connections tend to stay that way, unfortunately.</p>
<p>Make sure that you're closing the connections with your PHP code. Also, you could increase the maximum connections allowed in /etc/my.cnf.</p> <pre><code>max_connections=500 </code></pre> <p>Finally, you can login to a mysql prompt and type <code>show status</code> or <code>show processlist</code> to view various statistics with your server.</p> <p>If all else fails, restarting the server daemon should clear the persistent connections.</p>
9,461
<p>Anyone know a quick easy way to migrate a SQLite3 database to MySQL?</p>
<p>Everyone seems to starts off with a few greps and perl expressions and you sorta kinda get something that works for your particular dataset but you have no idea if it's imported the data correctly or not. I'm seriously surprised nobody's built a solid library that can convert between the two.</p> <p>Here a list of ALL the differences in SQL syntax that I know about between the two file formats: The lines starting with:</p> <ul> <li>BEGIN TRANSACTION</li> <li>COMMIT</li> <li>sqlite_sequence</li> <li>CREATE UNIQUE INDEX</li> </ul> <p>are not used in MySQL</p> <ul> <li>SQLite uses <code>CREATE TABLE/INSERT INTO &quot;table_name&quot;</code> and MySQL uses <code>CREATE TABLE/INSERT INTO table_name</code></li> <li>MySQL doesn't use quotes inside the schema definition</li> <li>MySQL uses single quotes for strings inside the <code>INSERT INTO</code> clauses</li> <li>SQLite and MySQL have different ways of escaping strings inside <code>INSERT INTO</code> clauses</li> <li>SQLite uses <code>'t'</code> and <code>'f'</code> for booleans, MySQL uses <code>1</code> and <code>0</code> (a simple regex for this can fail when you have a string like: 'I do, you don't' inside your <code>INSERT INTO</code>)</li> <li>SQLLite uses <code>AUTOINCREMENT</code>, MySQL uses <code>AUTO_INCREMENT</code></li> </ul> <p>Here is a very basic hacked up perl script which works for <em>my</em> dataset and checks for many more of these conditions that other perl scripts I found on the web. Nu guarantees that it will work for your data but feel free to modify and post back here.</p> <pre><code>#! /usr/bin/perl while ($line = &lt;&gt;){ if (($line !~ /BEGIN TRANSACTION/) &amp;&amp; ($line !~ /COMMIT/) &amp;&amp; ($line !~ /sqlite_sequence/) &amp;&amp; ($line !~ /CREATE UNIQUE INDEX/)){ if ($line =~ /CREATE TABLE \&quot;([a-z_]*)\&quot;(.*)/i){ $name = $1; $sub = $2; $sub =~ s/\&quot;//g; $line = &quot;DROP TABLE IF EXISTS $name;\nCREATE TABLE IF NOT EXISTS $name$sub\n&quot;; } elsif ($line =~ /INSERT INTO \&quot;([a-z_]*)\&quot;(.*)/i){ $line = &quot;INSERT INTO $1$2\n&quot;; $line =~ s/\&quot;/\\\&quot;/g; $line =~ s/\&quot;/\'/g; }else{ $line =~ s/\'\'/\\\'/g; } $line =~ s/([^\\'])\'t\'(.)/$1THIS_IS_TRUE$2/g; $line =~ s/THIS_IS_TRUE/1/g; $line =~ s/([^\\'])\'f\'(.)/$1THIS_IS_FALSE$2/g; $line =~ s/THIS_IS_FALSE/0/g; $line =~ s/AUTOINCREMENT/AUTO_INCREMENT/g; print $line; } } </code></pre>
<pre><code>echo ".dump" | sqlite3 /tmp/db.sqlite &gt; db.sql </code></pre> <p>watch out for CREATE statements</p>
3,920
<p>I am trying to increase the flow rate on my Ender 3 from 100 to 108 % but every time I start a new print it reverts back to the old 100 % flow rate. I have clicked through the settings and pressed the "store settings" button but it still reverts back at the start of every print. I don't want to do this in my slicer settings as I run 18 Ender 3's so I want to be able to use the same G-code for each.</p>
<p>Changing the <strong>flow rate</strong> during a print can <strong>not</strong> be saved. There simply is no way. It is usually meant to be a fix with filament inconsistencies or to look for the right extrusion factor for a new filament batch.</p> <h2>Slicer</h2> <p>The only way to consistently increase the flow rate would be to alter the <code>flow rate</code> in your slicer to what you have found to work best for each machine, probably using separate profiles. This will up the rate for every subsequently sliced print. Note though that this 108 % increased extrusion is converted extrusion factors that are simply numerical and 1.08 times the normal in the g-code. These numerical values will be taken as 100 % by the printer - and since it requires extra work to slice the gode for different profiles it is not the optimal solution.</p> <p>As you elaborated though, this is not a doable thing, so let's look further.</p> <h2>Source hunt &amp; Workaround</h2> <p>Since only one printer is showing underextrusion while the others do not, it is time to check the hard- and firmware:</p> <ul> <li>underextrusion can be caused by a defective extruder assembly or a damaged or blocked nozzle.</li> <li>if a machine has consistent underextrusion, its steps/mm in the firmware might be off. This could be altered and stored in the EEPROM. Since this could be a machine unique setting, here would be your point of attack to increase the extrusion of just one machine while using the identical G-code to all other machines.</li> </ul> <p>Note that the standard firmware of the Ender-3 in 2019 did not contain Thermal Runaway Protection (<a href="/q/8466/">What is Thermal Runaway Protection?</a>) and should be upgraded because of this anyway. You have to flash a bootloader too, so in the process of doing the upgradeability and safety-upgrade to all the machines, you could store the altered steps/mm to each machine individually so they get consistent output.</p>
<p>You should be able to add a global override to the flow percentage on Marlin firmware printers.</p> <p>Add this line somewhere in your start code:</p> <p><code>M221 S97 ; Flow Percentage hard set.</code></p> <p>In Cura, edit the printer's machine settings. The <code>S</code> is the percentage. In my case, 97 % works for PLA+.</p> <p>Here is a link you might find useful. <a href="https://marlinfw.org/docs/gcode/M221.html" rel="nofollow noreferrer">Marlin Docs</a></p>
1,506
<p>I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering about VS 2008 Team Suite, but I suppose tips for VS 2008 Pro on up would be suitable too since some MSTest functionality is now included with those versions as well.</p>
<p>MSTest is certainly not as efficient or extensible as some of the open source frameworks, but it is workable. Since the question asks about making life easier with MSTest and not about alternatives, here are my MSTest tips.</p> <ul> <li><strong>Shortcuts</strong>. Like Haacked said, take a few seconds to learn the shortcuts.</li> <li><strong>Current Context</strong>. Since MSTest is so slow, run tests only in the current context when you can. (<strong><kbd>CTRL</kbd>+<kbd>R</kbd></strong>, <strong><kbd>CTRL</kbd>+<kbd>T</kbd></strong>). If your cursor is in a test method, this will only run the method. If your cursor is outside a method, but in a test class, this will only run the test. And with namespace, etc etc</li> <li><strong>Efficient tests and organization</strong>. It's dog slow. Make things as best as you can by writing efficient tests. Move slow tests to other test classes or projects so you can run the fast tests more frequently.</li> <li><strong>Testing with WCF</strong>. If you're testing services, be sure to DEBUG tests rather than RUN tests so Visual Studio can fire up the ASP.NET development web servers. After these are up, then you can go back to RUN, but it can be easier to just always DEBUG so you don't have to think about it.</li> <li><strong>Config Files</strong>. Edit your test-run configuration to move .config files into the test execution folder.</li> <li><strong>Integration with Source Safe</strong>. You need to be aware that MSTest hates SourceSafe and the feeling is mutual. Because MSTest wants to put test files under source control, and add them to the solution, it must check out the solution every time you run tests. So SourceSafe must be running in multi-check-out mode to avoid killing your fellow developers.</li> <li><strong>Ignore the fluff</strong> With MSTest, you get a dozen different windows and views. Test Runs, Test View, Test Lists ... they're all less-than-helpful. Stick with Test Results and you'll be much happier. </li> <li><strong>Stick with "Unit Tests"</strong>. When you add a new test, you can add an ordered test, a unit test, or run through a wizard. Stick with just plain simple unit tests.</li> </ul>
<p>To answer a non-pointed question, my answer would be "probably NUnit just stays out of your face."</p> <p><strong>Disclaimer</strong>: I've no actual experience with MS version of xUnit, however I hear problems like 'You need to install the gigantic idea just to run your tests on a separate machine' - which is a complete No-No. Other than that MS has this way of contorting the right path for a newbie via some kind of IDE bell/whistle that runs counter to the whole idea. Like generating tests from classes was one I remember from a year or so back.. that defeats the whole point of <em>test-driving</em> - your design is supposed to emerge from tiny steps of RGR: writing a test-make it pass-refactor. If you use that tool - it robs you of the entire experience. </p> <p>I'll stop with my sermon.. now :)</p>
4,922
<p>I've got a Palm OS/Garnet 68K application that uses a third-party static library built with CodeWarrior. Can I rebuilt the application using PRC-Tools, the port of GCC for the Palm OS platform and still link with the third-party library?</p>
<p><em>(Expanding on Ben's original answer... not sure of the exact etiquette for that but I can't edit yet so I'll re-post)</em></p> <p>No, CodeWarrior uses a different object file format than PRC-Tools. Also, the compiler support libraries are different, so even if the code could be statically linked together, it may use symbols in a different way.</p> <p>However, if you can wrap the third-party static library into a Palm OS shared library using CodeWarrior, then you should be able to call it from PRC-Tools applications. The Palm OS shared library interface works across tools, but shared libraries have limited system support so you'll need to be sure the original code doesn't use global variables for this to work.</p> <p>For more information on shared libraries, see <a href="http://www.isaac.cs.berkeley.edu/pilot/shlib.html" rel="nofollow noreferrer" title="Shared libraries on the Palm Pilot">Shared libraries on the Palm Pilot</a>.</p>
<p>No, CodeWarrior uses a different object file format than PRC-Tools. Also, the compiler support libraries are different, so even if the code could be linked together, it may use symbols in a different way.</p> <p>However, if you can wrap the third-party library into a shared library using CodeWarrior, then you should be able to call it from PRC-Tools applications. The shared library interface works across tools, but shared libraries have limited system support, so you'll need to be sure the original code doesn't use global variables for this to work.</p>
3,784
<p>I am bit confused about ADO.Net Data Services.</p> <p>Is it just meant for creating RESTful web services? I know WCF started in the SOAP world but now I hear it has good support for REST. Same goes for ADO.Net data services where you can make it work in an RPC model if you cannot look at everything from a resource oriented view.</p> <p>At least from the demos I saw recently, it looks like ADO.Net Data Services is built on WCF stack on the server. Please correct me if I am wrong.</p> <p>I am not intending to start a REST vs SOAP debate but I guess things are not that crystal clear anymore.</p> <p>Any suggestions or guidelines on what to use where?</p>
<p>In my view ADO.Net data services is for creating restful services that are closely aligned with your domain model, that is the models themselves are published rather then say some form of DTO etc.</p> <p>Using it for RPC style services seems like a bad fit, though unfortunately even some very basic features like being able to perform a filtered counts etc. aren't available which often means you'll end up using some RPC just to meet the requirements of your customers i.e. so you can display a paged grid etc.</p> <p>WCF 3.5 pre-SP1 was a fairly weak RESTful platform, with SP1 things have improved in both Uri templates and with the availability of ATOMPub support, such that it's becoming more capable, but they don't really provide any elegant solution for supporting say JSON, XML, ATOM or even something more esoteric like payload like CSV simultaneously, short of having to make use of URL rewriting and different extension, method name munging etc. - rather then just selecting a serializer/deserializer based on the headers of the request.</p> <p>With WCF it's still difficult to create services that work in a more a natural restful manor i.e. where resources include urls, and you can transition state by navigating through them - it's a little clunky - ADO.Net data services does this quite well with it's AtomPub support though.</p> <p>My recommendation would be use web services where they're naturally are services and strong service boundaries being enforced, use ADO.Net Data services for rich web-style clients (websites, ajax, silverlight) where the composability of the url queries can save a lot of plumbing and your domain model is pretty basic... and roll your own REST layer (perhaps using an MVC framework as a starting point) if you need complete control over the information i.e. if you're publishing an API for other developers to consume on a social platform etc.</p> <p>My 2ø worth!</p>
<p>Actually, there are options to filter and skip to get the page like feature among others.</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc668791.aspx" rel="nofollow noreferrer">See here:</a> </p>
7,149
<p>What does it mean when a <a href="http://en.wikipedia.org/wiki/PostgreSQL" rel="noreferrer">PostgreSQL</a> process is "idle in transaction"?</p> <p>On a server that I'm looking at, the output of "ps ax | grep postgres" I see 9 PostgreSQL processes that look like the following:</p> <pre><code>postgres: user db 127.0.0.1(55658) idle in transaction </code></pre> <p>Does this mean that some of the processes are hung, waiting for a transaction to be committed? Any pointers to relevant documentation are appreciated.</p>
<p>The <a href="http://www.postgresql.org/docs/8.3/interactive/monitoring-ps.html" rel="noreferrer">PostgreSQL manual</a> indicates that this means the transaction is open (inside BEGIN) and idle. It's most likely a user connected using the monitor who is thinking or typing. I have plenty of those on my system, too.</p> <p>If you're using Slony for replication, however, the <a href="http://slony1.projects.postgresql.org/slony1-1.2.6/doc/adminguide/faq.html" rel="noreferrer">Slony-I FAQ</a> suggests <code>idle in transaction</code> may mean that the network connection was terminated abruptly. Check out the discussion in that FAQ for more details.</p>
<p>As mentioned here: <a href="http://archives.postgresql.org/pgsql-bugs/2008-06/msg00102.php" rel="noreferrer">Re: BUG #4243: Idle in transaction</a> it is probably best to check your pg_locks table to see what is being locked and that might give you a better clue where the problem lies.</p>
7,386
<p>My Printrbot simple metal's extruder is jammed and I need to heat it up to unjam it. Unfortunately, the printer does't want to connect to my laptop regardless of the program I'm using (Repetier-Host or Cura 15). </p> <p>Is there a way to use a micro SD card to heat up the printer hotend but not print anything?</p>
<p>Sure there is. As you use Cura, you can grab any G-code file (you already have) and use it to set hotend temperature (delete the actual printing part from the file) to get something like this:</p> <pre><code>;FLAVOR:Marlin ;TIME:102 ;Filament used: 0.0573674m ;Layer height: 0.2 ;Generated with Cura_SteamEngine 3.3.1 ; M190 S60 ;-&gt; this sets the bed temperature so we can comment it out ; the next line sets the hotend to 200 degrees Celsius M104 S200 </code></pre> <p>As every line that starts with a semi-colon is a comment and is ignored by the printer, <code>M104 S200</code>, would be the only line you need in the printout file.</p> <p>If you're interested in knowing more - look here: <a href="https://reprap.org/wiki/G-code" rel="nofollow noreferrer">G-codes on reprap wiki</a></p>
<p>I heated it up and was able to extract some plastic that had gotten jammed in the hot ends opening. </p> <p>I heated up the hotend by commenting out all the other lines of code in Cura's start and end G-code tabs (must have missed some because the printer moved. I would just unplug the printer when it stopped moving). I used an SD card but it would probably work with USB too. I tried to force the filament in to force the jam out of the hotend, but that did nothing.</p> <p>I took apart the extruder assembly and discovered that a section of filament that was too wide got stuck in the hotend's entrance. I pulled the filament out using me multitool and put the extruder back together. Hope this helps others with a similar problem.</p>
893
<p>The Gang of Four's <a href="http://en.wikipedia.org/wiki/Design_Patterns" rel="nofollow noreferrer">Design Patterns</a> uses a word processor as an example for at least a few of their patterns, particularly Composite and Flyweight.</p> <p>Other than by using C or C++, could you really use those patterns and the object-oriented overhead they entail to write a high-performing fully featured word processor? </p> <p>I know that Eclipse is written in Java but I haven't used it much so I don't know if it's all that fast or as polished as something like Visual Studio, which has a C++ based text editing system.</p> <hr> <p>I only used C++ and Java as examples. The question has more to do with the overhead of having a lot of in-memory objects like you would in an application such as a word processor or even a game. </p> <p>Design patterns promote abstraction at the expense of parsimony even though they usually point out when you might take some kind of performance hit. Word processors and especially games get the most benefit from being as close to the metal as possible. </p> <p>I was just wondering if anyone knew of an fast object-oriented word processor or text editor that wasn't written in C++, and whether they'd build one using patterns or would they forgoe a lot of the abstracting away of things?</p>
<p>Flyweight really is just a way of conserving resources in situations where there are thousands of objects with intrinsic shared state, so it could be useful in higher level languages than C/C++. Maybe the GoF's example using glyphs in a document was not the best choice to illustrate this pattern.</p> <p>I think there's a lot more to building a high performance word processor than just these basic patterns though - not sure whether there is anything in GoF that rules out being able to successfully do this.</p> <p>Generally, Visual Studio (VS) is more advanced and performs significantly better than Eclipse - at least, the versions of VS that I have seen. Eclipse is one of the most impressive Java applications out there though, it runs quite well on more recent machines with lots of RAM.</p>
<p>This question actually seems to be about Java vs. C++ performance, and that's not the object orientation so much as running on a virtual machine with garbage collection and such.</p> <p><a href="http://scribblethink.org/Computer/javaCbenchmark.html" rel="nofollow noreferrer">This whitepaper</a> on Java vs. C++ performance might be worth a read.</p>
3,641
<p>From what I understand, UV curing of resin prints works by starting a chemical reaction that hardens the resin permanently.</p> <p>Also, a curing step after print is needed to speed up the print and also to reduce the curing during print, which would cure resin beyond the current layer.</p> <p>However, what is the transmissivity of UV light in partially cured prints? If I print a more massive object, or if I use an opaque resin, how deep will the object harden properly? Absorption is always exponential, meaning that it decreases quickly with depth.</p> <p>Depending on the resin, how thick prints can be effectively cured? This information is not provided with the resin, which I actually would expect from reputable manufacturers.</p>
<p>A wide line works if there is something below it to squeeze the filament against, but if you don't have a full layer below it, it will stay thinner and it will droop. I would not use extreme ratios on overhangs. Still, do a parametric test: a overhang tower (a compact one) at different line widths and layer heights. If you test 3 layer heights and 3 line widths, it's only 9 short prints.</p> <p>However, as you can see in filament reviews, different materials behave differently. I think there is no <em>a priori</em> optimal value.</p>
<p>In terms of Cura's model for showing overhangs, I'm nearly sure it's just the ratio - rise over run, or rather run over rise. And indeed that's what makes sense mathematically:</p> <p>At least some portion of the wall extrusion in layer N+1 needs to sit on top of the corresponding wall extrusion in layer N. For a given 3D surface slope, the "run" - the distance the cross-section moves from one layer to the next, which needs to be bounded by some fraction of the line width - varies proportionally to the "rise" - the layer height.</p>
1,665
<p>Often, the pre-generated G-code is enough for start and end. However, sometimes we want to have something different. In this case: how to generate an audible alert of something like 4 bleeps at the end of the print, after putting the printer into the end position and when the bed has reached a "safe" 30 °C?</p>
<p>Let's put the parts one by one:</p> <ul> <li>Wait for bed temperature being at 30 °C: <code>M190 R30</code></li> <li>Play Bleep for 1/5th of a second: <code>M300 S440 P200</code></li> <li>Wait for 1/5th of a second: <code>G4 P200</code></li> </ul> <p>That gives:</p> <pre><code>M190 R30 M140 S0 M300 S440 P200 G4 P200 M300 S440 P200 G4 P200 M300 S440 P200 G4 P200 M300 S440 P200 G4 P200 </code></pre> <p>Just for 0scar:</p> <pre><code>M300 S1396.91 P400 ;f7 G4 P400 M300 S1661.22 P600 ;as7 M300 S1396.91 P400 ;f7 M300 S1396.91 P200 ;f7 M300 S1864.66 P400 ;b7 M300 S1244.51 P400 ;es7 M300 S1396.91 P400 ;f7 G4 P400 M300 S2093.00 P400 ;c8 M300 S1396.91 P400 ;f7 M300 S1396.91 P200 ;f7 M300 S2217.46 P400 ;des8 M300 S2093.00 P400 ;c8 M300 S1661.22 P400 ;as7 M300 S1396.91 P400 ;f7 M300 S2093.00 P400 ;c8 M300 S2793.83 P400 ;f8 M300 S1244.51 P400 ;es7 M300 S1244.51 P200 ;es7 M300 S1046.50 P400 ;c7 M300 S1567.98 P400 ;g7 M300 S1396.91 P1600 ;f7 </code></pre>
<p>Trish's version is good but wait for bed temperature being at 30 °C (<code>M190 R30</code>) before setting the temperature to 0 °C (<code>M140 S0</code>)</p> <p>So this is my version:</p> <pre><code>G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way G1 Y150 F5000 ;move completed part out M84 ;steppers off G90 ;absolute positioning M190 R30 ;waits until cooling to 30 °C M300 S300 P1000 ;beep M300 S300 P1000 ;beep M300 S300 P1000 ;beep M300 S300 P1000 ;beep M104 S0 ;extruder heater off M140 S0 ;heated bed heater off </code></pre>
1,472
<p>How do I convert a DateTime structure to its equivalent <a href="http://www.ietf.org/rfc/rfc3339.txt" rel="noreferrer">RFC 3339</a> formatted string representation and/or parse this string representation back to a <a href="http://msdn.microsoft.com/en-us/library/system.datetime.aspx" rel="noreferrer">DateTime</a> structure? The RFC-3339 date-time format is used in a number of specifications such as the <a href="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#date.constructs" rel="noreferrer">Atom Syndication Format</a>.</p>
<p>This is an implementation in C# of how to parse and convert a DateTime to and from its RFC-3339 representation. The only restriction it has is that the DateTime is in Coordinated Universal Time (UTC).</p> <pre><code>using System; using System.Globalization; namespace DateTimeConsoleApplication { /// &lt;summary&gt; /// Provides methods for converting &lt;see cref="DateTime"/&gt; structures to and from the equivalent RFC 3339 string representation. /// &lt;/summary&gt; public static class Rfc3339DateTime { //============================================================ // Private members //============================================================ #region Private Members /// &lt;summary&gt; /// Private member to hold array of formats that RFC 3339 date-time representations conform to. /// &lt;/summary&gt; private static string[] formats = new string[0]; /// &lt;summary&gt; /// Private member to hold the DateTime format string for representing a DateTime in the RFC 3339 format. /// &lt;/summary&gt; private const string format = "yyyy-MM-dd'T'HH:mm:ss.fffK"; #endregion //============================================================ // Public Properties //============================================================ #region Rfc3339DateTimeFormat /// &lt;summary&gt; /// Gets the custom format specifier that may be used to represent a &lt;see cref="DateTime"/&gt; in the RFC 3339 format. /// &lt;/summary&gt; /// &lt;value&gt;A &lt;i&gt;DateTime format string&lt;/i&gt; that may be used to represent a &lt;see cref="DateTime"/&gt; in the RFC 3339 format.&lt;/value&gt; /// &lt;remarks&gt; /// &lt;para&gt; /// This method returns a string representation of a &lt;see cref="DateTime"/&gt; that /// is precise to the three most significant digits of the seconds fraction; that is, it represents /// the milliseconds in a date and time value. The &lt;see cref="Rfc3339DateTimeFormat"/&gt; is a valid /// date-time format string for use in the &lt;see cref="DateTime.ToString(String, IFormatProvider)"/&gt; method. /// &lt;/para&gt; /// &lt;/remarks&gt; public static string Rfc3339DateTimeFormat { get { return format; } } #endregion #region Rfc3339DateTimePatterns /// &lt;summary&gt; /// Gets an array of the expected formats for RFC 3339 date-time string representations. /// &lt;/summary&gt; /// &lt;value&gt; /// An array of the expected formats for RFC 3339 date-time string representations /// that may used in the &lt;see cref="DateTime.TryParseExact(String, string[], IFormatProvider, DateTimeStyles, out DateTime)"/&gt; method. /// &lt;/value&gt; public static string[] Rfc3339DateTimePatterns { get { if (formats.Length &gt; 0) { return formats; } else { formats = new string[11]; // Rfc3339DateTimePatterns formats[0] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; formats[1] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK"; formats[2] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK"; formats[3] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK"; formats[4] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK"; formats[5] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK"; formats[6] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK"; formats[7] = "yyyy'-'MM'-'dd'T'HH':'mm':'ssK"; // Fall back patterns formats[8] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; // RoundtripDateTimePattern formats[9] = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern; formats[10] = DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern; return formats; } } } #endregion //============================================================ // Public Methods //============================================================ #region Parse(string s) /// &lt;summary&gt; /// Converts the specified string representation of a date and time to its &lt;see cref="DateTime"/&gt; equivalent. /// &lt;/summary&gt; /// &lt;param name="s"&gt;A string containing a date and time to convert.&lt;/param&gt; /// &lt;returns&gt;A &lt;see cref="DateTime"/&gt; equivalent to the date and time contained in &lt;paramref name="s"/&gt;.&lt;/returns&gt; /// &lt;remarks&gt; /// The string &lt;paramref name="s"/&gt; is parsed using formatting information in the &lt;see cref="DateTimeFormatInfo.InvariantInfo"/&gt; object. /// &lt;/remarks&gt; /// &lt;exception cref="ArgumentNullException"&gt;&lt;paramref name="s"/&gt; is a &lt;b&gt;null&lt;/b&gt; reference (Nothing in Visual Basic).&lt;/exception&gt; /// &lt;exception cref="FormatException"&gt;&lt;paramref name="s"/&gt; does not contain a valid RFC 3339 string representation of a date and time.&lt;/exception&gt; public static DateTime Parse(string s) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ if(s == null) { throw new ArgumentNullException("s"); } DateTime result; if (Rfc3339DateTime.TryParse(s, out result)) { return result; } else { throw new FormatException(String.Format(null, "{0} is not a valid RFC 3339 string representation of a date and time.", s)); } } #endregion #region ToString(DateTime utcDateTime) /// &lt;summary&gt; /// Converts the value of the specified &lt;see cref="DateTime"/&gt; object to its equivalent string representation. /// &lt;/summary&gt; /// &lt;param name="utcDateTime"&gt;The Coordinated Universal Time (UTC) &lt;see cref="DateTime"/&gt; to convert.&lt;/param&gt; /// &lt;returns&gt;A RFC 3339 string representation of the value of the &lt;paramref name="utcDateTime"/&gt;.&lt;/returns&gt; /// &lt;remarks&gt; /// &lt;para&gt; /// This method returns a string representation of the &lt;paramref name="utcDateTime"/&gt; that /// is precise to the three most significant digits of the seconds fraction; that is, it represents /// the milliseconds in a date and time value. /// &lt;/para&gt; /// &lt;para&gt; /// While it is possible to display higher precision fractions of a second component of a time value, /// that value may not be meaningful. The precision of date and time values depends on the resolution /// of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's /// resolution is approximately 10-15 milliseconds. /// &lt;/para&gt; /// &lt;/remarks&gt; /// &lt;exception cref="ArgumentException"&gt;The specified &lt;paramref name="utcDateTime"/&gt; object does not represent a &lt;see cref="DateTimeKind.Utc"&gt;Coordinated Universal Time (UTC)&lt;/see&gt; value.&lt;/exception&gt; public static string ToString(DateTime utcDateTime) { if (utcDateTime.Kind != DateTimeKind.Utc) { throw new ArgumentException("utcDateTime"); } return utcDateTime.ToString(Rfc3339DateTime.Rfc3339DateTimeFormat, DateTimeFormatInfo.InvariantInfo); } #endregion #region TryParse(string s, out DateTime result) /// &lt;summary&gt; /// Converts the specified string representation of a date and time to its &lt;see cref="DateTime"/&gt; equivalent. /// &lt;/summary&gt; /// &lt;param name="s"&gt;A string containing a date and time to convert.&lt;/param&gt; /// &lt;param name="result"&gt; /// When this method returns, contains the &lt;see cref="DateTime"/&gt; value equivalent to the date and time /// contained in &lt;paramref name="s"/&gt;, if the conversion succeeded, /// or &lt;see cref="DateTime.MinValue"&gt;MinValue&lt;/see&gt; if the conversion failed. /// The conversion fails if the s parameter is a &lt;b&gt;null&lt;/b&gt; reference (Nothing in Visual Basic), /// or does not contain a valid string representation of a date and time. /// This parameter is passed uninitialized. /// &lt;/param&gt; /// &lt;returns&gt;&lt;b&gt;true&lt;/b&gt; if the &lt;paramref name="s"/&gt; parameter was converted successfully; otherwise, &lt;b&gt;false&lt;/b&gt;.&lt;/returns&gt; /// &lt;remarks&gt; /// The string &lt;paramref name="s"/&gt; is parsed using formatting information in the &lt;see cref="DateTimeFormatInfo.InvariantInfo"/&gt; object. /// &lt;/remarks&gt; public static bool TryParse(string s, out DateTime result) { //------------------------------------------------------------ // Attempt to convert string representation //------------------------------------------------------------ bool wasConverted = false; result = DateTime.MinValue; if (!String.IsNullOrEmpty(s)) { DateTime parseResult; if (DateTime.TryParseExact(s, Rfc3339DateTime.Rfc3339DateTimePatterns, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out parseResult)) { result = DateTime.SpecifyKind(parseResult, DateTimeKind.Utc); wasConverted = true; } } return wasConverted; } #endregion } } </code></pre>
<p>In .NET (assuming UTC):</p> <pre><code> datetime.ToString("YYYY-MM-DD'T'HH:mm:ssZ") </code></pre> <p><code>DateTime.Parse()</code> can be used to convert back into a <code>DateTime</code> structure.</p>
3,772
<p>What would be the best strategy to generate anagrams.</p> <blockquote> <pre><code>An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; ex. </code></pre> <ul> <li><strong>Eleven plus two</strong> is anagram of <strong><em>Twelve plus one</em></strong> </li> <li><strong>A decimal point</strong> is anagram of <strong><em>I'm a dot in place</em></strong></li> <li><strong>Astronomers</strong> is anagram of <strong><em>Moon starers</em></strong></li> </ul> </blockquote> <p>At first it looks straightforwardly simple, just to jumble the letters and generate all possible combinations. But what would be the efficient approach to generate only the words in dictionary.</p> <p>I came across this page, <a href="http://lojic.com/blog/2007/10/22/solving-anagrams-in-ruby/" rel="noreferrer">Solving anagrams in Ruby</a>. </p> <p>But what are your ideas?</p>
<p>Most of these answers are horribly inefficient and/or will only give one-word solutions (no spaces). My solution will handle any number of words and is very efficient.</p> <p>What you want is a trie data structure. Here's a <strong>complete</strong> Python implementation. You just need a word list saved in a file named <code>words.txt</code> You can try the Scrabble dictionary word list here:</p> <p><a href="http://www.isc.ro/lists/twl06.zip" rel="noreferrer">http://www.isc.ro/lists/twl06.zip</a></p> <pre class="lang-py prettyprint-override"><code>MIN_WORD_SIZE = 4 # min size of a word in the output class Node(object): def __init__(self, letter='', final=False, depth=0): self.letter = letter self.final = final self.depth = depth self.children = {} def add(self, letters): node = self for index, letter in enumerate(letters): if letter not in node.children: node.children[letter] = Node(letter, index==len(letters)-1, index+1) node = node.children[letter] def anagram(self, letters): tiles = {} for letter in letters: tiles[letter] = tiles.get(letter, 0) + 1 min_length = len(letters) return self._anagram(tiles, [], self, min_length) def _anagram(self, tiles, path, root, min_length): if self.final and self.depth &gt;= MIN_WORD_SIZE: word = ''.join(path) length = len(word.replace(' ', '')) if length &gt;= min_length: yield word path.append(' ') for word in root._anagram(tiles, path, root, min_length): yield word path.pop() for letter, node in self.children.iteritems(): count = tiles.get(letter, 0) if count == 0: continue tiles[letter] = count - 1 path.append(letter) for word in node._anagram(tiles, path, root, min_length): yield word path.pop() tiles[letter] = count def load_dictionary(path): result = Node() for line in open(path, 'r'): word = line.strip().lower() result.add(word) return result def main(): print 'Loading word list.' words = load_dictionary('words.txt') while True: letters = raw_input('Enter letters: ') letters = letters.lower() letters = letters.replace(' ', '') if not letters: break count = 0 for word in words.anagram(letters): print word count += 1 print '%d results.' % count if __name__ == '__main__': main() </code></pre> <p>When you run the program, the words are loaded into a trie in memory. After that, just type in the letters you want to search with and it will print the results. It will only show results that use all of the input letters, nothing shorter.</p> <p>It filters short words from the output, otherwise the number of results is huge. Feel free to tweak the <code>MIN_WORD_SIZE</code> setting. Keep in mind, just using "astronomers" as input gives 233,549 results if <code>MIN_WORD_SIZE</code> is 1. Perhaps you can find a shorter word list that only contains more common English words.</p> <p>Also, the contraction "I'm" (from one of your examples) won't show up in the results unless you add "im" to the dictionary and set <code>MIN_WORD_SIZE</code> to 2.</p> <p>The trick to getting multiple words is to jump back to the root node in the trie whenever you encounter a complete word in the search. Then you keep traversing the trie until all letters have been used.</p>
<p>Off the top of my head, the solution that makes the most sense would be to pick a letter out of the input string randomly and filter the dictionary based on words that start with that. Then pick another, filter on the second letter, etc. In addition, filter out words that can't be made with the remaining text. Then when you hit the end of a word, insert a space and start it over with the remaining letters. You might also restrict words based on word type (e.g. you wouldn't have two verbs next to each other, you wouldn't have two articles next to each other, etc).</p>
7,894
<p>What is the general feeling amongst developers regarding the changing of files in the 12 hive. For example if you were asked to remove the sign is a different user menu item, you would need to modify the relevent user control on the filesystem. Now if you just go and modify it via notepad or copy over and then if you go and bring a new server into the farm you will need to remember to do the same on the new server. Obvouisly you could deploy the changed file as a solution and have that done automatically, but I'm just wondering if people are hesitant to make changes to the default installed files?</p>
<p>I have done a bit of SharePoint development, and I must tell you that messing with the 12-hive is a ticket to a world of pain if you ever want to move the app.</p> <p>I'd rather hack up some javascript to hide it, at least that can be bound to the master page, which is much more portable.<br> And remember, you never know when the next service pack comes around and nukes your changes :)</p>
<p>Not sure if there is much use pitching in, as everyone else pretty much has it covered, but I would also say don't do it. As tempting as it is, its just impossible to know the full impact of that little change you have made.</p> <p>From a support perspective you will make it difficult for Microsoft support (patches/hotfixes). From a maintenance perspective you are also opening yourself up to long term costs.</p> <p>Go the javascript route.</p>
4,643
<p>I have apache 2.2 and tomcat 5.5 running on a Windows XP machine.</p> <p>Which tomcat/apache connector is the easiest to set up and is well documented? </p>
<p><code><a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html" rel="noreferrer">mod_proxy_ajp</a></code> would be the easiest to use if you are using Apache 2.2. It is part of the Apache distribution so you don't need to install any additional software.</p> <p>In your <code>httpd.conf</code> you need to make sure that <code>mod_proxy</code> and <code>mod_proxy_ajp</code> are loaded:</p> <pre> LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so </pre> <p>Then you can use the <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass" rel="noreferrer">ProxyPass</a> and <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse" rel="noreferrer">ProxyPassReverse</a> directives as follows:</p> <pre> ProxyPass /portal ajp://localhost:8009/portal ProxyPassReverse /portal ajp://localhost:8009/portal </pre> <p>You should consult the Apache 2.2 documentation for a full catalog of the directives available.</p>
<p><code>mod_jk</code>, or simply just use <code>mod_proxy</code> even though it's not really a Tomcat connector.</p>
9,576
<p>What do I lose by adopting test driven design?</p> <p>List only negatives; do not list benefits written in a negative form.</p>
<p>If you want to do "real" TDD (read: test first with the red, green, refactor steps) then you also have to start using mocks/stubs, when you want to test integration points.</p> <p>When you start using mocks, after a while, you will want to start using Dependency Injection (DI) and a Inversion of Control (IoC) container. To do that you need to use interfaces for everything (which have a lot of pitfalls themselves). </p> <p>At the end of the day, you have to write a lot more code, than if you just do it the "plain old way". Instead of just a customer class, you also need to write an interface, a mock class, some IoC configuration and a few tests.</p> <p>And remember that the test code should also be maintained and cared for. Tests should be as readable as everything else and it takes time to write good code.</p> <p>Many developers don't quite understand how to do all these "the right way". But because everybody tells them that TDD is the only true way to develop software, they just try the best they can.</p> <p>It is much harder than one might think. Often projects done with TDD end up with a lot of code that nobody really understands. The unit tests often test the wrong thing, the wrong way. And nobody agrees how a good test should look like, not even the so called gurus.</p> <p>All those tests make it a lot harder to "change" (opposite to refactoring) the behavior of your system and simple changes just becomes too hard and time consuming.</p> <p>If you read the TDD literature, there are always some very good examples, but often in real life applications, you must have a user interface and a database. This is where TDD gets really hard, and most sources don't offer good answers. And if they do, it always involves more abstractions: mock objects, programming to an interface, MVC/MVP patterns etc., which again require a lot of knowledge, and... you have to write even more code.</p> <p>So be careful... if you don't have an enthusiastic team and at least one experienced developer who knows how to write good tests and also knows a few things about good architecture, you really have to think twice before going down the TDD road.</p>
<p>TDD requires a certain organization for your code. This might be inefficient or difficult to read. Or even architecturally wrong; for example, since <code>private</code> methods cannot be called outside a class, you have to make methods non-private to make them testable, which is just wrong.</p> <p>When code changes, you have to change the tests as well. With refactoring this can be a lot of extra work.</p>
8,987
<p>I am trying to resolve this for months and have tried almost everything, I guess.</p> <p>I am using Marlin firmware on a custom extruder with a custom fabricated heating block in which heater and thermistor (Marlin Temp_Sensor 11) are set up perpendicular to each other. Whenever I try to heat it up to 200 degree Celsius, it falls short and fails at around 140 and that too with a very low pace (especially between 100 to 140).</p> <p>I have already tried PID tuning, ADC values calibration, etc. Also, I have tried varying the values of <code>Watch_Temp_Sensor</code> in <code>Configuration_Adv.h</code>. I don't know what's going wrong.</p> <p>Can extruder coldend fan have an effect on the heating of thermal block? I have tried heating the hotend without cooling the coldend, although it takes around 10-12 minutes yet it works perfectly fine then and it reaches to the desired temperature.</p> <p>The power supply is working fine</p> <p>P.S. I am not using any kind of pre-built extruder like E3D etc.</p> <p>This is the setup:</p> <p><a href="https://i.stack.imgur.com/5xvI9.jpg" rel="nofollow noreferrer" title="Photo of hotend"><img src="https://i.stack.imgur.com/5xvI9.jpg" alt="Photo of hotend" title="Photo of hotend"></a></p> <p>This is the thermistor setup:</p> <p><a href="https://i.stack.imgur.com/tnbVn.jpg" rel="nofollow noreferrer" title="Thermistor setup"><img src="https://i.stack.imgur.com/tnbVn.jpg" alt="Thermistor setup" title="Thermistor setup"></a></p> <p>This is a view of heater position:</p> <p><a href="https://i.stack.imgur.com/Vl3b0.jpg" rel="nofollow noreferrer" title="Heater position"><img src="https://i.stack.imgur.com/Vl3b0.jpg" alt="Heater position" title="Heater position"></a></p>
<p>There are many unknowns at this point, you need to work methodically through each stage. You probably also need some test equipment, at least a basic multimeter. Ideally a temperature probe too.</p> <p>First, check that your power supply can drive the hot-end directly. You already know how long it takes to reach 120°C, so be sure to not let it heat too far beyond this time. This will bypass all of the control logic, and risks overheating your hotend/burning out the heater - but it should be OK if you limit to a few minutes.</p> <p>Check the temperature reading, and cross check with some PLA or other low melting point filament to see if you actually reach ~180°C. Check the voltage as close to the heating cartridge as you have a connection point. It should be at least 11V (with a 12V PSU). My guess is that you have a bad connection somewhere...</p> <p>If you observe the hotend getting hot enough to melt plastic, check the thermistor readings. You should see a fairly constant rate of heating well past 200°C. However, I expect this will work fine.</p> <p>Finally, check the hotend mosfet drive and output as the hotend reaches the target temperature. It should be on, then switching on/off, then off as you pass the target.</p> <p>If this all looks OK, repeat but with the board in-circuit and controlling the heater. It may be that the mosfet is damaged, or it is not being driven very well - but to progress past that point we need to see voltage readings at various points.</p>
<p>Now that we can see the real problem, your heater cartridge doesn't have good thermal contact to the block, and the block does not have good contact to the nozzle.</p> <p>Where is your heatbreak? You need to perform a basic analysis of the heat flow in your design. Anything that is expected to conduct needs to be clamped, and to have thermal paste. Any connection between hot and cold which is used for mechanical support needs to have minimal cross section, and maybe use materials with poor thermal conductivity.</p> <h2>Example</h2> <p>Here is a simplified diagram, with some assumed thermal resistances. Note that the geometry is not representative since your nozzle is actually within the throat, not between the heater and the throat as I've shown. </p> <p><a href="https://i.stack.imgur.com/CtbEO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CtbEO.png" alt="Heat Flow"></a> </p> <p>Total thermal resistance is 7.5 °C/W. Maximum heat in is 40W, so the heater is at 320°C, and the nozzle can reach 300°C.</p> <p>Replace the heater with a 20W element, and the nozzle drops to 170°C.</p> <p>Keep the heater at 20W, to achieve 220° at the nozzle, the throat needs to provide at least 4.5°C/W thermal resistance.</p> <p>Assuming you're using a 10 mm diameter aluminium bar as a heat break, it needs to be 7 cm long with a 20 W heater. If you use steel instead, the length can be reduced by a factor of about 3.</p>
1,027
<p>What's the best way of implementing a multiple choice option in Windows Forms? I want to enforce a single selection from a list, starting with a default value.</p> <p>It seems like a ComboBox would be a good choice, but is there a way to specify a non-blank default value?<br> I could just set it in the code at some appropriate initialisation point, but I feel like I'm missing something.</p>
<p>If you only want one answer from the group, then a RadioButton control would be your best fit or you could use the ComboBox if you will have a lot of options. To set a default value, just add the item to the ComboBox's collection and set the SelectedIndex or SelectedItem to that item.</p> <p>Depending on how many options you are looking at, you can use a ListBox with the SelectionMode property set to MultiSimple, if it will be multiple choice or you could use the CheckBox control.</p>
<p>If you are giving the user a small list of choices then stick with the radio buttons. However, if you will want want to use the combo box for dynamic or long lists. Set the style to DropDownList.</p> <pre><code>private sub populateList( items as List(of UserChoices)) dim choices as UserChoices dim defaultChoice as UserChoices for each choice in items cboList.items.add(choice) '-- you could do user specific check or base it on some other '---- setting to find the default choice here if choice.state = _user.State or choice.state = _settings.defaultState then defaultChoice = choice end if next '-- you chould select the first one if cboList.items.count &gt; 0 then cboList.SelectedItem = cboList.item(0) end if '-- continuation of hte default choice cboList.SelectedItem = defaultChoice end sub </code></pre>
3,543
<p>I've been unable to find a source for this information, short of looking through the Python source code myself to determine how the objects work. Does anyone know where I could find this online?</p>
<p>Checkout the <a href="http://wiki.python.org/moin/TimeComplexity" rel="noreferrer">TimeComplexity</a> page on the py dot org wiki. It covers set/dicts/lists/etc at least as far as time complexity goes.</p>
<p>If your asking what I think your asking, you can find them <a href="http://books.google.com/books?id=vpTAq4dnmuAC&amp;pg=RA1-PA476&amp;lpg=RA1-PA476&amp;dq=Big-O+of+Python+data+structures&amp;source=web&amp;ots=AOM5B5D7yA&amp;sig=deLGb6VrftTpnNYN6fILVbiirXM&amp;hl=en&amp;sa=X&amp;oi=book_result&amp;resnum=7&amp;ct=result#PRA1-PA479,M1" rel="nofollow noreferrer">Here</a>... page 476 and on.</p> <p>It's written around optimization techniques for Python; It's mostly Big-O notation of time efficiencies not much memory.</p>
6,704
<p>Is there an FTP browser hiding away in NetBeans 6.1? The help manual doesn't even suggest FTP exists. </p> <p>All I've been able to find so far is a tree viewer in the Services panel (no edit controls) and the ability to upload projects, folders and specific files from the Projects/Files views. Is there anywhere to delete or rename or will I have to keep switching back to my browser?</p> <p>I can see from the previews that there's a nice FTP controller in 6.5 but I'm not desperate enough to completely convert to a beta (yet).</p>
<p>It looks like something was recently added to netbeans for php... </p> <p><a href="http://blogs.oracle.com/netbeansphp/entry/ftp_support_added" rel="nofollow noreferrer">http://blogs.oracle.com/netbeansphp/entry/ftp_support_added</a></p> <p>don't know if you can make use of that...</p>
<p>The remotefs addin works for 6.5: <a href="http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=13195" rel="nofollow noreferrer">remotefs</a></p> <p><a href="https://i.stack.imgur.com/VoQbL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VoQbL.png" alt="alt text"></a><br> <sub>(source: <a href="http://plugins.netbeans.org/nbpluginportal/files/images/1220982228486_remotefs.png" rel="nofollow noreferrer">netbeans.org</a>)</sub> </p>
4,093
<p>I would like to know if I can open 2 different diagrams using MS Visio and each diagram have its own window. I've tried in several ways, but I always end up with 1 Visio window ...</p> <p>I'm using a triple monitor setup and I'd like to put one diagram to each side of my main monitor.</p> <p>[]'s</p> <p>André Casteliano</p> <p>PS: I'm using Visio 2007 here.</p>
<p>This allows you to open two or more instances of Visio so that you can view different Visio docs at the same time without going through the process to stretch the Visio window across two screens. I found this to be a simpler method and a bit easier to manipulate. If it doesn't work on your first try recheck the registry setting. It changed back on me a couple of times before it took.</p> <p>To implement the new behaviour, follow the following registry trick:</p> <ol> <li><p>Open Microsoft Visio.</p> </li> <li><p>Go to <code>Tools -&gt; Options -&gt; Advanced</code> or <code>File -&gt; Options -&gt; Advanced</code> in newer versions.</p> </li> <li><p>Check the Put all settings in Windows Registry option.</p> </li> <li><p>Close Microsoft Visio</p> </li> <li><p>Run Registry Editor (regedit).</p> </li> <li><p>Navigate to the following registry key:</p> <p><code>HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Visio\Application\</code><br /> <strong>Note:</strong> The value <code>12.0</code> in the key can be different. (i.e: for Visio 2010: <code>14.0</code>, Visio 2019: <code>16.0</code>)</p> </li> <li><p>In the right pane, right click on <code>SingleInstanceFileOpen</code>, and then select Modify. Update the value of <code>SingleInstanceFileOpen</code> from <code>1</code> to <code>0</code></p> </li> </ol> <p><strong>If the value <code>SingleInstanceFileOpen</code> doesn't exist</strong>, it can be created as a type REG_SZ.</p>
<p>Seems like my installation of Visio is the problem. I've tried on another computer here and it allow me to open 2 instances of the software.</p>
5,052
<p>I'm trying to get a Firefox plugin to read data from a HTTP get, parse the results and present them as links in a bookmark-like drop-down menu.</p> <p>My quesion then is: Does anyone have any sample code that will do this?</p>
<p>Having never developed one myself, I'm not certain how this is typically done in Firefox plugins, but since plugin scripting is JavaScript, I can probably help out with the loading part. Assuming a variable named url containing the URL you want to request:</p> <pre><code>var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange = function() { if(this.readyState == 4) { // Done loading? if(this.status == 200) { // Everything okay? // read content from this.responseXML or this.responseText } else { // Error occurred; handle it alert("Error " + this.status + ":\n" + this.statusText); } } }; xmlhttp.send(null); </code></pre> <p>A couple of notes on this code:</p> <ul> <li>You may want more sophisticated status code handling. For example, 200 is not the only non-error status code. Details on status codes can be found <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="nofollow noreferrer">here</a>.</li> <li>You probably want to have a timeout to handle the case where, for some reason, you don't get to readyState 4 in a reasonable amount of time.</li> <li>You may want to do things when earlier readyStates are received. <a href="http://www.w3.org/TR/XMLHttpRequest/#xmlhttprequest-object" rel="nofollow noreferrer">This page</a> documents the readyState codes, along with other properties and methods on the XMLHttpRequest object which you may find useful.</li> </ul>
<p>Robert Walker did a great job of describing <a href="https://stackoverflow.com/questions/40125/reading-from-a-http-get-presenting-in-firefox-bookmarks#40167">how to send the request</a>. You can read more about <a href="http://developer.mozilla.org/En/XMLHttpRequest" rel="nofollow noreferrer">Mozilla's xmlhttprequest here</a>.</p> <p><strike>I would just add that the response would be found (using Robert's code) using</p> <pre><code> xmlhttp.responseText </code></pre> <p></strike> (<em>Edit - i didn't read closely enough, thanks Robert</em>)</p> <p>You didn't indicate exactly what the data was, although you mentioned wanting to parse links from the data. You could the xmlhttp.responseText as an xml document, parse out the links, and place it into a menulist or whatever you like.</p>
6,134