instruction stringlengths 27 22.5k | chosen stringlengths 27 28.2k | rejected stringlengths 19 24.9k | __index_level_0__ int64 0 10k |
|---|---|---|---|
<p>In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?</p>
| <p>The following query will bring back a unique list of tables where <code>Column_Name</code> is equal to the column you are looking for:</p>
<pre><code>SELECT Table_Name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE Column_Name = 'Desired_Column_Name'
GROUP BY Table_Name
</code></pre>
| <pre><code>SELECT Table_Name
FROM Information_Schema.Columns
WHERE Column_Name = 'YourFieldName'
</code></pre>
| 2,565 |
<p>I know Hostmonster allows Python. Has anyone successfully run Django on there? Any problems? </p>
| <p>I know this is an old question, but here is the answer: <strong>yes, Hostmonster does support Django</strong></p>
<p>There used to be <a href="http://helpdesk.hostmonster.com/index.php/kb/article/000531" rel="nofollow noreferrer">this Hostmonster KB article</a> for details, including instructions on how to set it u... | <p>Well, if it support Python, you might be able to run Django using a FastCGI setup, as described here: <a href="https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/" rel="nofollow noreferrer">FastCGI Docs</a>. If it supports mod_python (which I guess it's what you mean), then sure, you can install it using... | 4,163 |
<p>How do I sort a list of dictionaries by a specific key's value? Given:</p>
<pre><code>[{'name': 'Homer', 'age': 39}, {'name': 'Bart', 'age': 10}]
</code></pre>
<p>When sorted by <code>name</code>, it should become:</p>
<pre><code>[{'name': 'Bart', 'age': 10}, {'name': 'Homer', 'age': 39}]
</code></pre>
| <p>The <a href="https://docs.python.org/library/functions.html#sorted" rel="noreferrer"><code>sorted()</code></a> function takes a <code>key=</code> parameter</p>
<pre><code>newlist = sorted(list_to_be_sorted, key=lambda d: d['name'])
</code></pre>
<p>Alternatively, you can use <a href="https://docs.python.org/library... | <p>sorting by multiple columns, while in descending order on some of them:
the cmps array is global to the cmp function, containing field names and inv == -1 for desc 1 for asc</p>
<pre><code>def cmpfun(a, b):
for (name, inv) in cmps:
res = cmp(a[name], b[name])
if res != 0:
return res *... | 9,850 |
<p>Almost 5 years ago Joel Spolsky wrote this article, <a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="nofollow noreferrer">"The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)"</a>.</p>
<p>Like many, I read it carefully, real... | <p>Since I read the Joel article and some other I18n articles I always kept a close eye to my character encoding; And it actually works if you do it consistantly. If you work in a company where it is standard to use UTF-8 and everybody knows this / does this it will work.</p>
<p>Here some interesting articles (besides... | <p>I spent a while working with search engine software - You wouldn't believe how many web sites serve up content with HTTP headers or meta tags which lie about the encoding of the pages. Often, you'll even get a document which contains both ISO-8859 characters and UTF-8 characters.</p>
<p>Once you've battled through ... | 8,357 |
<p>Does any know a good rule of thumb for the appropriate pagefile size for a Windows 2003 server running SQL Server?</p>
| <p>Irrelevant of the size of the RAM, you still need a pagefile at least 1.5 times the amount of physical RAM. This is true even if you have a 1 TB RAM machine, you'll need 1.5 TB pagefile on disk (sounds crazy, but is true).</p>
<p>When a process asks MEM_COMMIT memory via VirtualAlloc/VirtualAllocEx, the requested s... | <p>If you're looking for high performance, you are going to want to avoid paging completely, so the page file size becomes less significant. Invest in as much RAM as feasible for the DB server.</p>
| 2,472 |
<p>I have never worked with web services and rails, and obviously this is something I need to learn.
I have chosen to use hpricot because it looks great.
Anyway, _why's been nice enough to provide the following example on the <a href="http://code.whytheluckystiff.net/hpricot/" rel="nofollow noreferrer">hpricot website<... | <p>Model, model, model, model, model. Skinny controllers, simple views.</p>
<p>The RedHandedHomePage model does the parsing on initialization, then call 'def render' in the controller, set output to an instance variable, and print that in a view.</p>
| <p>I'd probably go for a REST approach and have resources that represent the different entities within the XML file being consumed. Do you have a specific example of the XML that you can give?</p>
| 4,845 |
<p>As first layer is so important, I am looking for an easy way to generate the gcode to print just the first layer.
I see that with Slic3r you can cut from a Z
But for test purposes I prefer just selecting a number of layers to be generated so I can easily generate different "first layer(s) tests" with different firs... | <p>I understand your question like this:</p>
<blockquote>
<p>I know I could cut the mesh and just slice the bottom of my model, but since I am interested in a given <strong>number of layers</strong> and the heigh of a layer may change according to settings (e.g.: 0.2mm, 0.1mm, 0.05mm...), I want to find a way to gen... | <p>You could just insert an M30 at the end of layer 1, and the job will end there.</p>
| 789 |
<p>Is there any need of Virtual Constructors? If so can any one post a scenario?</p>
| <p>If you are talking about virtual destructors in C++ (there isn't any such thing as virtual constructors) then they should always be used if you are using your child classes polymorphically.</p>
<pre><code>class A
{
~A();
}
class B : public A
{
~B();
}
A* pB = new B();
delete pB; // NOTE: WILL NOT CALL B's des... | <p>In C++, all constructors are implicitly virtual (with a little extra). That is, the constructor of the base class is called before that of the derived class. So, it's like they're sort of virtual. Because, in a virtual method, if the derived class implements a method of the same signature, only the method in the der... | 9,600 |
<p>If I have something like a UILabel linked to a xib file, do I need to release it on dealloc of my view? The reason I ask is because I don't alloc it, which makes me think I don't need to release it either?
eg (in the header):</p>
<pre><code>IBOutlet UILabel *lblExample;
</code></pre>
<p>in the implementation:</p>
... | <p>If you follow what is now considered to be best practice, you <em>should</em> release outlet properties, because you should have retained them in the set accessor:</p>
<pre><code>@interface MyController : MySuperclass {
Control *uiElement;
}
@property (nonatomic, retain) IBOutlet Control *uiElement;
@end
@imp... | <p>Related: <a href="https://stackoverflow.com/questions/6578/understanding-reference-counting-with-cocoa-objective-c">Understanding reference counting with Cocoa / Objective C</a></p>
| 8,714 |
<p>In my database, I have an entity table (let's call it Entity). Each entity can have a number of entity types, and the set of entity types is static. Therefore, there is a connecting table that contains rows of the entity id and the name of the entity type. In my code, EntityType is an enum, and Entity is a Hibernate... | <p>HQL:</p>
<pre><code>select entity from Entity entity where :type = some elements(entity.types)
</code></pre>
<p>I think that you can also write it like:</p>
<pre><code>select entity from Entity entity where :type in(entity.types)
</code></pre>
| <p>Is your relationship bidirectional, i.e., does <code>EntityType</code> have an <code>Entity</code> property? If so, you can probably do something like <code>entity.Name from EntityType where name = ?</code></p>
| 7,185 |
<p>I am writing a VC++ MFC dialog based app which requires Microsoft MapPoint embedding in it. To do this I'm using MS VC++ .NET 2003 and MapPoint Europe 2006 to do this but am having problems as when I select "Insert ActiveX Control" no MapPoint control appears in the list of options. I have tried manually registering... | <p>I've found some benefits to makefiles with large projects, mainly related to unifying the location of the project settings. It's somewhat easier to manage the list of source files, include paths, preprocessor defines and so on, if they're all in a makefile or other build config file. With multiple configurations, ... | <p>You can use nant to build the projects individually thus replacing the solution and have 1 coding solution and no build solutions.</p>
<p>1 thing to keep in mind, is that the solution and csproj files from vs 2005 and up are msbuild scripts. So if you get acquainted with msbuild you might be able to wield the exist... | 7,507 |
<p>In my most C++ project I heavily used ASSERTION statement as following:</p>
<pre><code>int doWonderfulThings(const int* fantasticData)
{
ASSERT(fantasticData);
if(!fantasticData)
return -1;
// ,,,
return WOW_VALUE;
}
</code></pre>
<p>But TDD community seems like to enjoy doing something lik... | <p>In my (limited) experience the first option is quite a bit safer. In a test-case you only test predefined input and compare the outcome, this works well as long as every possible edge-case has been checked. The first option just checks every input and thus tests the 'live' values, it filters out bugs real quickly, h... | <p>I don't know which particlar TDD subcommunity you're refering to but the TDD patterns I've come across either use Assert.AreEqual() for positive results or otherwise use an ExpectedException mechanism (e.g., attributes in .NET) to declare the error that should be observed.</p>
| 3,789 |
<p>I've got a JavaScript "object", built this way:</p>
<pre><code>function foo()
{
this.length = 0;
}
foo.prototype.getLength = function()
{
return this.length;
}
...
</code></pre>
<p>I know how to emulate namespaces with singleton JavaScript objects, but what is the best way to "namepace" an object such as... | <p>Simple:</p>
<pre><code>if(!MyNamespace) MyNamespace = {};
MyNamespace.foo = function() {
this.length = 0;
};
MyNamespace.foo.prototype.getLength = function() {
return this.length;
};
</code></pre>
| <p>Another alternative may be the <a href="http://www.bobjs.com" rel="nofollow">bob.js</a> framework:</p>
<pre><code>bob.ns.setNs('myApp.myFunctions', {
say: function(msg) {
console.log(msg);
}
});
//sub-namespace
bob.ns.setNs('myApp.myFunctions.mySubFunctions', {
hello: function(name) {
... | 4,296 |
<p>I took a data structures class in C++ last year, and consequently implemented all the major data structures in templated code. I saved it all on a flash drive because I have a feeling that at some point in my life, I'll use it again. I imagine <em>something</em> I end up programming will need a B-Tree, or is that ... | <p>Forever (or as close as I can get). That's the whole point of a source control system.</p>
| <p>Source control, keep it offsite and keep it for life! You'll never have to worry about it.</p>
| 9,365 |
<p>When building projects in C++, I've found debugging linking errors to be tricky, especially when picking up other people's code. What strategies do people use for debugging and fixing linking errors?</p>
| <p>Not sure what your level of expertise is, but here are the basics. </p>
<p>Below is a linker error from VS 2005 - yes, it's a giant mess if you're not familiar with it.</p>
<pre><code>ByteComparator.obj : error LNK2019: unresolved external symbol "int __cdecl does_not_exist(void)" (?does_not_exist@@YAHXZ) referenc... | <p>One of the common linking errors I've run into is when a function is used differently from how it's defined. If you see such an error you should make sure that every function you use is properly declared in some .h file.<br>
You should also make sure that all the relevant source files are compiled into the same lib... | 5,535 |
<p>A couple weeks before, I bought a custom 3D printer that has an Ultimaker 2 motherboard in it. However, the dimensions of the printer is not same with Ultimaker 2 (X and Y same, a bit smaller on Z). The printer had tinkerfirmware installed in it. Today, I tried to print a premade .gcode file (Which was for another 3... | <p>Your printer is an Ultimaker clone or something else? All of the original firmwares located on TinkerGnome's Github are configured for Ultimaker printers so if you are using them on something different you will need to configure it before using it. The easiest option would be editing this print file that changed y... | <p>Firmware <em>is</em> stored in EEPROM, and may contain some default values, but does not affect the <em>calibration</em> values which are stored in EEPROM.</p>
<p>You should be able to reset the calibration to 'factory defaults', this actually means to take the defaults in the firmware and store them in EEPROM.</p>... | 1,020 |
<p>I want to log onto Stack Overflow using OpenID, but I thought I'd set up my own OpenID provider, just because it's harder :) How do you do this in Ubuntu?</p>
<p>Edit: Replacing 'server' with the correct term OpenID provider (Identity provider would also be correct according to <a href="http://en.wikipedia.org/wiki... | <p>I personnally used <a href="https://siege.org/phpmyid.html" rel="nofollow noreferrer">phpMyID</a> just for StackOverflow. It's a simple two-files PHP script to put somewhere on a subdomain. Of course, it's not as easy as installing a .deb, but since OpenID relies completely on HTTP, I'm not sure it's advisable to in... | <p>I totally understand where you're coming from with this question. I already had a OpenID at <a href="http://www.myopenid.com" rel="nofollow noreferrer">www.myopenid.com</a> but it feels a bit weird relying on a 3rd party for such an important login (a.k.a my permanent "home" on the internet).</p>
<p>Luckil... | 4,820 |
<p>Has anyone succeeded in installing the auto bed levelling on a Rumba board with Marlin firmware?</p>
<p>I have the last stable version <a href="https://github.com/MarlinFirmware/Marlin/releases/tag/1.1.0-RC6" rel="nofollow noreferrer">1.1.0 RC6</a>.</p>
<p>I would appreciate some direction especially about:</p>
<... | <p>General note, I do not have this board so I cannot test these steps myself, read the documentation in configuration.h, it is very detailed and should guide you pretty well. I am specifically looking at Marlin 1.1 RC7 on Github, so the lines below may vary slightly from what you see.</p>
<p>As to the pins to connect... | <p><strong>For future reference.</strong></p>
<p>My issue about the servo not moving was caused by a wiring mistake.
The Exp. 3 has 14 pins has per this diagram.</p>
<p><a href="https://i.stack.imgur.com/g4yyn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g4yyn.png" alt="enter image description h... | 416 |
<p>After a long battle with SKR Mini v2, TFT35 and BLTouch and creating the right firmware. I thought I was through it all and ready to start printing again after finally being able to set the Z offset and auto level the bed. My printer has other thoughts. Now my bed temperature will only heat up to 10 °C below the set... | <p>Searching the error message "Heating Failed: Bed Printer Halted, Please Reset" seems to indicate that the bed heater is timing out from not reaching temperature.</p>
<ol>
<li><p>If you measure the voltage applied to the bed heater before the error message, does the voltage stay at Max.; i.e. 12 V for a 12 ... | <p>I was having the same issue after installing BTT SKR Mini E3 V2 and BLTouch on my Ender 5 Pro.</p>
<p>I did two things and my bed heats normally now, but I changed/did both things and can't say which fixed the issue for me.</p>
<ul>
<li>I noticed the case fan wasn't coming on. I had it plugged into <code>Fan 1</code... | 1,836 |
<p>I'm trying to use the <a href="http://optiflag.rubyforge.org/discussion.html" rel="nofollow noreferrer">Optiflag</a> package in my Ruby code and whenever I try to do the necessary <code>require optiflag.rb</code>, my program fails with the standard <code>no such file to load -- optiflag</code> message. I added the d... | <p>is it a gem? Are you doing </p>
<pre><code>require 'rubygems'
require 'optiflag'
</code></pre>
<p>or equivalent?</p>
| <p>I also keep having this problem with RubyXL, tried to use single and double quotes. Is there something else that needs to be done? Maybe putting a file somewhere? I already succesfully installed the gem with sudo gem install rubyXL (RubyXL actually din't work).</p>
| 7,670 |
<p>I have a recursive algorithm which steps through a string, character by character, and parses it to create a tree-like structure. I want to be able to keep track of the character index the parser is currently at (for error messages as much as anything else) but am not keen on implementing something like a tuple to ... | <p>Since you've already discovered the pseudo-mutable integer "hack," how about this option:</p>
<p>Does it make sense for you to make a separate Parser class? If you do this, you can store the current state in a member variable. You probably need to think about how you're going to handle any thread safety issues, a... | <p>To be honest I would recode the function to make it a linear algorithm that uses a loop. This way you have no chance of running out of heap space if you are stepping through an extremely large string. Also, you would not need to have a the extra parameter just to keep track of the count.</p>
<p>This also would prob... | 5,499 |
<p>I've seen this weird behavior on several sites recently: I scroll down a page and follow a link to another page. When I click the Back button and return, I am left back at the top of the previous page, not at the link. This is very annoying if I'm clicking on links in a search results page or a list of "10 Best Foo ... | <p>Many sites have a text box (for searching the site, or something) that is set to automatically take focus when the page loads (using javascript or something). In many browsers, the page will jump to that text box when it gets focus.</p>
<p>It really is very annoying :(</p>
| <p>Typically this behaviour is caused by the browser cache set by the site having a small or no time before expiry.</p>
<p>On many sites, when you hit "back" you get brought back to the link you hit, as your browser is pulling the page from your cache. If this cache has not been set, a new page request is made, and th... | 9,523 |
<p>There's a <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/8e0235d58c8635c2" rel="noreferrer" title="assertions: does it matter that they are disabled in production?">discussion</a> going on over at comp.lang.c++.moderated about whether or not assertions, which in C++ only exist i... | <p>Assertions are comments that do not become outdated. They document which theoretical states are intended, and which states should not occur. If code is changed so states allowed change, the developer is soon informed and needs to update the assertion.</p>
| <p>An assertion is error, pure and simple and therefore should be handled like one.</p>
<p>Since an error should be handled in release mode then you don't really need assertions.</p>
<p>The main benefit I see for assertions is a conditional break - they are much easier to setup than drilling through VC's windows to s... | 3,832 |
<p>I have a flex application that needs the ability to generate and execute JavaScript. When I say this, I mean I need to execute raw JavaScript that I create in my Flex application (not just an existing JavaScript method)</p>
<p>I am currently doing this by exposing the following JavaScript method:</p>
<pre><code>fu... | <p>There's no need for the JavaScript function, the first argument to <code>ExternalInterface</code> can be any JavaScript code, it doesn't have to be a function name (the documentation says so, but it is wrong).</p>
<p>Try this:</p>
<pre><code>ExternalInterface.call("alert('hello')");
</code></pre>
| <pre><code>ExternalInterface.call("eval", "alert('hello');");
</code></pre>
| 4,086 |
<p>From my experience with <a href="http://en.wikipedia.org/wiki/OpenID" rel="nofollow noreferrer">OpenID</a>, I see a number of significant downsides:</p>
<p><strong>Adds a <a href="http://en.wikipedia.org/wiki/Single_Point_of_Failure" rel="nofollow noreferrer">Single Point of Failure</a> to the site</strong><br>
It ... | <p>The benefit of making OpenID mandatory is simply that login code for the website does not need to be written (beyond the OpenID integration), and no precautions need to be taken around storing user passwords etc.</p>
<p>Not having your own login code also means not having to deal with a lot of support issues like r... | <p>The main benefit of having an OpenID will be seen in the long term. Instead of having to apply to different sites for an identity, you do that once and then use it on all the sites that require a unique identity. Of course for secure sites like banking and trading it will need a different kind of thinking altogether... | 8,529 |
<p>Suppose I have the X, Y, and Z coordinates (either in a list or a function z = f(x,y)) that defines a shape as the one provided and I want to 3D print it with a solid bottom, is there an easy way to do this? If not, how can a functionally well-defined shape be put into a 3D modeling software like FreeCAD?</p>
<p><a ... | <p>For stuff like this, OpenSCAD is your friend. There are several different approaches you could take:</p>
<ol>
<li><p>Generate an image file with grayscale color representing the height of the function on an XY grid, and use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surfa... | <p>Not sure what you're asking exactly, but you can use this workflow:</p>
<ol>
<li>SideFX Houdini: math function + STL file generation
<a href="https://i.stack.imgur.com/28jr1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/28jr1.jpg" alt="enter image description here" /></a>
<a href="https://i.stac... | 2,032 |
<p>Everyone remembers google browser sync right? I thought it was great. Unfortunately Google decided not to upgrade the service to Firefox 3.0. Mozilla is developing a replacement for google browser sync which will be a part of the Weave project. I have tried using Weave and found it to be very very slow or totally in... | <p>Mozilla Weave is capable of running on personal servers. It uses WebDAV to communicate with HTTP servers and can be configured to connect to private servers. I've tried setting it up on my own servers but with no success (Mainly because I'm not very good at working with Apache to configure WebDAV)</p>
<p>I'm hoping... | <p>I've been using the Firefox Scrapbook extension, sync'd via FolderShare. It takes a little setup, but the nice thing is that Scrapbook grabs a local copy of each page so it works offline or if the site goes away.</p>
| 3,444 |
<p>After hours of debugging, it appears to me that in FireFox, the innerHTML of a DOM reflects what is actually in the markup, but in IE, the innerHTML reflects what's in the markup PLUS any changes made by the user or dynamically (i.e. via Javascript).</p>
<p>Has anyone else found this to be true? Any interesting wor... | <p>I use jQuery's <a href="http://docs.jquery.com/Attributes/html" rel="noreferrer">.html()</a> to get a consistent result across browsers.</p>
| <p>Using prototype and the $("thisid") syntax instead of document.getElementById("thisid") might do the trick for you. It worked for me.</p>
| 5,738 |
<p>What is the difference between using angle brackets and quotes in an <code>include</code> directive?</p>
<ul>
<li><code>#include <filename></code></li>
<li><code>#include "filename"</code></li>
</ul>
| <p>What differs is the locations in which the preprocessor searches for the file to be included.</p>
<ul>
<li><p><code>#include <filename></code> The preprocessor searches in an implementation-defined manner, normally in directories pre-designated by the compiler/IDE. This method is normally used to include hea... | <p>There exists two ways to write #include statement.These are:</p>
<pre><code>#include"filename"
#include<filename>
</code></pre>
<p>The meaning of each form is </p>
<pre><code>#include"mylib.h"
</code></pre>
<p>This command would look for the file <code>mylib.h</code> in the current directory as well as the... | 4,174 |
<p>From the <a href="http://marlinfw.org/docs/gcode/M502.html" rel="nofollow noreferrer"><code>M502</code> documentation page</a> can be read that <code>M502</code>:</p>
<blockquote>
<p>Reset all configurable settings to their factory defaults.</p>
</blockquote>
<p><sub><em>Please note that this phrasing from the m... | <p>What Marlin does when <code>M502</code> is called is defined in the <a href="https://github.com/MarlinFirmware/Marlin/blob/bugfix-2.0.x/Marlin/src/module/configuration_store.cpp" rel="noreferrer"><code>configuration_store.cpp</code></a> file.</p>
<p>It resets:</p>
<ul>
<li>Max acceleration</li>
<li>Steps per mm</l... | <p>Technically, the description as "factory settings" is misguiding, as the settings called up are much better described as "firmware defined settings". But since Firmware upgrades usually are rare and far between, these settings can be considered "factory" for the usual user, even as we always urge users to test if th... | 1,519 |
<p>I once worked with an architect who banned the use of SQL views. His main reason was that views made it too easy for a thoughtless coder to needlessly involve joined tables which, if that coder tried harder, could be avoided altogether. Implicitly he was encouraging code reuse via copy-and-paste instead of encapsul... | <p>There are some very good uses for views; I have used them a lot for tuning and for exposing less normalized sets of information, or for UNION-ing results from multiple selects into a single result set.</p>
<p>Obviously any programming tool can be used incorrectly, but I can't think of any times in my experience whe... | <p>Let's see if I can come up with a lame analogy ...</p>
<p>"I don't need a phillips screwdriver. I carry a flat head and a grinder!"</p>
<p>Dismissing views out of hand will cause pain long term. For one, it's easier to debug and modify a single view definition than it is to ship modified code.</p>
| 6,417 |
<p>Ok I’m so new at Blender. Half the time it’s knowing what question you have to ask to get the answer you need...</p>
<p>I want to make a 3D printable warrior type action figure but I only have one very detailed frontal view. Can I input that image into somewhere and it gives me a 3D model to start from? Like will it... | <p>In short, no. A 2D image has insufficient information to determine a 3D form.</p>
<p>If you want to do this yourself, what you could do is start with the 2D outline in a program like Blender (as 0scar mentioned in a comment), extrude it to make a thin "cardboard cutout", then begin shaping it into three di... | <p>If you only have a 2D photo then as others have already said its not really possible. However if you have the action figure itself you could try a technique called Photogrammetry where you use your phone to take multiple images of the object and then use software to build up a model. Search youtube for guides on Ph... | 2,008 |
<p>I'm trying to write some PHP to upload a file to a folder on my webserver. Here's what I have:</p>
<pre><code><?php
if ( !empty($_FILES['file']['tmp_name']) ) {
move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']);
header('Location: http://www.mywebsite.com/dump/');... | <p>As it's Windows, there is no real 777. If you're using <a href="http://fr2.php.net/manual/en/function.chmod.php" rel="noreferrer">chmod</a>, check the Windows-related comments.</p>
<p>Check that the IIS Account can access (read, write, modify) these two folders:</p>
<pre><code>E:\inetpub\vhosts\mywebsite.com\httpd... | <p>Create a folder named "image" with folder permission <code>777</code></p>
<pre><code><?php
move_uploaded_file($_FILES['file']['tmp_name'],"image/".$_FILES['file']['name']);
?>
</code></pre>
| 2,569 |
<p>I'm using the VS2008 installer (plus a custom Orca action) to create an installer for my .NET product.</p>
<p>I just recently found out that one of the third-party assemblies I was using is x86-specific (as it includes some native code); thus, x64 customers were getting crashes on startup with errors about the asse... | <p>When I looked into this a year ago, I came to the conclusion that it was not possible. It's worth noting that many Microsoft-supplied MSI files come in separate x86 and x64 flavors -- and presumably, they'd only deliver a single file if that were possible.</p>
| <p>I have had some success by using two features to selectively include the two sets of files (in separate components of course, with their individualized file identifiers!). </p>
<p>The installation must be marked as x32 to install on both x32 and x64. It will always install to the x32 directories and will largely b... | 8,618 |
<p>How can I get the MAC Address using only the compact framework?</p>
| <p>1.4 of the OpenNETCF code gets the information from the following P/Invoke call:</p>
<pre><code> [DllImport ("iphlpapi.dll", SetLastError=true)]
public static extern int GetAdaptersInfo( byte[] ip, ref int size );
</code></pre>
<p>The physical address (returned as MAC address) I think is around about index ... | <p>Add a reference to System.Management.dll and use something like:</p>
<pre><code>Dim mc As System.Management.ManagementClass
Dim mo As ManagementObject
mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled"... | 6,440 |
<p>Do you know if it's possible to build an application for the LinkedIn platform?</p>
| <p>While LinkedIn has promised a public API for a very long time now, they have yet to deliver. </p>
<p>No, there is no <strong>public</strong> LinkedIn API yet. </p>
<p>IMO, their widgets (which there are only two of at the moment, which are very limited) don't count. </p>
<p>They say that they are open to bein... | <p>Yes, Linkedin has an API:</p>
<ul>
<li><a href="http://www.programmableweb.com/api/linkedin" rel="nofollow noreferrer">http://www.programmableweb.com/api/linkedin</a></li>
<li><a href="http://blog.linkedin.com/blog/2007/12/the-intelligent.html" rel="nofollow noreferrer">http://blog.linkedin.com/blog/2007/12/the-int... | 6,225 |
<p>I have heard there is a way to cheat single inheritance and implement multiple inheritance in Java. Does anyone know how to implement this(with out using interface)?</p>
<p>Just out of curiosity ;-)</p>
| <p>Sure you can, but it's tricky and you should really consider if that's the way you want to go.<br>
The idea is to use scope-based inheritance coupled with type-based one. Which is type-talk for saying that for internal purposes, inner classes "inherit" methods and fields of the outer class. It's a bit like mixins, w... | <p>Yes you can say that it's a trick and it is very Interesting you cannot inherit multiple classes to a single class but it is possible to implement multiple Interfaces to a class like</p>
<pre><code>public class parents implements first, second{
}
</code></pre>
<p>but remember, you have to override methods declare... | 9,596 |
<p>Given a table of votes (users vote for a choice, and must supply an email address):</p>
<pre><code>votes
--
id: int
choice: int
timestamp: timestamp
ip: varchar
email: varchar
</code></pre>
<p>What's the best way to count "unique" votes (a user being a unique combination of email + ip) given the constraint they ma... | <p>Something like </p>
<pre><code>select email, ip, count(choice)
from votes
group by email, ip, datepart(hour, timestamp)
</code></pre>
<p>If I understand correctly</p>
| <p>You could rewrite your insert statement to only allow votes to be inserted based on your contrainsts:</p>
<pre><code>Insert Into Votes
(Choice, Timestamp, IP, Email)
Select
Top 1
@Choice, @Timestamp, @IP, @Email
From
Votes
Where
(Select Count(*) From Votes Where
IP = @IP
and Email = @Email
and Timestamp... | 9,688 |
<p>Typically in a large network a computer needs to operate behind an authenticated proxy - any connections to the outside world require a username/password which is often the password a user uses to log into email, workstation etc.</p>
<p>This means having to put the network password in the <code>apt.conf</code> file... | <p>With the following approach you never have to save your proxy password in plain text. You just have to type in a password interactively as soon as you need http/https/ftp access:</p>
<ul>
<li>Use openssl to encrypt your plain text proxy password into a file, with e.g. AES256 encryption:</li>
</ul>
<blockquote>
<... | <p>Is public key authentication a valid alternative for you?</p>
| 3,945 |
<p>I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like for it to setting a transaction.IsSaved=true flag (this is a simplification the actual thing I'm trying to do is not quite so banal). So when mocking my TransactionDao with RhinoMocks how can I indicate that it ... | <p>Gorge, </p>
<p>The simplest solution, which I found, applied to your question is the following:</p>
<pre><code>Expect.Call(() => dao.Save(transaction))
.Do(new Action<Transaction>(x => x.IsSaved = true));
</code></pre>
<p>So you don't need to create a special delegate or anything else. Just use A... | <p>you should mock the transaction and make it return true fo IsSaved, if you can mock the transaction of course.</p>
<pre><code>ITransaction transaction = _Mocker.dynamicMock<ITransaction>;
Expect.Call(transaction.IsSaved).IgnoreArguments.Return(true);
_mocker.ReplayAll();
dao.Save(transaction);
</code></pre>
| 8,396 |
<p>I'm running Repetier Host v1.6.1 with Repetier Firmware v0.92.9. My computer is running Windows 7 Pro SP1, 64-bit.</p>
<p>If I set a print going via USB then switch to another user (note: I do not log out), then the pinter's display shows that the command buffer drops from 16 to 0 until it stops printing altogethe... | <p>Is it possible that in updating Repetier you inadvertently installed it for a single user rather than for everyone? If so, that might account for its stopping when the user is changed. </p>
| <p>I believe what happens here is that Windows suspends the process running the print job, either due to the program not being in focus, because you switch user, or both.</p>
<p>You could try to <em>increase the priority of the print process in task manager</em>, and see if that helps.</p>
<p><strong>In Windows 7:</s... | 297 |
<p>I have a <a href="http://www.samurize.com/modules/news/" rel="noreferrer">Samurize</a> config that shows a CPU usage graph similar to Task manager. </p>
<p>How do I also display the name of the process with the current highest CPU usage percentage? </p>
<p>I would like this to be updated, at most, once per secon... | <p>What you want to get its the instant CPU usage (kind of)...</p>
<p>Actually, the instant CPU usage for a process does not exists. Instead you have to make two measurements and calculate the average CPU usage, the formula is quite simple:</p>
<blockquote>
<p>AvgCpuUsed = [TotalCPUTime(process,time2) - TotalCPUTim... | <p>With PowerShell:</p>
<pre><code>Get-Process | Sort-Object CPU -desc | Select-Object -first 3 | Format-Table CPU,ProcessName -hidetableheader
</code></pre>
<p>returns somewhat like:</p>
<pre><code> 16.8641632 System
12.548072 csrss
11.9892168 powershell
</code></pre>
| 7,488 |
<p>Which compiles to faster code: "ans = n * 3" or "ans = n+(n*2)"?</p>
<p>Assuming that n is either an int or a long, and it is is running on a modern Win32 Intel box.</p>
<p>Would this be different if there was some dereferencing involved, that is, which of these would be faster?</p>
<pre>
long a;
long *pn;... | <p>IMO such micro-optimization is not necessary unless you work with some exotic compiler. I would put readability on the first place.</p>
| <p>Compilers are good at optimising code such as yours. Any modern compiler would produce the same code for both cases and additionally replace <code>* 2</code> by a left shift.</p>
| 7,730 |
<p>I have taken over a large code base and would like to get an overview how and where certain classes and their methods are used.</p>
<p>Is there any good tool that can somehow visualize the dependencies and draw a nice call tree or something similar?</p>
<p>The code is in C++ in Visual Studio if that helps narrow d... | <p>Here are a few options:</p>
<ul>
<li><a href="http://www.codedrawer.com/index.html" rel="nofollow noreferrer">CodeDrawer</a></li>
<li><a href="http://www.westernwares.com/" rel="nofollow noreferrer">CC-RIDER</a></li>
<li><a href="http://www.doxygen.nl/index.html" rel="nofollow noreferrer">Doxygen</a></li>
</ul>
<p... | <p>In Java I would start with JDepend. In .NET, with NDepend. Don't know about C++.</p>
| 5,630 |
<p>I have to do some JavaScript in the future, so it is time to update my toolbox. Right now I use Firefox with some addons:</p>
<ul>
<li>JavaScript Shell from <a href="https://www.squarefree.com/bookmarklets/webdevel.html" rel="nofollow noreferrer">https://www.squarefree.com/bookmarklets/webdevel.html</a></li>
<li>Fi... | <p>I use both Firefox and IE for Web Development and a few add-ons in each:</p>
<p><strong>Firefox:</strong></p>
<ul>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/1843" rel="nofollow noreferrer">Firebug</a></li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">W... | <p>A couple more::</p>
<ol>
<li>IE Explorer Toolbar </li>
<li>Firefox Developer Toolbar </li>
</ol>
| 5,470 |
<p>Does anyone know how to setup <a href="http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial" rel="noreferrer">Mercurial</a> to use <a href="http://www.perforce.com/perforce/products/merge.html" rel="noreferrer">p4merge</a> as the merge/diff tool on OS X 10.5?</p>
| <p><strong>This will work for merging:</strong></p>
<p>Place this into your <code>~/.hgrc</code> (or, optionally, your <code>Mercurial.ini</code> on Windows):</p>
<pre><code>[merge-tools]
p4.priority = 100
p4.premerge = True # change this to False if you're don't trust hg's internal merge
p4.executable = /Applicatio... | <p>I'm guessing there's a CLI tool for p4merge (which I know nothing about).</p>
<p>I wrote a blog post about using Changes.app, and some other GUI tools with Mercurial: <a href="http://schinckel.net/2008/04/26/mercurial-with-os-x-gui-tools/" rel="nofollow noreferrer">Using Mercurial with GUI Tools.</a></p>
<p>Basica... | 6,459 |
<p>Is there a way to have msdn documentation on a usb key ?
either web or the MSDN Library program.
i've been setting up my usbkey with portableapps stuff.</p>
| <p>i think when you do step 2 and install the documentation just tell direct it to the usb key drive letter. easy peasy.</p>
| <p><a href="https://windows-cdn.softpedia.com/screenshots/MSDN-to-USB_2.png" rel="nofollow noreferrer"><img src="https://windows-cdn.softpedia.com/screenshots/MSDN-to-USB_2.png" alt="enter image description here" /></a></p>
<p>@Oleg You can use <a href="https://marketplace.visualstudio.com/items?itemName=Moataz99.MSDNt... | 5,806 |
<p>As a LAMP developer considering moving to a .Net IIS platform, one of my concerns is the loss of productivity due to lack of shell... Has anyone else had this experience? Is there possibly a Linux shell equivalent for Windows?</p>
| <p>Depending on what version of IIS you're considering, I would second lbrandy's recommendation to check out <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" rel="noreferrer">PowerShell</a>. Microsoft is working on a PowerShell provider for IIS (specifically version 7... | <p>You should make your choice of server platform based on the environment as a whole, and that includes the admin/management interfaces supplied.</p>
<p>I'm afraid that if you don't like the way Windows implements management of IIS, then that's too bad. Having said that, a bit of delving around in the WMI interfaces... | 2,390 |
<p>Ok, I did it, I ordered myself an Ender-3, a genuine 24V e3D hotend, inductive sensor and some better tubing/clamps to cope with the problem the CR10/Ender line has occasionally.</p>
<p>But now I need to fix up my Cura for the machine coming in. The start is the CR10, and fixing the dimensions is easy.</p>
<p>But ... | <h2>The lazy way: Skirt/Brim</h2>
<p>With my TronXY X1 I learned pretty fast, that this first bit of extrusion on an unheated bed can totally mess up the first layer by being just in the way, as explained in the question.</p>
<p>To some degree, this behavior can be avoided by adding a skirt of a certain length. An equa... | <h2>Blob & Cut</h2>
<p>A different approach is to move to a position out off the print bed, then extrude a long piece of filament and then move forward, cutting the filament at the edge of the print surface. A sample G-code that needs to be adjusted to your bed:</p>
<pre><code>G28
G1 Y-5 X5 Z0.1 F500 ; Move off ... | 957 |
<p>In podcast #15, Jeff mentioned he twittered about how to run a regular event in the background as if it was a normal function - unfortunately I can't seem to find that through twitter. Now I need to do a similar thing and are going to throw the question to the masses.</p>
<p>My current plan is when the first user (... | <p>I think developing a custom solution for running background tasks doesn't always worth, so I recommend to use the <a href="http://www.quartz-scheduler.org/" rel="nofollow noreferrer">Quartz Scheduler</a> in Java.</p>
<p>In your situation (need to run background tasks in a web application) you could use the ServletC... | <p>Here is how they do it on StackOverflow.com:</p>
<p><a href="https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/">https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/</a></p>
| 7,070 |
<p>I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine:</p>
<pre><code>SELECT "Ugly OLAP name" as "Value"
FROM OpenQuery( OLAP, 'OLAP Query')
</code></pre>
<p>But if I try to add:</p>
<pre><code>WHERE "Value" > 0
</code></pre>
<p>I get an error</p>
<blockquote>
<p>In... | <p>This should work:</p>
<pre><code>SELECT A.Value
FROM (
SELECT "Ugly OLAP name" as "Value"
FROM OpenQuery( OLAP, 'OLAP Query')
) AS a
WHERE a.Value > 0
</code></pre>
<p>It's not that Value is a reserved word, the problem is that it's a column alias, not the column name. By making it an inline view, "Value" bec... | <p>Oh, bummer. I just saw, you select AS FOO. Don't you need a HAVING claus in this case?</p>
<pre><code>SELECT whatever AS value FROM table HAVING value > 1;
</code></pre>
<p>I still would not use "value". But to be sure, look it up in your docs!</p>
| 6,846 |
<p>The topic says the most of it - what is the reason for the fact that static methods can't be declared in an interface?</p>
<pre><code>public interface ITest {
public static String test();
}
</code></pre>
<p>The code above gives me the following error (in Eclipse, at least): "Illegal modifier for the interface ... | <p>There are a few issues at play here. The first is the issue of declaring a static method without defining it. This is the difference between</p>
<pre><code>public interface Foo {
public static int bar();
}
</code></pre>
<p>and</p>
<pre><code>public interface Foo {
public static int bar() {
...
}
}
</c... | <p>Perhaps a code example would help, I'm going to use C#, but you should be able to follow along.</p>
<p>Lets pretend we have an interface called IPayable</p>
<pre><code>public interface IPayable
{
public Pay(double amount);
}
</code></pre>
<p>Now, we have two concrete classes that implement this interface:</p>... | 4,188 |
<p>I'm working on a web application that needs to prints silently -- that is without user involvement. What's the best way to accomplish this? It doesn't like it can be done with strictly with Javascript, nor Flash and/or AIR. The closest I've seen involves a Java applet.</p>
<p>I can understand why it would a Bad ... | <p>Here’s what you need to do to enable Firefox immediately print without showing the print preferences dialog box.</p>
<ol>
<li><p>Type about:config at Firefox’s location bar and hit Enter.</p></li>
<li><p>Right click at anywhere on the page and select New > Boolean</p></li>
<li><p>Enter the preference name as print.... | <p>I have to be honest, I am kinda thinking out loud here.. But could it not be done with an applet or some sort (be it Java or whatever) that is given trusted permissions (such as that within the Intranet zone) or something?</p>
<p>May be worth investigating what permissions can be given to each zone?</p>
<p>Follow... | 4,193 |
<pre>
kt@rails-ubuntu:~/rails/ledger/releases/20080820144914/.git/hooks$ ls -al
ls: cannot access post-commit: No such file or directory
ls: cannot access update: No such file or directory
ls: cannot access post-update: No such file or directory
ls: cannot access commit-msg: No such file or directory
ls: cannot access ... | <p>First off, here's your question, nicely formatted (surround it in < pre > tags to get this):</p>
<pre>kt@rails-ubuntu:~/rails/ledger/releases/20080820144914/.git/hooks$ ls -al
ls: cannot access post-commit: No such file or directory
ls: cannot access update: No such file or directory
ls: cannot access post-updat... | <p>I had the same problem caused by Aptana Studio working with rails more than once.
The long term solution was to avoid using aptana to create files.</p>
| 9,854 |
<p>I came across several issues which seem to have been lowered.
Firstly, I changed from a 0.4 to a 0.5 mm nozzle. Because of the backpressure I was not able to print my PETG (Colorfabb XT filament) below 270°C which caused unresolvable oozing. After that I was able to extrude till 230°C.</p>
<p>The left print below s... | <p>Have you tried adjusting the Extra Restart Distance in Simplify3D or Retraction Extra Prime in Ultimaker Cura? Most slicers should have a similar setting, perhaps named just slightly differently. A small positive value can help prime the nozzle after a long travel when you've lost back pressure or oozed a little.<... | <p>Zero retraction is just a special (worst) case of under-retraction. You'll pretty much always lose material to oozing if you don't retract before travel. At best this ends up hidden inside the print (but can still affect weight and weight balance); usually it'll also harm the surface.</p>
<p>Ensure that retraction ... | 950 |
<p>I'm using a <code>Dictionary<string, int></code> where the <code>int</code> is a count of the key.</p>
<p>Now, I need to access the last-inserted Key inside the Dictionary, but I do not know the name of it. The obvious attempt:</p>
<pre><code>int LastCount = mydict[mydict.keys[mydict.keys.Count]];
</code></p... | <p>As @Falanwe points out in a comment, doing something like this is <strong><em>incorrect</em></strong>:</p>
<pre><code>int LastCount = mydict.Keys.ElementAt(mydict.Count -1);
</code></pre>
<p>You <strong>should not</strong> depend on the order of keys in a Dictionary. If you need ordering, you should use an <a href... | <p>Visual Studio's <a href="https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/16494583-generic-ordereddictionary" rel="nofollow noreferrer">UserVoice</a> gives a link to <a href="https://github.com/mattmc3/dotmore/blob/master/dotmore/Collections/Generic/OrderedDictionary.cs" rel="nofollow ... | 2,623 |
<p>Is there an easy way to tell if a ruby script is already running and then handle it appropriately? For example: I have a script called really_long_script.rb. I have it cronned to run every 5 minutes. When it runs, I want to see if the previous run is still running and then stop the execution of the second script... | <p>The ps is a really poor way of doing that and probably open to race conditions.</p>
<p>The traditional Unix/Linux way would be to write the PID to a file (typically in /var/run) and check to see if that file exists on startup.</p>
<p>e.g. the pidfile being located at /var/run/myscript.pid then you'd check to see i... | <p>In bash:</p>
<pre><code>if ps aux | grep really_long_script.rb | grep -vq grep
then
echo Script already running
else
ruby really_long_script.rb
fi
</code></pre>
| 5,910 |
<p>I have a self-referential Role table that represents a tree structure </p>
<pre><code>ID [INT] AUTO INCREMENT
Name [VARCHAR]
ParentID [INT]
</code></pre>
<p>I am using an ADO.NET DataTable and DataAdapter to load and save values to this table. This works if I only create children of existing rows. If I make a chil... | <p>I don't know ADO.net in particular, but most ORMs won't automatically insert the ID of a new record in a relationship. You'll have to resort to the 2-step process:</p>
<ol>
<li>build and save parent</li>
<li>build and save child with relationship to parent</li>
</ol>
<p>The reason that this is difficult for ORMs ... | <p>Does it make any difference if you go</p>
<pre><code>newRow.SetParentRow(parentRow, RoleTable.Relations("RoleToRole"))
</code></pre>
| 2,724 |
<p>We've got two developers on the same closed (ugh, stupid gov) network, Another developer a couple minutes drive down the road, and a fourth developer half-way across the country. E-Mail, ftp, and removal media are all possible methods of transfer for the people not on the same network.</p>
<p>I am one of the two cl... | <p>The users outside the network can make <a href="http://hgbook.red-bean.com/hgbookch12.html#x16-26800012.1" rel="nofollow noreferrer">patches</a>, and/or use <a href="http://hgbook.red-bean.com/hgbookch14.html#x18-32100014.4" rel="nofollow noreferrer">email</a> to send the updates to the main repo or someone, like yo... | <p>Correct. The only way anything makes it onto the closed network is via flash drive.</p>
| 2,660 |
<p>When I use the PrintOut method to print a Worksheet object to a printer, the "Printing" dialog (showing filename, destination printer, pages printed and a Cancel button) is displayed even though I have set DisplayAlerts = False. The code below works in an Excel macro but the same thing happens if I use this code in... | <p>When you say the "Printing" Dialog, I assume you mean the "Now printing xxx on " dialog rather than standard print dialog (select printer, number of copies, etc). Taking your example above & trying it out, that is the behaviour I saw - "Now printing..." was displayed briefly & then auto-closed.</p>
<p>What ... | <p>The API calls in the article linked by Kevin Haines hide the Printing dialog like so:</p>
<ol>
<li>Get the handle of the Printing dialog window.</li>
<li>Send a message to the window to tell it not to redraw</li>
<li>Invalidate the window, which forces a redraw that never happens</li>
<li>Tell Windows to repaint th... | 9,281 |
<p>I'm writing an application that is basically just a preferences dialog, much like the tree-view preferences dialog that Visual Studio itself uses. The function of the application is simply a pass-through for data from a serial device to a file. It performs many, many transformations on the data before writing it to ... | <p>A tidier way is to create separate forms for each 'pane' and, in each form constructor, set</p>
<pre><code>this.TopLevel = false;
this.FormBorderStyle = FormBorderStyle.None;
this.Dock = DockStyle.Fill;
</code></pre>
<p>That way, each of these forms can be laid out in its own designer, instantiated one or more tim... | <p>I would probably create several panel classes based on a base class inheriting CustomControl. These controls would then have methods like Save/Load and stuff like that. If so I can design each of these panels separately.</p>
<p>I have used a Wizard control that in design mode, handled several pages, so that one cou... | 2,577 |
<p>In Cura, I can edit my .ini profile settings as needed, for example, when I change filament or models. It's annoying to have to edit the profile on another computer and update it on my Pi just to change the infill, etc. I've searched <a href="http://plugins.octoprint.org/" rel="noreferrer">http://plugins.octoprint.o... | <p>As far as I know, this is currently not possible.</p>
| <p>There is an import function.
<a href="https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura" rel="nofollow">https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura</a></p>
<p>Btw. now in Cura 2.1 you'll also need to reimport your .ini.</p>
<p>Regards :)</p>
| 162 |
<p>I'm curious about everyones practices when it comes to using or distributing libraries for an application that you write.</p>
<p>First of all, when developing your application do you link the debug or release version of the libraries? (For when you run your application in debug mode)</p>
<p>Then when you run your ... | <p>I would first determine what requirements are needed from the library:</p>
<ol>
<li>Debug/Release</li>
<li>Unicode support</li>
<li>And so on..</li>
</ol>
<p>With that determined you can then create configurations for each combination required by yourself or other library users.</p>
<p>When compiling and linking ... | <p>I use VS. The way that I do it is that the libraries I need through the references of the project. Which basically just says in what folder to look for a specific library at project load time. I develop my libraries to be as project independent or reusable as possible. Therefore they are all projects of their own. S... | 6,776 |
<p>How is your javaScript code organized? Does it follow patterns like MVC, or something else? </p>
<p>I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with <a href="http://jquery.com" rel="noreferrer"... | <p>..but Javascript has many facets that <strong>are</strong> OO.</p>
<p>Consider this:</p>
<pre><code>var Vehicle = jQuery.Class.create({
init: function(name) { this.name = name; }
});
var Car = Vehicle.extend({
fillGas: function(){
this.gas = 100;
}
});
</code></pre>
<p>I've used this techniq... | <p>Not 100% sure what you mean here, but I will say that after doing ASP.NET for the last 6 years, my web pages are now mostly driven by JavaScript once the basic page rendering is done by the server. I use JSON for everything (have been for about 3 years now) and use <a href="http://www.mochikit.com" rel="nofollow nor... | 5,249 |
<p>I have a svn repository, R, that depends on a library, l, in another repository.</p>
<p>The goal is that when someone checks out R, they also check out l. We want l to still be in its own repository so that l can be updated without dependence on R.</p>
<p>I don't know much about external svn links, but I believe t... | <p>I suggest using a script wrapper for svn co. </p>
<pre><code>#!/bin/sh
svn co path://server/R svn-R
git clone path://server/l git-l
</code></pre>
<p>Or similar.</p>
| <p>I suggest using a script wrapper for svn co. </p>
<pre><code>#!/bin/sh
svn co path://server/R svn-R
git clone path://server/l git-l
</code></pre>
<p>Or similar.</p>
| 9,834 |
<p>When I was in China my company's website was blocked for about 24 hours.</p>
<p>I assume it was the "Great Chinese Firewall" but I was wondering if there is any way that I can find out exactly where a packet or TCP/IP connection gets blocked.</p>
<p>I was able to verify that it wasn't being blocked at our end(I us... | <p><a href="http://michael.toren.net/code/tcptraceroute/" rel="nofollow noreferrer">tcptraceroute</a></p>
| <p>I have lot's of problems with that firewall. Having my server into EEUU doesn't help. If you need tools to test your site hosted outside from china like you were in China, you can try that page:</p>
<p><a href="http://www.websitepulse.com/help/tools.php" rel="nofollow noreferrer">http://www.websitepulse.com/help/to... | 7,206 |
<p>Does someone have any tips/advice on database design for a web application? The kind of stuff that can save me a lot of time/effort in the future when/if the application I'm working on takes off and starts having a lot of usage.</p>
<p>To be a bit more specific, the application is a strategy game (browser based, ju... | <p>You have probably touched on a much larger issue of designing for high scalability and performance in general.</p>
<p>Essentially, for your database design I would follow good practices such as adding foreign keys and indexes to data you expect to be used frequently, normalise your data by splitting it into smaller... | <p>Why don't you post the schema you have now? It's too broad a question to answer usefully without some detail of what platform and database you're going to use and the table structure you're proposing...</p>
| 6,975 |
<p>Using Firebug v1.20b7 with Firefox v3.0.1 I use firebug a lot for web devlopment.</p>
<p>I have very often the problem that Firebug won't show its web console for seeing the <code>POSTs</code> and <code>GETs</code>. I can view all the other tabs, including the NET tab that gives me a lot of the same information tha... | <p>There is a limitation in firebug (or rather, in firefox iteself), which will be fixed in one of the newer Firefox releases.</p>
<p>The bug is caused by the fact that firebug needs to send data <em>a second time</em> to monitor what's going on in the connection.</p>
<p>There's now a special API hook in the firefox ... | <p>Well, 1.20b7 is technically a <em>beta</em> version of Firebug. :)</p>
<p>I've had problems with certain features off and on, but a restart of Firefox seems to fix it more often than not.</p>
| 2,759 |
<p>I've got a System.Generic.Collections.List(Of MyCustomClass) type object.</p>
<p>Given integer varaibles pagesize and pagenumber, how can I collect only any single page of <code>MyCustomClass</code> objects?</p>
<p>This is what I've got. How can I improve it?</p>
<pre><code>'my given collection and paging parame... | <p>Generic.List should provide the Skip() and Take() methods, so you could do this:</p>
<pre><code>Dim PageObjects As New System.Collections.Generic.List(Of MyCustomClass)
PageObjects = AllOfMyCustomClassObjects.Skip(pagenumber * pagesize).Take(pagesize)
</code></pre>
<hr>
<p>If by "without Linq" you meant on the 2.... | <p>You use GetRange on your IEnuramble implementing collection:</p>
<pre><code>List<int> lolInts = new List<int>();
for (int i = 0; i <= 100; i++)
{
lolInts.Add(i);
}
List<int> page1 = lolInts.GetRange(0, 49);
List<int> page2 = lilInts.GetRange(50, 100);
</code></pre>
<p>I trust you c... | 4,148 |
<p><code>System.IO.Directory.GetFiles()</code> returns a <code>string[]</code>. What is the default sort order for the returned values? I'm assuming by name, but if so how much does the current culture effect it? Can you change it to something like creation date? </p>
<p><strong>Update:</strong> MSDN points out tha... | <p>If you're interested in properties of the files such as CreationTime, then it would make more sense to use System.IO.DirectoryInfo.GetFileSystemInfos().
You can then sort these using one of the extension methods in System.Linq, e.g.:</p>
<pre><code>DirectoryInfo di = new DirectoryInfo("C:\\");
FileSystemInfo[] fil... | <p>Just an idea. I like to find an easy way out and try re use already available resources. if I were to sort files I would've just create a process and make syscal to "DIR [x:\Folders\SubFolders*.*] /s /b /on" and capture the output. </p>
<p>With system's DIR command you can sort by :</p>
<pre><code>/O List... | 7,618 |
<p>I have my own class inside the file "Particles.h" and the class's implementation is inside "Particles.cpp"</p>
<p>I want the file "Load.h" to recognize my classes inside there, so I've added the line</p>
<pre><code>#include "Particles.h"
</code></pre>
<p>and the file doesn't recognize it and in the past everythin... | <p>It sounds like your include path - the list of directories that the compiler scans in order to locate files that you #include - is set incorrectly. Which compiler are you using?</p>
| <p>make sure the file "Particles.cpp" has also included "Particles.h" to start with and the files are in the same folder and they are all part of the same project. it will help if you also share the error message that you are getting from your compiler.</p>
| 9,751 |
<p>What are they and what are they good for?</p>
<p>I do not have a CS degree and my background is VB6 -> ASP -> ASP.NET/C#. Can anyone explain it in a clear and concise manner?</p>
| <p>Imagine if every single line in your program was a separate function. Each accepts, as a parameter, the next line/function to execute. </p>
<p>Using this model, you can "pause" execution at any line and continue it later. You can also do inventive things like temporarily hop up the execution stack to retrieve a val... | <p>Think of threads. A thread can be run, and you can get the result of its computation. A continuation is a thread that you can copy, so you can run the same computation twice.</p>
| 6,186 |
<p>I have a spool of translucent PLA filament that doesn't work well with the filament sensor on my Prusa i3 MK3. The translucency trips up the sensor, making it think the filament ran out. I thought I'd create a filament profile in Slic3r and disable the sensor in the "Start G-code" block that gets inserted at the beg... | <p>Following on from Toon's answer, here is a run down of <a href="https://www.youtube.com/channel/UCb8Rde3uRL1ohROUVg46h1A" rel="nofollow noreferrer">Thomas Sanladerer</a>'s excellent
video: <a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">3D printing guides: Calibration and why you mig... | <p>Have you correctly calibrated your steps per mm a.k.a. esteps? Tom made a great video about it:</p>
<p><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">3D printing guides: Calibration and why you might be doing it wrong</a></p>
| 903 |
<p>I have an old notebook computer that works just fine, but the outside of the lid is badly damaged and needs to be replaced. The screen and wiring are fine, so I only need to replace the housing that is exposed to the outside world.</p>
<p><strong>What is the best filament for an impact-resistant printed housing?</st... | <p>For casings I use a combination of TPU and PETG or PLA. PETG shell gives it rigidity and TPU gives it a bit of impact protection. So corners and inside layers of TPU within a hard PETG or PLA shell (shell has no corners).</p>
<p>I haven't had a problem with either but obviously PLA won't withstand heat very well, so... | <p>If you just cared about impact resistance of the housing itself, the clear choice would be TPU, which would be basically indestructible. However, the housing is there to protect what's inside - not only from impact, but from stresses (e.g. bending) that could break it. This means you need a material that both provid... | 2,139 |
<p>The <code>datepicker</code> function only works on the first input box that is created.</p>
<p>I'm trying to duplicate a datepicker by cloning the <code>div</code> that is containing it.</p>
<pre><code><a href="#" id="dupMe">click</a>
<div id="template">
input-text <input type="text" value="... | <p>I use a CSS class instead:</p>
<pre><code><input type="text" id="BeginDate" class="calendar" />
<input type="text" id="EndDate" class="calendar" />
</code></pre>
<p>Then, in your <code>document.ready</code> function:</p>
<pre><code>$('.calendar').datepicker();
</code></pre>
<p>Using it that way for m... | <p>The html I am cloning has multiple datepicker inputs.</p>
<p>Using Ryan Stemkoski's answer and Alex King's comment, I came up with this solution:</p>
<pre><code>var clonedObject = this.el.find('.jLo:last-child')
clonedObject.find('input.ui-datepicker').each(function(index, element) {
$(element).removeClass('ha... | 5,515 |
<p>I've just installed two TMC2208 drivers on my RAMPS board. I followed a very good step by step tutorial and after some issues, I got it nearly to work.</p>
<p>One problem I still have is that when I tell the printer to lift the Z axis by 5 mm, it lifts it by 10 cm.</p>
<p>I haven't changed anything regarding the ste... | <p>I don't have these controllers, but I read that with default settings the TMC2208 will interpolate the microsteps set by the I/O configuration pins to
256 microsteps. Please look into how you set up the dip switches / jumper caps on your board, it seems that only 2 are used (MS1 and MS2). Furthermore, can't you just... | <p>Most likely your issue is related to the PDN_UART pin on TCM2208 Driver board, on some manufacturers boards the jumper is not set to UART mode by default, so most likely u need to solder jumper to right configuration. Look at datasheet of your driver board.
for example
<a href="https://github.com/bigtreetech/BIGTR... | 904 |
<p>Our software must be able to run on SQL Server 2000 and 2005. To simplify development, we're running our SQL Server 2005 databases in compatibility level 80. However, database performance seems slower on SQL 2005 than on SQL 2000 in some cases (we have not confirmed this using benchmarks yet). Would upgrading the... | <p>I think i read somewhere, that the SQL Server 2005 database engine should be about 30% faster than the SQL Server 2000 engine. It might be, that you have to run your database in compatibility mode 90 to get these benefits.</p>
<p>But i stumbled on two scenarios, where performance can drop dramatically when using ms... | <p>Also a FYI, if you run compatibility level 90 then some things are not supported anymore like old style outer joins <code>(*= and =*)</code></p>
| 2,885 |
<p>Is there any DRM or license management solution for 3D printing? I'm looking for something, that would help me limit the number of prints someone can make from my projects. Basically, I would like to sell the "right to make no more than X copies" of my design. I don't expect it to be bullet-proof (like Widevine L1 f... | <p>Good luck with that.</p>
<p>Issues you will face:</p>
<ul>
<li>using a G-code editor (or built-in printer software) to create multiple copies of the object in a single print session</li>
<li>user writing the printer file to an SD card, then block-copying the SD card</li>
<li>defining a "print". Specifically:</li>
... | <h2>Generally: No</h2>
<p>Let's face the obvious problems of the files exchanged and the files used for printing, and then look into why it is a bad idea in the first place.</p>
<h2>G-code</h2>
<p>G-code is in its design a .txt file that contains specific orders for a machine. There is a g-code command that forces the ... | 1,676 |
<p>Given a .SCAD file which contains some modules, how can I execute one of those modules from the command line?</p>
<p><strong>example.scad</strong></p>
<pre><code>module One() { ... }
module Two() { ... }
</code></pre>
<p><strong>render.sh</strong></p>
<pre><code>openscad -q -o one.stl --module One example.scad
</cod... | <p>The <code>openscad -D</code> option can actually include arbitrary code, not just variable definitions, so you can include a call to the module. You can even use <code>/dev/null</code> on Linux or NUL on Windows as the input file and have 100 % of your code in <code>-D</code> statements.</p>
| <p>elaborating on the answer from @r-github-stop-helping-ice, I find the following pattern useful:</p>
<h6>example.scad</h6>
<pre><code>module a() { .. }
module b() { .. }
module c() { .. }
module print(item=0) {
if (item==1) a();
if (item==2) b();
if (item==3) c();
}
item = 0;
print(item);
</code></pre>
<h6>re... | 1,786 |
<p>What kind of multi-threading issues do you have to be careful for in asp.net? </p>
| <p>One thing to watch out for at things that expire (I think httpContext does), if you are using it for operations that are "fire and forget" remember that all of a sudden if the asp.net cleanup code runs before your operation is done, you won't be able to access certain information. </p>
| <p>Programmatic Caching is one area which immediately comes to my mind. It is a great feature which needs to be used carefully. Since it is shared across requests, you have to put locks around it before updating it.</p>
<p>Another place I would check is any code accessing filesystem like writing to log files. If one r... | 7,293 |
<p>I'm trying to use <code>jQuery</code> to format code blocks, specifically to add a <code><pre></code> tag inside the <code><code></code> tag:</p>
<pre><code>$(document).ready(function() {
$("code").wrapInner("<pre></pre>");
});
</code></pre>
<p>Firefox applies the formatting correctly, b... | <p>That's the difference between <a href="http://www.w3.org/TR/html4/struct/global.html#h-7.5.3" rel="noreferrer">block and inline</a> elements. <a href="http://www.w3.org/TR/html4/sgml/dtd.html#block" rel="noreferrer"><code>pre</code> is a block level element</a>. It's not legal to put it inside a <code>code</code> ta... | <p>Are you using the latest jQuery ?
What if you try </p>
<pre><code>$("code").wrapInner(document.createElement("pre"));
</code></pre>
<p>Is it any better or do you get the same result ?</p>
| 3,387 |
<p>I get this error on an update panel within a popupControlExtender which is within a dragPanelExtender.</p>
<p>I see that a lot of other people have this issue and have various fixes none of which have worked for me.</p>
<p>I would love to hear a logical explanation for why this is occurring and a foolproof way to ... | <p>My best guess is that the UpdatePanel is not able to write out the custom "async" property to the postback request properly. This is likely due to blocking from one of the controls wrapping it (my gut feeling is that it's the popupControlExtender - it tends to have odd behavior with updatepanels, as it is intended t... | <p>Settign "EnablePartialRendering" to false on the ScriptManager control prevents the error, but it is not an optimal solution. Losing the benefit of partial rendering could be a big deal, depending on your application.</p>
<p>Just for the record, I wasn't doing exactly the same as other folks who saw the error. I ... | 8,191 |
<p>I've build a 3D printer from sourced parts and mounted the hotend cooler to blow air over the heatsink. </p>
<p>Talking to a friend, he said it's better to reverse the airflow over the heatsink, but couldn't give me an argument other than everywhere he saw it was like this: all coolers are mount to suck the hot air... | <p>Getting hot air from the radiator is definitely wrong idea because of few reasons:</p>
<ol>
<li>hot air can damage your fan (as they are usually not heatproof). Cold air cools the fan</li>
<li>cold air is denser so fan can suck more cold air than hot air so cooling is more efficient (fig A)</li>
<li>in terms of plu... | <p>In the case of 3D Printing, it's going to be faster to cool the radiator by blowing out the heat from the source.</p>
<p>The idea is that you're trying to get rid of as much heat as possible in the quickest means possible. By blowing away from the radiator, you're allowing the ambient temperature to cool the hot ai... | 481 |
<p>I deleted a branch in TFS and just found out that I need the changes that were on it.</p>
<p>How do I recover the branch or the changes done on it?</p>
| <p>Specifically in Visual Studio go to "Tools-Options" then Select "Source Control-visual Studio Team Founation Server" and check the "Show deleted items in the Source Control explorer".</p>
<p>Having done that - you can then right click a folder and say "Undelete"</p>
| <p>As described in the <a href="http://blogs.msdn.com/jimlamb/articles/tfsfaq.aspx" rel="noreferrer">TFS FAQ</a>:</p>
<p><strong>Are Deletes physical or logical? Can accidental deletes be recovered?</strong></p>
<p>Deletes are fully recoverable with the “undelete” operation. You wouldn’t want to do a SQL restore beca... | 7,203 |
<p>When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with either a boolean field like "IsLatest" or an integer "VersionId", and you never do any updates, you only insert new records when things change. </p>
<p>MVCC gives you automatic auditing for applications that require a... | <p>I might consider implementing the MVCC tier purely in the DB, using stored procs and views to handle my data operations. Then you could present a reasonable API to any ORM that was capable of mapping to and from stored procs, and you could let the DB deal with the data integrity issues (since it's pretty much build ... | <p>I always figured you'd use a db trigger on update and delete to push those rows out into a TableName_Audit table.</p>
<p>That'd work with ORMs, give you your history and wouldn't decimate select performance on that table. Is that a good idea or am I missing something?</p>
| 6,889 |
<p>Can i print out a url <code>/admin/manage/products/add</code> of a certain view in a template?</p>
<p>Here is the rule i want to create a link for</p>
<pre><code>(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),
</code></pre>
<p>I would like to have /manage/products/add in ... | <p>You can use <code>get_absolute_url</code>, but that will only work for a particular object. Since your object hasn't been created yet, it won't work in this case.</p>
<p>You want to use <a href="https://docs.djangoproject.com/en/1.2/topics/http/urls/#naming-url-patterns" rel="nofollow noreferrer">named URL pattern... | <p>The preferred way of creating the URL is by adding a <code>get_absolute_url</code> method to your model classes. You can hardcode the path there so you at least get closer to following the KISS philosophy.</p>
<p>You can go further by utilizing the <code>permalink</code> decorator that figures the path based on the... | 6,941 |
<p>Which class design is better and why?</p>
<pre><code>public class User
{
public String UserName;
public String Password;
public String FirstName;
public String LastName;
}
public class Employee : User
{
public String EmployeeId;
public String EmployeeCode;
public String DepartmentId;
}
... | <p>The question is simply answered by recognising that inheritance models an "IS-A" relationship, while membership models a "HAS-A" relationship.</p>
<ul>
<li>An employee IS A user</li>
<li>An employee HAS A userinfo</li>
</ul>
<p>Which one is correct? This is your answer.</p>
| <p>Three more options:</p>
<ol>
<li><p>Have the <code>User</code> class contain the supplemental information for both employees and members, with unused fields blank (the <code>ID</code> of a particular <code>User</code> would indicate whether the user was an employee, member, both, or whatever).</p></li>
<li><p>Have ... | 5,978 |
<p>How do you access a SQL Server 2005 Express Edition from a application in a network computer?</p>
<p>The access I need is both from application (Linq-to-SQL and ODBC) and from Management Studio</p>
| <p>See this KB Article. <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277" rel="noreferrer">How to configure SQL Server 2005 to allow remote connections</a>.<br>
Oh, and remember that the SQLServer name will probably be MyMachineName\SQLExpress</p>
| <p>If you're running it on a 2k3 box, you need to install all updates for Sql Server and the 2003 server. </p>
<p>Check the event logs after you start the Sql Server. It logs everything well, telling you if its being blocked, and where it is listening for connections.</p>
<p>From a remote machine, you can use telne... | 3,081 |
<p>I did this Just for kicks (so, not exactly a question, i can see the downmodding happening already) but, in lieu of Google's newfound <a href="http://www.google.com/search?hl=en&q=1999999999999999-1999999999999995&btnG=Search" rel="nofollow noreferrer">inability</a> to do <a href="http://www.google.com/searc... | <p>in C#, try (double.maxvalue == (double.maxvalue - 100)) , you'll get true ...</p>
<p>but thats what it is supposed to be:</p>
<p><a href="http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems</a> </p>
<p>thinking abou... | <blockquote>
<p>2^64 is not the maximum value of a double. 2^64 is the number of unique values that a double (or any other 64-bit type) can hold. Double.MaxValue is equal to 1.79769313486232e308.</p>
</blockquote>
<p>Not even; the IEEE encodings use multiple encodings for the same values. Specifically, NaN is repre... | 4,675 |
<p>I've got a Renkforce RF1000 which should be a good 3D printer. I got it second-hand for my birthday one year ago. I've got no way of contacting the old owner.</p>
<p>I spend a good amount of hours fine-tuning the slicer settings last year but at best got mediocre prints. Between September and a week ago I lived some... | <p>One hundred percent infill is not necessarily stronger than lower values. By having such a high infill figure, the forces on the model as it cools are magnified and not in a particularly good manner.</p>
<p>Consider that you could use twenty to thirty percent infill to get the strength you require for this applicat... | <p>The reason for this sort of error might be either
1) a clogged nozzel, <a href="https://www.youtube.com/watch?v=bg4sOaSvimY" rel="nofollow noreferrer">try doing this </a>
2) disturbed bed level,<a href="https://www.youtube.com/watch?v=lL3Gmy4hh3Y" rel="nofollow noreferrer">resolve this issue </a>
3) poor filament q... | 1,644 |
<p>I am using a FORM LABS 3 printer with clear resin. After printing the model, I wash it with Isopropenyl and dry it. Then I cure it using Formlabs Form Cure for 5 minutes under 60 C°.
After curing the model, the clear print loses some of its transparency.</p>
<p>Is this normal? can it be avoided?</p>
| <p>This happens to most resins and the amount of haziness is directly related to the type of resin. Not all clear resins do this mind you, but it has to do with the curing sprlectrum of light(natural sunlight cures do this way worse.)</p>
| <p>Clouding is a known issue with colored transparent resins, as is yellowing with clear resin.</p>
<p>Uncle Jessy did quite a good video explaining the issue and how to best avoid it.</p>
<p>The conclusion was that you should wash and dry them with as little UV exposure as possible (Drying them inside a box in a warm ... | 2,097 |
<p>In OS X, in order to quickly get at menu items from the keyboard, I want to be able to type a key combination, have it run a script, and have the script focus the Search field in the Help menu. It should work just like the key combination for Spotlight, so if I run it again, it should dismiss the menu. I can run t... | <p>Here is the script I came up with.</p>
<pre><code>tell application "System Events"
tell (first process whose frontmost is true)
click menu "Help" of menu bar 1
end tell
end tell
</code></pre>
| <p>Here is the script I came up with.</p>
<pre><code>tell application "System Events"
tell (first process whose frontmost is true)
click menu "Help" of menu bar 1
end tell
end tell
</code></pre>
| 9,477 |
<p>I'm trying to install <a href="http://godi.camlcity.org/godi/index.html" rel="noreferrer">GODI</a> on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what ... | <p>What is the output of <code>which godi_confdir</code>?</p>
<p>P.S. I remember having this exact same problem, but I don't remember precisely how I fixed it.</p>
| <p>What is the output of <code>which godi_confdir</code>?</p>
<p>P.S. I remember having this exact same problem, but I don't remember precisely how I fixed it.</p>
| 6,952 |
<p>We are rewriting our legacy <a href="https://en.wikipedia.org/wiki/Accounting_information_system" rel="nofollow noreferrer">accounting system</a> in VB.NET and SQL Server. We brought in a new team of .NET/ SQL Programmers to do the rewrite. Most of the system is already completed with the dollar amounts using floats... | <blockquote>
<p>Should Float or Decimal data type be used for dollar amounts?</p>
</blockquote>
<p>The answer is easy. Never floats. <em>NEVER</em>!</p>
<p>Floats were according to <a href="http://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=4610933" rel="nofollow noreferrer">IEEE 754</a> always binary, only th... | <p>Your accountants will want to control how you round. Using float means that you'll be constantly rounding, usually with a <code>FORMAT()</code> type statement, which isn't the way you want to do it (use <code>floor</code> / <code>ceiling</code> instead).</p>
<p>You have currency datatypes (<code>money</code>, <cod... | 8,718 |
<p>What is the best way of creating an alphabetically sorted list in Python?</p>
| <p>Basic answer:</p>
<pre><code>mylist = ["b", "C", "A"]
mylist.sort()
</code></pre>
<p>This modifies your original list (i.e. sorts in-place). To get a sorted copy of the list, without changing the original, use the <a href="http://docs.python.org/library/functions.html#sorted" rel="noreferrer"><code>sorted()</code>... | <p>Suppose <code>s = "ZWzaAd"</code> </p>
<p>To sort above string the simple solution will be below one.</p>
<pre><code>print ''.join(sorted(s))
</code></pre>
| 5,683 |
<p>I am designing a part that has to clamp around a 11mm bushing, and due to other design constraints, it has to be printed with a semicircle-shaped overhang:</p>
<p><a href="https://i.stack.imgur.com/LcLSm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LcLSm.png" alt="enter image description here"></a></p>... | <p>You could modify it as shown in my picture. I added lines tangent to the 11mm circle and in this example I set them to a 40 degree overhang which should be fine, the top line is also tangent to the circle and in my experience it's easier to bridge a small section rather than do a bunch of small overhangs like an ar... | <blockquote>
<p>if I printed it in a different orientation it would delaminate too easily</p>
</blockquote>
<p>If you flip it around, the orientation of the layers would be the same, except that you would print from top to bottom instead of bottom to top.</p>
<p>With the arch opening to the top, there would be <str... | 139 |
<p>I've started using Vim to develop Perl scripts and am starting to find it very powerful. </p>
<p>One thing I like is to be able to open multiple files at once with:</p>
<pre><code>vi main.pl maintenance.pl
</code></pre>
<p>and then hop between them with:</p>
<pre><code>:n
:prev
</code></pre>
<p>and see which fi... | <p>Why not use tabs (introduced in Vim 7)?
You can switch between tabs with <code>:tabn</code> and <code>:tabp</code>,
With <code>:tabe <filepath></code> you can add a new tab; and with a regular <code>:q</code> or <code>:wq</code> you close a tab.
If you map <code>:tabn</code> and <code>:tabp</code> to your <kbd... | <p>if you're on osx and want to be able to click on your tabs, use MouseTerm and SIMBL (taken from <a href="http://ayaz.wordpress.com/2010/10/19/using-mouse-inside-vim-on-terminal-app/" rel="nofollow noreferrer">here</a>). Also, check out this <a href="https://stackoverflow.com/questions/1727261/scrolling-inside-vim-in... | 7,720 |
<p>As you may know, in <code>VS 2008</code> <kbd>ctrl</kbd>+<kbd>tab</kbd> brings up a nifty navigator window with a thumbnail of each file. I love it, but there is one tiny thing that is annoying to me about this feature: <em>the window stays around after releasing the <kbd>ctrl</kbd> key</em>. When doing an <kbd>alt<... | <p>You probably have the text-to-speech narrator enabled.</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2467648&SiteID=1&mode=1" rel="nofollow noreferrer">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2467648&SiteID=1&mode=1</a></p>
<blockquote>
<p>Just uncheck all ch... | <p>Just in case anyone still needed a fix for this (I've encountered this behavior in VS2010) what you can do is:<br /></p>
<ul>
<li>Close VS</li>
<li>Enable sticky keys</li>
<li>Reopen VS</li>
<li>Disable sticky keys</li>
</ul>
<p>This solved it for me.</p>
| 3,758 |
<p>In Ruby, I'm trying to do the following.</p>
<pre><code>def self.stats(since)
return Events.find(:all, :select => 'count(*) as this_count', :conditions => ['Date(event_date) >= ?', (Time.now - since)]).first.this_count
end
</code></pre>
<p>where "since" is a string representing an amount of time ('1 hou... | <p>I hacked this together with the ActiveSupport gem:</p>
<pre><code>require 'active_support'
def string_to_date(date_string)
parts = date_string.split
return parts[0].to_i.send(parts[1])
end
sinces = ['1 hour', '1 day', '3 days']
sinces.each do |since|
puts "#{since} ago: #{string_to_date(since).ago(Time.now)... | <p>I agree with <a href="https://stackoverflow.com/a/40580/1933902">John Millikin</a>. <a href="http://chronic.rubyforge.org/" rel="nofollow noreferrer">Chronic</a>, or even your own helpers, would be a much lighter and effective dependency to carry than whole ActiveSupport, assuming you are not already trapped inside ... | 6,180 |
<p>How do you restore a database backup using SQL Server 2005 over the network? I recall doing this before but there was something odd about the way you had to do it.</p>
| <p>The database is often running as a service under an account with no network access. If this is the case, then you wouldn't be able to restore directly over the network. Either the backup needs to be copied to the local machine or the database service needs to run as a user with the proper network access.</p>
| <pre><code>EXEC sp_configure 'show advanced options', 1
GO
</code></pre>
<p>-- Update currently configured values for advanced options.</p>
<pre><code>RECONFIGURE
GO
-- To enable xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
GO
</code></pre>
<p>-- Update currently configured values for advanced options.</p>
<pre><... | 3,723 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.