instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>We have an SVN repository running on a Windows server, and I want to link internal documentation, feature changes, bugs and so on to code changes.</p>
<p>We've found WebSVN to be amazingly slow - the repository is too large for it (I think).</p>
<p>The team using it is primarily coding in C#, and while some have experience with other languages I'd really like a tool anyone on the team can maintain.</p>
<p>Most of the tools I've seen are based on PHP, Java, Python, etc. All languages the team could learn, but I'd rather something that uses the skills we already have.</p>
<p>Can you recommend a good web-based repository browser for SVN, ideally one that uses ASP.NET, <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a> and that runs on <a href="http://en.wikipedia.org/wiki/Internet_Information_Services" rel="nofollow noreferrer">IIS</a>?</p>
|
<p>Have a look at <a href="http://warehouseapp.com" rel="nofollow noreferrer">http://warehouseapp.com</a></p>
<p>It's Mongrel/Ruby/MySQL stack (should work on Windows though)</p>
<blockquote>
<p>but I'm looking to avoid installing
MySQL and Ruby on the server.</p>
</blockquote>
<p>I know (also using C# stack myself), but self-hosted web-based SVN client market is such a small niche that even offering in different language could be considered good enough. MySQL doesn't bite and installation of Ruby is pretty much x-copy command. I understand why you don't want to spoil your server with additional software though, but if are OK to host your SVN repositories with third-party, you get a nice web-based interface without maintenance hassles.</p>
<p>I'm using <a href="http://unfuddled.com" rel="nofollow noreferrer">http://unfuddled.com</a> (they also have some basic API to hook up on if needed).</p>
<blockquote>
<p>Not to promote reinventing the wheel,
but I originally wrote my own web SVN
browser by using the <strong>svn log --xml</strong>
command</p>
</blockquote>
<p>This is actually good idea. I'm also parsing some XML formatted output during my automated build process, but creating our own full-blown SVN browser is kind of overkill because now you have to maintain not one primary project, but also the tool. But then again, we, programmers, love to create tools that will make working on our primary projects easier.</p>
<p><strong>ASP.NET SVN browser sounds like promising open-source idea, anybody willing to start work on it? I would contribute.</strong></p>
|
<p>Not web-based but if your team is using TortoiseSVN there's a great repository browser there. Just right click on your local checkout and select TortoiseSVN / Repo-Browser.</p>
| 3,214
|
<p>I want to bring up a file dialog in Java that defaults to the application installation directory.</p>
<p>What's the best way to get that information programmatically?</p>
|
<pre><code>System.getProperty("user.dir")
</code></pre>
<p>gets the directory the Java VM was started from.</p>
|
<pre><code>System.getProperty("user.dir");
</code></pre>
<p>The above method gets the user's working directory when the application was launched. This is fine if the application is launched by a script or shortcut that ensures that this is the case.</p>
<p>However, if the app is launched from somewhere else (entirely possible if the command line is used), then the return value will be wherever the user was when they launched the app.</p>
<p>A more reliable method is to <a href="http://illegalargumentexception.blogspot.com/2008/04/java-finding-application-directory.html" rel="nofollow noreferrer">work out the application install directory using ClassLoaders</a>.</p>
| 4,807
|
<p><a href="https://www.youtube.com/watch?v=WIkT8asT90A" rel="nofollow noreferrer">This video</a> brought to my attention the 8 mm lead of the Ender 3's Z axis screw, which seems like an exceedingly bad choice from a standpoint of accuracy with respect to common grid alignments in the Z direction. In particular, with the stepper having 200 full steps per rotation, the 8 mm lead consumes all the powers of two out of 200, leaving 25 full steps per mm - and 25ths of a mm are not a typical unit that layer heights/feature heights are going to be in. It seems like a 5 mm lead would be ideal, giving you 40 steps per mm, evenly divisible by 3 powers of 2 and one power of 5, for exact tenths and exact eights.</p>
<p>Is there a motivation behind the choice of 8 mm lead? Is this common for other printers, and are there printers that use a 5 mm lead, or 5 mm replacements that work well?</p>
|
<p>I've not seen trapezoid lead screws with 5 mm lead, you can get 5 mm lead ball screws though.</p>
<p>On one printer I use 4 mm lead screws to get native 0.02 mm resolution (so 5 full steps for 0.1 mm, 10 for 0.2 mm, etc.). I also geared down 8 mm lead screws with a 2:1 ratio (e.g. to use a single Z-stepper driving a belt that drives 2 lead screws), works fine.</p>
|
<p>You are delving into the darker recesses of 3D printing here!</p>
<p>ACME threads, anti-backlash nuts, ball-screws, etc. will ALL follow...</p>
<p>The simple answer is that the Z-axis screw on all the cheaper 3D printers are pure crap! They use 8mm With triangular threads because it they are cheap and most software works with it. </p>
<p>The first major upgrade most folks make to a printer (after the print bed surface) is to replace the Z-axis screw and nut. Many are poorly mounted and/or warped, resulting in Z-axis wobble. Most suffer major backlash - offset only by the fact that most printing only ever goes upwards...</p>
<p>The ideal upgrade would be to replace the rod and nut with a good quality ball-screw assembly that is properly mounted. But, if you do change the pitch, make sure you can alter the software to account for it...</p>
<p>That said, if your prints are good, enjoy, and don’t sweat the details!</p>
| 1,363
|
<p>I have read that the iPhone SDK (part of Xcode 3) is restricted to Mac's with the intel chipset. Does this restriction apply to only the simulator part of the SDK or the complete shebang?</p>
<p>I have a Powerbook G4 running Leopard and would very much like to do dev on it rather than fork out for a new machine.</p>
<p>It is also worth clarifying that I am interested in development for personal reasons and therefore accept that I would need a certified platform to create a submission for the App Store. </p>
|
<p>As things have moved on since the original post on 3by9.com, here are the steps that I had to follow to get the environment working on my PowerBook G4.</p>
<p><strong>BTW, I would like to say that I realise that this is not a supported environment and I share this for purely pedagogic rea</strong>sons.</p>
<ol>
<li>Download and install the iPhoneSDK (final version)</li>
<li>After the install finishes, navigate to the packages directory in the mounted DMG</li>
<li>Install all of the pkg's that start with iPhone</li>
<li>Copy the contents of <code>/Platforms</code> to <code>/Developer/Platforms</code> (should be two folders starting with iPhone)</li>
<li>Locate '<code>iPhone Simulator Architectures.xcspec</code>' in <code>/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications</code> and open in a text editor.</li>
<li>Change line 12 to: <code>Name = "Standard (iPhone Simulator: i386 ppc)";</code></li>
<li>Change line 16 to: <code>RealArchitectures = ( i386, ppc );</code></li>
<li>Add the following to line 40 onwards:</li>
</ol>
<pre>
// PowerPC
{ Type = Architecture;
Identifier = ppc;
Name = "PowerPC";
Description = "32-bit PowerPC";
PerArchBuildSettingName = "PowerPC";
ByteOrder = big;
ListInEnum = NO;
SortNumber = 106;
},
</pre>
<ol start="9">
<li>Save the file and start Xcode</li>
<li>You should see under the New Project Folder the ability to create iPhone applications.</li>
<li>To get an app to work in the simulator (and using the WhichWayIsUp example) open Edit Project Settings under the Project menu</li>
<li>On the Build tab change the Architectures to: Standard (iPhone Simulator:i386 ppc)</li>
<li>Change Base SDK to Simulator - iPhone OS 2.0</li>
<li>Build and go should now see the app build and run in the simulator</li>
</ol>
|
<blockquote>
<p>I have a Powerbook G4 running Leopard and would very much like to do dev on it </p>
</blockquote>
<p>Not sure what sort of application you are developing, but if you jailbreak your iPhone, you can:</p>
<ul>
<li>develop applications using Ruby/Python/Java which won't require compiling at all</li>
<li>compile on the phone(!), as there is an GCC/Toolchain install in Cydia - although I've no idea how long that'll take, or if you can simply take a regular iPhone SDK project and SSH it to the phone, and run <code>xcodebuild</code>)</li>
</ul>
<p>You <em>should</em> be able to compile iPhone applications from a PPC machine, as you can compile PPC applications from an Intel Mac, and vice-versa, there shouldn't be any reason you can't compile an ARM binary from PPC.. Wether or not Apple include the necessary stuff with Xcode to allow this is a different matter.. The steps that <a href="http://3by9.com/85/" rel="nofollow noreferrer">Ingmar posted</a> seem to imply you can..?</p>
| 5,866
|
<p>For those of us who use standard shared hosting packages, such as GoDaddy or Network Solutions, how do you handle datetime conversions when your hosting server (PHP) and MySQL server are in different time zones?</p>
<p>Also, does anybody have some best practice advice for determining what time zone a visitor to your site is in and manipulating a datetime variable appropriately?</p>
|
<p>As of PHP 5.1.0 you can use <a href="http://www.php.net/manual/en/function.date-default-timezone-set.php" rel="noreferrer"><em>date_default_timezone_set()</em></a> function to set the default timezone used by all date/time functions in a script. </p>
<p>For MySql (quoted from <a href="http://dev.mysql.com/doc/refman/4.1/en/time-zone-support.html" rel="noreferrer">MySQL Server Time Zone Support</a> page)</p>
<blockquote>
<p>Before MySQL 4.1.3, the server operates only in the system time zone set at startup. Beginning with MySQL 4.1.3, the server maintains several time zone settings, some of which can be modified at runtime. </p>
</blockquote>
<p>Of interest to you is per-connection setting of the time zones, which you would use at the beginning of your scripts</p>
<pre><code>SET timezone = 'Europe/London';
</code></pre>
<p>As for detecting the client timezone setting, you could use a bit of JavaScript to get and save that information to a cookie, and use it on subsequent page reads, to calculate the proper timezone.</p>
<pre><code>//Returns the offset (time difference) between Greenwich Mean Time (GMT)
//and local time of Date object, in minutes.
var offset = new Date().getTimezoneOffset();
document.cookie = 'timezoneOffset=' + escape(offset);
</code></pre>
<p>Or you could offer users the chioce to set their time zones themselves.</p>
|
<p>I save all my dates as a bigint due to having had issues with the dateTime type before. I save the result of the time() PHP function into it, now they count as being in the same timezone :)</p>
| 3,903
|
<p>I want to create a Java application bundle for Mac without using Mac.</p>
<p>According to <a href="http://developer.apple.com/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html#//apple_ref/doc/uid/TP40001885-208447-TPXREF120" rel="noreferrer">Java Deployment Options for Mac OS X</a>, I can do this by using Xcode, Jar Bundler, or from the command line. Once the files and folders are set up, all I need for the command line method is to call /Developer/Tools/SetFile. Is there a SetFile clone on Linux or Windows? If not, do I have to get a Mac?</p>
|
<p>A Java application bundle on OS X is nothing more than a directory containing your .jars and a number of configuration files. The SetFile tool sets a custom HFS filesystem property on the directory to tell finder that it is an app, but giving it a ".app" extension serves the same purpose. I don't think there's anything stopping you from building one on, say, Windows, though of course you have no way of testing that it works, but if you are able to test it at least once on a real Mac, you could then conceivably update the .jars within it on Windows to reflect code changes without too much difficulty.</p>
<p>Have a look at the <a href="http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/CFBundles.html" rel="nofollow noreferrer">Bundle Programming Guide</a> for more info.</p>
|
<p>One way is to generate a zip file with the App using for example Ant. In ant you can specify that the file in Contents/MacOS should have execute-permissions using something like filemode="755".</p>
| 6,026
|
<p>What are the other types of database systems out there. I've recently came across couchDB that handles data in a non relational way. It got me thinking about what other models are other people is using.</p>
<p>So, I want to know what other types of data model is out there. (I'm not looking for any specifics, just want to look at how other people are handling data storage, my interest are purely academic)</p>
<p>The ones I already know are:</p>
<ol>
<li>RDBMS (mysql,postgres etc..)</li>
<li>Document based approach (couchDB, lotus notes)</li>
<li>Key/value pair (BerkeleyDB) </li>
</ol>
|
<p><a href="http://www.db4o.com" rel="nofollow noreferrer">db4o</a></p>
<p>Quote from the "about" page:</p>
<blockquote>
<p>db4o is the open source object database that enables Java and .NET developers to store and retrieve any application object with only one line of code, eliminating the need to predefine or maintain a separate, rigid data model. </p>
</blockquote>
|
<h1>4. Navigational. Includes Tree/Hierarchy and Graph/Network.</h1>
<p>File systems, the semantic web, XML, Object databases, CODASYL, and many others all fit into this category.</p>
<p>Those 4 are pretty much it.</p>
| 7,389
|
<p>I would like to use something like CLR Profiles on .Net 2.0 to see what objects are taking more space in the heap at any given time (of an ASP.Net worker process).</p>
<p>However, the CLR Profiler only lets me START an app, not attach to an existing one. I assume this is because it tracks allocations and GC too, but i'm not very interested in that. I would just like something that takes a snapshot of the current state of the heap, and shows me what is there and how many objects of each kind there are, and how many bytes total are being used by each object type.</p>
<p>Any ideas?</p>
|
<p><a href="http://memprofiler.com/" rel="nofollow noreferrer">.Net Memory Profiler</a> is exactly what you need. It's not free but there's a trial version. Actually I used the trial to find leaks on our last project. One notable feature is:</p>
<blockquote>
<p>Easily identify memory leaks by
collecting and comparing snapshots of
.NET memory</p>
</blockquote>
<p>I think this is what your looking for.</p>
|
<p><a href="http://memprofiler.com/" rel="nofollow noreferrer">.Net Memory Profiler</a> is exactly what you need. It's not free but there's a trial version. Actually I used the trial to find leaks on our last project. One notable feature is:</p>
<blockquote>
<p>Easily identify memory leaks by
collecting and comparing snapshots of
.NET memory</p>
</blockquote>
<p>I think this is what your looking for.</p>
| 5,379
|
<p>We have a few projects that involve building an application that is composed of maybe 50% custom functionality, but then pulls in, say, a wiki, a forum, and other components that are "wheels" that have already been invented that we do not wish to re-write from scratch.</p>
<p>These third-party applications usually have their own databases, themes, and authentication systems. Getting things to work like a single-sign-on, or a common theme, or tagging/searching across entities in multiple sub-apps are pretty challenging problems, in my experience. What are some of the best practices for this kind of integration project?</p>
<p>Our approach, so far, has been to try and pick your components carefully, choosing ones that have a clearly defined API, preferably via HTTP (like REST or SOAP), though that isn't always possible (we haven't found a decent forum that works that way). Are there suggestions folks can give to anyone trying to do this, as I suspect many of us are more and more frequently these days?</p>
|
<p>Make sure that the interface between your application and the third-party application or library is such that you can replace it easily with something else just in case. In some cases the third-party software may just be an implementation of an standard API (Java does this a lot with JDBC, JMS, JNDI, ...). In other cases this means wrapping the third-party library in some API that you come up with. </p>
<p>Of course there are times to throw that idea out the window and have things tightly integrated with the third-party software. Just be sure that you REALLY want to bind your application to that third-party. Once you go down this road it's REALLY hard to go back and change your mind. </p>
|
<p>Donald Knuth said that even better then reusable code is modifiable code, so if there is no API, you should seek for an open source app that is written well and therefore possible to customize. </p>
<p>As for databases and login systems and other programming parts (i don't see how e.g. theming could benefit), you can also try, depending on circumstances wrapping stuff so that module believes it's on it's own, but actually talks to your code.</p>
| 7,074
|
<p>as it is currently, there are several <a href="https://3dprinting.stackexchange.com/questions/tagged/diy-3d-printer" class="post-tag" title="show questions tagged 'diy-3d-printer'" rel="tag">diy-3d-printer</a> questions that gave info about a specific printer. While I tried to add the appropriate names for these kit-printers, I feel that it technically is inappropriate for these to actually <em>have</em> this tag. Even as the DIY tag contains the "assembled from a kit by the end user" in the wiki, there is also non-commercially in it, meaning it seems to be meant for a true DIY kits like <a href="https://www.thingiverse.com/thing:2254103" rel="nofollow noreferrer">Hypercube</a> or such. They are so vastly different, that I fel we should encourage the following:</p>
<ul>
<li>pull any comercial kits out of the <a href="https://3dprinting.stackexchange.com/questions/tagged/diy-3d-printer" class="post-tag" title="show questions tagged 'diy-3d-printer'" rel="tag">diy-3d-printer</a> tag</li>
<li>add a tag <a href="https://3dprinting.stackexchange.com/questions/tagged/printer-kit-assembly" class="post-tag" title="show questions tagged 'printer-kit-assembly'" rel="tag">printer-kit-assembly</a> or use <a href="https://3dprinting.stackexchange.com/questions/tagged/printer-building" class="post-tag" title="show questions tagged 'printer-building'" rel="tag">printer-building</a> for questions that struggle with the assembly of a kit together with the specific model's tag</li>
<li>enforce the specific tag of the kit for questions having problems with it</li>
</ul>
|
<p>To me, the dividing line between "DIY" and "not DIY" is who you deal with if a part is defective when you get it.</p>
<p>If you're contacting different vendors for a jammed bearing, a miswired stepper motor, or a dead controller board, it's DIY. If you talk to the same person regardless of which part is defective out of the box, it's not DIY. So, from Greenonline's examples, 1, 2, and 3 are DIY, while 4 and 5 aren't.</p>
<p>Yes, that means that a printer can evolve from "not DIY" to "DIY". For example, if you start with a preassembled Prusa i3 Mk3, but then replace the V6 hotend with a Volcano hotend in an extruder found on Thingiverse, switch to a 320-watt Meanwell PSU, replace the display with a touchscreen, change out the ball bearings for sleeve bearings, upgrade the steppers for more precision, and install a BuildTak bed, you've now got a DIY printer.</p>
|
<p>It got too long to fit in a comment:</p>
<p>That does seem sort of reasonable. A DIY printer should be one that has been sourced from various parts. Or should that also include (or be exclusively) DIY designs? I mean, DIY means Do It Yourself, so a commercial kit, is literally a DIY printer, even though it is following a recognised design. It may seem a pedantic point over semantics but what is classed as DIY? Is it:</p>
<ol>
<li>A true home brew, DIY design? And everything made from scratch with a lathe and possibly another 3D printer?</li>
<li>Following a RepRap design straight of the Wiki/Github and printing the plastic parts yourself</li>
<li>Following a RepRap design straight of the Wiki/Github but buying the plastic parts (because you don't yet have a printer)</li>
<li>Following a RepRap design straight of the Wiki/Github but a complete kit</li>
<li>Buying a commercial printer available as a kit, in kit form.</li>
</ol>
<p>To me, there is not much difference between the last two, <em>if</em> the commercial printer is derived from a RepRap. Even 2 and 3 are just as DIY as each other, really.</p>
<p>So, just to play devil's advocate, here are four real word scenarios... </p>
<ul>
<li>Would you class a P3Steel as a DIY <a href="https://3dprinting.stackexchange.com/questions/tagged/diy-3d-printer" class="post-tag" title="show questions tagged 'diy-3d-printer'" rel="tag">diy-3d-printer</a> tag <em>or</em> as a printer-kit <a href="https://3dprinting.stackexchange.com/questions/tagged/printer-building" class="post-tag" title="show questions tagged 'printer-building'" rel="tag">printer-building</a> tag <em>if</em> the frame was purchased as a kit from Poland, but the rest of it was sourced separately from various places, such as Chinese eBay vendors? </li>
<li>Likewise, a Kossel, whose plastic parts were bought from a eBay vendor and then the aluminium struts were cut to length in the back streets of Bangkok - would that be a commercial kit (because the plastic parts were available commercially), or DIY? </li>
<li>Also, a Wilson II, whose plastic parts were from MJRice (the designer of the Wilson), but the aluminium came from a cottage industry aluminium extruder in Vietnam, who you had had to walk miles to find. Commercial kit or DIY tag?</li>
<li>Now, twisting it slightly... What about a complete Wilson II kit? Where the entire frame and kit has been purchased from an eBay vendor, or MJRice. Is that commercial or not? </li>
</ul>
<p>There seems to be a fine line between the last two. We might need to be very specific in the tag definitions if people aren't going to get confused.</p>
<p>If, all four examples are DIY then fine. If none of them are, because the plastic parts were purchased, then ok, we have a <em>very strict</em> definition of DIY.</p>
<p>Just for completeness, the first three scenarios are my personal purchasing experiences, where I considered them as DIY printers.</p>
<p>Now, to be fair to your question, I <em>think</em> I know what you mean. You are referring to printer kits from established manufacturers that are available pre-built, <em>or</em> as kits. Is that right? I just want to clarify what defines a commercial kit and a DIY kit.</p>
<p>Does that make sense? I might have got a bit carried away.</p>
| 50
|
<p>Comparing trends show that 3D printing stepped over to another level around 2012~2013. Why?</p>
<p><a href="https://i.stack.imgur.com/9tFj9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9tFj9.png" alt="3D printing vs 3D scanning" /></a></p>
<p><a href="https://i.stack.imgur.com/N488f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N488f.png" alt="3D printer vs 3D scanner" /></a></p>
|
<p>A great story on the history of 3D printing is published by <a href="https://www.3dsourced.com/guides/history-of-3d-printing/" rel="noreferrer">3DSOURCED</a>. It shows that the patents for FDM and SLA expired a few years earlier and the <a href="https://reprap.org/wiki/RepRap" rel="noreferrer">RepRap</a> 3D printer self replicating project became very popular. Also, 3D printer manufacturers emerged and electronics, software and parts became available at a larger scale, so that it was more affordable for a hobbyist to dive in.</p>
|
<p>Another opinion received:</p>
<blockquote>
<p>That’s the result of MakerBot and others promoting the tech to the general public for the first time after the patents expired. They were just running up stock prices to make a lot of money</p>
</blockquote>
| 1,884
|
<p>Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd) that is only sized at 8.2 GB. I would like to double the size to something like 16-20GB. I see options for compacting the VHD but nothing to expand it. It's set to "dynamically expand" but I'm installing some software and it doesn't seem to resize itself to a larger space.</p>
<p>Thanks much.</p>
|
<p><a href="http://vmtoolkit.com/files/folders/converters/entry87.aspx" rel="nofollow noreferrer">VHD Resizer</a></p>
|
<p>Never worked with Virtual PC but from other virtualization software I know I guess that dynamically expand means that initially the .vhd file will take less space in the HD than the specified and will dynamically grow as you keep installing programs or adding files into the virtual drive UP TO the specified size.</p>
<p>For what you want I guess that you will have to modify the specified size in the virtual hard drive from Virtual PC's setup window.</p>
<p>A bit offtopic but give a go to Virtual Box: www.virtualbox.org</p>
| 4,859
|
<p>Anyone using WPF for real LOB applications?</p>
<p>We have all seen the clever demos of WPF showing videos mapped onto 3D elements. These look great but what about the real world of line-of-business applications that make up the majority of developers efforts. Is WPF just for nice eye candy?</p>
|
<p>While we discussing it, smart guys are building amazing apps:</p>
<p><a href="http://channel9.msdn.com/shows/Continuum/LawsonSmartOffice/" rel="nofollow noreferrer">Lawson Smart Office brings WPF goodness to the enterprise</a></p>
<p><a href="http://windowsclient.net/learn/video.aspx?v=48556" rel="nofollow noreferrer">IGT’s Next-Generation UI with WPF</a></p>
<p><a href="http://www.dnrtv.com/default.aspx?showNum=115" rel="nofollow noreferrer">Billy Hollis on Getting Smart with WPF</a></p>
|
<p>I feel the eye candy demos are targeted mostly towards designers. Having said that, there is a huge potential in improving usability of LOB apps using WPF. <a href="http://www.ddj.com/windows/210300284" rel="nofollow noreferrer">Check this article about the potential of Silverlight</a>.</p>
<p><em>Line-of-business applications have a notorious reputation for being all business and no pleasure. The fact is that "user experience" has never really been a top concern when developing line-of-business (LOB) applications. While many LOB-style applications are putting an increasing emphasis on usability, they often fall short on appeal. User experience is actually a combination of both usability and appeal.</em> </p>
| 8,716
|
<p>I know this is pretty exotic, but I want to deploy a Ruby web application (not Rails, but Rack based, so it plugs into most Ruby servers just fine) using JRuby. Google and friends give me a few success stories, but mostly rails related and if not, no details on the deployment are provided. The framework I'm using is Ramaze, if it matters.</p>
<p>Any help would be greatly appreciated.</p>
|
<p>In my opinion, running a Rack based application with a rackup script is the real Ruby way. And I wanted to apply the same for JRuby too. That is why I've written jetty-rackup <a href="http://github.com/geekq/jetty-rackup" rel="nofollow noreferrer">http://github.com/geekq/jetty-rackup</a></p>
<p>We are using it for deploying a Sinatra web application. No Java specific configuration needed. A typical, small config.ru is enough. Embedded jetty web server is used in place of Webrick then.</p>
|
<p>This is the "just works" gem for me: <a href="https://github.com/matadon/mizuno" rel="nofollow">https://github.com/matadon/mizuno</a></p>
| 3,768
|
<p>If I have the following:</p>
<pre><code>Public Class Product
Public Id As Integer
Public Name As String
Public AvailableColours As List(Of Colour)
Public AvailableSizes As List(Of Size)
End Class
</code></pre>
<p>and I want to get a list of products from the database and display them on a page along with their available sizes and colours, should I </p>
<ol>
<li>have one method (GetProducts()) which makes use of a single view that joins the relevant tables, that then loops through each row and creates the objects as required? Or…</li>
<li>have several methods which are responsible only for creating one object each? eg. GetProducts(), GetAvailableColoursForProduct(id), etc</li>
</ol>
<p>I'm currently doing a) but as I add other other properties (multiple images, optional tassels, etc) the code is getting very messy (having to check that this isn't the same product as the previous row, has this colour already been added, etc) so I'm tempted to go with b) however, this will really ramp up the number of round trips to the database.</p>
|
<p>You're probably best off benchmarking both and finding out. I've seen situations where just doing multiple queries (MySQL likes this) is faster than JOINs and one big slow query that takes a lot memory and causes the DB server to thrash. I say benchmark because it's going to depend on your database server, how much memory and concurrent connections it has, sizes of your tables, how your indexes are optimized and the size of your typical recordsets. JOINs on large unindexed columns are very expensive (so you should either not do them or add indexes).</p>
<p>You will probably also learn a bit more/be more satisfied in the end if you write at least a little of both implementations (you don't need to write the methods, just a bunch of test queries) and then benchmark, vs. just going with one or the other. The trickiest (but important) part of testing though is simulating concurrent users hitting the DB at the same time -- realistic production memory and cpu load.</p>
<p>Keep in mind you are dealing with 2 issues: One is the DBA issue, how do I make it fastest and most efficient. The second is the programmer who wants pretty, maintainable code. (b) makes your code more readable and extensible than just having giant queries with complicated JOINs, so you may decide to prefer it over (a) as long as it isn't drastically slower.</p>
|
<p>Personally, I'd get more data from the database through fewer methods and then bind the UI against only those parts of the data set that I currently want to display. Managing lots of small methods that get out specific chunks of data is harder than getting out large chunks and using only those parts you need.</p>
| 9,708
|
<p>In my <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices">previous question</a>, most commenters agreed that having validation logic both at client & server sides is a good thing.</p>
<p>However there is a problem - you need to keep your validation rules in sync between database and client code.</p>
<p>So the question is, how can we deal with it?</p>
<p>One approach is to use ORM techniques, modern ORM tools can produce code that can take care of data validation prior sending it to the server.</p>
<p>I'm interested in hearing your opinions.</p>
<p>Do you have some kind of standard process to deal with this problem? Or maybe you think that this is not a problem at all?</p>
<hr />
<p><strong>EDIT</strong></p>
<p>Guys, first of all thank you for your answers.</p>
<p>Tomorrow I will sum up you answers and update question's text like in <a href="https://stackoverflow.com/questions/39371/database-exception-handling-best-practices">this case</a>.</p>
|
<p>As mentioned in one of the answers to the other post, if you are going to keep your layers separated, there is no good way to avoid duplicating the validation logic in each layer. If you use something to automatically tie them together, you have introduced a sort of coupling between the layers that might hinder you down the road. This might be one of those cases where you just have to keep track of things manually.</p>
<p>However you go about it, you have to make sure each layer is doing its own validation, because you never know how that layer is going to be accessed. There's no guarantee that all the layers you implemented will always stay together.</p>
|
<p>If you're using ASP.Net there are a number of validation controls you can use. These controls are written in a very generic way, such that most of them automatically duplicate your validation logic between the client and server, even though you only set options for the control in one place. </p>
<p>You are also free to inherit from them to create additional domain specific validators, and there are third-party control packs on the web you can get that add to the base controls.</p>
<p>Even if you're not using ASP.Net it's worth taking a look at how this is done. It will give you ideas for how to do something similar in your own platform.</p>
| 6,072
|
<p>What is the best way to determine duplicate records in a SQL Server table?</p>
<p>For instance, I want to find the last duplicate email received in a table (table has primary key, receiveddate and email fields).</p>
<p>Sample data:</p>
<pre><code>1 01/01/2008 stuff@stuff.com
2 02/01/2008 stuff@stuff.com
3 01/12/2008 noone@stuff.com
</code></pre>
|
<p>something like this</p>
<pre><code>select email ,max(receiveddate) as MaxDate
from YourTable
group by email
having count(email) > 1
</code></pre>
|
<p>Couldn't you join the list on the e-mail field and then see what nulls you get in your result?</p>
<p>Or better yet, count the instances of each e-mail address? And only return the ones with count > 1</p>
<p>Or even take the email and id fields. And return the entries where the e-mail is the same, and the IDs are different. (To avoid duplicates don't use != but rather either < or >.)</p>
| 6,900
|
<p>First off, I understand the reasons why an interface or abstract class (in the .NET/C# terminology) cannot have abstract static methods. My question is then more focused on the best design solution.</p>
<p>What I want is a set of "helper" classes that all have their own static methods such that if I get objects A, B, and C from a third party vendor, I can have helper classes with methods such as</p>
<pre>
AHelper.RetrieveByID(string id);
AHelper.RetrieveByName(string name);
AHelper.DumpToDatabase();
</pre>
<p>Since my AHelper, BHelper, and CHelper classes will all basically have the same methods, it seems to makes sense to move these methods to an interface that these classes then derive from. However, wanting these methods to be static precludes me from having a generic interface or abstract class for all of them to derive from.</p>
<p>I could always make these methods non-static and then instantiate the objects first such as</p>
<pre>
AHelper a = new AHelper();
a.DumpToDatabase();
</pre>
<p>However, this code doesn't seem as intuitive to me. What are your suggestions? Should I abandon using an interface or abstract class altogether (the situation I'm in now) or can this possibly be refactored to accomplish the design I'm looking for?</p>
|
<p>Looking at <a href="https://stackoverflow.com/questions/14614/static-methods-in-an-interfaceabstract-class#14655">your response</a> I am thinking along the following lines:</p>
<ul>
<li>You could just have a static method that takes a type parameter and performs the expected logic based on the type.</li>
<li>You could create a virtual method in your abstract base, where you specify the SQL in the concrete class. So that contains all the common code that is required by both (e.g. exectuting the command and returning the object) while encapsulating the "specialist" bits (e.g. the SQL) in the sub classes.</li>
</ul>
<p>I prefer the second option, although its of course down to you. If you need me to go into further detail, please let me know and I will be happy to edit/update :)</p>
|
<p>How do I post feedback on Stack Overflow? Edit my original post or post an "answer"? Anyway, I thought it might help to give an example of what is going on in AHelper.RetrieveByID() and BHelper.RetreiveByID()</p>
<p>Basically, both of these methods are going up against a third party webservice that returns various a generic (castable) object using a Query method that takes in a pseudo-SQL string as its only parameters.</p>
<p>So, AHelper.RetrieveByID(string ID) might look like</p>
<pre>
public static AObject RetrieveByID(string ID)
{
QueryResult qr = webservice.query("SELECT Id,Name FROM AObject WHERE Id = '" + ID + "'");
return (AObject)qr.records[0];
}
public static BObject RetrieveByID(string ID)
{
QueryResult qr = webservice.query("SELECT Id,Name,Company FROM BObject WHERE Id = '" + ID + "'");
return (BObject)qr.records[0];
}
</pre>
<p>Hopefully that helps. As you can see, the two methods are similar, but the query can be quite a bit different based on the different object type being returned.</p>
<p>Oh, and Rob, I completely agree -- this is more than likely a limitation of my design and not the language. :)</p>
| 3,541
|
<p>I need to create a historical timeline starting from 1600's to the present day. I also need to have some way of showing events on the timeline so that they do not appear cluttered when many events are close together.</p>
<p>I have tried using Visio 2007 as well as Excel 2007 Radar Charts, but I could not get the results I wanted. the timeline templates in Visio are not great and using Radar charts in Excel leads to cluttered data.</p>
<p>Are there any other tools or techniques I could use to create these?</p>
<p><b>@Darren:</b><br>
The first link looks great. Thanks! The second link did not work in Firefox and was rendered as ASCII. It opened up fine in IE.<br>
And yes, this is for the end users. So I want it to look as presentable as possible, if you know what I mean. <br>
Thanks again!</p>
|
<p>SIMILIE Timeline would probably suit your needs.
<a href="http://simile.mit.edu/timeline/" rel="noreferrer">http://simile.mit.edu/timeline/</a></p>
<p>Timeline .NET: <a href="http://www.codeplex.com/timelinenet" rel="noreferrer">http://www.codeplex.com/timelinenet</a></p>
<p>Oh, i guess i should ask... for personal use or for display to end users? that might change what i would suggest, but this could work for internal purposes too i suppose.</p>
|
<p>@Pascal this page? <a href="http://tools.mscorlib.com/timeline/Default.aspx" rel="nofollow noreferrer">http://tools.mscorlib.com/timeline/Default.aspx</a>. If it's looking like ascii maybe look for a js error, but that renders on my system fine. If all else fails, it's a decent js library by the MIT team as it is, so you could wire up your own implementation</p>
| 3,333
|
<p>When I am working with ASP.NET, I find that there are always unexpected things I run into that take forever to debug. I figure that having a consolidated list of these would be great for those "weird error" circumstances, plus to expand our knowledge of oddness in the platform.</p>
<p>So: answer with one of your "Gotcha"s!</p>
<p>I'll start:
Under ASP.NET (VB), performing a Response.Redirect inside a try/catch block does not stop execution of the current Response, which can lead to two concurrent Responses executing against the same Session.</p>
|
<p>Don't dynamically add controls after the page init event as it will screw up the viewstate tree.</p>
|
<p>(VB.NET) If you send an Object via a Property's Get accessor into a function with a ByRef keyword, it will actually attempt to update the object using the Set accessor for the Property.</p>
<p>Ex:</p>
<p><code>UpdateName(ByRef aName as String)</code></p>
<p><code>UpdateName(Employee.Name)</code> will attempt to update the name by using the Set on the Name property of Employee.</p>
| 9,178
|
<p>One of the things I'd like to do in my browser-based application is allow the user to select some text (not in a <textarea>, just plain ol' text!), and have my application pop up a small toolbar that then can interact with the next (in my case, add annotations).</p>
<p>I've found a lot of stuff on google that seems to be focused on writing WYSIWYG editors, <strong>but that isn't what I want</strong>, and most of it worked in IE but not in FF2 or 3. Ideally, I'd like some function that can return the currently selected text in the browser window that works in <strong>IE7 (and 6 if possible), FireFox 2 & 3 and Safari 2</strong>. If it works in Opera, that'd be a bonus, but it's not a requirement.</p>
<p>Anyone have a function that does this? Or an idea of where to start?</p>
|
<p>Have a look at <a href="http://jquery.com" rel="noreferrer">jQuery</a> and the <a href="http://plugins.jquery.com/project/wrapSelection" rel="noreferrer">wrapSelection plugin</a>. It may be what you are looking for.</p>
|
<p>The behaviour of individual browsers with regard to selection is <a href="http://quirksmode.org/dom/w3c_range.html" rel="nofollow noreferrer">outlined here</a>.</p>
| 3,167
|
<p>Before the print has actually started I have set up Auto Bed Leveling using a BLTouch sensor, during the period that this runs I find that material leaks out of the nozzle and curls back onto itself and by the time it finishes it is substantial enough to cause problems when the nozzle is primed drawing the line to the left of the print. The material that leaks out catches on the material extruded to prime the nozzle, before printing the model so when the first line of the model are extruded to very quickly pulls up off the bed and becomes a massive tangle of material.</p>
<p>I try to catch it my self using various thin instruments to scrape it off the nozzle as it starts the priming but this isn't always successful and is far from ideal. I have also tried adding a retraction before the bed levelling starts suing the gcode commands added to the beginning of every print, at the moment however I find that a retraction large enough to stop the leaking material also means that material doesn't come out for the priming in time so the first lines of the print don't work.</p>
<p>The gcode at the beginning of the print is as follows:</p>
<pre><code>; Ender 3 Custom Start G-code
M104 S{material_print_temperature_layer_0} ; Set Extruder temperature
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature
G28 ; Home all axes
G1 F1800 E-3 ; Retract filament 3 mm to prevent oozing
G29 ; BLTOUCH Mesh Generation
G92 E0 ; Reset Extruder
G1 Z5.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z5.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
</code></pre>
<p>I am using an Ender 3 running Marlin 1.1.9 with BlTouch Auto Leveling, With slicing done by CURA 3.5.6</p>
<p>Any suggestions you have that would help to stop this would be greatly appreciated.</p>
|
<p>The oozing is due to hot-end getting hot before the bed leveling procedure: if you move the hot-end warm up command <strong>after</strong> the <code>G29</code> line you avoid that oozing</p>
<pre><code>; Ender 3 Custom Start G-code
M104 S{material_print_temperature_layer_0} ; Set Extruder temperature
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
G28 ; Home all axes
G29 ; BLTOUCH Mesh Generation
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature
G1 F1800 E-3 ; Retract filament 3 mm to prevent oozing
G92 E0 ; Reset Extruder
G1 Z5.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z5.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
</code></pre>
<p>The above code will activate the heating elements but starts homing and leveling procedure without waiting for the elements to get up to temperature. Only after the bed leveling is finished the printer will pause and wait for the heating elements reach the desired temperature.</p>
<p>This will prevent oozing on a cold start, but you will still be affected if you start a print right after another print, when the hot-end is still close to melting temperature.</p>
<p>If you prefer to avoid that condition you might want to also move the <code>M104</code> and <code>M140</code> commands after the <code>G29</code> bed leveling command.</p>
|
<p>The best solution would be to heat the bed, but not the nozzle at startup. If you level with a cold bed, your ABL mesh is going to be off, since the aluminum heated bed plate expands considerably once the heat is applied. </p>
<p>You could also issue a retract command before leveling, and then add a counteracting filament feed command after ABL is complete. I have no idea how that code would look though. Just my 2 cents.</p>
| 1,141
|
<p>Brand new to Slic3r, I've been using Cura for a while, so not sure is happening. I tried to load <a href="https://www.shapeways.com/product/YDCPJF8KV/knight" rel="nofollow noreferrer">this Knight model</a> into Slic3er (v1.2.9 running on OS X), and it's reporting "Manifold: auto-repaired (11430 errors)", and the model looks incomplete. Hovering the model with the mouse shows more details:</p>
<p><a href="https://i.stack.imgur.com/hb2DY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hb2DY.png" alt="Slic3r Screenshot"></a></p>
<p>Preview mode shows supports holding up the head, so I don't think it's just a screen rendering issue. But I loaded this same model into Cura earlier today, and it worked just fine; I've printed the resulting GCode. So I believe the model is fine. I wanted to print using Slic3r and compare the results. </p>
<p>Is this a known issue with certain types of models? Not sure what to try next.</p>
|
<p>Dimensional accuracy is not as important as dimensional uniformity. I can print with undersized (or oversized) filament, adjusting the flow appropriately, provided the filament has a consistent diameter. When creating filament in-house, without expensive equipment, it is difficult to maintain the same diameter throughout the entire extrusion. It is likely this extrusion diameter (when creating filament, rather than the output of the actual print head) to which Barafu is referring when he mentions his tolerances: +/- 0.05 mm <em>in diameter</em>. Which is reasonable.</p>
<p>The "miniature printing" comment likely refers to printing miniature models for tabletop gaming.</p>
<p>If the source filament becomes wider than expected, the output will have overflow, or more material than desired will be deposited, and this will certainly affect the quality of the piece.</p>
|
<p>Put it simply: they say 1.75 mm with a ± error of 0.05 mm. Which means your flow may vary ±2.9 % while you are printing creating blobs and such. </p>
<p>The smaller the filament tolerance, the more expensive the production costs.</p>
| 501
|
<p>This should be simple. I'm trying to import data from Access into SQL Server. I don't have direct access to the SQL Server database - it's on GoDaddy and they only allow web access. So I can't use the Management Studio tools, or other third-party Access upsizing programs that require remote access to the database.</p>
<p>I wrote a query on the Access database and I'm trying to loop through and insert each record into the corresponding SQL Server table. But it keeps erroring out. I'm fairly certain it's because of the HTML and God knows what other weird characters are in one of the Access text fields. I tried using CFQUERYPARAM but that doesn't seem to help either.</p>
<p>Any ideas would be helpful. Thanks.</p>
|
<p>Try using the <a href="http://blog.godaddyhosting.com/2007/07/20/presentingdrum-roll-please-the-ms-sql-backuprestore-feature.aspx" rel="nofollow noreferrer">GoDaddy SQL backup/restore tool</a> to get a local copy of the database. At that point, use the <a href="http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx" rel="nofollow noreferrer">SQL Server DTS tool</a> to import the data. It's an easy to use, drag-and-drop graphical interface.</p>
|
<p>It's never advisable to loop through records when a SQL Update can be used.</p>
<p>It's not clear from your question what database interface layer you are using, but it is possible with the right interfaces to insert data from a source outside a database <em>if</em> the interface being used supports both types of databases. This can be done in the FROM clause of your SQL statement by specifying not just the table name, but the connect string for the database. Assuming that your web host has ODBC drivers for Jet data (you're not actually using Access, which is the app development part -- you're only using the Jet database engine), the connect string should be sufficient.</p>
<p>EDIT: If you use the Jet database engine to do this, you should be able to specify the source table something like this (where tblSQLServer is a table in your Jet MDB that is linked via ODBC to your SQL Server):</p>
<pre><code>INSERT INTO tblSQLServer (ID, OtherField )
SELECT ID, OtherField
FROM [c:\MyDBs\Access.mdb].tblSQLServer
</code></pre>
<p>The key point is that you are leveraging the Jet db engine here to do all the heavy lifting for you.</p>
| 9,158
|
<p>Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time.</p>
<p>If the target is a directory, it might be possible to chdir() into the directory and then call getcwd(), but I really want to do this from a shell script rather than writing a C helper. Unfortunately, shells have a tendency to try to hide the existence of symlinks from the user (this is bash on OS X):</p>
<pre><code>$ ls -ld foo bar
drwxr-xr-x 2 greg greg 68 Aug 11 22:36 bar
lrwxr-xr-x 1 greg greg 3 Aug 11 22:36 foo -> bar
$ cd foo
$ pwd
/Users/greg/tmp/foo
$
</code></pre>
<p>What I want is a function resolve() such that when executed from the tmp directory in the above example, resolve("foo") == "/Users/greg/tmp/bar".</p>
|
<pre><code>readlink -f "$path"
</code></pre>
<p><sup>Editor's note: The above works with <em>GNU</em> <code>readlink</code> and <em>FreeBSD/PC-BSD/OpenBSD</em> <code>readlink</code>, but <em>not</em> on OS X as of 10.11.<br>
<em>GNU</em> <code>readlink</code> offers additional, related options, such as <code>-m</code> for resolving a symlink whether or not the ultimate target exists.</sup></p>
<p>Note since GNU coreutils 8.15 (2012-01-06), there is a <strong>realpath</strong> program available that is less obtuse and more flexible than the above. It's also compatible with the FreeBSD util of the same name. It also includes functionality to generate a relative path between two files.</p>
<pre><code>realpath $path
</code></pre>
<hr>
<p>[Admin addition below from comment by <a href="/users/65889/halloleo">halloleo</a> —<a href="/users/65889/danorton">danorton]
</a></p>
<p>For Mac OS X (through at least 10.11.x), use <code>readlink</code> without the <code>-f</code> option:</p>
<pre><code>readlink $path
</code></pre>
<p><sup>Editor's note: This will not resolve symlinks <em>recursively</em> and thus won't report the <em>ultimate</em> target; e.g., given symlink <code>a</code> that points to <code>b</code>, which in turn points to <code>c</code>, this will only report <code>b</code> (and won't ensure that it is output as an <em>absolute path</em>).<br>
Use the following <code>perl</code> command on OS X to fill the gap of the missing <code>readlink -f</code> functionality:<br>
<code>perl -MCwd -le 'print Cwd::abs_path(shift)' "$path"</code></sup></p>
|
<p>Here I present what I believe to be a cross-platform (Linux and macOS at least) solution to the answer that is working well for me currently.</p>
<pre><code>crosspath()
{
local ref="$1"
if [ -x "$(which realpath)" ]; then
path="$(realpath "$ref")"
else
path="$(readlink -f "$ref" 2> /dev/null)"
if [ $? -gt 0 ]; then
if [ -x "$(which readlink)" ]; then
if [ ! -z "$(readlink "$ref")" ]; then
ref="$(readlink "$ref")"
fi
else
echo "realpath and readlink not available. The following may not be the final path." 1>&2
fi
if [ -d "$ref" ]; then
path="$(cd "$ref"; pwd -P)"
else
path="$(cd $(dirname "$ref"); pwd -P)/$(basename "$ref")"
fi
fi
fi
echo "$path"
}
</code></pre>
<p>Here is a macOS (only?) solution. Possibly better suited to the original question.</p>
<pre><code>mac_realpath()
{
local ref="$1"
if [[ ! -z "$(readlink "$ref")" ]]; then
ref="$(readlink "$1")"
fi
if [[ -d "$ref" ]]; then
echo "$(cd "$ref"; pwd -P)"
else
echo "$(cd $(dirname "$ref"); pwd -P)/$(basename "$ref")"
fi
}
</code></pre>
| 2,925
|
<p>I am creating a 3D printed part which will act as an attachment between a plate (actually a strain gauge) with two M2.5 bolts and a 2kg load with a single M4 bolt. I wouldn't be happy with tapping a screw thread into the print itself so I want to try embedding the nuts into the print itself - so I'll pause the print at the right layer and then insert the nut and, hopefully, the print will resume.</p>
<p>I'm wondering is it worth also including washers? It's a major pain because, while a nut can be captive in a hex space, a washer is circular. So it needs to be glued down on insertion in case it rotates while the printer is printing on top of it.</p>
<p>For a 2kg load I don't believe the nut will attempt to pull through the part but there isn't a whole lot of support between the bore hole and the edge of an M2.5 nut though, only about 1mm.</p>
<p>Edit: I'll add an image of my initial design. The strain gauge is one of a set pulled out of a weighing scales (from Lidl, €5.99. You can buy each separately on the internet for 20 euro, so I saved 74 euro!). The gauge itself is mounted on the narrow "neck" of the gauge. The whole block will drop into a holder that grabs the outer edge of the gauge.</p>
<p><a href="https://i.stack.imgur.com/Bdelf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bdelf.png" alt="enter image description here"></a></p>
|
<p>It could depend on how well your printer-filament type combination can bridge. If you can generate bridges wider than the washer diameter, then print not only the hex recess but a disc recess for the washer, then print over both.</p>
<p>However, my preference would be to redesign the part so that the washer&hex nut are on the far side of the part so that you don't need to deal with printing over&around them. This has the added advantage that you can replace the nut if it ever gets worn or stripped. </p>
|
<p>If your nut will be exposed, you can simply insert it into the printed cavity and then seat it in place by heating it with a soldering iron.</p>
| 572
|
<p>How do I make a user's browser blink/flash/highlight in the task bar using JavaScript? For example, if I make an AJAX request every 10 seconds to see if the user has any new messages on the server, I want the user to know it right away, even if he is using another application at the time.</p>
<p><em>Edit: These users do want to be distracted when a new message arrives.</em></p>
|
<p>this won't make the taskbar button flash in changing colours, but the title will blink on and off until they move the mouse. This should work cross platform, and even if they just have it in a different tab.</p>
<pre><code>newExcitingAlerts = (function () {
var oldTitle = document.title;
var msg = "New!";
var timeoutId;
var blink = function() { document.title = document.title == msg ? ' ' : msg; };
var clear = function() {
clearInterval(timeoutId);
document.title = oldTitle;
window.onmousemove = null;
timeoutId = null;
};
return function () {
if (!timeoutId) {
timeoutId = setInterval(blink, 1000);
window.onmousemove = clear;
}
};
}());
</code></pre>
<hr>
<p><em>Update</em>: You may want to look at using <a href="https://paulund.co.uk/how-to-use-the-html5-notification-api" rel="noreferrer">HTML5 notifications</a>.</p>
|
<blockquote>
<p><i>These users do want to be distracted when a new message arrives.</i></p>
</blockquote>
<p>It sounds like you're writing an app for an internal company project. </p>
<p>You might want to investigate writing a small windows app in .net which adds a notify icon and can then do fancy popups or balloon popups or whatever, when they get new messages.</p>
<p>This isn't overly hard and I'm sure if you ask SO 'how do I show a tray icon' and 'how do I do pop up notifications' you'll get some great answers :-)</p>
<p>For the record, I'm pretty sure that (other than using an alert/prompt dialog box) you can't flash the taskbar in JS, as this is heavily windows specific, and JS really doesn't work like that. You may be able to use some IE-specific windows activex controls, but then you inflict IE upon your poor users. Don't do that :-(</p>
| 5,782
|
<p>I am looking for a plastic which is transparent to radio waves. I want to place my transmitter in a cylinder. That cylinder would be placed in a big RC plane ( whose body is made up of cardboard). I want the plane to be both telemetry, and RC controlled. That cylinder should allow the signals, should be strong and light.<br>
So which material would you suggest and is that material easy to do 3d print? </p>
|
<p>For the kind of application you are looking for, transparency to radio signal shouldn't really be an issue, so you are more or less free to choose whatever suits your taste better.</p>
<p>Looking at the 3d printed drone community, the 3 most common materials I see being used there are:</p>
<ul>
<li>impact-resistent PLA</li>
<li>PETG</li>
<li>ABS</li>
</ul>
<p>This order also match their "ease of use", with PLA being very easy to print even without heated bed, behaving well with glues in the assembly and being easy to paint on. The impact resistance of "though PLA" still doesn't match that of - say - ABS, but is typically considered "good enough" for anything but the propellers.</p>
<p>PETG is tougher. Print relatively easy (stringing and oozing being the typical problems) but it is known to be somewhat difficult to glue and paint. It is also quite dense, so - dimensions being the same - it will weight more than PLA.</p>
<p>Finally, ABS is a classic. It is strong, durable, easy to finish (with acetone) but it is the most finicky material to print with, requiring an enclosure and proper ventilation (the fumes being toxic).</p>
|
<p>To second @mac, </p>
<p>For drone usage, ABS will be your pal*. Both tough-PLA and PETG are relatively heavy, which is a disadvantage for flying saucers. Unless you power up and don't care!</p>
<ul>
<li>And I say this as someone who does not recommend ABS for general printing and I don't like printing ABS myself because of the smell, how much it warps, and most importantly the harmful nano particles it releases when printing (yes, all filaments do this, but ABS is on the very bad side of the spectrum). </li>
</ul>
<p>Note that tough-PLA differs manufacturer to manufacturer - basically it's not supposed to behave like PLA, so you get proprietary blends. PETG is traditionally tougher than PLA, but with the modified PLA, who knows. I have not personally met tough PLA tougher than regular PETG. </p>
<hr>
<p>SO: </p>
<ul>
<li>PETG if weight is not an issue. It prints well and it's tough. </li>
<li>ABS if weight is an issue. It's not easy to print; and make sure it's well well ventilated area (while venting during the print would mess up your print.)</li>
<li>Tough PLA if you only have cold bed. </li>
</ul>
| 797
|
<p>I am writing my own slicer and wonder if there is a mathematical proof that proves that the intersection of the slicing plane with the STL file will only produce closed-loop polygons for every given slicing plane?</p>
<p>Thanks!</p>
|
<p>You can't prove that because it isn't true. An STL file is just a collection of triangles. There is no guarantee that an intersection with the slicing plane will consist of closed-loop polygons. To be suitable for 3D printing an STL file should represent one or more closed, disjoint polyhedra (which would yield closed-loop polygons) but this is not always the case. Many slicers have heuristics to try and "fix" bad STL files on a best-effort basis. Especially considering the possibility of rounding errors, it is important to at least detect polygons that are almost (but not quite) closed and connect their endpoints together.</p>
|
<p>I am also trying to write my own slicer and so I would just like to offer some additional information. </p>
<p>What you will find is that .stl files just store triangles and don't validate that the triangles assemble to create a printable model so a lot if not most .stl files are going to have data that isn't exactly what you want it to be. So you will want to have additional steps before you get to slicing, to fix up the data you get from the stl file. </p>
<p>A lot of stl models are designed for 3d graphics where intersecting other triangles and not being manifold isn't an issue. So you will probably want to write some code to test your models before trying to slice them. </p>
<p>For example if you just sliced the layers of the <a href="https://www.thingiverse.com/thing:821" rel="nofollow noreferrer">Utah Teapot</a>
<a href="https://i.stack.imgur.com/d7qm0.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d7qm0.gif" alt="Teapot"></a> and don't repair the model for 3D printing first you will get two different types of errors. The handle of the teapot does not actually attach to the teapot and is a separate model. And the spout of the teapot is a separate model that intersects the teapot. Both the handle and spout are also open at the ends and not water tight.</p>
| 767
|
<p>How does a virtual machine generate native machine code on the fly and execute it?</p>
<p>Assuming you can figure out what are the native machine op-codes you want to emit, how do you go about actually running it?</p>
<p>Is it something as hacky as mapping the mnemonic instructions to binary codes, stuffing it into an char* pointer and casting it as a function and executing?</p>
<p>Or would you generate a temporary shared library (.dll or .so or whatever) and load it into memory using standard functions like <code>LoadLibrary</code> ?</p>
|
<p>You can just make the <a href="http://en.wikipedia.org/wiki/Program_counter" rel="noreferrer">program counter</a> point to the code you want to execute. Remember that data can be data or code. On x86 the program counter is the EIP register. The IP part of EIP stands for instruction pointer. The JMP instruction is called to jump to an address. After the jump EIP will contain this address.</p>
<blockquote>
<p>Is it something as hacky as mapping the mnemonic instructions to binary codes, stuffing it into an char* pointer and casting it as a function and executing?</p>
</blockquote>
<p>Yes. This is one way of doing it. The resulting code would be cast to a <a href="http://en.wikipedia.org/wiki/Pointer_to_function" rel="noreferrer">pointer to function</a> in C.</p>
|
<p>As far as i know it compiles everything in memory because it has to run some heuristics to to optimize the code (i.e.: inlining over time) but you can have a look at the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8c09fd61-3f26-4555-ae17-3121b4f51d4d&displaylang=en" rel="nofollow noreferrer">Shared Source Common Language Infrastructure 2.0</a> rotor release. The whole codebase is identical to .NET except for the Jitter and the GC.</p>
| 6,728
|
<p>I'm trying to find the latitude and longitude of the corners of my map while in birdseye view. I want to be able to plot pins on the map, but I have hundreds of thousands of addresses that I want to be able to limit to the ones that need to show on the map.</p>
<p>In normal view, VEMap.GetMapView().TopLeftLatLong and .BottomRightLatLong return the coordinates I need; but in Birdseye view they return blank (or encrypted values). The SDK recommends using VEBirdseyeScene.GetBoundingRectangle(), but this returns bounds of up to two miles from the center of my scene which in major cities still returns way too many addresses.</p>
<p>In previous versions of the VE Control, there was an undocumented VEDecoder object I could use to decrypt the LatLong values for the birdseye scenes, but this object seems to have disappeared (probably been renamed). How can I decode these values in version 6.1?</p>
|
<p>Here's the code for getting the Center Lat/Long point of the map. This method works in both Road/Aerial and Birdseye/Oblique map styles.</p>
<pre><code>function GetCenterLatLong()
{
//Check if in Birdseye or Oblique Map Style
if (map.GetMapStyle() == VEMapStyle.Birdseye || map.GetMapStyle() == VEMapStyle.BirdseyeHybrid)
{
//IN Birdseye or Oblique Map Style
//Get the BirdseyeScene being displayed
var birdseyeScene = map.GetBirdseyeScene();
//Get approximate center coordinate of the map
var x = birdseyeScene.GetWidth() / 2;
var y = birdseyeScene.GetHeight() / 2;
// Get the Lat/Long
var center = birdseyeScene.PixelToLatLong(new VEPixel(x,y), map.GetZoomLevel());
// Convert the BirdseyeScene LatLong to a normal LatLong we can use
return (new _xy1).Decode(center);
}
else
{
// NOT in Birdseye or Oblique Map Style
return map.GetCenter();
}
}
</code></pre>
<p>This code was copied from here:
<a href="http://pietschsoft.com/post/2008/06/Virtual-Earth-Get-Center-LatLong-When-In-Birdseye-or-Oblique-Map-Style.aspx" rel="nofollow noreferrer">http://pietschsoft.com/post/2008/06/Virtual-Earth-Get-Center-LatLong-When-In-Birdseye-or-Oblique-Map-Style.aspx</a></p>
|
<p>According to <a href="http://dev.live.com/virtualearth/sdk/" rel="nofollow noreferrer">http://dev.live.com/virtualearth/sdk/</a> this should do the trick:</p>
<pre><code>function GetInfo()
{
alert('The latitude,longitude at the center of the map is: '+map.GetCenter());
}
</code></pre>
| 5,258
|
<p>This link describes an exploit into my app using fckEditor:
<a href="http://knitinr.blogspot.com/2008/07/script-exploit-via-fckeditor.html" rel="nofollow noreferrer">http://knitinr.blogspot.com/2008/07/script-exploit-via-fckeditor.html</a></p>
<p>How do I make my app secure while still using fckEditor? Is it an fckEditor configuration? Is it some processing I'm supposed to do server-side after I grab the text from fckEditor?</p>
<p>It's a puzzle because fckEditor <em>USES</em> html tags for its formatting, so I can't just HTML encode when I display back the text.</p>
|
<p>Sanitize html server-side, no other choice. For PHP it would be <a href="http://htmlpurifier.org" rel="nofollow noreferrer">HTML Purifier</a>, for .NET I don't know. It's tricky to sanitize HTML - it's not sufficient to strip script tags, you also have to watch out for on* event handlers and even more, thanks to stupidities of IE for example.</p>
<p>Also with custom html and css it's easy to hijack look and layout of your site - using overlay (absolutely positioned) which covers all screen etc. Be prepared for that.</p>
|
<blockquote>
<p>I understand the DONTS. I'm lacking a DO.</p>
</blockquote>
<p>Is use of FCKEditor a requirement, or can you use a different editor/markup language? I advise using Markdown and WMD Editor, the same language used by StackOverflow. The Markdown library for .NET should have an option to escape all HTML tags -- be sure to turn it on.</p>
| 9,144
|
<p>I have an xPC target application that talks to a device over RS-232. I am using the xPC serial block for this.<br>
To talk to this device I first have to start at a default speed, say, 9600 bps, request a change of speed to, say 57600 bps, then change the speed on my side to match it.<br>
The problem with the xPC block is that it forces you to choose a specific speed before running, and can't change it at run time. Is there a way/trick/hack to do this?</p>
|
<p>Here is my take so far. I don't think it can be done using existing Simulink blocks. I think I am going to have to take the xpcserial C code that comes with Matlab, take the code that sets the RS-232 speed, and wrap it in my own S-function.</p>
|
<p>Ian,</p>
<p>What I've done before on this stuff is just modify the registers behind XPC target's back. It's ugly, but xPCTarget is ugly in the first place. </p>
<p>Try modify Line Control Register and set the divisors directly -- all you need is the serial port IO address, and you know that.</p>
<p>It's worth a shot anyway, you're going to have to do it anyway.</p>
| 6,480
|
<p>I would like to monitor a log file that is being written to by an application. I want to process the file line by line as, or shortly after, it is written. I have not found a way of detecting that a file has been extended after reaching eof.</p>
<p>The code needs to work on Mac and PC, and can be in any language, though I am most familiar with C++ and Perl.</p>
<p>Does anybody have a suggestion for the best way to do it?</p>
|
<p>In Perl, the <a href="http://search.cpan.org/dist/File-Tail/" rel="noreferrer">File::Tail</a> module does exactly what you need.</p>
|
<p>I'd have thought outputting the actions via tee, and thence tail'ing (or using the loop <a href="https://stackoverflow.com/questions/62832#63446">above</a>) the file created by tee some use.</p>
| 8,833
|
<p>My coworker and I have encountered a nasty situation where we have to use an active X control to manipulate a web camera on a page. </p>
<p>Is it possible to assign a javascript event handler to a button in the active x control so that it would fire an action on the page when clicked, or do we have to create a button on the html page itself that manipulates the Active X Control and then can fire any necessary actions on the page?</p>
|
<p><em>Please</em> just use an existing ActiveX control. Like Flash or Silverlight. Flash has built-in webcam support and is controllable via JavaScript. Silverlight doesn't have built-in camera support, but it's JavaScript integration is fantastic.</p>
<p>If you must write your own then fret not, it is trivial to get it to interact with JavaScript. You just have to expose the <a href="http://msdn.microsoft.com/en-us/library/ms221608.aspx" rel="noreferrer"><code>IDispatch</code></a> interface.</p>
<p>For events, you need to learn about <a href="http://msdn.microsoft.com/en-us/library/98b11x9k(VS.80).aspx" rel="noreferrer">Connection Points</a>.</p>
|
<p>Yes! You can throw events in C++/ActiveX land which makes the JavaScript code run an event handler function. I was even able to make an entire invisible ActiveX control (same color as page background) with no buttons or visual feedback that did all of its GUI work through JavaScript and CSS.</p>
<p>edit: Frank's advice is right on. <a href="https://msdn.microsoft.com/en-us/library/ms974564.aspx" rel="nofollow noreferrer">Here's the link on scripting events.</a></p>
<p>My strategy was to call a C++ function called MyUpdate (which implements IConnectionPoint) when I wanted to force updates in the browser.</p>
<p>(Also, I made sure to pump Windows messages in the Fire_MyUpdate method because sometimes JavaScript code would call back into C++ land by calling methods on the ActiveX control; this avoids freezing up the browser and ensures that the JavaScript GUI stays responsive, e.g. for a Cancel button.)</p>
<p>On the browser side, the JavaScript code has the global variable referencing the object, followed by "::", followed by the method name:</p>
<pre><code>function Uploader::MyUpdate()
{
// ... code to fetch the current state of various
// properties from the Uploader object and do something with it
// for example check Uploader.IsActive and show or hide an HTML div
}
</code></pre>
| 4,608
|
<p>This is related to <a href="https://stackoverflow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field">another question I asked</a>. In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in!</p>
<p>I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username.</p>
<p>The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it?</p>
<p><strong>Edit</strong>: I'm hoping for a solution that doesn't require anything stored in a database. Application state would be okay, except that it won't survive an IIS restart or work at all in a web farm or garden scenario. I'm accepting Chris's answer, for now, because I'm not convinced it's even possible to secure this without a database. But if someone comes up with an answer that does not involve the database, I'll accept it!</p>
|
<p>If you hash in a time-stamp along with the user name and password, you can close the window for replay attacks to within a couple of seconds. I don't know if this meets your needs, but it is at least a partial solution.</p>
|
<p>If you only accept each key once (say, make the key a GUID, and then check when it comes back), that would prevent replays. Of course, if the attacker responds <em>first</em>, then you have a new problem...</p>
| 6,615
|
<p>I'm writing some data acquisition software and need a gui plotting library that is fast enough to do realtime updated graphs. I've been using Nplot which is pretty good for a free library, but I'm wondering if there are any better libraries (preferably free or cheap).</p>
|
<p>There's a good post about this <a href="http://weblogs.asp.net/gbarnett/archive/2008/06/03/visualising-data.aspx" rel="nofollow noreferrer">here</a> and <a href="http://weblogs.asp.net/gbarnett/archive/2008/03/23/free-graphing-libraries-for-net-my-thoughts.aspx" rel="nofollow noreferrer">here</a>. I have also used NPlot in our last project since it's easier to use.</p>
|
<p>You might want to take a look at <a href="http://teethgrinder.co.uk/open-flash-chart/" rel="nofollow noreferrer">Open Flash Chart</a>. It's an open source graphing tool built in flash and can be dynamically updated.</p>
<p>Check out the <a href="http://teethgrinder.co.uk/open-flash-chart/gallery-js-2.php" rel="nofollow noreferrer">Ajax example</a> for an idea of what it can do.</p>
| 2,760
|
<p>I'm using <a href="http://www.zend.com/en/products/studio/" rel="nofollow noreferrer">Zend Studio</a> to do remote debugging of my php scripts on a dev server. It works great for web code, but can I make it work with command line scripts?</p>
<p>I have several helper apps to make my application run. It would be really useful to fire up the remote debugger through command line instead of a web browser so I can test these out. </p>
<p>I assume it's possible, since I think Zend is using xdebug to talk to Eclipse. Apparently, it adds some parameters to the request to wake the Zend code up on a request. I'm guessing I'd need to tap into that?</p>
<p><em>UPDATE</em></p>
<p>I ended up using xdebug with <a href="http://protoeditor.sourceforge.net/" rel="nofollow noreferrer">protoeditor</a> over X to do my debugging.</p>
|
<p>I was able to get <a href="http://thenazg.blogspot.com/2008/12/remote-cli-debugging-via-eclipse-pdt.html" rel="nofollow noreferrer">remote CLI debugging working in Eclipse</a>, using xdebug, though I've not tried it with the zend debugger. I would assume this should work the same with ZSfE, if that's the "Zend Studio" you're using.</p>
|
<p>Haven't tried, but you can set the QUERY_STRING environment variable to the one that toggles the Zend debugger on.</p>
<p>Per <a href="http://greg.chiaraquartet.net/archives/16-Incredible-Zend-ZDE-debugging-trick-for-debugging-CLI-apps.html" rel="nofollow noreferrer">this article</a>.</p>
<pre><code>export QUERY_STRING=start_debug=1&debug_host=<host name or IP of the local machine>&debug_port=<the port that is configured in your ZDE settings>&debug_stop=1
</code></pre>
<p>And then run the CLI script.</p>
| 4,489
|
<p>I have observed some occasional delamination in horizontal layers of my resin prints — see two examples:</p>
<p><a href="https://i.stack.imgur.com/DxGPD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DxGPD.png" alt="downward" /></a>
<a href="https://i.stack.imgur.com/BZEoF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BZEoF.png" alt="upward" /></a></p>
<p>What is the cause, and how can this be minimized?</p>
|
<p>With the information provided my thought is that your layers are underexposed for their thickness. Each layer is just barely bonding to the layer above it. After being pulled on by layers below eventually one of the layers fails. This is especially likely to happen on a thin part of the print any may need more support if it is followed by wider layers. But I would suggest trying to increase your exposure time first.</p>
<p>option two: it could be your FEP if that has seen too much use it may be time to replace it.</p>
<p><a href="https://ameralabs.com/blog/key-things-calibrating-resin-3d-printer/" rel="nofollow noreferrer">calibrating a resin 3D printer</a></p>
|
<p><a href="https://3dprinting.stackexchange.com/a/14947/8884">Besides the options of underexposure or bad FEP film</a>, there's also the option of the print being in a bad orientation for printing. Often, the quality gets better if you tilt the model some degrees. You do have to clean up some places, but the stresses from pulling free of the FEP get distributed more evenly and are lower, resulting in generally better prints.</p>
<p>Other factors that can impact the print quality is the resin's viscosity: the more viscous, the more likely resin can't flow in enough. Resin's viscosity is antiproportional to the room temperature - the hotter the room, the less viscous the resin.</p>
| 1,780
|
<p>What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes).</p>
<p>I've already seen a <a href="http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/" rel="noreferrer">few</a> <a href="http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/" rel="noreferrer">ways</a> to do it, but can't decide on which one is the best.</p>
|
<p>The least painful and indeed Django-recommended way of doing this is through a <code>OneToOneField(User)</code> property.</p>
<blockquote>
<h2><a href="https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model" rel="noreferrer">Extending the existing User model</a></h2>
<p>…</p>
<p>If you wish to store information related to <code>User</code>, you can use a <a href="https://docs.djangoproject.com/en/dev/ref/models/fields/#ref-onetoone" rel="noreferrer">one-to-one relationship</a> to a model containing the fields for additional information. This one-to-one model is often called a profile model, as it might store non-auth related information about a site user.</p>
</blockquote>
<p>That said, extending <code>django.contrib.auth.models.User</code> and supplanting it also works...</p>
<blockquote>
<h2><a href="https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model" rel="noreferrer">Substituting a custom User model</a></h2>
<p>Some kinds of projects may have authentication requirements for which Django’s built-in <code>User</code> model is not always appropriate. For instance, on some sites it makes more sense to use an email address as your identification token instead of a username.</p>
<p><em>[Ed: <strong>Two warnings and a notification follow</strong>, mentioning that this is <strong>pretty drastic</strong>.]</em></p>
</blockquote>
<p>I would definitely stay away from changing the actual User class in your Django source tree and/or copying and altering the auth module.</p>
|
<p>Currently as of Django 2.2, the recommended way when starting a new project is to create a custom user model that inherits from AbstractUser, then point AUTH_USER_MODEL to the model.</p>
<p>Source: <a href="https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project" rel="nofollow noreferrer">https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project</a></p>
| 6,577
|
<p>Need to parse some basic XML (one root element, 3-4 subelements, 1-3 attributes each) from a ksh script (ideally stick to ksh, given the script already exists and it's just trying to read some extra configuration created in XML by another program).</p>
<p>I know I can use sed and do pattern matching, but it's not foolproof given that the input XML could change and attributes could be duplicated on the various subelements (or new subelements).</p>
<p>So far, I'm thinking of using an XSLT against the XML to extract the few attributes (for specific elements) that the ksh script cares about as individual fields. I can use Oracle for this given we are a DB-driven product, and Oracle would always be installed on our systems, but that seems a bit heavy handed. </p>
<p>Any other safe approach to extract specific attributes from the input XML in a cross-platform manner that doesn't require access to 3rd-party parser/transformer?</p>
|
<p>You might want to take a look at this <a href="http://www.linuxfromscratch.org/pipermail/alfs-discuss/2006-January/007537.html" rel="nofollow noreferrer">pure bash implementation</a>, if keeping it all in shell script is that important.</p>
<p>That said, other scripting languages such as Python and Perl are also highly portable, and will make your life a lot easier. Perl's <a href="http://xmltwig.com/xmltwig/" rel="nofollow noreferrer">XML::Twig</a> module, for instance, comes with an end-user script called "xml_grep", which can already be passed the <code>--text_only</code> option to extract just the text of a node found from a complex search. It shouldn't be that much harder to modify it to return a specified attribute as well.</p>
|
<p>Can't do it entirely in ksh, but try python xml?</p>
<p>If you want lightweight, you might try libxml2 and a small C program.</p>
| 8,802
|
<p>I'm looking for shell scripts files installed on my system, but <strong>find</strong> doesn't work:</p>
<pre><code>$ find /usr -name *.sh
</code></pre>
<p>But I know there are a ton of scripts out there. For instance:</p>
<pre><code>$ ls /usr/local/lib/*.sh
/usr/local/lib/tclConfig.sh
/usr/local/lib/tkConfig.sh
</code></pre>
<p>Why doesn't <strong>find</strong> work?</p>
|
<p>Try quoting the wildcard:</p>
<pre><code>$ find /usr -name \*.sh
</code></pre>
<p>or:</p>
<pre><code>$ find /usr -name '*.sh'
</code></pre>
<p>If you happen to have a file that matches <strong>*.sh</strong> in the current working directory, the wildcard will be expanded before find sees it. If you happen to have a file named tkConfig.sh in your working directory, the <strong>find</strong> command would expand to:</p>
<pre><code>$ find /usr -name tkConfig.sh
</code></pre>
<p>which would only find files named tkConfig.sh. If you had more than one file that matches <strong>*.sh</strong>, you'd get a syntax error from <strong>find</strong>:</p>
<pre><code>$ cd /usr/local/lib
$ find /usr -name *.sh
find: bad option tkConfig.sh
find: path-list predicate-list
</code></pre>
<p>Again, the reason is that the wildcard expands to both files:</p>
<pre><code>$ find /usr -name tclConfig.sh tkConfig.sh
</code></pre>
<p>Quoting the wildcard prevents it from being prematurely expanded.</p>
<p>Another possibility is that /usr or one of its subdirectories is a symlink. <strong>find</strong> doesn't normally follow links, so you might need the <strong>-follow</strong> option:</p>
<pre><code>$ find /usr -follow -name '*.sh'
</code></pre>
|
<p>For finding files on your disks, lean to use "locate" instead that is instantaneous
(looks into a daily built index)
you example would be:</p>
<pre><code>locate '/usr*.sh'
</code></pre>
| 3,936
|
<p>Let’s say I'm developing a helpdesk application that will be used by multiple departments. Every URL in the application will include a key indicating the specific department. The key will always be the first parameter of every action in the system. For example</p>
<pre><code>http://helpdesk/HR/Members
http://helpdesk/HR/Members/PeterParker
http://helpdesk/HR/Categories
http://helpdesk/Finance/Members
http://helpdesk/Finance/Members/BruceWayne
http://helpdesk/Finance/Categories
</code></pre>
<p>The problem is that in each action on each request, I have to take this parameter and then retrieve the Helpdesk Department model from the repository based on that key. From that model I can retrieve the list of members, categories etc., which is different for each Helpdesk Department. This obviously violates DRY.</p>
<p>My question is, how can I create a base controller, which does this for me so that the particular Helpdesk Department specified in the URL is available to all derived controllers, and I can just focus on the actions?</p>
|
<p>I have a similar scenario in one of my projects, and I'd tend to use a ModelBinder rather than using a separate inheritance hierarchy. You can make a ModelBinder attribute to fetch the entity/entites from the RouteData:</p>
<pre><code>public class HelpdeskDepartmentBinder : CustomModelBinderAttribute, IModelBinder {
public override IModelBinder GetBinder() {
return this;
}
public object GetValue(ControllerContext controllerContext, string modelName, Type modelType, ModelStateDictionary modelState) {
//... extract appropriate value from RouteData and fetch corresponding entity from database.
}
}
</code></pre>
<p>...then you can use it to make the HelpdeskDepartment available to all your actions:</p>
<pre><code>public class MyController : Controller {
public ActionResult Index([HelpdeskDepartmentBinder] HelpdeskDepartment department) {
return View();
}
}
</code></pre>
|
<p><em>Disclaimer: I'm currently running MVC Preview 5, so some of this may be new.</em></p>
<p>The best-practices way: Just implement a static utility class that provides a method that does the model look-up, taking the RouteData from the action as a parameter. Then, call this method from all actions that require the model.</p>
<p>The kludgy way, for only if every single action in every single controller needs the model, and you really don't want to have an extra method call in your actions: In your Controller-implementing-base-class, override ExecuteCore(), use the RouteData to populate the model, then call the base.ExecuteCore().</p>
| 9,373
|
<p>We created a tool which converts a language called P2, a language similar to assembly which I think exists only in Japan, to C#. There are at least a hundred modules written in P2 and we want to verify if the conversion to C# is right? How can we test this?</p>
|
<p>You don't test the converter, you test the final code. </p>
<p>If the code doesn't compile, clearly your converter is failing. If the code compiles and your functionality tests fail, then you can tweak the code so that it passes the test. If you are fairly successful you should see that you only need to fix the modules that actually fail.</p>
<p>Goodluck!</p>
|
<p>Short of a formal mathematical proof (which I imagine would be difficult), the proof of the pudding is in the unit tests. You have to find a way to wrap the converted C# snippets, compile the and run them under a similar environment, then compare the output against the original. Unless you're rigorous in your testing, there's no way you can be confident of the result.</p>
| 3,808
|
<p>I am looking at printing a fair amount of text, ideally using some custom fonts. I quite like <a href="https://pixelify.net/download/free-fonts/script-handwritten/stay-classy-font-free/" rel="nofollow noreferrer">Stay Classy</a> but will likely have to consider change if it causes issues.</p>
<p>I am a little stuck on where to start with using these in some tools. I have tried creating an SVG using the font and importing to Tinkercad however that always fails. I only want to print the text, nothing else.</p>
<p>How do I properly convert my font into .svg and import that so I can make my bodies? While I have tried Tinkercad I am open to alternative tools if this can be achieved more easily.</p>
|
<p>I think @Trish answered your question more specifically, but an alternate route (that I think its simpler assuming you don't mind the learning curve) is using Blender.</p>
<p>Rather than creating an svg in a different software and having to go from something like photoshop to inkscape to tinkercad to your printer software... Blender could do most of that in one step, and its free.</p>
<p>In Blender, add text:
<a href="https://i.stack.imgur.com/8vXWf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8vXWf.png" alt="enter image description here" /></a></p>
<p>Hit tab to go into "Edit" mode and in edit mode you can simply backspace and type whatever you want.
<a href="https://i.stack.imgur.com/UdUXU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UdUXU.png" alt="enter image description here" /></a></p>
<p>In the "Font" menu, you can choose from any font on your computer.
<a href="https://i.stack.imgur.com/1hkC1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1hkC1.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/zMbeY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zMbeY.png" alt="enter image description here" /></a></p>
<p>And you can make it "3D" by extruding it:
<a href="https://i.stack.imgur.com/SzlG0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SzlG0.png" alt="enter image description here" /></a></p>
<p>When it looks good and you're ready to print it, make sure to convert it to a mesh, then export as .stl for your printing software. (Cura/Slic3r/etc.)
<a href="https://i.stack.imgur.com/5V2yx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5V2yx.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/03VPQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/03VPQ.png" alt="enter image description here" /></a></p>
|
<p>Fonts are not saved in a format that is .svg compatible. However, text that is written in a font and saved as a black-and-white picture can be turned into a .svg by software. This .svg can be imported by Tinkercad then.</p>
<h1>Step 1: Text Picture</h1>
<p>Use any software to create a .png or .jpg or something similar. Among the multitude of programs that can do this are GIMP and Adobe Photoshop. Even Paint can do this, or any word processor and then screen capture. If you know your Inkscape, you can skip this.</p>
<h1>Step 2: making the .svg</h1>
<p>Either you use software like <a href="https://inkscape.org/" rel="nofollow noreferrer">Inkscape</a> to import your picture and trace the outlines, or you use a web service. For example <a href="https://convertio.co/jpg-svg" rel="nofollow noreferrer">Convertino</a> or the <a href="http://www.fontsquirrel.com/tools/webfont-generator" rel="nofollow noreferrer">Fontquirrel Webfont generator</a>. You only need the outlines, no filling!</p>
<p>In Inkscape the rundown to tracing is:</p>
<ul>
<li>File/Import</li>
<li>Path/Trace Bitmap</li>
<li>Update
<ul>
<li>OK</li>
</ul>
</li>
</ul>
<h1>Step 3: Import</h1>
<p>You got your outline .svg, so import that into any software and you can start making your embossed letters. Personally, I would use Fusion360, but most CAD software support importing an SVG and treat that the same as if you had sketched in that software.</p>
| 1,842
|
<p>I need to produce a calculation trace file containing tabular data showing intermediate results. I am currently using a combination of the standard ascii pipe symbols (|) and dashes (-) to draw the table lines:</p>
<p>E.g. </p>
<pre><code>Numerator | Denominator | Result
----------|-------------|-------
6 | 2 | 3
10 | 5 | 2
</code></pre>
<p>Are there any unicode characters that could be used to produce a more professional looking table?</p>
<p>(The file must be a raw text format and cannot use HTML or any other markup)</p>
<p><strong>Edit:</strong> I've added an example of what the table now looks like having taken the suggestion on board and used the unicode box drawing characters:</p>
<pre><code>Numerator │ Denominator │ Result
──────────┼─────────────┼───────
6 │ 2 │ 3
10 │ 5 │ 2
</code></pre>
|
<p>There are <a href="http://www.unicode.org/charts/symbols.html" rel="nofollow noreferrer">Unicode box drawing characters</a> (look for Box Drawing under Geometrical Symbols - the <a href="http://www.unicode.org/charts/PDF/U2500.pdf" rel="nofollow noreferrer">chart itself</a> is a PDF). I don't have any idea how widely supported those characters are, though.</p>
|
<p>You should look at this <a href="https://marklodato.github.io/js-boxdrawing/" rel="nofollow noreferrer"><strong>Javascript Box Drawing Demo</strong></a>. This is a JavaScript Unicode box drawing tool whose purpose is to make it easy for users to draw <strong>Unicode box art in HTML textareas</strong>. There you will see how to draw boxes using the arrow keys.</p>
<ul>
<li><p>First you should select a style other than "<strong>Off</strong>". </p></li>
<li><p>Then using the <strong>arrow keys</strong> move around and you will see the box being drawn as you type</p></li>
<li><p>Once you are satisfied with the look of your drawing, simply copy it from the box and paste it on your HTML code.</p></li>
</ul>
| 5,635
|
<p>For example, if passed the following:</p>
<pre><code>a = []
</code></pre>
<p>How do I check to see if <code>a</code> is empty?</p>
|
<pre><code>if not a:
print("List is empty")
</code></pre>
<p>Using the <a href="https://docs.python.org/library/stdtypes.html#truth-value-testing" rel="noreferrer">implicit booleanness</a> of the empty <code>list</code> is quite Pythonic.</p>
|
<p>Simply use is_empty() or make function like:- </p>
<pre><code>def is_empty(any_structure):
if any_structure:
print('Structure is not empty.')
return True
else:
print('Structure is empty.')
return False
</code></pre>
<p>It can be used for any data_structure like a list,tuples, dictionary and many more. By these, you can call it many times using just <code>is_empty(any_structure)</code>. </p>
| 7,701
|
<p>In SQL Server 2005, we can create temp tables one of two ways:</p>
<pre><code>declare @tmp table (Col1 int, Col2 int);
</code></pre>
<p>or</p>
<pre><code>create table #tmp (Col1 int, Col2 int);
</code></pre>
<p>What are the differences between these two? I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory. </p>
<p>In which scenarios does one out-perform the other? </p>
|
<p>There are a few differences between Temporary Tables (#tmp) and Table Variables (@tmp), although using tempdb isn't one of them, as spelt out in the MSDN link below.</p>
<p>As a rule of thumb, for small to medium volumes of data and simple usage scenarios you should use table variables. (This is an overly broad guideline with of course lots of exceptions - see below and following articles.)</p>
<p>Some points to consider when choosing between them: </p>
<ul>
<li><p>Temporary Tables are real tables so you can do things like CREATE INDEXes, etc. If you have large amounts of data for which accessing by index will be faster then temporary tables are a good option.</p></li>
<li><p>Table variables can have indexes by using PRIMARY KEY or UNIQUE constraints. (If you want a non-unique index just include the primary key column as the last column in the unique constraint. If you don't have a unique column, you can use an identity column.) <a href="https://stackoverflow.com/questions/886050/sql-server-creating-an-index-on-a-table-variable/17385085#17385085">SQL 2014 has non-unique indexes too</a>.</p></li>
<li><p>Table variables don't participate in transactions and <code>SELECT</code>s are implicitly with <code>NOLOCK</code>. The transaction behaviour can be very helpful, for instance if you want to ROLLBACK midway through a procedure then table variables populated during that transaction will still be populated!</p></li>
<li><p>Temp tables might result in stored procedures being recompiled, perhaps often. Table variables will not.</p></li>
<li><p>You can create a temp table using SELECT INTO, which can be quicker to write (good for ad-hoc querying) and may allow you to deal with changing datatypes over time, since you don't need to define your temp table structure upfront. </p></li>
<li><p>You can pass table variables back from functions, enabling you to encapsulate and reuse logic much easier (eg make a function to split a string into a table of values on some arbitrary delimiter).</p></li>
<li><p>Using Table Variables within user-defined functions enables those functions to be used more widely (see CREATE FUNCTION documentation for details). If you're writing a function you should use table variables over temp tables unless there's a compelling need otherwise.</p></li>
<li><p>Both table variables and temp tables are stored in tempdb. But table variables (since 2005) default to the collation of the current database versus temp tables which take the default collation of tempdb (<a href="https://learn.microsoft.com/sql/t-sql/language-elements/declare-local-variable-transact-sql" rel="noreferrer">ref</a>). This means you should be aware of collation issues if using temp tables and your db collation is different to tempdb's, causing problems if you want to compare data in the temp table with data in your database.</p></li>
<li><p>Global Temp Tables (##tmp) are another type of temp table available to all sessions and users. </p></li>
</ul>
<p>Some further reading:</p>
<ul>
<li><p><a href="https://dba.stackexchange.com/a/16386">Martin Smith's great answer</a> on dba.stackexchange.com</p></li>
<li><p>MSDN FAQ on difference between the two: <a href="https://support.microsoft.com/en-gb/kb/305977" rel="noreferrer">https://support.microsoft.com/en-gb/kb/305977</a></p></li>
<li><p>MDSN blog article: <a href="https://learn.microsoft.com/archive/blogs/sqlserverstorageengine/tempdb-table-variable-vs-local-temporary-table" rel="noreferrer">https://learn.microsoft.com/archive/blogs/sqlserverstorageengine/tempdb-table-variable-vs-local-temporary-table</a></p></li>
<li><p>Article: <a href="https://searchsqlserver.techtarget.com/tip/Temporary-tables-in-SQL-Server-vs-table-variables" rel="noreferrer">https://searchsqlserver.techtarget.com/tip/Temporary-tables-in-SQL-Server-vs-table-variables</a></p></li>
<li><p>Unexpected behaviors and performance implications of temp tables and temp variables: <a href="https://sql.kiwi/2012/08/temporary-tables-in-stored-procedures.html" rel="noreferrer">Paul White on SQLblog.com</a></p></li>
</ul>
|
<p>In SQL the Temporary tables are stored in the TempDB and the local temporary tables are only visible in the current session and it will not be visible in another session. This can be shared between nested stored procedure calls. The Global temporary tables are visible to all other sessions and they are destroyed when the last connection referencing table is closed. For Example,</p>
<pre><code>Select Dept.DeptName, Dept.DeptId, COUNT(*) as TotalEmployees
into #TempEmpCount
from Tbl_EmpDetails Emp
join Tbl_Dept Dept
on Emp.DeptId = Dept.DeptId
group by DeptName, Dept.DeptId
</code></pre>
<p>Table variables are similar to tempTables, a table variable is also created in TempDB. The scope of a table variable is the batch, stored procedure, or statement block in which it is declared. They can be passed as parameters between procedures. The same query can be written using Table variable by</p>
<pre><code>Declare @tblEmployeeCount table
(DeptName nvarchar(20),DeptId int, TotalEmployees int)
Insert @tblEmployeeCount
Select DeptName, Tbl_Dept.DeptId, COUNT(*) as TotalEmployees
from Tbl_EmpDetails
join Tbl_Dept
on Tbl_EmpDetails.DeptId = Tbl_Dept.DeptId
group by DeptName, Tbl_Dept.DeptId
</code></pre>
| 4,755
|
<p>I use Eclipse, Maven, and Java in my development. I use Maven to download dependencies (jar files and javadoc when available) and Maven's eclipse plug-in to generate the .project and .classpath files for Eclipse. When the dependency downloaded does not have attached javadoc I manually add a link for the javadoc in the .classpath file so that I can see the javadoc for the dependency in Eclipse. Then when I run Maven's eclipse plugin to regenerate the .classpath file it of course wipes out that change.</p>
<p>Is there a way to configure Maven's eclipse plug-in to automatically add classpath attributes for javadoc when running Maven's eclipse plug-in? </p>
<p>I'm only interested in answers where the javadoc and/or sources are not provided for the dependency in the maven repository, which is the case most often for me. Using downloadSources and/or downloadJavadocs properties won't help this problem.</p>
|
<p>From the Maven Eclipse Plugin <a href="http://maven.apache.org/plugins/maven-eclipse-plugin/examples/attach-library-sources.html" rel="noreferrer">FAQ</a></p>
<blockquote>
<p>The following example shows how to do
this in the command-line:</p>
<pre><code>mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
</code></pre>
<p>or in your pom.xml:</p>
<pre><code><project>
[...]
<build>
[...]
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
[...]
</plugins>
[...]
</build>
[...]
</project>
</code></pre>
</blockquote>
|
<p>Would having the sources for the dependency help? You can tell the eclipse plugin to download those (and refer to them in the .classpath) with <code>-DdownloadSources=true</code></p>
| 6,617
|
<p>I have created a database report generator in Excel. I am trying to create a dialog box that displays status information as the program runs.</p>
<p>When I generate the report, although the dialog box appears, I cannot refresh/update the information it displays. Most of the time, the dialog box only partially appears. I have tried using the .repaint method, but I still get the same results. I only see the complete dialog box, after the report is generated.</p>
|
<p>I have used Excel's own status bar (in bottom left of window) to display progress information for a similar application I developed in the past.</p>
<p>It works out very well if you just want to display textual updates on progress, and avoids the need for an updating dialog at all.</p>
<p>Ok @JonnyGold, here's an example of the kind of thing I used...</p>
<pre><code>Sub StatusBarExample()
Application.ScreenUpdating = False
' turns off screen updating
Application.DisplayStatusBar = True
' makes sure that the statusbar is visible
Application.StatusBar = "Please wait while performing task 1..."
' add some code for task 1 that replaces the next sentence
Application.Wait Now + TimeValue("00:00:02")
Application.StatusBar = "Please wait while performing task 2..."
' add some code for task 2 that replaces the next sentence
Application.Wait Now + TimeValue("00:00:02")
Application.StatusBar = False
' gives control of the statusbar back to the programme
End Sub
</code></pre>
<p>Hope this helps!</p>
|
<p>The dialog box is also running on the same UI thread. So, it is too busy to repaint itself. Not sure if VBA has good multi-threading capabilities.</p>
| 7,516
|
<p>In GWT I have to specify what locales are supported in my application. The code get compiled in various files, one for each locale (beside other versions), but I have to give my clients one only URL. This URL is supposed to be a page that should be displayed according to the locale preferred by the browser.
I dont't want to have an HTTP parameter for the locale since I want to forse the locale preferred by the browser.
How can this be coded in GWT?</p>
<p>Should I try to to this using apache rewrite rules? I thied it, but I think I cannot access such parameter easely in a rewrite rule.</p>
<p>Thanks a lot,
Giuseppe</p>
|
<p>I had the same problem as you, but as I really need to know the current locale (I'm requesting a second server for data that I want to be localizable) I found this class:
<code>com.google.gwt.i18n.client.LocaleInfo#getCurrentLocale()</code>. That should give you what GWT uses currently.</p>
|
<p>Unless I am reading the documentation incorrectly I don't think you have to do anything.</p>
<p><a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Internationalization.html#SpecifyingLocale" rel="nofollow noreferrer">GWT and Locale</a></p>
<blockquote>
<p>By making locale a client property, the standard startup process in gwt.js chooses the appropriate localized version of an application, providing ease of use (it's easier than it might sound!), optimized performance, and minimum script size. </p>
</blockquote>
<p>The way I read it, as long as your module has added all the locale choices to it, it should be automatic?</p>
| 3,742
|
<p>How do I Unit Test a MVC redirection?</p>
<pre><code>public ActionResult Create(Product product)
{
_productTask.Save(product);
return RedirectToAction("Success");
}
public ActionResult Success()
{
return View();
}
</code></pre>
<p>Is <a href="http://www.ayende.com/Blog/archive/2007/12/13/Dont-like-visibility-levels-change-that.aspx" rel="nofollow noreferrer">Ayende's</a> approach still the best way to go, with preview 5:</p>
<pre><code> public static void RenderView(this Controller self, string action)
{
typeof(Controller).GetMethod("RenderView").Invoke(self,new object[] { action} );
}
</code></pre>
<p>Seems odd to have to do this, especially as the MVC team have said they are writing the framework to be testable.</p>
|
<pre><code>[TestFixture]
public class RedirectTester
{
[Test]
public void Should_redirect_to_success_action()
{
var controller = new RedirectController();
var result = controller.Index() as RedirectToRouteResult;
Assert.That(result, Is.Not.Null);
Assert.That(result.Values["action"], Is.EqualTo("success"));
}
}
public class RedirectController : Controller
{
public ActionResult Index()
{
return RedirectToAction("success");
}
}
</code></pre>
|
<p>You can assert on the ActionResult that is returned, you'll need to cast it to the appropriate type but it does allow you to use state-based testing. A search on the Web should find some useful links, here's <a href="http://sebastienlachance.com/2008/05/06/testing-controllers-in-aspnet-mvc-aka-actionresult/" rel="nofollow noreferrer">just one</a> though.</p>
| 8,286
|
<p>I recently downloaded ndepend and ran an analysis on an open source project I participate in.</p>
<p>I did not now where to look next - a bit of visual and information overload and it turned out I don't even know where to start.</p>
<p>Can anyone suggest starting points?</p>
<ul>
<li>What information should I look for first?</li>
<li>What points out problems in the code (in a BIG way)?</li>
<li>What would the low hanging fruit that can immediately seen?</li>
</ul>
|
<p>Scott Hanselman / Stuart Celarier / Patrick Cauldwell's <a href="http://www.hanselman.com/blog/EducatingProgrammersWithPlacematsNDependStaticAnalysisPoster.aspx" rel="noreferrer">poster</a> with ndepend metrics has some useful information on it. Rather than trying to break down all the heuristics being used I'd focus on only a few at a time starting with "zone of pain / zone of uselessness" and cyclomatic complexity. </p>
<p>There is also a <a href="http://www.hanselman.com/blog/HanselminutesPodcast51StaticCodeAnalysisWithNDepend.aspx" rel="noreferrer">podcast</a> which covers some of the basics of the tool. </p>
<p>Between that and running nDepend on a few different projects you may be able to start gathering useful data that you can make into insights.</p>
|
<p>Excellent pair of web casts (30 minute videos) where Patrick Smacchia and Filip Ekberg talk through some of the features of nDepend and how to use them:</p>
<p><a href="http://codebetter.com/patricksmacchia/2012/10/31/two-screencasts-on-how-to-demystify-spaghetti-code/" rel="nofollow">http://codebetter.com/patricksmacchia/2012/10/31/two-screencasts-on-how-to-demystify-spaghetti-code/</a></p>
| 6,640
|
<p>I want to prevent XSS attacks in my web application. I found that HTML Encoding the output can really prevent XSS attacks. Now the problem is that how do I HTML encode every single output in my application? I there a way to automate this?</p>
<p>I appreciate answers for JSP, ASP.net and PHP.</p>
|
<p>You don't want to encode all HTML, you only want to HTML-encode any user input that you're outputting. </p>
<p>For PHP: <a href="http://us.php.net/htmlentities" rel="nofollow noreferrer">htmlentities</a> and <a href="http://us.php.net/manual/en/function.htmlspecialchars.php" rel="nofollow noreferrer">htmlspecialchars</a></p>
|
<p>If you do actually HTML encode every single output, the user will see plain text of &lt;html&gt; instead of a functioning web app.</p>
<p>EDIT: If you HTML encode every single input, you'll have problem accepting external password containing < etc..</p>
| 8,311
|
<p>I've got to get a directory listing that contains about 2 million files, but when I do an <code>ls</code> command on it nothing comes back. I've waited 3 hours. I've tried <code>ls | tee directory.txt</code>, but that seems to hang forever. </p>
<p>I assume the server is doing a lot of inode sorting. Is there any way to speed up the <code>ls</code> command to just get a directory listing of filenames? I don't care about size, dates, permission or the like at this time.</p>
|
<pre><code>ls -U
</code></pre>
<p>will do the ls without sorting.</p>
<p>Another source of slowness is <code>--color</code>. On some linux machines, there is a convenience alias which adds <code>--color=auto'</code> to the ls call, making it look up file attributes for each file found (slow), to color the display. This can be avoided by <code>ls -U --color=never</code> or <code>\ls -U</code>.</p>
|
<p>Lots of other good solutions here, but in the interest of completeness:</p>
<pre><code>echo *
</code></pre>
| 6,142
|
<p>I am new to 3d printing having only recieved it for christmas. The filament is jammed somewhere in the extruder of my Wanhao Duplicator i3 Plus. I have tried removing it with the included hook but was unsuccessful. Is there anything else I should try before I before I dismantle the extruder, which i very much want to avoid.</p>
|
<p>Try to preheat your printer, the temperature should be above 180°C then push the filament to come out from the nozzle just 4 to 7 mm, then take out the filament from the extruder. With this step the plastic lump will get soft and will release the filament.</p>
<p>Then use the tool to clean the nozzle pushing the residue inside the nozzle.</p>
<p>This is a common problem if someone tries to change the filament without feeding a little bit (3-5mm).</p>
|
<p>Try to preheat your printer, the temperature should be above 180°C then push the filament to come out from the nozzle just 4 to 7 mm, then take out the filament from the extruder. With this step the plastic lump will get soft and will release the filament.</p>
<p>Then use the tool to clean the nozzle pushing the residue inside the nozzle.</p>
<p>This is a common problem if someone tries to change the filament without feeding a little bit (3-5mm).</p>
| 778
|
<p>I am looking to 3D print some small molds that will allow wood glue to dry but <em><strong>not</strong></em> stick.</p>
<p>Is there a recommended filament that is known to <em><strong>resist</strong></em> binding to simple wood glue?</p>
<p>Alternately, is there an inexpensive adhesive (like wood glue) I could use instead that will <em><strong>not</strong></em> stick to the 3D printed mold?</p>
|
<p>You are looking for a filament that does not bond to wood glue, or as weak as possible. You misunderstand how wood glue "bonds" to plastics:</p>
<p>Wood glue is typically PVA. It <em>bonds</em> to wood and paper by seeping into them before curing and hardening. The mesh of the glue entangles fibers of the wood/paper and itself, bonding with not only the exposed surface but also with material up to the depth it penetrates.</p>
<p>When such a glue is applied to a typical print surface, it seeps into the cracks and through print imperfections but does not penetrate the print to the same degree as it does in the open wood fiber setup. It clings to the surface and only bonds - if it does - only to the surface layers. The <em>same</em> effect happens when you cast resin into for example a silicone mold: there is much less chemical bonding, at best at the interface, and quite some interlock.</p>
<p>To prevent such, two things should be made: first, you need to smooth the mold as much as possible and have all the angles right. It might be easier and faster to coat the hard molds in a smooth lacquer, which not only removes the creep areas but also acts as an interlayer, making release easier.</p>
<p>Then, you should use a mold release agent. Mold release agents come in many shapes: I have seen Talcum Powder being used effectively for both metal as well as cold casts, if the shape of the mold was well made (no undercuts, no unpowdered areas). Easier to apply are usually mold release sprays for many applications - careful, some are PVA based and would be the same as the glue you want to cast. For a concrete casting, I had used plant fat as a decent mold release agent.</p>
<p>What might be an alternative to wood glue depends on what you want to do with the finished product.</p>
<p>As far as materials that actively don't bond go, you could look into POM (Which is a pain to print and expensive - it's a bearing material) or nylon (also a pain to print).</p>
|
<p>You are looking for a filament that does not bond to wood glue, or as weak as possible. You misunderstand how wood glue "bonds" to plastics:</p>
<p>Wood glue is typically PVA. It <em>bonds</em> to wood and paper by seeping into them before curing and hardening. The mesh of the glue entangles fibers of the wood/paper and itself, bonding with not only the exposed surface but also with material up to the depth it penetrates.</p>
<p>When such a glue is applied to a typical print surface, it seeps into the cracks and through print imperfections but does not penetrate the print to the same degree as it does in the open wood fiber setup. It clings to the surface and only bonds - if it does - only to the surface layers. The <em>same</em> effect happens when you cast resin into for example a silicone mold: there is much less chemical bonding, at best at the interface, and quite some interlock.</p>
<p>To prevent such, two things should be made: first, you need to smooth the mold as much as possible and have all the angles right. It might be easier and faster to coat the hard molds in a smooth lacquer, which not only removes the creep areas but also acts as an interlayer, making release easier.</p>
<p>Then, you should use a mold release agent. Mold release agents come in many shapes: I have seen Talcum Powder being used effectively for both metal as well as cold casts, if the shape of the mold was well made (no undercuts, no unpowdered areas). Easier to apply are usually mold release sprays for many applications - careful, some are PVA based and would be the same as the glue you want to cast. For a concrete casting, I had used plant fat as a decent mold release agent.</p>
<p>What might be an alternative to wood glue depends on what you want to do with the finished product.</p>
<p>As far as materials that actively don't bond go, you could look into POM (Which is a pain to print and expensive - it's a bearing material) or nylon (also a pain to print).</p>
| 1,837
|
<p>Is there an existing application or library in <em>Java</em> which will allow me to convert a <code>CSV</code> data file to <code>XML</code> file? </p>
<p>The <code>XML</code> tags would be provided through possibly the first row containing column headings.</p>
|
<p>Maybe this might help: <a href="http://jsefa.sourceforge.net/quick-tutorial.html" rel="noreferrer">JSefa</a></p>
<p>You can read CSV file with this tool and serialize it to XML.</p>
|
<p>This may be too basic or limited of a solution, but couldn't you do a <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)" rel="nofollow noreferrer"><code>String.split()</code></a> on each line of the file, remembering the result array of the first line to generate the XML, and just spit each line's array data out with the proper XML elements padding each iteration of a loop?</p>
| 2,257
|
<p>In the code below</p>
<pre><code>For i = LBound(arr) To UBound(arr)
</code></pre>
<p>What is the point in asking using <code>LBound</code>? Surely that is always 0.</p>
|
<p>Why not use <code>For Each</code>? That way you don't need to care what the <code>LBound</code> and <code>UBound</code> are.</p>
<pre><code>Dim x, y, z
x = Array(1, 2, 3)
For Each y In x
z = DoSomethingWith(y)
Next
</code></pre>
|
<p>This is my approach:</p>
<pre><code>dim arrFormaA(15)
arrFormaA( 0 ) = "formaA_01.txt"
arrFormaA( 1 ) = "formaA_02.txt"
arrFormaA( 2 ) = "formaA_03.txt"
arrFormaA( 3 ) = "formaA_04.txt"
arrFormaA( 4 ) = "formaA_05.txt"
arrFormaA( 5 ) = "formaA_06.txt"
arrFormaA( 6 ) = "formaA_07.txt"
arrFormaA( 7 ) = "formaA_08.txt"
arrFormaA( 8 ) = "formaA_09.txt"
arrFormaA( 9 ) = "formaA_10.txt"
arrFormaA( 10 ) = "formaA_11.txt"
arrFormaA( 11 ) = "formaA_12.txt"
arrFormaA( 12 ) = "formaA_13.txt"
arrFormaA( 13 ) = "formaA_14.txt"
arrFormaA( 14 ) = "formaA_15.txt"
Wscript.echo(UBound(arrFormaA))
''displays "15"
For i = 0 To UBound(arrFormaA)-1
Wscript.echo(arrFormaA(i))
Next
</code></pre>
<p>Hope it helps.</p>
| 2,450
|
<p>I had a Z probe installed but the wires came out of the header so I am trying to use software endstops, but any time I <code>G28</code> the nozzle will always ram into the bed. I am using Marlin Firmware. Which I am relatively new with. I'm used to having hardware endstops, but,</p>
<p><strong>I don't have a hardware endstop currently (no probe/no switch).</strong> </p>
<ul>
<li><p>Is it possible to do this with software? </p></li>
<li><p>I took out <code>G28</code>/<code>G29</code> in my G-code and it shows that it is going to z0.2 and working upward (but it still hits the bed). If the bed is level do I need a <code>G28</code>?</p></li>
<li><p>Should Z probe offset be 0?</p></li>
</ul>
<pre>
#define USE_XMIN_PLUG
#define USE_YMIN_PLUG
#define USE_ZMIN_PLUG
//#define USE_XMAX_PLUG
//#define USE_YMAX_PLUG
//#define USE_ZMAX_PLUG
#if DISABLED(ENDSTOPPULLUPS)
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_ZMIN_PROBE
#endif
#define X_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
#define Z_MIN_PROBE_ENDSTOP_INVERTING true // set to true to invert the logic of the probe.
// Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles.
#define ENDSTOP_INTERRUPTS_FEATURE
#define PROBE_MANUALLY
#define X_PROBE_OFFSET_FROM_EXTRUDER 1 // X offset: -left +right [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER -55 // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER -3.4
#define MULTIPLE_PROBING 2
#define Z_CLEARANCE_DEPLOY_PROBE 0 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 3 // Z Clearance between probe points
// For M851 give a range for adjusting the Z probe offset
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#define INVERT_Z_DIR true
#define Z_MIN_POS 0
#if ENABLED(MIN_SOFTWARE_ENDSTOPS)
//#define MIN_SOFTWARE_ENDSTOP_X
//#define MIN_SOFTWARE_ENDSTOP_Y
#define MIN_SOFTWARE_ENDSTOP_Z
#endif
#define AUTO_BED_LEVELING_BILINEAR
#define MANUAL_Z_HOME_POS 0
#define Z_SAFE_HOMING
#if ENABLED(Z_SAFE_HOMING)
#define Z_SAFE_HOMING_X_POINT ((X_BED_SIZE) / 2) // X point for Z homing when homing all axes (G28).
#define Z_SAFE_HOMING_Y_POINT ((Y_BED_SIZE) / 2) // Y point for Z homing when homing all axes (G28).
#endif
</pre>
|
<p>If you want to mirror the print to get the top to the bottom, and visa versa, you just need to rotate the part using the XYZ rotation tool. Mirroring is used to make a mirror image in the X-Z or Y-Z plane, not the X-Y plane. </p>
<p>You might just caught a bug, you could post that of their forum.</p>
<p>Update: </p>
<p>If that does not fix it, you might have an incorrect STL model, e.g. the normals of the faces are incorrect. You could try to fix this by repairing the model through an online service like <a href="https://service.netfabb.com" rel="nofollow noreferrer">this one</a>.</p>
|
<p>If you want to mirror the print to get the top to the bottom, and visa versa, you just need to rotate the part using the XYZ rotation tool. Mirroring is used to make a mirror image in the X-Z or Y-Z plane, not the X-Y plane. </p>
<p>You might just caught a bug, you could post that of their forum.</p>
<p>Update: </p>
<p>If that does not fix it, you might have an incorrect STL model, e.g. the normals of the faces are incorrect. You could try to fix this by repairing the model through an online service like <a href="https://service.netfabb.com" rel="nofollow noreferrer">this one</a>.</p>
| 978
|
<p>What actually happens to the file system when you do a Subclipse Share Project on an Eclipse project that was externally checked out from Subversion? All the .svn folders are already in place. I get an error when I try to Share Project the right way, and I'd rather not delete and re-checkout the projects from the SVN Repository browser.</p>
|
<p>Dunno exactly what happens within eclipse, I presume it does some funky stuff in the .metadata directory of the workspace. That said, I would recommend the following to get eclipse to learn about the svn settings of the project:</p>
<ul>
<li>Delete the project from the workspace (keep "Delete project contents on disk" unchecked)</li>
<li>File > Import... > General > Existing Projects into Workspace</li>
<li>Browse to the folder containing the original project(s) of interest</li>
<li>Import the projects into your workspace</li>
</ul>
<p>This seems to have the side effect of subclipse noticing the subversion settings when importing the "new" projects into your workspace.</p>
|
<p>I'm not sure what version of Eclipse you are using or whether this will apply since I'm using Subversive instead of Subclipse. When I use the share project feature to commit the project into svn when I already have all of the .svn directories in place, I get a choice of like "Use current project settings" and then eclipse automatically reattaches the project svn information to the team integration. You can screw it up if you try to enter different information.</p>
| 6,650
|
<p>I've been using Window Home Server for my backups here at home for most of a year now, and I'm really pleased with it. It's far better than the software I was using previously (Acronis). I'm thinking about a backup strategy for my work machine and I'd like to know how WHS compares with Vista's built-in backup and restore features. The plan is to do a full backup to a local external hard drive and backup the documents folder to a network drive on the server. Anyone have experience using the Vista backup feature like this?</p>
|
<p>Chris, </p>
<p>They're different beasts. WHS backup is pretty much automatic and uses deltas - Vista's is manual and I don't believe offers incremental updates.</p>
<p>While your solution (Vista + network copy) would preserve your data it has two problems I an see;</p>
<ol>
<li>Your documents will only have the latest revision. If you find something was corrupted a month ago it could be very awkward to recover it. Vista's shadow copies may help though.</li>
<li>As soon as you install a program/patch/config your Vista backup is out of date and needs remade, or these repeated if you reinstall.</li>
</ol>
<p>These might not be dealbreakers and indeed Vista's backup is pretty decent, it's just nowhere near as good as WHS. In my opinion WHS leaves almost everything else standing, you can be sure this tech will be in the "big brother" server versions shortly.</p>
|
<p>WHS is such a quick, simple, robust way to get your stuff backed up. Plug it in to the network; install the client software; done. I'd hate to live without it.</p>
<p>However, as a programmer, I also set up scripts to run each night and back up my pending changes to another machine. For example, when using TFS, I run 'tf workspaces' then 'tf shelve' on each workspace to make a copy. Shelveset names begin with 'z' to make them sort to the end of the list.</p>
| 5,620
|
<p>I am having trouble integrating two products, one of which is mine and they appear not to be talking. So I want to make sure they are communicating correctly. I had a look around for network monitor and found TCP Spy. This works but only shows 1 side of the conversation at a time (it has to run locally) I would ideally like to see both sides at the same time - but you can't run two copies of TCP Spy.</p>
<p>I've hit Sourceforge, but nothing seems to jump out - I'm a Windows developer, I don't have perl installed.</p>
<p>I've found a couple of others which are cripple-ware and totally useless, so I was wondering what do the SO guys use for watching the TCP conversation?</p>
<p>BTW - the 'not-written-here' product is not a browser.</p>
|
<p><a href="http://www.wireshark.org/" rel="noreferrer">Wireshark</a> is a really good and mature network sniffer. It's been around for years.</p>
<ul>
<li>Deep inspection of hundreds of protocols, with more being added all the time</li>
<li>Live capture and offline analysis </li>
<li>Decryption support for many protocols, including IPsec, ISAKMP, Kerberos, SNMPv3, SSL/TLS, WEP, and WPA/WPA2</li>
<li>Coloring rules can be applied to the packet list for quick, intuitive analysis</li>
<li>Output can be exported to XML, PostScript®, CSV, or plain text </li>
</ul>
|
<p>Strange that I did not see WireShark when I visited SourceForge. The top result of the 60 returned was a bizarre german thing.</p>
| 4,798
|
<p>I try to use the Forms-Based authentication within an embedded Jetty 6.1.7 project.</p>
<p>That's why I need to serve servlets and html (login.html) under the same context
to make authentication work. I don't want to secure the hole application since
different context should need different roles. The jetty javadoc states that a
ContextHandlerCollection can handle different handlers for one context but I don't
get it to work. My sample ignoring the authentication stuff will not work, why?</p>
<pre><code>ContextHandlerCollection contexts = new ContextHandlerCollection();
// serve html
Context ctxADocs= new Context(contexts,"/ctxA",Context.SESSIONS);
ctxADocs.setResourceBase("d:\\tmp\\ctxA");
ServletHolder ctxADocHolder= new ServletHolder();
ctxADocHolder.setInitParameter("dirAllowed", "false");
ctxADocHolder.setServlet(new DefaultServlet());
ctxADocs.addServlet(ctxADocHolder, "/");
// serve a sample servlet
Context ctxA = new Context(contexts,"/ctxA",Context.SESSIONS);
ctxA.addServlet(new ServletHolder(new SessionDump()), "/sda");
ctxA.addServlet(new ServletHolder(new DefaultServlet()), "/");
contexts.setHandlers(new Handler[]{ctxA, ctxADocs});
// end of snippet
</code></pre>
<p>Any helpful thought is welcome!</p>
<p>Thanks.</p>
<p>Okami</p>
|
<p>Finally I got it right, solution is to use latest jetty 6.1.12 rc2.
I didn't check out what they changed - I'm just happy that it works now.</p>
|
<p>Use the web application descriptor:</p>
<p>Paste this in to your web.xml:</p>
<pre><code><login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<role-name>MySiteRole</role-name>
</security-role>
<security-constraint>
<display-name>ProtectEverything</display-name>
<web-resource-collection>
<web-resource-name>ProtectEverything</web-resource-name>
<url-pattern>*.*</url-pattern>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>MySiteRole</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>ExcludeLoginPage</web-resource-name>
<url-pattern>/login.html</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
</code></pre>
<p>Without authentication this will hide everything but the login.html.</p>
| 9,866
|
<p>I have a wcf application hosted in a windows service running a local windows account. Do I need to set an SPN for this account? If so, what's the protocol the SPN needs to be set under? I know how to do this for services over HTTP, but have never done it for net.tcp.</p>
|
<p>By default (i.e. out of the box) net.tcp services are unsecured and don't perform any authentication at all. So you won't need (and in fact can't) set a service principal name. </p>
<p>If you need to authenticate, then check the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.nettcpsecurity.aspx" rel="nofollow noreferrer">net.tcp security</a> modes on MSDN. The best way to understand the different combinations is to experiment!</p>
|
<p>By default (i.e. out of the box) net.tcp services are unsecured and don't perform any authentication at all. So you won't need (and in fact can't) set a service principal name. </p>
<p>If you need to authenticate, then check the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.nettcpsecurity.aspx" rel="nofollow noreferrer">net.tcp security</a> modes on MSDN. The best way to understand the different combinations is to experiment!</p>
| 5,974
|
<p>I'm updating some of our legacy C++ code to use the "MFC feature pack" that Microsoft released for Visual Studio 2008. We've used the new classes to derive our application from CFrameWndEx, and are applying the Office 2007 styles to give our application a more modern appearance. This gives us gradient filled window titles, status bars etc, and the use of the ribbon toolbars.</p>
<p>However, our application contains some owner drawn controls, and I'd like to update these to match the color scheme used by the feature pack. Ideally I'd like to know the light and shaded toolbar colors that are currently in use.</p>
<p>I've had a hunt around the documentation and web and have not yet found anything. Does anyone know how to find this information out?</p>
<p>[Edit]</p>
<p>In particular we need to find out which colors are being used at runtime. You can change the appearance of your application at runtime using the new static function CMFCVisualManager::SetDefaultManager.</p>
<p>The following msdn page shows you what kind of styles are available, in particular the Office2007 look:
<a href="http://msdn.microsoft.com/en-us/library/cc137831.aspx" rel="nofollow noreferrer">link to msdn</a></p>
|
<p>Have you looked in the MFC source code, which you'll find in something like</p>
<p>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc</p>
|
<p>Have you tried: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=19E3BF38-434B-4DDD-9592-3749F6647105&displaylang=en" rel="nofollow noreferrer">2007 Office System Document: UI Style Guide for Solutions and Add Ins</a>
?</p>
| 3,026
|
<p>Example:</p>
<pre><code>select ename from emp where hiredate = todate('01/05/81','dd/mm/yy')
</code></pre>
<p>and </p>
<pre><code>select ename from emp where hiredate = todate('01/05/81','dd/mm/rr')
</code></pre>
<p>return different results</p>
|
<p><a href="http://oracle.ittoolbox.com/groups/technical-functional/oracle-dev-l/difference-between-yyyy-and-rrrr-format-519525" rel="noreferrer">http://oracle.ittoolbox.com/groups/technical-functional/oracle-dev-l/difference-between-yyyy-and-rrrr-format-519525</a></p>
<blockquote>
<p>YY allows you to retrieve just two digits of a year, for example, the 99 in
1999. The other digits (19) are automatically assigned to the current
century. RR converts two-digit years into four-digit years by rounding.</p>
<p>50-99 are stored as 1950-1999, and dates ending in 00-49 are stored as
2000-2049. RRRR accepts a four-digit input (although not required), and
converts two-digit dates as RR does. YYYY accepts 4-digit inputs butdoesn't
do any date converting</p>
</blockquote>
<p>Essentially, your first example will assume that 81 is 2081 whereas the RR one assumes 1981. So the first example should not return any rows as you most likely did not hire any guys after May 1 2081 yet :-)</p>
|
<p>RR stands for after 1990 and yy assumes 90 as 2090....as we are in the current yr,...</p>
| 3,956
|
<p>I have a XULRunner application that needs to copy image data to the clipboard. I have figured out how to handle copying text to the clipboard, and I can paste PNG data from the clipboard. What I can't figure out is how to get data from a data URL into the clipboard so that it can be pasted into other applications.</p>
<p>This is the code I use to copy text (well, XUL):</p>
<pre><code>var transferObject=Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
var stringWrapper=Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
var systemClipboard=Components.classes["@mozilla.org/widget/clipboard;1"].
createInstance(Components.interfaces.nsIClipboard);
var objToSerialize=aDOMNode;
transferObject.addDataFlavor("text/xul");
var xmls=new XMLSerializer();
var serializedObj=xmls.serializeToString(objToSerialize);
stringWrapper.data=serializedObj;
transferObject.setTransferData("text/xul",stringWrapper,serializedObj.length*2);
</code></pre>
<p>And, as I said, the data I'm trying to transfer is a PNG as a data URL. So I'm looking for the equivalent to the above that will allow, e.g. Paint.NET to paste my app's data.</p>
|
<p>Here's a workaround that I ended up using that solves the problem pretty well. The variable <code>dataURL</code> is the image I was trying to get to the clipboard in the first place.</p>
<pre><code>var newImg=document.createElement('img');
newImg.src=dataURL;
document.popupNode=newImg;
var command='cmd_copyImageContents'
var controller=document.commandDispatcher.getControllerForCommand(command);
if(controller && controller.isCommandEnabled(command)){
controller.doCommand(command);
}
</code></pre>
<p>That copies the image to the clipboard as an 'image/jpg'.</p>
|
<p>Neal Deakin has an <a href="http://developer.mozilla.org/en/Using_the_Clipboard" rel="nofollow noreferrer">article on manipulating the clipboard</a> in xulrunner. I'm not sure if it answers your question specifically, but it's definitely worth checking out.</p>
| 9,360
|
<p><strong>Is there a way to utilise the GCC compiler whilst still being able to develop via the Visual Studio IDE?</strong></p>
<p>Our project is cross-platform, and I quite frequently get into trouble from my <a href="https://stackoverflow.com/users/912/jkp">colleague</a> because I'm checking in code that's not standards compliant (this can be attributed to the VS compiler!). </p>
<p>I'd still like to be able to compile using the MS compiler, so I can continue debugging, etc, however I'd like to be able to <em>switch</em> to compile using GCC, just so that I can be sure I'm not breaking the build on other platforms.</p>
<p><strong>Is this possible?</strong></p>
|
<p>What I am about to suggest would still require a makefile, so I am partially repeating the advice from an earlier reply. Or, as was also mentioned earlier, maybe you already have a makefile, in which case you will have even fewer steps in order to accomplish what I am about to describe.</p>
<p>Once you know your specific windows command-line command for invoking make or g++ on your code, then you create a "Pre-Build Event" in your Visual Studio Project. ("Project Properties >> Configuration Properties >> Build Events >> Pre-Build Event").</p>
<p>The pre-build event can call a bat file script, or any other script on your machine, and that script will be able to return an error-code. Essentially, "script OK," or "script FAILED" is the extent of the amount of communication your script can have BACK to visual studio.</p>
<p>The script doesn't automatically see all the visual studio environment variables (such as $(InputDir), $(ProjectDir), $(SolutionName), etc), however you can use those variables when you specify how to call the script. In other words, you can pass those values to the script as arguments.</p>
<p>Set this up so that every time you build in Visual Studio, the pre-build event will FIRST try to run make/g++ on your code. If your script (the one that calls make/g++) detects any problems, then the script returns an error and the build can be STOPPED right then and there. The script can print to stdout or stderr and that output should be visible to you in the Visual Studio Build output window (the window that usually shows stuff like "========== Build: 3 succeeded, 0 failed").</p>
<p>You can have the script print:</p>
<p>"BUILD FAILED, non-portable code detected, make/g++ returned the following:........."</p>
<p>This way, you don't have to remember to periodically switch from Visual Studio to the command line. It will be automatically done for you every time you build.</p>
|
<p>I had to maintain separate makefiles for compiling with gcc. There's an upfront cost associated with learning make, but you'll benefit from the intimate knowledge of your code and the differences between VS C++ and gcc. When I did this, I was using VC 6, so there may be a better way now with VS 2005.</p>
| 8,841
|
<p>I use TFS 2008. We run unit tests as part of our continuous integration build and integration tests nightly.</p>
<p>What other types of testing do you automate and include in your build process? what technologies do you use to do so? </p>
<p>I'm thinking about smoke tests, performance tests, load tests but don't know how realistic it is to integrate these with Team Build.</p>
|
<p>First, we have check-in (smoke) tests that must run before code can be checked in. It's done automatically by running a job that runs the tests and then makes the check-in to source control upon successful test completion. Second, cruise control kicks off build and regression tests. The product is built then several sets of integration tests are run. The number of tests vary by where we are in the release cycle. More testing is added late in the cycle during ramp down. Cruise control takes all submissions within a certain time window (12 minutes) so your changes may be built and tested with a small number of others. Third, there's an automated nightly build and tests that are quite extensive. We have load or milestone points every 2 or 3 weeks. At a load point, all automated tests are run plus manual testing is done. Performance testing is also done for each milestone. Performance tests can be kicked off on request but the hardware available is limited so people have to queue up for performance tests. Usually people rely on the load performance tests unless they are making changes specifically to improve performance. Finally, stress tests are also done for each load. These tests are focussed on making sure the product has no memory leaks or anything else that prevents 24/7 running of the product as opposed to performance. All of this is done with ant, cruise control, and Python scripts.</p>
|
<p>Integrating load testing during you build process is a bad idea, just do your normal unit testing to make sure that all your codes work as expected. Load and performance testing should be done separately.</p>
| 5,451
|
<p>Does a filament exist that can resist ozone (like certain silicone tubing's can). Most glass bottles come with tin or plastic screw hard tops and I would like to replace the screw caps with something that is more resistant to ozone.</p>
<p>The reason for this is I make my own homemade ozonated oil in glass bottles and I would like to print out different hard screw top caps for some of the bottles.</p>
|
<p>If making your own caps ends up being the best solution, TPU (thermoplastic polyurethane) is probably your best bet. I don't have specific information on printed TPU filament and ozone, but TPU is widely regarded as one of the most chemical-resistant materials you can easily print with, and <a href="https://ozonesolutions.com/blog/ozone-compatible-materials/" rel="nofollow noreferrer">this page by Ozone Solutions</a> rates polyurethane (no mention of specific types) A/Excellent described as:</p>
<blockquote>
<p>Ozone has <strong>no effect</strong> on these materials. They will last indefinitely.</p>
</blockquote>
<p>Being at least slightly flexible, TPU will also yield a good seal without any additional gasket. You should probably choose an unpigmented "natural/clear" TPU filament in case the pigments do react.</p>
<p>It might (probably would) also work to coat an existing cap with polyurethane. I'm not sure how you'd best get it to adhere, but lightly sanding the plastic then using a spray in multiple coats is what I'd try first.</p>
|
<p>According to <a href="https://www.calpaclab.com/polyetherether-ketone-peek-chemical-compatibility-chart/" rel="nofollow noreferrer">https://www.calpaclab.com/polyetherether-ketone-peek-chemical-compatibility-chart/</a> and <a href="https://www.polyfluor.nl/en/chemical-resistance/peek/" rel="nofollow noreferrer">https://www.polyfluor.nl/en/chemical-resistance/peek/</a> PEEK is very resistant to ozone.</p>
<p>PEEK does cost about as much per gram as silver.</p>
| 1,638
|
<p>I'm using the .NETCF (Windows Mobile) <code>Graphics</code> class and the <code>DrawString()</code> method to render a single character to the screen.</p>
<p>The problem is that I can't seem to get it centred properly. No matter what I set for the Y coordinate of the location of the string render, it always comes out lower than that and the larger the text size the greater the Y offset.</p>
<p>For example, at text size 12, the offset is about 4, but at 32 the offset is about 10.</p>
<p>I want the character to vertically take up most of the rectangle it's being drawn in and be centred horizontally. Here's my basic code. <code>this</code> is referencing the user control it's being drawn in.</p>
<pre><code>Graphics g = this.CreateGraphics();
float padx = ((float)this.Size.Width) * (0.05F);
float pady = ((float)this.Size.Height) * (0.05F);
float width = ((float)this.Size.Width) - 2 * padx;
float height = ((float)this.Size.Height) - 2 * pady;
float emSize = height;
g.DrawString(letter, new Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular),
new SolidBrush(Color.Black), padx, pady);
</code></pre>
<p>Yes, I know there is the label control that I could use instead and set the centring with that, but I actually do need to do this manually with the <code>Graphics</code> class.</p>
|
<p>I'd like to add another vote for the StringFormat object.
You can use this simply to specify "center, center" and the text will be drawn centrally in the rectangle or points provided:</p>
<pre><code>StringFormat format = new StringFormat();
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
</code></pre>
<p>However there is one issue with this in CF. If you use Center for both values then it turns TextWrapping off. No idea why this happens, it appears to be a bug with the CF.</p>
|
<p>You can use an instance of the <code>StringFormat</code> object passed into the <code>DrawString</code> method to center the text.</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/21kdfbzs.aspx" rel="nofollow noreferrer">Graphics.DrawString Method</a> and <a href="http://msdn.microsoft.com/en-us/library/system.drawing.stringformat.aspx" rel="nofollow noreferrer">StringFormat Class</a>.</p>
| 2,954
|
<p>I want to test the web pages I create in all the modern versions of Internet Explorer (6, 7 and 8 beta) but I work mainly on a Mac and often don't have direct access to a PC.</p>
|
<p><strong>Update:</strong> Microsoft now provide virtual machine images for various versions of IE that are ready to use on all of the major OS X virtualisation platforms (<a href="https://www.virtualbox.org" rel="nofollow noreferrer">VirtualBox</a>, <a href="http://www.vmware.com/products/fusion/overview.html" rel="nofollow noreferrer">VMWare Fusion</a>, and <a href="http://www.parallels.com/" rel="nofollow noreferrer">Parallels</a>).</p>
<p>Download the appropriate image from: <a href="https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/" rel="nofollow noreferrer">https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/</a></p>
<hr>
<p>On an Intel based Mac you can run Windows within a virtual machine. You will need one virtual machine for each version of IE you want to test against.</p>
<p>The instructions below include free and legal virtualisation software and Windows disk images.</p>
<ol>
<li>Download some virtual machine software. The developer disk images we're going to use are will work with either <a href="http://www.vmware.com/products/fusion/" rel="nofollow noreferrer">VMWare Fusion</a> or <a href="http://www.virtualbox.org/" rel="nofollow noreferrer">Sun Virtual Box</a>. VMWare has more features but costs $80, Virtual Box on the other hand is more basic but is free for most users (see <a href="http://www.virtualbox.org/wiki/Licensing_FAQ" rel="nofollow noreferrer">Virtual Box licensing FAQ</a> for details).</li>
<li>Download the IE developer disk images, which are free from Microsoft: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/...</a></li>
<li>Extract the disk images using <a href="http://www.cabextract.org.uk/" rel="nofollow noreferrer">cabextract</a> which is available from <a href="http://www.macports.org" rel="nofollow noreferrer">MacPorts</a> or as source code (Thanks to <a href="https://stackoverflow.com/users/6262/clinton">Clinton</a>).</li>
<li>Download Q.app from <a href="http://www.kju-app.org/" rel="nofollow noreferrer">http://www.kju-app.org/</a> and put it in your /Applications folder (you will need it to convert the disk images into a format VMWare/Virtual Box can use)</li>
</ol>
<p>At this point, the process depends on which VM software you're using.</p>
<p><strong>Virtual Box users</strong></p>
<ol>
<li><p>Open a Terminal.app on your Mac (you can find it in /Applications/Utilities) and run the following sequence of commands, replacing <em>input.vhd</em> with the name of the VHD file you're starting from and <em>output.vdi</em> with the name you want your final disk image to have:</p>
<pre><code>/Applications/Q.app/Contents/MacOS/qemu-img convert -O raw -f vpc "input.vhd" temp.bin
VBoxManage convertdd temp.bin "output.vdi"
rm temp.bin
mv "output.vdi" ~/Library/VirtualBox/VDI/
VBoxManage modifyvdi "output.vdi" compact
</code></pre></li>
<li>Start Virtual Box and create a new virtual machine</li>
<li>Select the new VDI file you've just created as the boot hard disk</li>
</ol>
<p><strong>VMWare fusion users</strong></p>
<ol>
<li><p>Open a Terminal.app on your Mac (you can find it in /Applications/Utilities) and run the following commands, replacing <em>input.vhd</em> and <em>output.vmdk</em> with the name of the VHD file you're working on and the name you want your resulting disk image to have:</p>
<pre><code>/Applications/Q.app/Contents/MacOS/qemu-img convert -O vmdk -f vpc "input.vhd" "output.vmdk"
mv "output.vmdk" ~/Documents/Virtual\ Machines.localized/
</code></pre>
<p>This will probably take a while (It takes around 30 minutes per disk image on my 2.4GHz Core 2 Duo MacBook w/ 2Gb RAM).</p></li>
<li>Start VMWare Fusion and create a new virtual machine</li>
<li>In the advanced disk options select "use and existing disk" and find the VMDK file you just created</li>
</ol>
|
<p>If this is a business web site (or a serious site where it is important that it actually works on IE), then don't take the cheap route - invest in a Windows machine or two. Your customers will thank you.</p>
<p>Otherwise, virtualize.</p>
| 7,939
|
<p>Working on a project at the moment and we have to implement soft deletion for the majority of users (user roles). We decided to add an <code>is_deleted='0'</code> field on each table in the database and set it to <code>'1'</code> if particular user roles hit a delete button on a specific record.</p>
<p>For future maintenance now, each <code>SELECT</code> query will need to ensure they do not include records <code>where is_deleted='1'</code>.</p>
<p>Is there a better solution for implementing soft deletion?</p>
<p>Update: I should also note that we have an Audit database that tracks changes (field, old value, new value, time, user, ip) to all tables/fields within the Application database.</p>
|
<p>You could perform all of your queries against a view that contains the <code>WHERE IS_DELETED='0'</code> clause.</p>
|
<pre><code>@AdditionalCriteria("this.status <> 'deleted'")
</code></pre>
<p>put this on top of your <code>@entity</code></p>
<p><a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/SoftDelete" rel="nofollow noreferrer">http://wiki.eclipse.org/EclipseLink/Examples/JPA/SoftDelete</a></p>
| 9,382
|
<p>I use Prusa i3 with one extruder for some years and I would like to print from one material in two colors or from different materials for one model. Therefore I'm lookig for new printer with dual extruder.</p>
<p>Is there some way how to measure and/or compare quality of printers with dual extruder on the market?</p>
<p>For example to create 3d model - ask the seller(s) to print it - and then compare? - what details to focus on?</p>
|
<p>As you suggest yourself, ordering test prints of some model is one way to do it. </p>
<p><a href="https://www.3dhubs.com">3D Hubs</a> and <a href="https://www.makexyz.com/">MakeXYZ</a> allows you to get your model printed by hobbyists and small businesses for a fair price. Both sites also allow you to order prints based on printer type, which I believe is what you may be looking for.</p>
<p>On 3D Hubs, visit on of the <a href="https://www.3dhubs.com/trends">trend reports</a>, and select the printer you want a sample from. Similarly, on MakeXYZ, <a href="https://www.makexyz.com/3dprinters/">search local makers</a> for your desired printer.</p>
|
<p>"Make" Magazine compares 3-D printers in a way that is as scientific as possible to help determine the strengths/weaknesses of each 3-D printer compared to others. The link to the November 2015 comparison test is available here: <a href="http://makezine.com/comparison/3dprinters/" rel="nofollow">http://makezine.com/comparison/3dprinters/</a> I was unable to find the ability to compare among dual-extruders, however. </p>
| 288
|
<p>I recently upgraded my Ender 3 Pro with a <a href="https://printermods.com/products/direct-drive-mod-for-creality-ender-3-cr-10" rel="nofollow noreferrer">direct drive kit</a>, primarily so I can print soft materials like TPU. I bought a spool of <a href="https://rads.stackoverflow.com/amzn/click/com/B07VBKDM74" rel="nofollow noreferrer" rel="nofollow noreferrer">Overture TPU</a> to try it out.</p>
<p>I'm getting really bad stringing on every print, to the point where it's pretty much unusable. This is my first time printing with TPU, so I'm at a loss for what to do.</p>
<p><strong>Direct Drive mod</strong> -
After modding the printer I did a few prints with PLA, and it works great with very little stringing. So I assume I assembled the mod correctly and that's not the issue.</p>
<p><strong>Material</strong> -
Reviews of the Overture TPU on Amazon mostly say it has low stringing and are generally positive, so I'm assuming it's not just bad filament.</p>
<p><strong>Temperature</strong> - The consensus in the Amazon reviews seems to be that 230°C is the sweet spot. I did a temperature tower from 205 °C to 230 °C by 5 °C, and the print quality and stringing was pretty much uniform throughout.</p>
<p><strong>Retraction</strong> - I tried with retraction off, then with 1 mm, 2 mm, and 6.5 mm, in various combinations with temperature and speed. Results varied in details, but all were pretty bad.</p>
<p><strong>Speed</strong> - I tried slowing down to 15 mm/s (from Cura's default of 50). Results got even worse.</p>
<p>Following are photos of a stringing test with various combinations of settings.</p>
<p><a href="https://i.stack.imgur.com/GF47t.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GF47t.jpg" alt="PLA - 205 °C - Layer thickness 0.2 mm - Retraction 1 mm" /></a>
PLA for reference - 205 °C - Layer thickness 0.2 mm - Retraction 1 mm</p>
<p><a href="https://i.stack.imgur.com/qBOOk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qBOOk.jpg" alt="TPU - 205 °C - Layer thickness 0.2 mm - Retraction 2 mm - Print speed 15 mm/s" /></a>
TPU - 205 °C - Layer thickness 0.2 mm - Retraction 2 mm - Print speed 15 mm/s</p>
<p><a href="https://i.stack.imgur.com/vgTIt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vgTIt.jpg" alt="TPU - 230 °C - Layer thickness 0.2 mm - Retraction 1 mm - Print speed 15 mm/s" /></a>
TPU - 230 °C - Layer thickness 0.2 mm - Retraction 1 mm - Print speed 15 mm/s</p>
<p><a href="https://i.stack.imgur.com/SygEx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SygEx.jpg" alt="TPU - 230°C - Layer thickness 0.2 mm - Retraction 1 mm" /></a>
TPU - 230 °C - Layer thickness 0.2 mm - Retraction 1 mm</p>
<p><a href="https://i.stack.imgur.com/JLrgw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JLrgw.jpg" alt="TPU - 230 °C - Layer thickness 0.2 mm - Retraction 2 mm" /></a>
TPU - 230 °C - Layer thickness 0.2 mm - Retraction 2 mm</p>
<p><a href="https://i.stack.imgur.com/LVlGv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LVlGv.jpg" alt="TPU - 230 °C - Layer thickness 0.2 mm - Retraction 6.5 mm" /></a>
TPU - 230 °C - Layer thickness 0.2 mm - Retraction 6.5 mm</p>
<p><a href="https://i.stack.imgur.com/uwuMV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uwuMV.jpg" alt="TPU - 230 °C - Layer thickness 0.12 mm - No retraction" /></a>
TPU - 230 °C - Layer thickness 0.12 mm - No retraction</p>
<p><a href="https://i.stack.imgur.com/lUOSK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lUOSK.jpg" alt="TPU - 240 °C - Layer thickness 0.2 mm - No retraction" /></a>
TPU - 240 °C - Layer thickness 0.2 mm - No retraction</p>
<p>Is there something else I should try to reduce stringing? Is it possible that I just got a bad spool of TPU? Or is it more likely something's wrong with my printer?</p>
|
<p>That depends very much on what your goal is with the box. If it needs to be hollow and you don't need any access to the inside (and also prefer it to be printed in one piece) than the answer provided by user77232 would probably be the best.</p>
<p>Alternatively, if you need access to the inside of the box you would probably be best off printing the box in two pieces. A box and a lid. This way you can print the box without support and also save on material that would otherwise be used as infill.</p>
<p>The amount of light coming into your box also depends on the translucency of your material and brightness of the light source. To find the required wall thickness would be a matter of testing with the desired material.</p>
|
<ol>
<li>Print it as a whole object</li>
<li>Use 20% infill.</li>
<li>Profit!</li>
</ol>
| 1,739
|
<p>I need to calculate <code>Math.exp()</code> from java very frequently, is it possible to get a native version to run faster than <strong>java</strong>'s <code>Math.exp()</code>??</p>
<p>I tried just jni + C, but it's slower than just plain <strong>java</strong>.</p>
|
<p>+1 to writing your own exp() implementation. That is, if this is <em>really</em> a bottle-neck in your application. If you can deal with a little inaccuracy, there are a number of extremely efficient exponent estimation algorithms out there, some of them dating back centuries. As I understand it, Java's exp() implementation is fairly slow, even for algorithms which must return "exact" results.</p>
<p>Oh, and don't be afraid to write that exp() implementation in pure-Java. JNI has a lot of overhead, and the JVM is able to optimize bytecode at runtime sometimes even beyond what C/C++ is able to achieve.</p>
|
<p>Since the Java code will get compiled to native code with the just-in-time (JIT) compiler, there's really no reason to use JNI to call native code.</p>
<p>Also, you shouldn't cache the results of a method where the input parameters are floating-point real numbers. The gains obtained in time will be very much lost in amount of space used.</p>
| 9,191
|
<p>I've created an assembly and referenced it in my Reporting Services report. I've tested the report locally (works), and I then uploaded the report to a report server (doesn't work).</p>
<p>Here is the error that is thrown by the custom code I've written.</p>
<blockquote>
<p>System.Security.SecurityException:
Request for the permission of type
'System.Security.Permissions.SecurityPermission,
mscorlib, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089'
failed. at
System.Security.CodeAccessSecurityEngine.CheckNReturnSO(PermissionToken
permToken, CodeAccessPermission
demand, StackCrawlMark& stackMark,
Int32 unrestrictedOverride, Int32
create) at
System.Security.CodeAccessSecurityEngine.Assert(CodeAccessPermission
cap, StackCrawlMark& stackMark) at
System.Security.CodeAccessPermission.Assert()
at [Snipped Method Name] at
ReportExprHostImpl.CustomCodeProxy.[Snipped Method Name] The action that failed was:
Demand The type of the first
permission that failed was:
System.Security.Permissions.SecurityPermission
The Zone of the assembly that failed
was: MyComputer</p>
</blockquote>
<p>This project is something I inherited, and I'm not intimately familiar with it. Although I do have the code (now), so I can at least work with it :)</p>
<p>I believe the code that is failing is this:</p>
<pre><code> Dim fio As System.Security.Permissions.FileIOPermission = New System.Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted)
fio.Assert()
</code></pre>
<p>However, this kind of stuff is everywhere too:</p>
<pre><code>Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hhash As Integer, ByVal pbData As String, ByVal dwDataLen As Integer, ByVal dwFlags As Integer) As Integer
</code></pre>
<p>I can see either of these being things that Reporting Services would not accommodate out of the box.</p>
|
<p>This is how I was able to solve the issue:</p>
<ul>
<li>strongly sign the custom assembly in question</li>
<li><p>modify the rssrvpolicy.config file to add permissions for the assembly</p>
<pre><code> <CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Test"
Description="This code group grants the Test code full trust. ">
<IMembershipCondition
class="StrongNameMembershipCondition"
version="1"
PublicKeyBlob="0024000004800000940100000602000000240000575341310004000001000100ab4b135615ca6dfd586aa0c5807b3e07fa7a02b3f376c131e0442607de792a346e64710e82c833b42c672680732f16193ba90b2819a77fa22ac6d41559724b9c253358614c270c651fad5afe9a0f8cbd1e5e79f35e0f04cb3e3b020162ac86f633cf0d205263280e3400d1a5b5781bf6bd12f97917dcdde3c8d03ee61ccba2c0"
/>
</CodeGroup>
</code></pre></li>
</ul>
<p>Side note: here is a great way to get the public key blob of your assembly
<a href="http://www.andrewconnell.com/blog/archive/2006/09/15/4587.aspx" rel="noreferrer">VS trick for obtaining the public key token and blob of a signed assembly</a>. </p>
|
<p>Run your service in administrator mode</p>
| 5,236
|
<p>Anyone know this compiler feature? It seems GCC support that. How does it work? What is the potential gain? In which case it's good? Inner loops?</p>
<p>(this question is specific, not about optimization in general, thanks)</p>
|
<p>It works by placing extra code to count the number of times each codepath is taken. When you compile a second time the compiler uses the knowledge gained about execution of your program that it could only guess at before. There are a couple things PGO can work toward:</p>
<ul>
<li>Deciding which functions should be inlined or not depending on how often they are called.</li>
<li>Deciding how to place hints about which branch of an "if" statement should be predicted on based on the percentage of calls going one way or the other.</li>
<li>Deciding how to optimize loops based on how many iterations get taken each time that loop is called.</li>
</ul>
<p>You never really know how much these things can help until you test it.</p>
|
<p>The fun thing about optimization is that speed gains are found in the unlikeliest of places.</p>
<p>It's also the reason you need a profiler, rather than guessing where the speed problems are.</p>
<p>I recommend starting with a profiler (<code>gperf</code> if you're using GCC) and just start poking around the results of running your application through some normal operations.</p>
| 7,578
|
<p>I'm thinking of another extruder on my printer, and I'm curious about this one....</p>
<p>Is it necessary to have both hot ends on same height? Why yes / why not? (if there is not)</p>
|
<p>I have a dual extruder Replicator 1 and having the nozzles at the same height is a must and albeit a bit of a struggle otherwise. At one point, I had to disassemble my extruder head and the nozzles didn't line up quite right. There after, printing with the lower one obviously didn't have any troubles, however, printing with the high extruder made it so the lower extruder would scrape the molten plastic layer. This made my surface finish horrible and almost impossible for support structures to be printed.</p>
<p>Instead of fighting with my stock nozzle assembly to get everything perfectly lined up, I just shimmed the one side with some stacks of paper cutouts. This brought my extruders very close to even.</p>
<p>Also, you'll want to make sure excess plastic is cleaned off of <strong>BOTH</strong> nozzles when printing with either nozzle. I found that some prints would fail because of a small discharge from a previous print on the other nozzle.</p>
|
<p>To add to the above answers, besides the obvious point that one hotend might collide with something another hotend positioned lower than it has printed, you also want both hotends to be positioned X microns above the bed at minimum height so your filament will stick to the bed properly. Position one a bit higher than the other and what it prints won't stick to the bed very well, position one a bit lower and it will hit the bed and clog/be unable to print the first layer.
The only reason I can think of when you'd want one hotend to be higher is a situation when you're not using both hotends and don't want the second hotend to drag on and deform a layer the main hotend has printed and is still warm and deformable. If that's an issue (I doubt) then sure, move it a bit higher.</p>
<p>If there are other reasons for what you would like to have the hotends at different heights, please add that to your question. I can't think of one myself.</p>
| 181
|
<p>How do I implement some logic that will allow me to reproduce on Windows the functionality that I have on Linux with the <code>fork()</code> system call, using Python?</p>
<p>I'm specifically trying to execute a method on the SAPI Com component, while continuing the other logic in the main thread without blocking or waiting.</p>
|
<p>Use the python <a href="http://docs.python.org/library/multiprocessing.html" rel="noreferrer">multiprocessing module</a> which will work everywhere.</p>
<p>Here is a <a href="http://www.ibm.com/developerworks/aix/library/au-multiprocessing/" rel="noreferrer">IBM developerWords article</a> that shows how to convert from os.fork() to the multiprocessing module.</p>
|
<p>Possibly a version of spawn() for python? <a href="http://en.wikipedia.org/wiki/Spawn_(operating_system)" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Spawn_(operating_system)</a></p>
| 4,337
|
<p>How can I find the last row that contains data in a specific column and on a specific sheet?</p>
|
<p>How about:</p>
<pre><code>Function GetLastRow(strSheet, strColumn) As Long
Dim MyRange As Range
Set MyRange = Worksheets(strSheet).Range(strColumn & "1")
GetLastRow = Cells(Rows.Count, MyRange.Column).End(xlUp).Row
End Function
</code></pre>
<p>Regarding a comment, this will return the row number of the last cell even when only a single cell in the last row has data:</p>
<pre><code>Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
</code></pre>
|
<pre><code>Function LastRow(rng As Range) As Long
Dim iRowN As Long
Dim iRowI As Long
Dim iColN As Integer
Dim iColI As Integer
iRowN = 0
iColN = rng.Columns.count
For iColI = 1 To iColN
iRowI = rng.Columns(iColI).Offset(65536 - rng.Row, 0).End(xlUp).Row
If iRowI > iRowN Then iRowN = iRowI
Next
LastRow = iRowN
End Function
</code></pre>
| 9,663
|
<p>Does anyone have the secret formula to resizing transparent images (mainly GIFs) <em>without</em> ANY quality loss - what so ever?</p>
<p>I've tried a bunch of stuff, the closest I get is not good enough.</p>
<p>Take a look at my main image:</p>
<p><a href="http://www.thewallcompany.dk/test/main.gif" rel="noreferrer">http://www.thewallcompany.dk/test/main.gif</a></p>
<p>And then the scaled image:</p>
<p><a href="http://www.thewallcompany.dk/test/ScaledImage.gif" rel="noreferrer">http://www.thewallcompany.dk/test/ScaledImage.gif</a></p>
<pre><code>//Internal resize for indexed colored images
void IndexedRezise(int xSize, int ySize)
{
BitmapData sourceData;
BitmapData targetData;
AdjustSizes(ref xSize, ref ySize);
scaledBitmap = new Bitmap(xSize, ySize, bitmap.PixelFormat);
scaledBitmap.Palette = bitmap.Palette;
sourceData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadOnly, bitmap.PixelFormat);
try
{
targetData = scaledBitmap.LockBits(new Rectangle(0, 0, xSize, ySize),
ImageLockMode.WriteOnly, scaledBitmap.PixelFormat);
try
{
xFactor = (Double)bitmap.Width / (Double)scaledBitmap.Width;
yFactor = (Double)bitmap.Height / (Double)scaledBitmap.Height;
sourceStride = sourceData.Stride;
sourceScan0 = sourceData.Scan0;
int targetStride = targetData.Stride;
System.IntPtr targetScan0 = targetData.Scan0;
unsafe
{
byte* p = (byte*)(void*)targetScan0;
int nOffset = targetStride - scaledBitmap.Width;
int nWidth = scaledBitmap.Width;
for (int y = 0; y < scaledBitmap.Height; ++y)
{
for (int x = 0; x < nWidth; ++x)
{
p[0] = GetSourceByteAt(x, y);
++p;
}
p += nOffset;
}
}
}
finally
{
scaledBitmap.UnlockBits(targetData);
}
}
finally
{
bitmap.UnlockBits(sourceData);
}
}
</code></pre>
<p>I'm using the above code, to do the indexed resizing.</p>
<p>Does anyone have improvement ideas?</p>
|
<p>If there's no requirement on preserving file type after scaling I'd recommend the following approach.</p>
<pre><code>using (Image src = Image.FromFile("main.gif"))
using (Bitmap dst = new Bitmap(100, 129))
using (Graphics g = Graphics.FromImage(dst))
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(src, 0, 0, dst.Width, dst.Height);
dst.Save("scale.png", ImageFormat.Png);
}
</code></pre>
<p>The result will have really nice anti aliased edges</p>
<ul>
<li><em>removed image shack image that had been replaced by an advert</em></li>
</ul>
<p>If you must export the image in gif you're in for a ride; GDI+ doesn't play well with gif. See <a href="http://www.ben-rush.net/blog/PermaLink.aspx?guid=103ed74d-c808-47ba-b82d-6e9367714b3e&dotnet=consultant" rel="noreferrer">this blog post</a> about it for more information</p>
<p><strong>Edit:</strong> I forgot to dispose of the bitmaps in the example; it's been corrected</p>
|
<p>While PNG is definitely better that GIF, occasionally there is a use case for needing to stay in GIF format. </p>
<p>With GIF or 8-bit PNG, you have to address the problem of quantization.</p>
<p>Quantization is where you choose which 256 (or fewer) colors will best preserve and represent the image, and then turn the RGB values back into indexes. When you perform a resize operation, the ideal color palette changes, as you are mixing colors and changing balances. </p>
<p>For slight resizes, like 10-30%, you may be OK preserving the original color palette. </p>
<p>However, in most instances you'll need to re-quantize. </p>
<p>The primary two algorithms to pick from are Octree and nQuant. Octree is very fast and does a very good job, especially if you can overlay a smart dithering algorithm. nQuant requires at least 80MB of RAM to perform an encode (it builds a complete histogram), and is typically 20-30X slower (1-5 seconds per encode on an average image). However, it sometimes produces higher image quality that Octree since it doesn't 'round' values to maintain consistent performance.</p>
<p>When implementing transparent GIF and animated GIF support in the <a href="http://imageresizing.net" rel="nofollow">imageresizing.net</a> project, I chose Octree. Transparency support isn't hard once you have control of the image palette.</p>
| 5,046
|
<p>It is open season for posting ads on other sites. It might be a good idea to take advantage of this to help 3dPrinting.SE grow. I'm wondering what everyone might think about it?</p>
<p>If it does interest you, please post up an answer to this question with where you might think would be a good place to advertise. Usually, the other site would need to relate to this one in some way. It's been my experience if it doesn't relate, the ad will get shut (or shot) down. </p>
<p>If you feel you have the artistry to create an ad for another site, post that up, too! We can critique the work and ensure most everyone likes the idea before posting it over. We really do want to put our best foot forward! There are some rules in making an image:</p>
<ul>
<li>The image that you create must be 300 x 250 pixels, or double that if high DPI.</li>
<li>Must be hosted through our standard image uploader (imgur)</li>
<li>Must be GIF or PNG</li>
<li>No animated GIFs</li>
<li>Absolute limit on file size of 150 KB</li>
<li>If the background of the image is white or partially white, there must be a 1px border (2px if high DPI) surrounding it.</li>
</ul>
<p>If you have some ideas and would like to discuss, you can also post ideas or questions a little more free form over on the <a href="https://chat.stackexchange.com/rooms/79830/public-3d-printing-room">site chat</a>.</p>
<p>If you like the idea, please let everyone know! </p>
|
<p>Considering 3D printing needs 3D models, I think it would be natural to advertise on <a href="https://blender.meta.stackexchange.com/q/2580/13218">Blender.SE</a>, perhaps with a catchphrase like "Want to print your Blender model?"</p>
<p><a href="https://graphicdesign.meta.stackexchange.com/q/3573/30985">GraphicDesign.SE</a> also has questions about 3D design (not necessarily 3D <em>model</em>), and the scope on 3D-related questions is debatable. Regardless of that, I think there's nothing to lose trying to advertise there?</p>
|
<p>Sounds like a great idea. StackOverflow is by for the most populated site (and the one I came from).</p>
<p>3D printing interests nerdy-trendy folks like those the in SO, that's where I can from.</p>
<p>Prehaps woodworking SE sites would work as well.</p>
| 64
|
<p>Are there any good oracle podcasts around? The only ones I've found is produced by oracle corp, and as such are little more than advertising pieces pushing their technology of the moment.</p>
<p>I'm specifically interested in Database technologies.</p>
|
<h2>Oracle Podcast Center</h2>
<hr>
<p><a href="http://www.oracle.com/applications/podcasts-sustainability.html" rel="nofollow noreferrer">Green Enterprise Podcasts</a></p>
<p>Host: Paul Salinger, VP Marketing</p>
<p>Listen to discussions with customers, partners, and Oracle green experts, exploring topics that can help Oracle customers better understand how Oracle products can support their sustainability initiatives and enable a green enterprise.</p>
<hr>
<p><a href="http://www.oracle.com/customers/cust_successcasts.html" rel="nofollow noreferrer">Oracle AppCasts</a> </p>
<p><em>Host: Cliff Godwin, SVP, Applications Technology</em></p>
<p>Tune into "Live with Cliff" to hear from application technology experts, product and industry experts, and customers about what's saving Oracle customers time and money when using Oracle E-Business Suite, PeopleSoft, and JD Edwards applications.</p>
<hr>
<p><a href="http://www.oracle.com/customers/cust_successcasts.html" rel="nofollow noreferrer">Oracle Customer SuccessCasts</a> </p>
<p>Tune into Oracle Customer SuccessCasts, where customers describe how Oracle helps them to run their businesses more successfully.</p>
<hr>
<p><a href="http://www.oracle.com/database/podcasts.html" rel="nofollow noreferrer">Oracle Database Podcasts</a> </p>
<p>Tune into this podcast series to get the latest information on Oracle Database from Oracle technical experts.</p>
<hr>
<p><a href="http://www.oracle.com/products/middleware/ofmradio.html" rel="nofollow noreferrer">Oracle Fusion Middleware Radio</a></p>
<p><em>Host: Rick Schultz, VP, Product Marketing for Oracle Fusion Middleware & Security Products</em></p>
<p>Tune into this podcast series about Oracle Fusion Middleware to hear about Oracle's middleware product strategy and explore what middleware means to your business—growth, agility, insight, and reduced risk.</p>
<hr>
<p><a href="http://www.oracle.com/technology/syndication/magcasts/index.html" rel="nofollow noreferrer">Oracle Magazine Feature Casts</a> </p>
<p>Tune into conversations with Oracle Magazine editors, authors, and Oracle subject matter experts about featured articles in Oracle Magazine. Go beyond print with additional insight into Oracle products, technologies, customers, and more.</p>
<hr>
<p><a href="http://www.oracle.com/partners/home/news/global/auth/opn-partnercasts.html" rel="nofollow noreferrer">Oracle PartnerNetwork (OPN) PartnerCast</a></p>
<p>Tune in and learn how to grow your business with Oracle, exclusively for Oracle PartnerNetwork members.</p>
<hr>
<p><a href="http://www.oracle.com/technology/syndication/arch2arch-podcasts/index.html" rel="nofollow noreferrer">Oracle Technology Network Arch2Arch Podcast</a> </p>
<p><em>Host: Bob Rhubart, Manager, Architect Community, OTN</em></p>
<p>Listen in as architects and other experts from across the Oracle community discuss the topics, tools, and technologies that drive the evolution of software architecture.</p>
<hr>
<p><a href="http://www.oracle.com/technology/syndication/techcasts/index.html" rel="nofollow noreferrer">Oracle Technology Network TechCasts</a> </p>
<p><em>Host: Justin Kestelyn, OTN Editor-in-Chief</em></p>
<p>Tune into "fireside chats" with experts about new tools, technologies, and trends in application development.</p>
<hr>
<p><a href="http://feeds.feedburner.com/Oraclework" rel="nofollow noreferrer">Oracle@Work</a> </p>
<p>Through Oracle@Work Video Podcasts you'll learn how Oracle customers from aerospace and automotive to travel and television address business and technical issues with the latest Oracle technology and applications solutions. Oracle@Works play like short television news magazine pieces shot on location, world wide. See Oracle customers in action, first hand, with Oracle@Work Video Podcasts.</p>
<hr>
<p><a href="http://www.oracle.com/profit/audiocasts.html" rel="nofollow noreferrer">Profit Online Executive Briefing Audiocasts</a> </p>
<p>Every month, Profit Online presents conversations with Oracle executives, customers, and partners, discussing developments in their businesses and trends in their industries. Tune into and stay up to date on how IT and business leaders are expanding into new markets, improving business processes, and creating the future of the enterprise.</p>
<hr>
<p><em>Reference: <a href="http://www.oracle.com/podcasts/index.html" rel="nofollow noreferrer">Oracle Podcasts</a></em></p>
|
<p>Asking for an "Oracle podcast" that isn't going to be a product marketing focused is too broad. It's almost like asking for a "Microsoft Podcast." Anything you get is going to be broad and shallow. An introduction, nothing in depth.</p>
<p>What are you looking for? DB, Middleware, Linux/OS, ERP, CRM, BI, Information Security, Identify Management, Integration, PL/SQL etc. . . . For what kind of audience? Developer, Sysadmin, DBA, Apps DBA (very diff believe it or not), Technology Manager, Accountant, Finance Director, White Hat security specialist, etc.</p>
| 6,950
|
<p>Is there a fast and clean way of returning a JSON hash back from any node in a Ruby on Rails' acts_as_nested_set without using recursion?</p>
<p>Here's the recursive solution for reference:</p>
<pre><code>class Node < ActiveRecord::Base
has_many :products
def json_hash
if children.size > 0
children.collect { |node| { node.name => node.json_hash }.to_json
else
{ node.name => node.products.find(:all).collect(&:name) }.to_json
end
end
end
</code></pre>
|
<p>There is a <a href="http://en.wikipedia.org/wiki/Tree_traversal" rel="nofollow noreferrer">wikipedia article</a> on tree traversal which shows different alternatives to the recursive solution you are using. It may be tricky to use them in your specific case, but it should be possible.</p>
<p>However, my question to you is, is there a specific reason you want to use iteration instead of recursion? I don't think any of the iterative solutions will be nearly as clean. Are your trees so big that you are running out of stack space (they would have to be pretty big)? Otherwise, I'm not so sure an iterative solution will really be faster.</p>
<p>I see one potential for improvement though, if you are seeing performance issues... but I don't know rails, so I'm not sure if it is accurate:</p>
<p>Does the find method return a new array? If so, you probably want to invoke .collect! instead of .collect, because if find creates an array, you are just creating an array and then throwing it away to the call to collect (which also creates an array), which surely is not going to be very efficient and may slow you down a lot if you have a big tree there.</p>
<p>So </p>
<pre><code>{ node.name => node.products.find(:all).collect(&:name) }.to_json
</code></pre>
<p>might become</p>
<pre><code>{ node.name => node.products.find(:all).collect!(&:name) }.to_json
</code></pre>
<p>EDIT: Also, it may be more efficient to create your hash of hashes, and then convert the whole thing to json in 1 fell swoop, rather than converting it piecemail like you are doing.</p>
<p>So</p>
<pre><code>class Node < ActiveRecord::Base
has_many :products
def json_hash
if children.size > 0
children.collect { |node| { node.name => node.json_hash }.to_json
else
{ node.name => node.products.find(:all).collect!(&:name) }.to_json
end
end
end
</code></pre>
<p>might become</p>
<pre><code>class Node < ActiveRecord::Base
has_many :products
def json_hash
to_hash.to_json
end
def to_hash
if children.size > 0
children.collect { |node| { node.name => node.to_hash }
else
{ node.name => node.products.find(:all).collect!(&:name) }
end
end
end
</code></pre>
<p>Whether this works and is more efficient I leave as an exercise for you ;-)</p>
|
<p>JSONifier!</p>
<pre><code>node.to_json(:include=>{:products=>{:include=>:product_parts}})
</code></pre>
| 6,249
|
<p>I see 2 main ways to set events in JavaScript:</p>
<ol>
<li><p>Add an event directly inside the tag like this:</p>
<p><code><a href="" onclick="doFoo()">do foo</a></code></p></li>
<li><p>Set them by JavaScript like this:</p>
<p><code><a id="bar" href="">do bar</a></code></p></li>
</ol>
<p>and add an event in a <code><script></code> section inside the <code><head></code> section or in an external JavaScript file, like that if you're using <strong>prototypeJS</strong>:</p>
<pre><code>Event.observe(window, 'load', function() {
$('bar').observe('click', doBar);
}
</code></pre>
<p>I think the first method is easier to read and maintain (because the JavaScript action is directly bound to the link) but it's not so clean (because users can click on the link even if the page is not fully loaded, which may cause JavaScript errors in some cases).</p>
<p>The second method is cleaner (actions are added when the page is fully loaded) but it's more difficult to know that an action is linked to the tag.</p>
<p>Which method is the best?</p>
<p>A killer answer will be fully appreciated!</p>
|
<blockquote>
<p>I think the first method is easier to read and maintain</p>
</blockquote>
<p>I've found the opposite to be true. Bear in mind that sometimes more than one event handler will be bound to a given control.</p>
<p>Declaring all events in one central place helps to organize the actions taking place on the site. If you need to change something you don't have to search for all places making a call to a function, you simply have to change it in one place. When adding more elements that should have the same functionality you don't have to remember to add the handlers to them; instead, it's often enough to let them declare a class, or even not change them at all because they logically belong to a container element of which all child elements get wired to an action. From an actual code:</p>
<pre><code>$$('#itemlist table th > a').invoke('observe', 'click', performSort);
</code></pre>
<p>This wired an event handler to all column headers in a table to make the table sortable. Imagine the effort to make all column headers sortable separately.</p>
|
<p>Libraries like YUI and jQuery provide methods to add events only once the DOM is ready, which can be before window.onload. They also ensure that you can add multiple event handlers so that you can use scripts from different sources without the different event handlers overwriting each other.</p>
<p>So your practical choices are;</p>
<p>One. If your script is simple and the only one that will ever run on the page, create an init function like so:</p>
<pre><code>window.onload = function () {
init();
}
function init() {
// actual function calls go here
doFoo();
}
</code></pre>
<p>Two. If you have many scripts or plan to mashup scripts from different sources, use a library and its <code>onDOMReady</code> method to safely add your event handlers</p>
| 5,430
|
<p>How do I take a set of polygons which contain arbitrary values and create a corresponding bitmap where each pixel contains the value of the polygon at that location?</p>
<p>To put the question into context, my polygons contain information about the average number of people per square kilometre within the polygon. I need to create a raster/bitmap that contains pixels representing the population in 200 metre bins.</p>
<p>I've done something similar in the past where I've used a polygon to create a mask by drawing into a bitmap and filling values, then converting the bitmap into an array that I can manipulate. I'm sure there's a better method for doing this!</p>
<p>I'm clarifying the question a bit more as requested.</p>
<ol>
<li>There are multiple polygons, each polygon is a set of vectors</li>
<li>Each polygon will have a single unique value</li>
<li>The polygons don't overlap</li>
</ol>
<p>Thanks</p>
<p>Nick</p>
|
<p>What GIS software are you using? ArcGIS offers the Polygon to Raster tool in ArcGIS 9.2 or later, which is scriptable as the PolygonToRaster_conversion function.</p>
<pre><code>PolygonToRaster_conversion (in_features, value_field, out_raster_dataset, cell_assignment, priority_field, cellsize)
</code></pre>
|
<p>ImageMagick can convert from svg to png, maybe you can take a look at the code, or simply create svg and use IM for the conversion? <a href="http://scruffy.rubyforge.org/" rel="nofollow noreferrer" title="Scruffy">Scruffy</a> does that.</p>
| 8,306
|
<p>For example,
Look at the code that calculates the n-th Fibonacci number:</p>
<pre><code>fib(int n)
{
if(n==0 || n==1)
return 1;
return fib(n-1) + fib(n-2);
}
</code></pre>
<p>The problem with this code is that it will generate stack overflow error for any number greater than 15 (in most computers).</p>
<p>Assume that we are calculating fib(10). In this process, say fib(5) is calculated a lot of times. Is there some way to store this in memory for fast retrieval and thereby increase the speed of recursion?</p>
<p>I am looking for a generic technique that can be used in almost all problems.</p>
|
<p>Yes your insight is correct.
This is called <a href="http://en.wikipedia.org/wiki/Dynamic_programming" rel="nofollow noreferrer">dynamic programming</a>. It is usually a common memory runtime trade-off.</p>
<p>In the case of fibo, you don't even need to cache everything :</p>
<p>[edit]
The author of the question seems to be looking for a general method to cache rather than a method to compute Fibonacci. Search wikipedia or look at the code of the other poster to get this answer. Those answers are linear in time and memory.</p>
<p>**Here is a linear-time algorithm O(n), constant in memory **</p>
<pre><code>in OCaml:
let rec fibo n =
let rec aux = fun
| 0 -> (1,1)
| n -> let (cur, prec) = aux (n-1) in (cur+prec, cur)
let (cur,prec) = aux n in prec;;
in C++:
int fibo(int n) {
if (n == 0 ) return 1;
if (n == 1 ) return 1;
int p = fibo(0);
int c = fibo(1);
int buff = 0;
for (int i=1; i < n; ++i) {
buff = c;
c = p+c;
p = buff;
};
return c;
};
</code></pre>
<p>This perform in linear time. But log is actually possible !!!
Roo's program is linear too, but way slower, and use memory.</p>
<p><strong>Here is the log algorithm O(log(n))</strong></p>
<p>Now for the log-time algorithm (way way way faster), here is a method :
If you know u(n), u(n-1), computing u(n+1), u(n) can be done by applying a matrix:</p>
<pre><code>| u(n+1) | = | 1 1 | | u(n) |
| u(n) | | 1 0 | | u(n-1) |
</code></pre>
<p>So that you have :</p>
<pre><code>| u(n) | = | 1 1 |^(n-1) | u(1) | = | 1 1 |^(n-1) | 1 |
| u(n-1) | | 1 0 | | u(0) | | 1 0 | | 1 |
</code></pre>
<p>Computing the exponential of the matrix has a logarithmic complexity.
Just implement recursively the idea :</p>
<pre><code>M^(0) = Id
M^(2p+1) = (M^2p) * M
M^(2p) = (M^p) * (M^p) // of course don't compute M^p twice here.
</code></pre>
<p>You can also just diagonalize it (not to difficult), you will find the gold number and its conjugate in its eigenvalue, and the result will give you an EXACT mathematical formula for u(n). It contains powers of those eigenvalues, so that the complexity will still be logarithmic.</p>
<p><em>Fibo is often taken as an example to illustrate Dynamic Programming, but as you see, it is not really pertinent.</em></p>
<p>@John:
I don't think it has anything to do with do with hash.</p>
<p>@John2:
A map is a bit general don't you think? For Fibonacci case, all the keys are contiguous so that a vector is appropriate, once again there are much faster ways to compute fibo sequence, see my code sample over there.</p>
|
<p>If you're using a language with first-class functions like Scheme, you can add memoization without changing the initial algorithm:</p>
<pre><code>(define (memoize fn)
(letrec ((get (lambda (query) '(#f)))
(set (lambda (query value)
(let ((old-get get))
(set! get (lambda (q)
(if (equal? q query)
(cons #t value)
(old-get q))))))))
(lambda args
(let ((val (get args)))
(if (car val)
(cdr val)
(let ((ret (apply fn args)))
(set args ret)
ret))))))
(define fib (memoize (lambda (x)
(if (< x 2) x
(+ (fib (- x 1)) (fib (- x 2)))))))
</code></pre>
<p>The first block provides a memoization facility and the second block is the fibonacci sequence using that facility. This now has an O(n) runtime (as opposed to O(2^n) for the algorithm without memoization).</p>
<p><em>Note: the memoization facility provided uses a chain of closures to look for previous invocations. At worst case this can be O(n). In this case, however, the desired values are always at the top of the chain, ensuring O(1) lookup.</em></p>
| 4,375
|
<p>we're developing a web app to cover all aspects of a printing company from finances, to payroll, to job costing. Its important to be able to control who can access what parts of these applications. Don't want a line employee giving himself a raise, etc...</p>
<p>I've heard of the concept of ACL & ACO, but haven't found a good example that we could adapt to our project.</p>
<p>Anyone know where I can find good information to work from?</p>
|
<p>A brief rundown on ACLs, where they should be used and how they should be structured and implemented for various applications and user levels can be found here:</p>
<p><a href="http://c2.com/cgi/wiki?AccessControlList" rel="nofollow noreferrer">LINK</a></p>
|
<p>I've had to implement that type of security a couple of times. Unfortunately I don't know of any really good articles that provide examples. My implementations were mainly piecing together the parts through trial and error.</p>
<p>However, I did come across this link on MSDN:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/52kd59t0(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/52kd59t0(VS.71).aspx</a></p>
<p>It has some of the concepts.</p>
<hr>
<p>After my original post, I did some more research. I found this article:</p>
<p><a href="http://www.aspfree.com/c/a/C-Sharp/Implementing-Role-Based-Security-using-CSharp/" rel="nofollow noreferrer">http://www.aspfree.com/c/a/C-Sharp/Implementing-Role-Based-Security-using-CSharp/</a></p>
<p>it seems pretty promising, I didn't go through all the details, but it at least guides you through the high-level topics.</p>
| 3,368
|
<p>I've been using user controls extensively but never use a HttpHandler and was wondering if I am doing something suboptimal or wrong</p>
|
<p>Unfortunately your question is a little like "Should I use a sandwich or a cement mixer". HttpHandlers and User controls are completely different things.</p>
<p>HttpHandlers are used to process HTTP requests. For example, if you wanted to dynamically create an RSS feed, you could write an HTTP handler that handles all requests for ".rss" files, creates the output and sends it back to the user.</p>
<p>User controls are used within ASPX pages to encapsulate units of functionality that you want to re-use accross many pages.</p>
<p>Chances are, if you're using user controls successfully, you don't want to use HttpHandlers!</p>
|
<p>Even an <code>Asp.Net</code> page is an <code>HttpHandler</code>.</p>
<pre><code>public class Page : TemplateControl, IHttpHandler
</code></pre>
<p>A user control actually resides within the asp.net aspx page.</p>
| 4,216
|
<p>I've been printing successfully on my CR-10 for the past year now. I've had issues now and then but have been able to look around the internet and solve them. I've been using some Flashforge white PLA with great results.</p>
<p>Example:
<a href="https://i.stack.imgur.com/JlMqb.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/JlMqb.jpg" alt="The whitePLA I've been using so far without much issues"></a></p>
<p>Last week I got a couple of new rolls of filament, black and orange. SinceI tried printing with them, I've got nothing but jams. The white prints fine, however.</p>
<p><a href="https://i.stack.imgur.com/bC6Tt.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/bC6Tt.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/5M8YN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/5M8YN.jpg" alt="enter image description here"></a></p>
<p>I dug around online and found this was happening to my printer: <a href="https://www.youtube.com/watch?v=-vH_spN5wyw" rel="noreferrer">https://www.youtube.com/watch?v=-vH_spN5wyw</a></p>
<p>So yesterday I opened up my hotend to clean it out and got quite a bit of gunk out:</p>
<p><a href="https://i.stack.imgur.com/MbatW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/MbatW.jpg" alt="enter image description here"></a></p>
<p>I also changed my nozzle. I printed some with the old white PLA and printed fine. The moment I switched over to the new orange filament, it jammed after a few layers.</p>
<p>I ensured my nozzle was tightened and then got to measuring the filament. The older white one is 1.75mm in most places with some at 1.73mm.</p>
<p>The new ones that I got are pretty inconsistent - the orange one ranging from 1.68mm to 1.72mm; I found very few places where it was actually 1.75mm. The black one averaged 1.72mm.</p>
<p>So I made the change in my slicer but even then the first layer was visibly underextruding and it jammed soon after. I took apart the hotend and cleaned it out. Now, I put the white one back and its back printing fine.</p>
<p>Should I go ahead and return the filament?</p>
|
<p>Not all filaments are created equal. Even with the very same manufacturer, the addition of colorful pigments can change the needed printing temperature a lot! I have had a white china PLA that was giving ok quality at 200°C, but the same brand's clear PLA only took 195°C to print. My white Kaisertech prints better at the 200°C while orange needs a little more, something about 205°C - this is the same brand and manufacturer mind you. The matte "natural" PLA I have even needs some more heat, 210°C.</p>
<p>As a rule of thumb: <strong>Printing temerature is filament dependant.</strong> Test around (there are temperature tests - use them!) to find the ideal one for each brand and color combo you have.</p>
<p>It is also a goood idea to replace the claps on the Bowden tube, if the plugs appear more often.</p>
|
<p>Not all filaments are created equal. Even with the very same manufacturer, the addition of colorful pigments can change the needed printing temperature a lot! I have had a white china PLA that was giving ok quality at 200°C, but the same brand's clear PLA only took 195°C to print. My white Kaisertech prints better at the 200°C while orange needs a little more, something about 205°C - this is the same brand and manufacturer mind you. The matte "natural" PLA I have even needs some more heat, 210°C.</p>
<p>As a rule of thumb: <strong>Printing temerature is filament dependant.</strong> Test around (there are temperature tests - use them!) to find the ideal one for each brand and color combo you have.</p>
<p>It is also a goood idea to replace the claps on the Bowden tube, if the plugs appear more often.</p>
| 1,006
|
<p>I have a two dimensional array that I need to load data into. I know the width of the data (22 values) but I do not know the height (estimated around 4000 records, but variable).</p>
<p>I have it declared as follows: </p>
<pre><code>float[,] _calibrationSet;
....
int calibrationRow = 0;
While (recordsToRead)
{
for (int i = 0; i < SensorCount; i++)
{
_calibrationSet[calibrationRow, i] = calibrationArrayView.ReadFloat();
}
calibrationRow++;
}
</code></pre>
<p>This causes a NullReferenceException, so when I try to initialize it like this: </p>
<pre><code>_calibrationSet = new float[,];
</code></pre>
<p>I get an "Array creation must have array size or array initializer."</p>
<p>Thank you,
Keith</p>
|
<p>You can't use an array.
Or rather, you would need to pick a size, and if you ended up needing more then you would have to allocate a new, larger, array, copy the data from the old one into the new one, and continue on as before (until you exceed the size of the new one...)</p>
<p>Generally, you would go with one of the collection classes - ArrayList, List<>, LinkedList<>, etc. - which one depends a lot on what you're looking for; List will give you the closest thing to what i described initially, while LinkedList<> will avoid the problem of frequent re-allocations (at the cost of slower access and greater memory usage). </p>
<p>Example:</p>
<pre><code>List<float[]> _calibrationSet = new List<float[]>();
// ...
while (recordsToRead)
{
float[] record = new float[SensorCount];
for (int i = 0; i < SensorCount; i++)
{
record[i] = calibrationArrayView.ReadFloat();
}
_calibrationSet.Add(record);
}
// access later: _calibrationSet[record][sensor]
</code></pre>
<p>Oh, and it's worth noting (as <a href="https://stackoverflow.com/questions/50558/how-do-you-initialize-a-2-dimensional-array-when-you-do-not-know-the-size#50591">Grauenwolf</a> did), that what i'm doing here doesn't give you the same memory structure as a single, multi-dimensional array would - under the hood, it's an array of references to other arrays that actually hold the data. This speeds up building the array a good deal by making reallocation cheaper, but can have an impact on access speed (and, of course, memory usage). Whether this is an issue for you depends a lot on what you'll be doing with the data after it's loaded... and whether there are two hundred records or two million records.</p>
|
<p>I generally use the nicer collections for this sort of work (List, ArrayList etc.) and then (if really necessary) cast to T[,] when I'm done.</p>
| 7,334
|
<p>Are people still writing <a href="http://zeroc.com/blogs/michi/" rel="noreferrer">SOAP services</a> or is it a technology that has passed its <a href="http://www.addsimplicity.com/" rel="noreferrer">architectural shelf life</a>? Are people returning to binary formats?</p>
|
<p>The alternative to SOAP is not binary formats.</p>
<p>I think you're seeing a surge in the desire to leave the complexities of WS-* behind in favor of REST and JSON, because they're much simpler to use and don't require frameworks to be used successfully. The problems that WS-* ostensibly tries to solve aren't problems for most users, but they have to pay for the complexity any way.</p>
|
<p>Yes, some people <strong>still</strong> are (and now it's 2011!). I think the main reason is that MS WCF automatically generates SOAP bindings. The horror. </p>
| 5,938
|
<p>What would be the best way to calculate someone's age in years, months, and days in T-SQL (SQL Server 2000)?</p>
<p>The <code>datediff</code> function doesn't handle year boundaries well, plus getting the months and days separate will be a bear. I know I can do it on the client side relatively easily, but I'd like to have it done in my <a href="http://en.wikipedia.org/wiki/Stored_procedure" rel="noreferrer">stored procedure</a>.</p>
|
<p>Here is some T-SQL that gives you the number of years, months, and days since the day specified in @date. It takes into account the fact that DATEDIFF() computes the difference without considering what month or day it is (so the month diff between 8/31 and 9/1 is 1 month) and handles that with a case statement that decrements the result where appropriate.</p>
<pre><code>DECLARE @date datetime, @tmpdate datetime, @years int, @months int, @days int
SELECT @date = '2/29/04'
SELECT @tmpdate = @date
SELECT @years = DATEDIFF(yy, @tmpdate, GETDATE()) - CASE WHEN (MONTH(@date) > MONTH(GETDATE())) OR (MONTH(@date) = MONTH(GETDATE()) AND DAY(@date) > DAY(GETDATE())) THEN 1 ELSE 0 END
SELECT @tmpdate = DATEADD(yy, @years, @tmpdate)
SELECT @months = DATEDIFF(m, @tmpdate, GETDATE()) - CASE WHEN DAY(@date) > DAY(GETDATE()) THEN 1 ELSE 0 END
SELECT @tmpdate = DATEADD(m, @months, @tmpdate)
SELECT @days = DATEDIFF(d, @tmpdate, GETDATE())
SELECT @years, @months, @days
</code></pre>
|
<pre><code>DECLARE @DoB AS DATE = '1968-10-24'
DECLARE @cDate AS DATE = CAST('2000-10-23' AS DATE)
SELECT
--Get Year difference
DATEDIFF(YEAR,@DoB,@cDate) -
--Cases where year difference will be augmented
CASE
--If Date of Birth greater than date passed return 0
WHEN YEAR(@DoB) - YEAR(@cDate) >= 0 THEN DATEDIFF(YEAR,@DoB,@cDate)
--If date of birth month less than date passed subtract one year
WHEN MONTH(@DoB) - MONTH(@cDate) > 0 THEN 1
--If date of birth day less than date passed subtract one year
WHEN MONTH(@DoB) - MONTH(@cDate) = 0 AND DAY(@DoB) - DAY(@cDate) > 0 THEN 1
--All cases passed subtract zero
ELSE 0
END
</code></pre>
| 8,193
|
<p>I am trying to code TDD style in PHP and one of my biggest stumbling blocks (other than lack of a decent IDE) is that I have to make my own hacked together IoC container just to inject all my mock objects properly.</p>
<p>Has anyone used an Ioc container in PHP? All I've been able to find is <a href="http://www.phpclasses.org/browse/package/3382.html" rel="nofollow noreferrer">PHP IOC on the ever-annoying phpclasses.org</a> and it seems to have almost no documentation and not much of a following.</p>
|
<p>I played with some DI Frameworks for PHP, but I haven't used one in production. Have some links:</p>
<ol>
<li><a href="http://www.stubbles.net" rel="noreferrer">http://www.stubbles.net/</a> which
I think is the oldest I tried</li>
<li><a href="http://php.xjconf.net/" rel="noreferrer">http://php.xjconf.net/</a></li>
<li><a href="http://flow3.typo3.org/" rel="noreferrer">FLOW3</a> - I belive this one will
become a very nice framework (its
beta right now)</li>
</ol>
<p>You mentioned you would use it for TDD - so maybe have a look at <a href="http://techblog.tilllate.com/2007/08/21/using-dependency-injection-for-unit-tests/" rel="noreferrer">Dependency Injection for Unit Tests in PHP</a></p>
|
<p>Laravel 4 has the best IoC and DI framework. if you dont mind using a framework the Laravel 4 is the way to go</p>
| 7,530
|
<p>My goal is to maintain a web file server separately from my main ASP.NET application server for better scalability. The web file server will store a lot of files downloaded by users.<br>
So the question is: Is it worth to adopt FreeBSD + Apache + ZFS, or will good old IIS be сonvenient enough?</p>
|
<p>I understand you will serve only static files. In this case, lightweight HTTP servers will give you a higher performance for a given machine. The following are well known:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Lighttpd" rel="nofollow noreferrer">Lighttpd</a></li>
<li><a href="http://en.wikipedia.org/wiki/Thttpd" rel="nofollow noreferrer">Thttpd</a></li>
<li><a href="http://www.nginx.net/" rel="nofollow noreferrer">Nginx</a></li>
</ul>
<p>Many more are listed on <a href="http://en.wikipedia.org/wiki/Tiny_web_servers" rel="nofollow noreferrer">Wikipedia</a>. There's a more recent <a href="http://www.ibm.com/developerworks/web/library/wa-ltwebserv/" rel="nofollow noreferrer">article</a> on IBM DeveloperWorks.</p>
|
<p>If you're serving files over the Internet, you might also consider <a href="http://www.amazon.com/gp/browse.html?node=16427261" rel="nofollow noreferrer">Amazon's S3 service</a>. I've found the rates and reliability to be better than anything I could do (or find) on my own.</p>
| 4,746
|
<p>Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this:</p>
<p><strong>Before:</strong></p>
<pre><code>Some Text here
This gets cut
Some Code there
</code></pre>
<p><strong>After:</strong></p>
<pre><code>Some Text here
Some Code there
</code></pre>
<p><strong>What I want:</strong></p>
<pre><code>Some Text here
Some Code there
</code></pre>
<p>PS: I don't want to select the whole line or something like this... only the text I want to cut.</p>
|
<p>Unless I misunderstood you:<br>
Just place cursor on the line you want to cut (no selection) and press <kbd>Ctrl</kbd> + <kbd>x</kbd>. That cuts the line (leaving no blanks) and puts the text in the Clipboard. (tested in <em>MS VC# 2008 Express</em> with no additional settings I'm aware of)</p>
<p>Is that what you want?</p>
|
<p>Don't select anything, just hit <kbd>ctrl</kbd>+<kbd>x</kbd> when the cursor is on the line.</p>
| 8,409
|
<p>I've been writing C / C++ code for almost twenty years, and I know Perl, Python, PHP, and some Java as well, and I'm teaching myself JavaScript. But I've never done any .NET, VB, or C# stuff. What exactly does <strong>managed</strong> code mean?</p>
<p>Wikipedia <a href="http://en.wikipedia.org/wiki/Managed_code" rel="noreferrer">describes it</a> simply as</p>
<blockquote>
<p>Code that executes under the management of a virtual machine</p>
</blockquote>
<p>and it specifically says that Java is (usually) managed code, so</p>
<ul>
<li><strong>why does the term only seem to apply to C# / .NET?</strong></li>
<li><strong>Can you compile C# into a .exe that contains the VM as well, or do you have to package it up and give it to another .exe (a la java)?</strong></li>
</ul>
<p>In a similar vein,</p>
<ul>
<li><strong>is .NET a <em>language</em> or a <em>framework</em>, and what exactly does "framework" mean here?</strong></li>
</ul>
<p>OK, so that's more than one question, but for someone who's been in the industry as long as I have, I'm feeling rather N00B-ish right now...</p>
|
<p>When you compile C# code to a .exe, it is compiled to Common Intermediate Language(CIL) bytecode. Whenever you run a CIL executable it is executed on Microsofts Common Language Runtime(CLR) virtual machine. So no, it is not possible to include the VM withing your .NET executable file. You must have the .NET runtime installed on any client machines where your program will be running.</p>
<p>To answer your second question, .NET is a framework, in that it is a set of libraries, compilers and VM that is not language specific. So you can code on the .NET framework in C#, VB, C++ and any other languages which have a .NET compiler. </p>
<p><a href="https://bitbucket.org/brianritchie/wiki/wiki/.NET%20Languages" rel="noreferrer">https://bitbucket.org/brianritchie/wiki/wiki/.NET%20Languages</a></p>
<p>The above page has a listing of languages which have .NET versions, as well as links to their pages.</p>
|
<p>Managed Code--MSIL and IL and Managed Code are same.When we build our application the .dll or .exe files are generated in the Bin folder.These files are called as Managed code.Later these files are given to CLR to generate Native code which would be understood by OS.</p>
| 8,238
|
<p>I'm using Cura to slice prints from a biodegradable polyester called PCL (<a href="https://en.wikipedia.org/wiki/Polycaprolactone" rel="nofollow noreferrer">Polycaprolactone</a>).</p>
<p>I need to print @ ~70 °C but extruder does not run until nozzle reaches 175 °C.</p>
<p>Which setting to change so extruder will turn on when nozzle temperature has reached 70 °C?</p>
<p>Here are my settings for the material:</p>
<p><strong><a href="https://i.stack.imgur.com/IIh9C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IIh9C.png" alt="strong text" /></a></strong></p>
|
<p>70 °C is a specialty filament. It is well below the <code>MIN_TEMP</code> defined in any sane firmware. In Marlin, you <strong>can't</strong> turn on the extruder in any way, while this is online.</p>
<p>You do need to define your firmware to allow such a print - either by dropping the value in the firmware or disabling Mintemp-protection and then <em>flashing that firmware</em>. That is quite invasive.</p>
<p>To <a href="https://marlinfw.org/docs/gcode/M302.html" rel="nofollow noreferrer">temporarily</a> disable the <code>MIN_TEMP</code>, you need to run the G-code <code>M302 P1</code> or <code>M302 S0</code> - <code>M302</code> on its own does nothing. However, some firmware distributions might explicitly prevent these two commands of <em>turning off</em> the check.</p>
<p>In that case, you might use <code>M302 S65</code> or similar to drop the <code>MIN_TEMP</code>.</p>
|
<p>In Cura Machine Settings, add <code>M302 S70</code>.</p>
<p>Apparently, <code>M302 P1</code> and <code>M302 S0</code> do nothing, you need to define a non-zero minimum, and in my case, 70. Thanks to 0scar and Trish for your help.</p>
| 1,849
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.