instruction
stringlengths 21
27.8k
| chosen
stringlengths 18
28.2k
| rejected
stringlengths 18
33.6k
| __index_level_0__
int64 0
50k
|
|---|---|---|---|
<p>How would you model these relationships in a db?</p>
<p>You have a Page entity that can contain PageElements.</p>
<p>A PageElement can for instance be an Article, or a Picture. An Article table obviously has other members / columns than a Picture. An article could have ie. "Title", "Lead", "Body" columns that are all of type nvarchar, while a Picture might have something like "AltText", "Path", "Width", "Height". I like this to be extensible, who knows what PageElements I might need in 3 months? So I guess I'd need a PageElementTypes table.</p>
<p>For the relationships, what about tables like these:</p>
<p><strong>Pages</strong> with an Id, and other mumbo jumbo. (Create Date, Visible, what not)</p>
<p><strong>Pages_PageElements</strong> with PageId and PageElementId.</p>
<p><strong>PageElements</strong> with an Id and a PageElementTypeId and more mumbojumbo (SortOrder, Visibility etc.).</p>
<p><strong>PageElementTypes</strong> with an Id and a Name (for instance "Article", "Picture", "AddressBlock")</p>
<p>Now, should I create a PageElementId column in every Articles, Pictures, AddressBlocks table to finish things up? That's where I'm a bit stuck, it's a simple 1:1 relationship so this should work, but somehow I might miss something.</p>
<p><em>Follow up:</em></p>
<p>The recommended solutions below with separate attributes would force me to store all attributes as the same type, or not? What If one PageElement has attributes that are nvarchar(255) and some are nvarchar(1000), what if some are integers?</p>
<p>If I got the EAV way I would have to create tons of tables for holding the attribute values for all the different data types out there. </p>
|
<p>The two common choices are <a href="http://martinfowler.com/eaaCatalog/singleTableInheritance.html" rel="nofollow noreferrer">Single Table Inheritance</a> and <a href="http://martinfowler.com/eaaCatalog/classTableInheritance.html" rel="nofollow noreferrer">Multi Table Inheritance</a>. Other approaches include having <a href="http://martinfowler.com/eaaCatalog/concreteTableInheritance.html" rel="nofollow noreferrer">tables for each concrete class</a> which I've never used, and what I'd call a meta-table implementation, where the attribute definitions are moved into data rather than any sort of schema. </p>
<p>I've had generally good experiences with <a href="http://martinfowler.com/eaaCatalog/singleTableInheritance.html" rel="nofollow noreferrer">STI</a>, and provided you don't expect a plethora of classes and attributes it's the simplest solution. Simple is very good in my book.</p>
<p>Unless new page element types need to be created by users at runtime, I'd avoid the meta-tables approach and anything that begins to look like it. In my experience such code quickly becomes a quagmire and rarely delivers much value compared to a more concrete implementation updated at regular intervals by developers.</p>
|
<p>The universal solution would be:</p>
<pre><code>PageElementType: ID, Name, [Mumbo Jumbo]
PageElementTypeParameter: ID, PageElementTypeID, [Mumbo Jumbo]
Page: ID, [Mumbo Jumbo]
PageElement: ID, PageElementTypeID, [Mumbo Jumbo]
PageElementParameters: ID, PageElementID, PageElementTypeParameterID, Value, [Mumbo Jumbo]
</code></pre>
<p>In human words: There is a table for page element types, and an associated table, which lists possible parameters for each page element (like SRC and ALT for an image; TEXT for an article, etc).</p>
<p>Then there is a table with all the pages; an associated table which lists elements in each page; and a table which lists parameter values for each element.</p>
| 43,217
|
<p>Putting aside the fact that one is open-source, which tool is more feature rich and performant for SVN support within Visual Studio.</p>
|
<p>I've recently switched back to Ankhsvn (2.0) from VisualSVN. Prior to VisualSVN I was using Ankhsvn (1.0).</p>
<p>I prefer AnkhSVN 2.0 because it integrates with Visual Studio as a source control module, rather than an add-in and as a result it feels more like using Visual SourceSafe (which I am forced to use at my 9 to 5). Basically it integrates with Visual Studio the way Microsoft intended source control to integrate with Visual Studio.</p>
<p>For me it simplifies going back and forth between Visual SourceSafe and Subversion since they both behave essentially the same way.</p>
|
<p>I like the way that VisualSVN keeps you closer to tortoise. I also like its diff tools better.</p>
<p>I'm not sure if they changed it, but Ankh did not allow renaming of files in VS when I last used it. That was a pretty big pain for me as I have refactoritis and generally suck at naming files really well the first time.</p>
| 44,041
|
<p>Alright, after doing a ton of research and trying almost every managed CPP Redist I can find as well as trying to copy my DLLs locally to the executing directory of the app I cannot figure out what dependencies i'm missing for this mixed mode library.</p>
<p>Basically I have a large C# application and I'm trying to use a mixed mode library I made. On the development machine it works perfect (of course) but deployed when the library needs to be loaded for use it exceptions out because of missing CRT dependencies (I assume).</p>
<p>I have used dependency walker to check all the DLLs referenced and ensured they exist on the deployment machine with no luck, I'm wondering if maybe it's some dependencies that need to be registered that I am missing, but i can't figure out what.</p>
<p>I get the following exception when code tries to instantiate a class from the mixed mode library.</p>
<blockquote>
<p>Exception Detail:
System.IO.FileLoadException: Could not
load file or assembly 'USADSI.MAPI,
Version=1.0.3174.25238,
Culture=neutral, PublicKeyToken=null'
or one of its dependencies. This
application has failed to start
because the application configuration
is incorrect. Reinstalling the
application may fix this problem.
(Exception from HRESULT: 0x800736B1)</p>
</blockquote>
<p>I am compiling the library using VS2008 SP1 with /clr:oldSyntax specified.</p>
<p>The intermediate manifest looks like this:</p>
<pre><code><assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
</code></pre>
<p>I can provide any more information as needed, unfortunately i'm not well versed in making mixed mode libraries so this has thrown me off.</p>
<p>If anyone can offer any advice I would greatly appreciate it!</p>
|
<p>Did you deploy the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en" rel="nofollow noreferrer">CRT libraries</a> on the target machine? Long shot: since you have a dependency on 32-bit code, you should set Target Platform in the Build property tab to x86.</p>
<p>EDIT: trouble-shoot side-by-side resolving problems with the <a href="http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx" rel="nofollow noreferrer">Sxstrace.exe utility</a>, available on Vista.</p>
|
<p>I had a similar problem the first time I deployed a VS 2005 app on a target machine -- had to bring over the MSVCRT80 DLL. Are you saying you already have the 2008 VS runtime library there?</p>
<p>ETA: Also, dumb question, but are you sure you have both the CRT Runtime (linked to above) <em>and</em> the .NET Runtime, with the same version you compiled against (probably 3.5)? You probably already know this (especially considering your score) but they're 2 different things.</p>
| 28,559
|
<p>I'm working on moving from using tables for layout purposes to using divs (yes, yes the great debate). I've got 3 divs, a header, content and footer. The header and footer are 50px each. How do I get the footer div to stay at the bottom of the page, and the content div to fill the space in between? I don't want to hard code the content divs height because the screen resolution can change.</p>
|
<h1>Flexbox solution</h1>
<p>Using flex layout we can achieve this while allowing for natural height header and footer. Both the header and footer will stick to the top and bottom of the viewport respectively (much like a native mobile app) and the main content area will fill the remaining space, while any vertical overflow will be scrollable within that area.</p>
<p><a href="https://jsfiddle.net/osvx1zoo/3/" rel="noreferrer">See JS Fiddle</a></p>
<p><strong>HTML</strong></p>
<pre><code><body>
<header>
...
</header>
<main>
...
</main>
<footer>
...
</footer>
</body>
</code></pre>
<p><strong>CSS</strong></p>
<pre><code>html, body {
margin: 0;
height: 100%;
min-height: 100%;
}
body {
display: flex;
flex-direction: column;
}
header,
footer {
flex: none;
}
main {
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
flex: auto;
}
</code></pre>
|
<p>if you are trying to maximize the height of your content div, in the CSS add </p>
<p>height: 100%;</p>
| 25,316
|
<p>I'm getting this error on a compact framework form.</p>
<p>"code generation for property 'inputControl' failed. Error was: 'object reference not set to an instance of an object.'"</p>
<p>Anyone have any idea why? It just started and was never an issue before. </p>
|
<p>Take a look at where 'inputControl' is intiially being accessed and ensure it's being instantiated correctly.</p>
|
<p>When a User Control won't load into the Visual Studio designer here is what you need to do. These instruction are for vb.net project but c# should be similar. Also, before doing this close all open windows (or at least the source and designer files of the control you are working on.)</p>
<p>One last thing. The FIRST thing you should do is ensure that restarting visual studio doesn't fix the problem. If not you can try the steps that follow. These instructions assume that the errant user controls are in control library project in visual studio. If not you should be able to adjust the directions a bit to get it to work but it is much easier when the control is in its own project.</p>
<p>Do the following:</p>
<ol>
<li>Make the control library your startup project. </li>
<li>Open the properties for the control library project and click on the debug tab. </li>
<li>Under Start Action click the Start external program option and browse to the Visual Studio executable.</li>
</ol>
<p>NOTE: what this means is that when you run your solution it will fire up another instance of Visual Studio instead of actually running your solution. The First Instance of Visual Studion (INSTANCE_1) will "host" a second instance of visual studio (INSTANCE_2) when you run it. </p>
<ol start="4">
<li>Run your solution. INSTANCE_2 will load.</li>
<li>Switch back to INSTANCE_1. </li>
<li>In INSTANCE_1 hit CTRL-ALT-E. This will open up the exceptions dialog box. Check On the THROWN column checkbox next to Common Language Runtime Exceptions.</li>
</ol>
<p>NOTE: This will ensure that INSTANCE_1 will BREAK at ANY runtime error even if it is hit in a try block.</p>
<ol start="7">
<li>Switch to INSTANCE_2. In Solution Explorer double-click to open the errant user control. </li>
</ol>
<p>You should find that INSTANCE_1 OF Visual Studio should have stopped at the line of code that caused the designer to not load the control. Fix the code (which usually means testing for IsNot Nothing before references an object properties...but could mean other things.)</p>
<p>Also, sometimes I find that the control WILL load in INSTANCE_2 instead of breaking on an error in INSTANCE_1. In that case just stop debugging...close INSTANCE_2. Save/Restart INSTANCE_1 and your problem will often have gone away. </p>
<p>The lesson is this. User Control MUST be able to load/reference all objects and their members in order to load it into the designer. So for User Controls that will be placed onto other containers I will usually design events to notify the parent rather than trying to push objects into the child control. </p>
<p>Hope this helps for future reference on this old question.</p>
<p>Seth</p>
| 31,755
|
<p>Subversion is a great way to update our web applications on our servers. With a simple <code>svn update</code> all changed files get... well, changed.</p>
<p>Except for the omnipresent configuration files such as <code>config.php</code> which hold the database access configuration, server paths etc. And are therefore different on my local development system and the remote server.</p>
<p>With the <code>update</code> command, a file modified on the server won't get overwritten, but if I change the file locally and commit it, the server gets the wrong configuration file.</p>
<p>But I don't want to set the <code>svn:ignore</code> property either, since the config file belongs to the project.</p>
<p>Is there a Subversion-mechanism which will allow me to easily handle these kind of files? Or is the only way to solve this problem to make a system switch within the config file which will determine the executing system and sets the configuration accordingly?</p>
|
<p>Create a template for the file (e.g. config.php-default) and let the user copy the template. She can also do a diff to see what changed between versions to incorporate these changes in the locally deployed version of the file.</p>
|
<p>On the projects I am currently working on we have 2 properties files for the database schema information - one for the production environment and one for development. We have a class that loads all of our properties for the module being executed, with logic that determines which file to load.</p>
<p>Since our development environment locally is a Windows file system and the production servers operate on UNIX file systems, our solution was to determine the operating system of the host and load the correct file.</p>
<p>We keep these directly within our source control in order to keep a history of any changes made. I think we learned a lesson from our (internal) client finger pointing in regards to <strong>INSANELY FREQUENT REQUIREMENTS CHANGES</strong>, in that we needed to be able to defend any of the past changes to the files.</p>
<p>This may be unique for our situation, but I've found this to be extremely helpful, especially if I am trying to replicate a test run from a previous revision.</p>
| 16,008
|
<p>I have a database on ms sql 2000 that is being hit by hundreds of users at a time. There are intense reports using reporting services 2005 hitting the same database.</p>
<p>When there are lots of reports running and people using the database concurrently we see blocking processes to the level that the system starts to give time out to any transaction made after some time in that situation.</p>
<p>Is there a global way of minimize blocking so the transaction can continue to flow.</p>
|
<p>Use optimistic locking, if updates are not happening often and the database is mainly used for reporting.</p>
<p>SQL Server has quite a pessimistic locking default.</p>
<p>A look into <a href="http://msdn.microsoft.com/en-us/library/ms187373.aspx" rel="nofollow noreferrer">SQL Server Table Hints</a> might get you started.</p>
|
<p>Thanks everyone for your support. What we do to mitigate the problem was to create a new database whit a logshipping procedure every hour to mantain in sync to the real one. The reports that do no need real time data where point to that database and the ones that needs real time data where restricted so only a few people can access them. The drawbacks whit the method is tha the data will be up to one hour out of sync and we need to create a new server for that purpose only. Also when the loggshipping procedure runs every connetion is drop for a very short period of time but it can be a problem to really long procedures or reports. After this I will verify the querys from the reports so I can understand what can be optimize. Thanks and I will recomend the site to the whole IT department.</p>
| 23,315
|
<p>I am involved in development of a tiered application that uses LINQ2SQL separated from the web server with a NET.TCP Binding on WCF. </p>
<p>My questions are: </p>
<ol>
<li>What sort of measures should I take
to achieve the best performance?</li>
<li>Since the entity objects returned by
the LINQ need to be converted to a
IEnumerable list to be serialized
everytime, is there anyway to remove
this dependency?</li>
</ol>
|
<p>1) Concentrate on a properly normalized database design. I would say that when you are forced to make design tradeoffs in your code vs. database design, if performance is your goal, make tradeoffs in your object design instead of your database design. Understand that you aren't going to be able to do a proper supertype/subtype database design which will work with Linq to SQL (I'm told you need to use the EF instead). </p>
<p>2) Depends what you mean here. If you're asking how you would serialize anonymous classes across the wire, the easy answer is: "you can't, so don't try". If you want to put lists of objects across the wire, just use the ToArray() extension method on your IEnumerable collections to ship arrays of your business objects over the wire.</p>
|
<p>Linq to SQL is very slow unless you compile queries. Otherwise your application will be CPU bound as most of the time will be spend converting Expression trees into SQL. </p>
<p>We are talking about 10x performance gain if you use compiled queries. Try it :)</p>
| 20,690
|
<p>I am trying to bind an event to a "method" of a particular instance of a Javascript "class" using jQuery. The requirement is that I in the event handler should be able to use the "this" keyword to refer to the instance I originally bound the event to.</p>
<p>In more detail, say I have a "class" as follows:</p>
<pre><code>function Car(owner) {
this.owner = owner;
}
Car.prototype = {
drive: function() {
alert("Driving "+this.owner+"s car!");
}
}
</code></pre>
<p>And an instance:</p>
<pre><code>var myCar = new Car("Bob");
</code></pre>
<p>I now want to bind an event to the drive "method" of my car so that when ever I click a button for example the drive "method" is called on the myCar instance of the Car "class".</p>
<p>Up until now I've been using the following function to create a closure that allows me to comfortably access instance members using the "this" keyword in my "methods".</p>
<pre><code>function createHandler( obj, method ) {
return function( event ) {
return obj[method](event||window.event);
}
}
</code></pre>
<p>I've used it as follows:</p>
<pre><code>document.getElementById("myButton")
.addEventListener("click", createHandler(myCar,"drive"));
</code></pre>
<p>How do I accomplish something like this with JQuery? </p>
<p>I'm specifically asking about associating "this" with a designated instance, the other cruft all around I can handle on my own.</p>
|
<p>Just use an anonymous function:</p>
<pre><code>$("#myButton").click(function() { myCar.drive(); });
</code></pre>
|
<p>Try this :</p>
<pre><code>$("#myButton").each(function() {
var $btn = $(this);
$btn.on('click',function(){
// Do whatever you want.
});
});
</code></pre>
<p>Here you first create a loop to target all #myButton elements (Which is wrong in your example, You should be using Class instead) like:</p>
<pre><code>$(".myButton").each(...
</code></pre>
<p>Then we attach the click event handler to all of them.</p>
| 14,294
|
<p>How do you calculate the distance between 2 cities? </p>
|
<p>If you need to take the curvature of the earth into account, the Great-Circle distance is what you're looking for. <a href="http://en.wikipedia.org/wiki/Great-circle_distance" rel="nofollow noreferrer">The Wikipedia article</a> probably does a better job of explaining how the formula works than me, and there's also <a href="http://www.edwilliams.org/avform.htm" rel="nofollow noreferrer">this aviation formulary page</a> that covers that goes into more detail.</p>
<p>The formulas are only the first part of the puzzle though, if you need to make this work for arbitrary cities, you'll need a location database to get the lat/long from. Luckily you can get this for free from <a href="http://www.geonames.org/" rel="nofollow noreferrer">Geonames.org</a>, although there are commercial db's available (ask google). So, in general, look up the two cities you want, get the lat/long co-orinates and plug them into the formula as in <a href="http://en.wikipedia.org/wiki/Great-circle%5Fdistance#Worked_example" rel="nofollow noreferrer">the Wikipedia Worked Example</a>.</p>
<p>Other suggestions:</p>
<ul>
<li>For a full commercial solution,
there's <a href="http://www.alk.com/pcmiler/pcmiler-system-req.asp" rel="nofollow noreferrer">PC Miler</a> which is used
by many trucking companies to
calculate shipping rates.</li>
<li>Make calls to the Google Maps (or other) api. If you need to do many requests per day, consider caching the results on the server.</li>
<li>Also <strong>very important</strong> is to consider building an equivalence database for cities, suburbs, towns etc. if you think you'll ever need to group your data. This gets really complicated though, and you may not find a one-size-fits-all solution for your problem.</li>
</ul>
<p>Last but not least, Joel wrote an article about this problem a while back, so here you go: <a href="http://www.joelonsoftware.com/items/2006/10/09.html" rel="nofollow noreferrer">New Feature: Job Search</a></p>
|
<p>You find the Lat/Lon of the city, then use a distance estimation algorithm for Lat/Lon coordinates.</p>
| 4,348
|
<p>How do I pull out the filename from a full path using regular expressions in C#?</p>
<p>Say I have the full path <code>C:\CoolDirectory\CoolSubdirectory\CoolFile.txt</code>.</p>
<p>How do I get out CoolFile.txt using the .NET flavor of regular expressions? I'm not really good with regular expressions, and my RegEx buddy and me couldn't figure this one out.</p>
<p>Also, in the course of trying to solve this problem, I realized that I can just use <code>System.IO.Path.GetFileName</code>, but the fact that I couldn't figure out the regular expression is just making me unhappy and it's going to bother me until I know what the answer is.</p>
|
<p>Why must you use regular expressions? .NET has the built-in <code>Path.GetFileName()</code> method specifically for this which works across platforms and filesystems.</p>
|
<p>You should rather use the System.Path class. It will mean you will have to worry about less if you ever decide to support Mono/Linux (dlamblin's example takes the path seperator into account, but you may get a strange OS that has strange paths). The System.Path class can also combine two paths into one. So for example:</p>
<pre><code>Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "My App Stuff");
</code></pre>
<p>would resolve to:</p>
<ul>
<li>Windows: C:\Documents and Settings\[User]\My Documents\My App Stuff</li>
<li>Linux: /[User]/My App Stuff</li>
</ul>
| 27,547
|
<p>I've noticed this on almost ever print I've ever had. On the initial first line that clears the extruder nozzle tiny little bubbles/craters seem to form on the line. While I don't think these are causing any issue with my prints I'm curious to know the reason why they form at all. </p>
<p>Is this due to water absorption in my filament that turns to steam, which then bursts through the molten plastic? Is it due to air bubbles in the filament that are cause by the manufacturing process of the filament? Or is this more an indication that my nozzle is damaged or clogged in some way?</p>
<p><a href="https://i.stack.imgur.com/2we0A.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/2we0A.jpg" alt="Bubbles in extrusion"></a></p>
<p>This image was made using ABS plastic and a heated build plate. I've noticed these same 'bubbles' appearing using PLA, and Nylon. </p>
<p>Edit: Nozzle temperature 240°C, build plate temperature 150°C, Nozzle diameter 0.4 mm, filament diameter (measured 1.75 mm) retraction distance 1.7 mm. Using the Makerbot Desktop Slicer.</p>
<p>The first line that my printer extrudes, where I'm seeing these 'bubbles' is a nearly full line. Makerbot starts from the right side of the image, extruding to the left. </p>
<p><a href="https://i.stack.imgur.com/3sf99.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/3sf99.jpg" alt="Single line extrusion on printer bed"></a></p>
|
<p>Oh yeah, that's simple. You are printing too hot and are literally boiling the plastic. Else you have water. However if it was water you would hear Crackling as it printed. If it is too hot you will not hear nearly as much. I am 87.341% sure you are printing too hot.</p>
<p>Looking at your printing temps you are without a doubt printing too hot.</p>
<p>From <a href="https://www.3dhubs.com/talk/thread/best-printing-practices-makerbot-replicator-2-and-2x" rel="noreferrer">this link</a> on 3d hubs.</p>
<blockquote>
<p>PLA (Only on Replicator 2) Print temp: 210°C (at 100m/s) Notes: heated
bed optional between 40 and 60°C</p>
<p>ABS (Only on Replicator 2X) Print
temp: 230°C (at 100m/s) Notes: heated bed at 110°C</p>
</blockquote>
|
<p>There is only one way to find out, which is by isolating any reasons, starting from the simplest one: </p>
<ul>
<li>Firstly, clean and check, or change, your nozzle;</li>
<li>Secondly, if that does not work, then change the filament, or find a way to get it dry (some people, with some filaments, use an oven to get moisture out - careful, don't burn it);</li>
<li>Finally, change filament brand and get a better quality filament or another type of filament. </li>
</ul>
<p>Another reason that it does not extrude consistently, is that what you mention as [appearing to be] bubbles maybe [intentional] gaps [in the print].</p>
| 495
|
<p>I'm working through previous years ACM Programming Competition problems trying to get better at solving Graph problems. </p>
<p>The one I'm working on now is I'm given an arbitrary number of undirected graph nodes, their neighbors and the distances for the edges connecting the nodes. What I NEED is the distance between the two farthest nodes from eachother (the weight distance, not by # of nodes away).</p>
<p>Now, I do have Dijkstra's algorithm in the form of:</p>
<pre><code>// Dijkstra's Single-Source Algorithm
private int cheapest(double[] distances, boolean[] visited)
{
int best = -1;
for (int i = 0; i < size(); i++)
{
if (!visited[i] && ((best < 0) || (distances[i] < distances[best])))
{
best = i;
}
}
return best;
}
// Dijkstra's Continued
public double[] distancesFrom(int source)
{
double[] result = new double[size()];
java.util.Arrays.fill(result, Double.POSITIVE_INFINITY);
result[source] = 0; // zero distance from itself
boolean[] visited = new boolean[size()];
for (int i = 0; i < size(); i++)
{
int node = cheapest(result, visited);
visited[node] = true;
for (int j = 0; j < size(); j++)
{
result[j] = Math.min(result[j], result[node] + getCost(node, j));
}
}
return result;
}
</code></pre>
<p>With this implementation I can give it a particular node and it will give me a list of all the distances from that node. So, I could grab the largest distance in that list of distances but I can't be sure that any particular node is one of the two furthest ones at either end. </p>
<p>So the only solution I can think of is to run this Dijkstra's algorithm on every node, go through each returned list of distances and looking for the largest distance. After exhausting each node returning it's list of distances I should have the value of the largest distance between any two nodes (the "road" distance between the two most widely seperated villages). There has got to be an easier way to do this because this seems really computationally expensive. The problem says that there could be sample inputs with up to 500 nodes so I wouldn't want it to take prohibitively long. Is this how I should do it?</p>
<p>Here is a sample input for the problem:</p>
<p>Total Nodes: 5 </p>
<p>Edges:<br>
Nodes 2 - Connect - Node 4. Distance/Weight 25<br>
Nodes 2 - Connect - Node 5. Distance/Weight 26<br>
Nodes 3 - Connect - Node 4. Distance/Weight 16<br>
Nodes 1 - Connect - Node 4. Distance/Weight 14 </p>
<p>The answer to this sample input is "67 miles". Which is the length of the road between the two most widely separated villages.</p>
<p>So should I do it how I described or is there a much simpler and much less computationally expensive way?</p>
|
<p>It looks like you can use either of:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Floyd_Warshall" rel="nofollow noreferrer">Floyd Warshall algorithm</a></li>
<li><a href="http://en.wikipedia.org/wiki/Johnson's_algorithm" rel="nofollow noreferrer">Johnson's algorithm</a>. </li>
</ul>
<p>I can't give you much guidance about them though - I'm no expert.</p>
|
<p>You can use your Dijkstra's implementation as follows:</p>
<ol>
<li>Pick a random node,(a), run Dijkstra from node a, and find the furthest node from it. Mark that node as node b.</li>
<li>Run Dijkstra again starting at node b, and find the furthest node from it. Mark that node as node c.</li>
</ol>
<p>I don't have proof for this, but I think b and c will be furthest away nodes. You might need to run one more iteration (I'm still thinking about it).</p>
| 20,493
|
<p>I am receiving the expcetion <code>CGI::Session::CookieStore::TamperedWithCookie</code> after changing the <code>config.action_controller.session.secret</code> setting on an app (as part of preparation to full deployment. </p>
<p>Am I right in assuming that changing the secret while testers have cookies set is the cause of this, and what other cause could there be (both due to secuirty attacks, and coding issues) </p>
|
<p>The cause of your exception is most certainly changing the secret while testers have cookies set. The cookie is cryptographically signed using the secret to protect against users tampering with their cookie. For example, they might try to change their stored user id in order to elevate their privileges.</p>
<p>You could ask the testers to clear their cookies. Or, you could catch the exception and remove the cookie for your application. Some sites prefer to use <a href="http://api.rubyonrails.org/classes/ActionController/Base.html" rel="nofollow noreferrer">ActiveRecordSession</a> store for more control over their sessions so they drop all sessions when required but at a cost of performance.</p>
|
<p>I found a <a href="http://github.com/mhartl/catch_cookie_exception" rel="nofollow">plugin on Github</a> that will trap the error and write it to the log without exposing the error to the user. I was plagued by this problem on a Rails 2.1 instance and it did the trick.</p>
| 13,925
|
<p>I have an importer process which is running as a windows service (debug mode as an application) and it processes various xml documents and csv's and imports into an SQL database. All has been well until I have have had to process a large amount of data (120k rows) from another table (as I do the xml documents).</p>
<p>I am now finding that the SQL server's memory usage is hitting a point where it just hangs. My application never receives a time out from the server and everything just goes STOP. </p>
<p>I am still able to make calls to the database server separately but that application thread is just stuck with no obvious thread in SQL Activity Monitor and no activity in Profiler.</p>
<p>Any ideas on where to begin solving this problem would be greatly appreciated as we have been struggling with it for over a week now.</p>
<p>The basic architecture is c# 2.0 using NHibernate as an ORM data is being pulled into the actual c# logic and processed then spat back into the same database along with logs into other tables.</p>
<hr>
<p>The only other prob which sometimes happens instead is that for some reason a cursor is being opening on this massive table, which I can only assume is being generated from ADO.net the statement like exec sp_cursorfetch 180153005,16,113602,100 is being called thousands of times according to Profiler</p>
|
<p>When are you <code>COMMIT</code>ting the data? Are there any locks or deadlocks (sp_who)? If 120,000 rows is considered large, how much RAM is SQL Server using? When the application hangs, is there anything about the point where it hangs (is it an <code>INSERT</code>, a lookup <code>SELECT</code>, or what?)?</p>
<p>It seems to me that that commit size is way too small. Usually in SSIS ETL tasks, I will use a batch size of 100,000 for narrow rows with sources over 1,000,000 in cardinality, but I never go below 10,000 even for very wide rows.</p>
<p>I would not use an ORM for large ETL, unless the transformations are extremely complex with a lot of business rules. Even still, with a large number of relatively simple business transforms, I would consider loading the data into simple staging tables and using T-SQL to do all the inserts, lookups etc.</p>
|
<p>Are you running this into SQL using BCP? If not, the transaction logs may not be able to keep up with your input. On a test machine, try turning the recovery mode to Simple (non-logged) , or use the BCP methods to get data in (they bypass T logging)</p>
| 37,895
|
<p>My MFC application using the "ESRI MapObjects LT2" ActiveX plugin throws an ASSERT at me when closing it.
The error occurs in <code>cmdtarg.cpp</code>:</p>
<pre><code>CCmdTarget::~CCmdTarget()
{
#ifndef _AFX_NO_OLE_SUPPORT
if (m_xDispatch.m_vtbl != 0)
((COleDispatchImpl*)&m_xDispatch)->Disconnect();
ASSERT(m_dwRef <= 1); //<--- Fails because m_dwRef is 3
#endif
m_pModuleState = NULL;
}
</code></pre>
<p>I built the (native C++) application with VC9.
When I compile the application with VC6, it behaves nicely.</p>
<p>What could be the reason for this?</p>
|
<p>That looks like a reference count. Could this "target" be referenced by something else, something that's not releasing it?</p>
|
<p>Using <code>_ATL_DEBUG_INTERFACES</code> did not yield any additional output...
I defined it on the first line of <code>stdafx.</code>h, directly after <code>#pragma once</code> so I guess this is early enough.</p>
<p>Maybe the reason is how I am using the ActiveX control:<br>
I'm not calling <code>AddRef()</code> or <code>Release()</code> by myself.<br>
The MapObjects Installer comes with sample code with lots of wrapper classes which must have been generated by VC6 or something earlier.<br>
I tried to generate wrapper classes myself with VC9 but there occured errors which I wasn't able to fix.
I use the control by letting one of my windows have a member of type <code>CMap1</code> (derived from <code>CWnd</code>), which is one of those generated wrapper classes. In <code>CMyWnd::OnCreate()</code> I also call <code>CMap1::Create()</code> and that's it, I'm finished: I can add a layer and the control displays a world map.<br>
I have pretty much no idea what the reference-count stuff is about as I have not added or released any references. At least not knowingly...</p>
<p>The control is pretty old: The .OCX file has the year 2000 in its version information.<br>
It's also not officially supported anymore but I don't have any substitue.</p>
| 25,149
|
<p>The following code works for me:</p>
<pre><code>var webProxy = WebProxy.GetDefaultProxy();
webProxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = webProxy;
</code></pre>
<p>Unfortunately, <code>WebProxy.GetDefaultProxy()</code> is deprecated. What else should I be doing?</p>
<p>(using app.config to set the defaultProxy settings is not allowed in my deployment)</p>
|
<p>From .NET 2.0 you shouldn't need to do this. If you do not explicitly set the Proxy property on a web request it uses the value of the static WebRequest.DefaultWebProxy. If you wanted to change the proxy being used by all subsequent WebRequests, you can set this static DefaultWebProxy property.</p>
<p>The default behaviour of WebRequest.DefaultWebProxy is to use the same underlying settings as used by Internet Explorer.</p>
<p>If you wanted to use <strong>different proxy settings</strong> to the current user then you would need to code </p>
<pre><code>WebRequest webRequest = WebRequest.Create("http://stackoverflow.com/");
webRequest.Proxy = new WebProxy("http://proxyserver:80/",true);
</code></pre>
<p>or</p>
<pre><code>WebRequest.DefaultWebProxy = new WebProxy("http://proxyserver:80/",true);
</code></pre>
<p>You should also remember the object model for proxies includes the concept that the proxy can be different depending on the destination hostname. This can make things a bit confusing when debugging and checking the property of webRequest.Proxy. Call </p>
<p><code>webRequest.Proxy.GetProxy(new Uri("http://google.com.au"))</code> to see the actual details of the proxy server that would be used.</p>
<p>There seems to be some debate about whether you can set <code>webRequest.Proxy</code> or <code>WebRequest.DefaultWebProxy = null</code> to prevent the use of any proxy. This seems to work OK for me but you could set it to <code>new DefaultProxy()</code> with no parameters to get the required behaviour. Another thing to check is that if a <a href="http://msdn.microsoft.com/en-us/library/sa91de1e.aspx" rel="noreferrer">proxy element</a> exists in your applications config file, the .NET Framework will <strong>NOT</strong> use the proxy settings in Internet Explorer.</p>
<p>The MSDN Magazine article <a href="http://msdn.microsoft.com/en-gb/magazine/cc300743.aspx" rel="noreferrer">Take the Burden Off Users with Automatic Configuration in .NET</a> gives further details of what is happening under the hood.</p>
|
<p>Is need in some systems set null the Proxy proprerty:</p>
<p>Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim request As WebRequest = WebRequest.Create(sRemoteFileURL)
request.Proxy = Nothing</p>
<p>It's a bug.</p>
| 38,441
|
<p>I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error:</p>
<pre><code>Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4
</code></pre>
<p>I am using Gmail SMTP to send the emails and I haven't changed any of the ActionMailer::Base.smtp_settings just installed ar_mailer.</p>
<p>Versions: </p>
<p>Rails: 2.1, ar_mailer: 1.3.1</p>
|
<p>Did some digging in the lib and it seems that if you want to use TLS (as you do with Gmail) then it adds a new option to the ActionMailer::Base.smtp_settings of :tls (default of which is false) which you should set to true.</p>
<p>The only thing the installation instructions mention regarding TLS is to remove any other smtp_tls files, but the one I had didn't require the tls option to work.</p>
|
<p>What version of ar_mailer are you using? A gmail specific bug was fixed in 1.3.1, as shown here:</p>
<p><a href="http://rubyforge.org/forum/forum.php?forum_id=16364" rel="nofollow noreferrer">http://rubyforge.org/forum/forum.php?forum_id=16364</a></p>
| 13,497
|
<p>I have quickly read (and will read with more care soon) the article of Scott Allen concerning the possibility to use an other provider of the default SQL Express or SQL Server database to use the "<a href="http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-Roles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx" rel="nofollow noreferrer">Membership and Role Providers</a>" for ASP.NET.</p>
<p>We will soon need to open a part of our project to some client via the web and I thought about using the "<a href="http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-Roles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx" rel="nofollow noreferrer">Membership and Role Providers</a>" but our database is PostGreSql. </p>
<p>Does any one have some experience with "<a href="http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-Roles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx" rel="nofollow noreferrer">Membership and Role Providers</a> and an other database type (not SQL Server)? Is it worth it or it's a pain?</p>
|
<p>That's a pretty common coding style when writing SQL statements:</p>
<pre><code>SELECT field1
, field2
, field3
-- , field4
, field5
FROM tablename
</code></pre>
<p>Advantages:</p>
<ul>
<li>Lets you add, remove, or rearrange fields easily without having to worry about that final trailing comma.</li>
<li>Lets you easily comment out a row (TSQL uses "--") without messing up the rest of the statement.</li>
</ul>
<p>I wouldn't think you'd want to rearrange parameter order in a function as frequent as you do in SQL, so maybe its just somebody's habit.</p>
<p>The ability to comment one of them out will depend on the specific language being used. Not sure about C++. I know that VB.Net wouldn't allow it, but that's because it requires a continuation character ( _ ) to split statements across lines.</p>
|
<p>I know when I wrap and's in a sql or if statement I try to make sure the and is the start of the next line. </p>
<p>If A and B <br>
and C </p>
<p>I think it makes it clear the the C is still part of the if. The first format you show may be that. But as with most style questions the simple matter is that if the team decides on one style then it should be adhered to.</p>
| 28,578
|
<p>I was recently looking at some web hosting solutions and some of the providers offered various hosting locations e.g. US or UK based servers.</p>
<p>My question is: does it really make a difference from the performance point of view?
Lets say that I am expecting most of the traffic coming from continental Europe? </p>
<p>Would the fact that the servers are based in UK make bigger difference if the traffic was coming from the UK.</p>
<p>Any pros and cons of having a website hosted in the same county as the most of the expected traffic?</p>
|
<p>Yes, obviously it does matter to some degree.</p>
<p>This degree depends on the level of your site optimization (size of the pages, usage of AJAX, Flash etc)</p>
<p>Example from my experience. Round-trip from russia to USA is 200ms. It does not make any difference for the small web site optimized for the performance, but it makes a huge usability difference for SmartClient accessing Web API of this site.</p>
|
<p>Yes. Performance depends on how far is the data center from users. Nearer means faster, and the opposite.</p>
| 18,994
|
<p>Is it a good idea for me to use Qt Jambi in Java as a toolkit? </p>
<p>I see that Qt Jambi is hard to learn, and Swing is easier than Qt Jambi, but I think that Qt Jambi is more powerful.</p>
|
<p>Two years ago, I started a Java Desktop Application and used Swing as a GUI framweork. Up to that point, I had experience with C++/MFC (<em>shudder</em>) and C++/Qt (<em>very nice</em>).</p>
<p>After trying to get along with Swing for a while (including reading lots of tutorials and even a book) I came to the following conclusion:</p>
<p><strong>Swing is much more difficult and clumsy than Qt for three reasons:</strong></p>
<ol>
<li>A lot of simple stuff requires more code than it should. </li>
<li>Some things that Qt brings for free are almost impossible to achieve in a reasonable amount of time.</li>
<li>Swing doesn't bring a WYSIWYG GUI Editor and I could not find a free one that comes close to Qt's Designer.</li>
</ol>
<p>I then threw away the Swing GUI, switched to Qt Jambi and was really impressed by it. One weekend later I had a nice Qt GUI and lived happily ever after.</p>
|
<p>If you think being familiar with Qt would be useful in the future, when you might want to develop in C++ (or change some Qt-based software), I think it would be nice.</p>
| 16,864
|
<p>I'm trying to validate that a submitted URL doesn't already exist in the database.</p>
<p>The relevant parts of the Form class look like this:</p>
<pre><code>from django.contrib.sites.models import Site
class SignUpForm(forms.Form):
# ... Other fields ...
url = forms.URLField(label='URL for new site, eg: example.com')
def clean_url(self):
url = self.cleaned_data['url']
try:
a = Site.objects.get(domain=url)
except Site.DoesNotExist:
return url
else:
raise forms.ValidationError("That URL is already in the database. Please submit a unique URL.")
def clean(self):
# Other form cleaning stuff. I don't *think* this is causing the grief
</code></pre>
<p>The problem is, regardless of what value I submit, I can't raise the <code>ValidationError</code>. And if I do something like this in the <code>clean_url()</code> method:</p>
<pre><code>if Site.objects.get(domain=url):
raise forms.ValidationError("That URL is already in the database. Please submit a unique URL.")
</code></pre>
<p>then I get a <code>DoesNotExist</code> error, even for URLs that already exist in the Database. Any ideas?</p>
|
<p>django channel in IRC saved me here. The problem was that the URLField.clean() does two things I wasn't expecting:</p>
<ol>
<li>If no URL scheme is present (eg, http://) the method prepends 'http://' to the url</li>
<li>the method also appends a trailing slash.</li>
</ol>
<p>The results are returned and stored in the form's cleaned_data. So I was checking <code>cleaned_data['url']</code> expecting something like <code>example.com</code> and actually getting <code>http://example.com/</code>. Suffice to say, changing my <code>clean_url()</code> method to the following works:</p>
<pre><code>def clean_url(self):
url = self.cleaned_data['url']
bits = urlparse(url)
dom = bits[1]
try:
site=Site.objects.get(domain__iexact=dom)
except Site.DoesNotExist:
return dom
raise forms.ValidationError(u'That domain is already taken. Please choose another')
</code></pre>
|
<p>I think, you can return '' and fill _errors.</p>
<pre><code>msg = u"That URL is already in the database. Please submit a unique URL."
self._errors["url"]=ErrorList([msg])
return ''
</code></pre>
<p>or</p>
<pre><code>from django.contrib.sites.models import Site
class SignUpForm(forms.Form):
# ... Other fields ...
url = forms.URLField(label='URL for new site, eg: example.com')
def clean_url(self):
url = self.cleaned_data['url']
try:
a = Site.objects.get(domain=url)
raise forms.ValidationError("That URL is already in the database. Please submit a unique URL.")
except Site.DoesNotExist:
return url
return ''
def clean(self):
# Other form cleaning stuff. I don't *think* this is causing the grief
</code></pre>
| 44,072
|
<p>I've been taking a look at some different products for .NET which propose to speed up development time by providing a way for business objects to map seamlessly to an automatically generated database. I've never had a problem writing a data access layer, but I'm wondering if this type of product will really save the time it claims. I also worry that I will be giving up too much control over the database and make it harder to track down any data level problems. Do these type of products make it better or worse in the already tough case that the database and business object structure must change?</p>
<p>For example:
<a href="http://www.devexpress.com/Products/NET/ORM/" rel="nofollow noreferrer">Object Relation Mapping from Dev Express</a></p>
<p>In essence, is it worth it? Will I save "THAT" much time, effort, and future bugs?</p>
|
<p>I have used SubSonic and EntitySpaces. Once you get the hang of them, I beleive they can save you time, but as complexity of your app and volume of data grow, you may outgrow these tools. You start to lose time trying to figure out if something like a performance issue is related to the ORM or to your code. So, to answer your question, I think it depends. I tend to agree with Eric on this, high volume enterprise apps are not a good place for general purpose ORMs, but in standard fare smaller CRUD type apps, you might see some saved time.</p>
|
<p>There are lots of choices of ORMs. Linq to Sql, nHibernate. For pure object databases there is db4o.</p>
<p>It depends on the application, but for a high volume enterprise application, I would not go this route. You need more control of your data.</p>
| 4,840
|
<p>So, I have an API that I need to implement in to an existing framework. This API manages interactions with an external server. I've been charged with coming up with a way to create an easily repeatable "pattern," so that if people are working on new projects in the given framework they have a simple solution for integrating the API. </p>
<p>My first idea was to create a class for your "main" class of the framework to extend that, would provide all the virtual functions necessary to interact with the API. However, my boss vetoed this, since the existing framework is "inheritence heavy" and he wants to avoid adding to the madness. I obviously can't incapsulate my API, because that is what the API itself is supposed to be doing, and doing so might hide functionality. </p>
<p>Short of asking futures developers to copy and paste my example, what do I do? </p>
|
<p>If your boss is hostile to inheritance, try aggregation. (<em>Has-a</em> relationships rather than inheritance's <em>is-a</em> relationship.) Assuming you interface with the API in question via an object, maybe you can just keep that object in a property of your framework 'main' class, so you'd interact with it like <code>main->whateverapi->doWhatever()</code>. If the API isn't object-implemented or you need to load a lot of functionality specific to your environment onto it, that points toward making your own class that goes into that role and relates to the third party API however it needs to. Yeah, this basically means you're building an API to the API. Aggregation allows you to avoid the masking-functionality problem, though; even if you do have to do an intermediary layer, you can expose the original API as <code>main->yourobject->originalapi</code> and not have to worry about inheritance mucking things up.</p>
|
<p>Sounds to me like what your boss is having a problem with is the Framework part of this. There is an important distiction between Framework and API, in order to code to a framework you must have a good understanding of it and how it fits within your overall development, much more of a wholeistic view, adding to frameworks should never be taken lightly.</p>
<p>API's on the other hand are just an interface to your application / Framework and usually just a library of utility calls, I can't see that he would have a problem with inheritance or aggregation in a library, seems to me that the issue would be creating additional complexity in the framework itself, i.e. requiring developers to extend the main class of the framework is much more onerous than creating a stand alone API library that people can just call into (if they choose) I would be willing to bet that your boss would not care (in fact probably support) if the library itself contained inheritance.</p>
| 49,706
|
<p>I've written a little script to iterate across files in folders to count lines of code.</p>
<p>The heart of the script is this function to count lines of whitespace, comments, and code. (Note that for the moment it is tailored to C# and doesn't know about multi-line comments).</p>
<p>It just doesn't look very nice to me - has anyone got a cleaner version?</p>
<pre><code>// from list of strings return tuple with count of (whitespace, comments, code)
let loc (arr:List<string>) =
let innerloc (whitesp, comment, code) (l:string) =
let s = l.Trim([|' ';'\t'|]) // remove leading whitespace
match s with
| "" -> (whitesp + 1, comment, code) //blank lines
| "{" -> (whitesp + 1, comment, code) //opening blocks
| "}" -> (whitesp + 1, comment, code) //closing blocks
| _ when s.StartsWith("#") -> (whitesp + 1, comment, code) //regions
| _ when s.StartsWith("//") -> (whitesp, comment + 1, code) //comments
| _ -> (whitesp, comment, code + 1)
List.fold_left innerloc (0,0,0) arr
</code></pre>
|
<p>I think what you have is fine, but here's some variety to mix it up. (This solution repeats your problem of ignoring trailing whitespace.)</p>
<pre><code>type Line =
| Whitespace = 0
| Comment = 1
| Code = 2
let Classify (l:string) =
let s = l.TrimStart([|' ';'\t'|])
match s with
| "" | "{" | "}" -> Line.Whitespace
| _ when s.StartsWith("#") -> Line.Whitespace
| _ when s.StartsWith("//") -> Line.Comment
| _ -> Line.Code
let Loc (arr:list<_>) =
let sums = Array.create 3 0
arr
|> List.iter (fun line ->
let i = Classify line |> int
sums.[i] <- sums.[i] + 1)
sums
</code></pre>
<p>"Classify" as a separate entity might be useful in another context.</p>
|
<p>Can't see much wrong with that other than the fact you will count a single brace with <em>trailing</em> spaces as code instead of whitespace.</p>
| 21,023
|
<p>A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only.</p>
<p>Unfortunately I lost the name of the library and was unable to Google it. Anyone any ideas?</p>
<p><strong>Edit:</strong> reStructuredText aka rst == docutils. That's not what I'm looking for :)</p>
|
<p>Okay. I found it now. It's called <a href="http://glyphobet.net/pottymouth/" rel="nofollow noreferrer">PottyMouth</a>.</p>
|
<p><a href="http://sphinx.pocoo.org/" rel="nofollow noreferrer">Sphinx</a> is a documentation generator using reStructuredText. It's quite nice, although I haven't used it personally.</p>
<p>The website <a href="http://sphinx.pocoo.org/" rel="nofollow noreferrer">Hazel Tree</a>, which compiles python text uses Sphinx, and so does the new Python documentation.</p>
| 14,310
|
<p>What book or website would you recommend to learn about QEMU? I'd like to see some usage examples as well as how to use the APIs.</p>
|
<p><strong>Best Resources:</strong></p>
<ul>
<li><a href="http://wiki.qemu.org/Manual" rel="nofollow noreferrer">Main QEMU Usage Documentation</a></li>
<li><a href="http://manpages.ubuntu.com/manpages/lucid/man1/qemu.1.html" rel="nofollow noreferrer">Qemu Man Page</a> - Invaluable resource when working with qemu.</li>
<li><a href="http://ubuntu-tutorials.com/2007/07/04/setting-up-qemu-kqemu-on-ubuntu-704-feisty/" rel="nofollow noreferrer">Quick Start Guide</a> - Slightly ubuntu/debian specific. Covers KVM.</li>
<li><a href="http://www.h7.dion.ne.jp/%7Eqemu-win/HowToNetwork-en.html" rel="nofollow noreferrer">Qemu Networking Guide</a> - Great resource, super useful.</li>
</ul>
<p>Have fun qemu's a great tool.</p>
|
<p><strong>Detailed technical info:</strong></p>
<ul>
<li><a href="http://www.csd.uoc.gr/~hy428/reading/qemu-internals-slides-may6-2014.pdf" rel="noreferrer">http://www.csd.uoc.gr/~hy428/reading/qemu-internals-slides-may6-2014.pdf</a></li>
<li><a href="http://lists.gnu.org/archive/html/qemu-devel/2011-04/pdfhC5rVdz7U8.pdf" rel="noreferrer">http://lists.gnu.org/archive/html/qemu-devel/2011-04/pdfhC5rVdz7U8.pdf</a><br>
I was not able to find the other chapters</li>
<li><a href="http://connect.ed-diamond.com/GNU-Linux-Magazine/GLMF-147/Qemu-Visite-au-caeur-de-l-emulateur" rel="noreferrer">http://connect.ed-diamond.com/GNU-Linux-Magazine/GLMF-147/Qemu-Visite-au-caeur-de-l-emulateur</a> (French only unfortunately)</li>
</ul>
| 18,755
|
<p>In SQL Server 2000/2005,</p>
<p>Is it possible to force the default value to be written to already existing rows when adding a new column to a table <strong>without</strong> using NOT NULL on the new column?</p>
|
<p>You need two statements. First create the column with not null. Then change the not null constraint to nullable</p>
<pre><code>alter table mytable add mycolumn varchar(10) not null default ('a value')
alter table mytable alter column mycolumn varchar(10) null
</code></pre>
|
<p><code>ALTER TABLE {TABLENAME}
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL}
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
[**WITH VALUES]**</code></p>
<p><strong>WITH VALUES</strong> can be used to store the default value in the new column for each existing row in the table.</p>
<p>more detail on MSDN link .
<a href="https://msdn.microsoft.com/en-in/library/ms190273.aspx" rel="nofollow">https://msdn.microsoft.com/en-in/library/ms190273.aspx</a></p>
| 12,571
|
<p>I manage four 3D Printers for my college's robotics team. They are used pretty constantly throughout the school year; that is, they are used more as manufacturing printers than hobbyist printers. The environment they are in is less than ideal: The outdoor climate is typically cold and has low humidity, and the room they are in has fine dust particles that are less than 80 microns diameter and have electrostatic properties. The room's temperature also fluctuates week to week. As such, static electricity is fairly common in that room.</p>
<p>What effects does static electricity have on our 3D printers? I have had numerous problems recently with a motherboard with resistors that failed and another printer with an unknown issue that we suspect also has to do with the motherboard. Could the static electricity be causing these or other issues, or affecting the quality of our printed parts?</p>
<p>We use ZylTech filament, and print using a Creality Ender 3 Pro, CR-10S Pro, Ender 5 Plus, and a FlashForge Creator Pro. The dust particles mimic "regolith", or lunar soil, that comes from one of our team's test facilities.</p>
|
<p>Static electricity is detrimental to nearly all electronic devices. A stray zap from touching the frame of your printer could migrate to the controller boards, terminating normal operation. If you wish to protect the printers from static electricity, connect the frame to a confirmed electrical ground. The power supply may be grounded via the electrical cord, but you'd want to ensure that the entire structure shares that ground. Additionally, provide a <a href="https://www.glinkster.com/how-to-use-anti-static-wrist-strap/" rel="nofollow noreferrer">grounding strap</a> to which an operator would connect prior to using the machine.
Image below courtesy of linked site.</p>
<p><a href="https://i.stack.imgur.com/4DSQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4DSQE.png" alt="anti-static grounding strap" /></a></p>
<p>The more unfortunate aspect of your description is the issue of particulates in the air. Moving parts will be subject to excessive wear and your printer has plenty of moving parts. The stepper motors may "ingest" particles and the fans on the power supply will certainly pull in abrasive dust. The rails and bearings are going to be collecting as well.</p>
<p>If you wish to ensure a longer lifespan for the printer, a filtered enclosure with an overpressure environment is going to be needed. This presumes that one desires to provide cooling air to the printer and power supply. The box around the printer would have to be fed by a fan which is protected by a filter capable of preventing the dust you describe from entering. One could create a box around the printer without fans and another around the power supply with fans and filters.</p>
<p>One could use the reverse concept, that is, build a box from filters and have a fan suck the air into the box, into the fan and back out into the environment. This would provide for a greater surface area of filter material, reducing the frequency of filter changes. In the first example, the box is created from a solid material and the fan forces air for cooling, into the box, as dust-free as the filters will allow. In the reverse method, the box is created from filters and the fan is used to move air from the box to the outside, pulling clean, cool air into the enclosure.</p>
<p>It sounds like a tough place to be a 3D printer.</p>
|
<p>Static electricity does not affect the printing process but it can destroy or disrupt the electronics of the system. The dry air environment is really good for the printing process because keeping moisture out of the filament is one of the most important concerns for a good quality print. Dust is the other. If you can find a solution where the filament is drawn directly from the dry box; that would be best. (I am assuming that you have a dry box ;)</p>
<p>One problem that can occur in especially dry environments is static build-up during printing. A 3D printer can become a mini Van de Graaff generator with static being generated on the spool, being transferred to the nozzle. Normally this is a very rare problem but it sounds like your environment is very dry. You should try earthing the nozzle. Determine a spot on the cold side of the hot end assembly onto which you can connect a wire to earth, and ensure that it is connected via a very large ohmage resistor (100Mohm). This should keep static away from the stepper which should keep it away from the controller.</p>
| 1,858
|
<p>I am using the AJAX Control Toolkit Popup Calendar Control in a datagrid. When it is in the footer it looks fine. When it is in the edit side of the datagrid it is inheriting the style from the datagrid and looks completely different (i.e. too big). </p>
<p>Is there a way to alter the CSS so that it does not inherit the style from the datagrid?</p>
|
<p>Open the page in firefox. However, first, download the firebug extension. Then, right click on the offending version and go down to inspect element.</p>
<p>Firebug is awesome because it let's you navigate the css of any element. You have two options here:</p>
<p>1) Assign the topmost element an css class and work it that way.
or
If that's not an option, you can use firebug to get the xpath to the offending element.
Xpaths look like body/table/tr/td/table/tr[2]</p>
<p>what you want to do with that in css is</p>
<pre><code>body table tr td table tr {
/*css goes here */
}
</code></pre>
<p>Option 1 is definitely the better pick. Option 2 is more of a dirty way of getting things
done when things like asp.net doesn't let us have the fine grain of control we want.</p>
<p>It would be really awesome if you used a pastebin and posted the link to your rendered page's html. </p>
|
<p>It uses the style from the grid, because it's in it. If you want to change it's style, change the style of the control. What do you want it to do?</p>
| 8,967
|
<p>I have a CVS repository on my local workstation. I've demonstrated to my employer that version control is a great idea. Alright! So now I want to migrate my CVS history from my local workstation onto a real server.</p>
<p>I have installed CVS on the server and it is working.</p>
<p>Now, can I just move my repository files? Or do I have to do some sort of import command?</p>
<p>I know I could just check the current codebase into the new CVS server, but that'd lose the history, right?</p>
|
<p>just copy the files - there really isn't anything else to it (at least if source and destination OS are the same)</p>
|
<p>I just migrated one last week. </p>
<p>We're using Subversion at work, and all I did was move the root Subversion directory from one machine to the other. Then when I installed the <a href="http://www.visualsvn.com/server/" rel="nofollow noreferrer">VisualSVN server</a> on the new machine, I just chose the existing Subversion root that I ported rather than creating a new repository. It seamlessly maintained history and files.</p>
<p>I'm not sure how well this will work with other source control systems.</p>
| 28,120
|
<p>Is there an efficient way to take a subset of a C# array and pass it to another peice of code (without modifying the original array)? I use CUDA.net which has a function which copies an array to the GPU. I would like to e.g. pass the function a 10th of the array and thus copy each 10th of the array to the GPU seperately (for pipelining purposes).</p>
<p>Copying the array in this way should be as efficient as copying it in one go. It can be done with unsafe code and just referencing the proper memory location but other than that I'm not sure. The CopyTo function copies the entire array to another array so this does not appear useful.</p>
|
<p>Okay, I'd misunderstood the question before.</p>
<p>What you want is <a href="http://msdn.microsoft.com/en-us/library/system.buffer.blockcopy.aspx" rel="noreferrer">System.Buffer.BlockCopy</a> or <a href="http://msdn.microsoft.com/en-us/library/z50k9bft.aspx" rel="noreferrer">System.Array.Copy</a>.</p>
<p>The LINQ ways will be hideously inefficient. If you're able to reuse the buffer you're copying into, that will also help the efficiency, avoiding creating a new array each time - just copy over the top. Unless you can divide your "big" array up equally though, you'll need a new one for the last case.</p>
|
<p>You could use extension methods and yield return:</p>
<pre><code>public static IEnumerable Part<T>(this T[] array, int startIndex, int endIndex )
{
for ( var currentIndex = startIndex; currentIndex < endIndex; ++currentIndex )
yield return array[currentIndex];
}
</code></pre>
| 33,702
|
<p>Not so much a question as an observation...</p>
<p>I'm just upgrading to SQL Server 2008 on my development machine in anticipation of upgrading my live applications. I didn't anticipate any problems since [I think] I generally use standard T-SQL, and probably not too far from ANSI standard SQL. So far so good, but I was really thrown by a very simple change:</p>
<p>I was creating a simple, small look-up table to store a list of codes and including a bit column to indicate the current default code. But when I used the new/modified 'Edit Top 200 Rows' option, and entered my 0s and 1s in the the bit column I got an error:</p>
<blockquote>
<p>'Invalid value for cell - String was
not recognised as a valid boolean'</p>
</blockquote>
<p>After a bit of head-scratching, I tried True and False - and they worked. </p>
<p>So it seems this new Edit feature requires 4 or 5 characters to be typed, rather than the previous 1.</p>
<p>Checking further, we can still use '<code>...where bitval = 1</code>' but can now also use '<code>...where bitval = 'true'</code>'. But any results returned render these bit columns as 0 or 1 still.</p>
<p>It all sounds like half a step backwards. Not the end of the world, but and unnecessary annoyance.</p>
<p>Does anybody have any insight on this issue? Or there any other new Gotchas with SQL Server 2008?</p>
<p><strong>2012 Update:</strong>
Having just installed SQL Server 2012, I notice that this behaviour has been 'corrected' - Just as I could before, I can now enter 1/0 rather than True/False directly into rows, using the 'Edit Top 200 Rows' option. It's a small thing, but I'm happy.</p>
|
<p>You've always been able to use 'True' and 'False' to compare against BIT columns... I think this change to "force" it is a good one to be clear that the field is a BIT, and not an INT.</p>
<p>Personally, I like that C# doesn't support "if (0) ..." I guess it's just a preference for clarity.</p>
|
<p>Just found this (after preparing soemthing else) <a href="http://msdn.microsoft.com/en-us/library/ms177603.aspx" rel="nofollow noreferrer">Built in by design</a></p>
| 44,336
|
<p>I am developing an application in using Ruby on Rails, mostly as an excuse to learn the language.</p>
<p>This is not intended to be a web-based application - and perhaps I have chosen the wrong language, but...</p>
<p>My understanding is, that in order to run an instance of this application on somebody else's computer, they would need to install ruby on rails, and a webserver (or webrick, perhaps), as well as my application code.</p>
<p>I am just curious if there are any other options for distributing my application as a standalone app, or perhaps just a simple way to package up a web browser and ROR together with my app for a simple, one-step install?</p>
|
<p>I have personally never needed to do this. But, I have ran across this tutorial <a href="http://www.erikveen.dds.nl/distributingrubyapplications/rails.html" rel="noreferrer">http://www.erikveen.dds.nl/distributingrubyapplications/rails.html</a> that I think will be helpful. The tutorial covers how to actually convert a rails app into a standalone exe file.</p>
|
<p>You do not specifically say whether it is supposed to be a GUI application or not. From the other answers, I would guess so. </p>
<p>Therefore, you need to clarify what your goals are. RoR is a specialized framework for web applications. If your goal is to learn RoR, I'd say to get yourself some inexpensive web hosting and make yourself an app. If your goal is to learn Ruby, not necessarily Rails, then Shoes, IronRuby, JRuby, MacRuby and others may be good options to look at. </p>
| 7,953
|
<p>After a year of printing smaller models, I finally went to print something that would take up most of the build plate from left to right and realized that my nozzle cannot reach "true" X home.</p>
<p>As seen in this picture:
<a href="https://i.stack.imgur.com/h4oFv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h4oFv.jpg" alt="enter image description here" /></a>
the X-axis endstop does not allow a true X0, thus losing me precious mm of print space! I over-exaggerate, but truly is there any way to shift the X-axis more to the left or the Y axis/build plate more to the right to gain full bed usage?</p>
<p>Additional photo showing that the actual hotend plate is hitting the endstop:
<a href="https://i.stack.imgur.com/b5NRV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b5NRV.jpg" alt="enter image description here" /></a></p>
<p>Is this an Ender 3 problem in general that I have missed in my internet searches on this or is it just a manufacturing lottery that I unfortunately lost?</p>
|
<p>The rated build space for the Ender 3 takes into account the few mm of inaccessible bed width at the Xmin side, along with a similar strip at the Xmax where the hotend carriage runs into the bracket that holds the wheels for that side's Z frame. If your slicer has an Ender 3 profile, the space it allows you to use will print on the Ender 3 (unless you have bull clips holding a glass build surface in place; then they'll interfere, but mainly on the Ymin and Ymax edges).</p>
<p>Don't forget, even though your actual bed is 235 mm square, the <em>usable</em> build volume is rated as only 200 mm square (by 225 mm high).</p>
|
<p>You do have hit the true home. You will have to physically move the endstop to alter that position. Your problem is, that the endstop-home is on the build area - and that is printer dependant. My Ender 3 has about 4 mm diagonal distance from the bed in its physical home, for which I accounted via a firmware swap, including a "virtual" firmware home.</p>
| 1,839
|
<p>There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away. Would it be enough just to set to null the only referece which points to that subgraph to make it eligible for garbage collection?</p>
<p>My concern is that internal cross-references may "protect" the entire subgraph from garbage collection. In other words, is the garbage collector wise enough to figure out that all references in a subgraph do not leave the boundaries of the subgraph and therefore entire subgraph can be purged.</p>
|
<p>As stated in this <a href="https://stackoverflow.com/questions/176745/circular-references-in-java">SO question</a>, circular reference is well managed.</p>
<p>Java does not do reference counting, it does uses <a href="https://en.wikipedia.org/wiki/Tracing_garbage_collection" rel="nofollow noreferrer">tracing garbage collection</a> (for example mark-and-sweep, copying collection or a some combination thereof). If follows all the active references to find out what objects are "reachable" and then it cleans up everything else.</p>
<p>References in objects not themselves reachable don't affect reachability so it doesn't matter if they are null or not.</p>
<p>About the only case in which setting a reference to null might, conceivably, have a significant effect is in discarding a very large object in the middle of a long running method. </p>
<p>In that case, setting null to the reference of the graph will help making an <strong>island of isolation</strong> (even for internal circular references) as described in this <a href="http://detailfocused.blogspot.com/2008/03/garbage-collection.html" rel="nofollow noreferrer">article</a>.</p>
<p>You will find more details about the unreachable state in <a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html" rel="nofollow noreferrer">The Truth About Garbage Collection</a>:</p>
<p><strong>Unreachable</strong></p>
<p>An object enters an unreachable state when no more strong references to it exist.<br>
When an object is unreachable, it is a candidate for collection. </p>
<p>Note the wording:<br>
Just because an object is a candidate for collection doesn’t mean it will be immediately
collected. The JVM is free to delay collection until there is an immediate need for thememory being consumed by the object.</p>
<p>It’s important to note that not just any strong reference will hold an object in memory. These must be references that chain from a garbage collection root. GC roots are a special class of variable that includes:</p>
<ul>
<li>Temporary variables on the stack (of any thread)</li>
<li>Static variables (from any class)</li>
<li>Special references from JNI native code</li>
</ul>
<p><strong>Circular strong references don’t necessarily cause memory leaks</strong>.
Consider a code creating two objects, and assigns them references to each other.</p>
<pre><code>public void buidDog() {
Dog newDog = new Dog();
Tail newTail = new Tail();
newDog.tail = newTail;
newTail.dog = newDog;
}
</code></pre>
<p>Before the method returns, there are strong references from the temporary stack variables in the <code>buildDog</code> method pointing to both the <code>Dog</code> and the <code>Tail</code>.</p>
<p>After the <code>buildDog</code> method returns, the <code>Dog</code> and <code>Tail</code> both become unreachable from a root and are candidates for collection (although the VM might not actually collect these objects for an indefinite amount of time).</p>
|
<p>The JVM operates on the notion of "islands of unreachability". If there is an unreachable 'island' of interconnected objects then that set of objects is eligible for garbage collection in its entirety.</p>
| 34,150
|
<p>I've been using my Ender 3 for about four months now and it's been working wonderfully. The print quality is amazing and all the prints are very strong. Then about three weeks ago, my entire system crashed while Ultimaker Cura was open and it lost the profile for my 3D printer. I recreated the profile to the best of my ability with other people's working profiles online, but none of them worked right. I've been getting severe under extrusion in all my prints, and they're incredibly fragile. For now, I've just been printing a 1"x1"x1" test cube. I've tried many steps from other people's posts online to fix the problem, including:</p>
<ol>
<li><p>Raising the print temperature for PLA to 200 °C.</p></li>
<li><p>Checking the extruder for signs of too little tension or too much tension. I checked, and the PLA has light tooth imprints on it, and no grinding or damage to the filament.</p></li>
<li><p>Clearing out the extruder. I disassembled the whole extruder assemble, and flushed all the plastic from each part with a heat gun, and metal pick, and then tried reprinting, but it didn't work.</p></li>
<li><p>Trying a newer Ultimaker Cura version. At the time, I was using Ultimaker Cura 3.1 and hadn't updated because it was working well. I then tried the newest stable release of Ultimaker Cura 3.6, with a few different profiles, and then I also tried the beta version of Ultimaker Cura 4.0, but none of these worked.</p></li>
<li><p>Increasing the extrusion rate. I incrementally increased the extrusion rate from 100 % all the way up to 130 %. The prints looked a little better and were a lot stronger, but this still didn't fix it.</p></li>
<li><p>Trying a different slicer. I then downloaded Slic3r and created a new profile in that. The prints turned out a lot better, but there was still significant under extruding.</p></li>
<li><p>Checking the filament tube for any burns or damage, and ensuring it's inside the extruder assembly all the way.</p></li>
</ol>
<p>If anyone can help me figure out what's going on with my printer, I'd really appreciate it!</p>
<p>Here are some pictures of the prints I've been getting:
These were made in Ultimaker Cura with different small changes to the profile made</p>
<p><a href="https://i.stack.imgur.com/zZDWV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zZDWV.jpg" alt="Ultimaker Cura Settings Under Extrusion"></a></p>
<p>These were made in slic3r with a flow rate adjusted up to 130%
<a href="https://i.stack.imgur.com/rV2sO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rV2sO.jpg" alt="Slic3r Under Extrusion"></a></p>
<p>These were prints I made before I lost all my settings in Ultimaker Cura.
<a href="https://i.stack.imgur.com/V7hie.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V7hie.jpg" alt="Good Prints"></a></p>
<p>Here's some of the material I read/watched and checked before posting myself:</p>
<ul>
<li><a href="https://3dprinting.stackexchange.com/questions/2931/i-am-experiencing-some-severe-under-extrusion">I am experiencing some severe under extrusion</a></li>
<li><a href="https://3dprinting.stackexchange.com/questions/6807/sudden-underextrusion-on-ender3">Sudden underextrusion on Ender3</a></li>
<li><a href="https://www.reddit.com/r/3Dprinting/comments/8vxttn/under_extrusion_on_ender_3_sharing_my_mistake_and/" rel="nofollow noreferrer">r/3DPrinting: Under extrusion on Ender 3</a></li>
<li><a href="https://www.youtube.com/watch?v=x35aWmnZ_A0" rel="nofollow noreferrer">Fixing a Filament Flow Problem on CR-10 mini, CR-10 or Ender 3 by CHEP</a></li>
</ul>
<p>Edit: Here's my printer profile:
<a href="https://drive.google.com/file/d/1sn2d9IWmpEiSsuOhOJTkYu7RPEc8xjO1/view?usp=sharing" rel="nofollow noreferrer">Ender 3 Profile Google Drive</a></p>
|
<p>It is not too rare to create a new machine in Ultimaker Cura to be set to 2.85 mm as this is the default. Also some bugs in the past did reset or assume this diameter unless you manually set it, and unless we know your exact version we can't confirm it is really this.</p>
<h2>Underextrusion why?</h2>
<p>The 0.55 mm more radius result in an underextrusion due to the pressed through volume, and since <span class="math-container">$V=A\times l$</span>, we need to see the area to see how severe the underextrusion is for one given extruded length. <span class="math-container">$A_{1.75}=2.405\text{ mm²}$</span> and <span class="math-container">$A_{2.85}=6.379\text{ mm²}$</span> are rather obvious, so <span class="math-container">$\frac {\text{real extrusion diameter}} {\text{calculated extrusion diameter}}=\frac{A_{1.75}}{A_{2.85}}=37.7\ \%$</span>, so only about 40 % of the needed filament is pressed through the nozzle as the slicer thinks it is almost twice the diameter. This matches well with the 130% still being very spotty, as that'd need a much higher factor to compensate for the underextrusion. A compensating extrusion multiplier would be <span class="math-container">$\frac 1 {0.377}=265.25\ \%$</span>.</p>
<h2>Fixing</h2>
<p>To fix this, check under filament and set it to 1.75 mm so you force the correct diameter. Remember that filament diameter is <strong>not</strong> saved in the <em>printer profile</em> but in the <em>material database</em>.</p>
<p>You might need to restart Ultimaker Cura to activate these new settings.</p>
|
<p>The following saved me from under extrusion on Ender 3 Pro.</p>
<ol>
<li><p>Check the diameter of the material referenced and the nozzle parameter in your slicer (Cura, ...). Then re-slice.</p></li>
<li><p>If not sufficient, it may be a printer parameter issue. The extruder parameter is missconfigured: the stepper to filameter distance ratio is not correct and as a result, it does not feed the requested length of filament.
To fix the printer parameter, send the following gcode sequence (use a G-code console like "GCode Sender - Pronterface").
We will follow this procedure:</p>
<ul>
<li>ask to feed 100 mm of filament </li>
<li>mesure the actual length feeded</li>
<li>read the parameter inside the printer</li>
<li>write correct value.</li>
</ul></li>
</ol>
<p>G-code: </p>
<pre><code>M83 ; set to extruder relative mode
; Be ready to mesure how much filament will really be consumed
G1 E100 F100 ; request 100 mm of filament
; Let "L" be the length in mm you mesured
; Now read the extruder related value in the printer
M503 ; and let "V" be the last number at line "echo: M92"
; Then set the correct value
M92 E{V*100/L}; Eg "M92 E222"
M500 ; write to memory
</code></pre>
| 1,242
|
<p>I would like to know what would be the best way to do unit testing of a servlet. </p>
<p>Testing internal methods is not a problem as long as they don't refer to the servlet context, but what about testing the doGet/doPost methods as well as the internal method that refer to the context or make use of session parameters?</p>
<p>Is there a way to do this simply using classical tools such as JUnit, or preferrably TestNG? Did I need to embed a tomcat server or something like that?</p>
|
<p>Most of the time I test Servlets and JSP's via 'Integration Tests' rather than pure Unit Tests. There are a large number of add-ons for JUnit/TestNG available including:</p>
<ul>
<li><a href="http://httpunit.sourceforge.net/" rel="noreferrer">HttpUnit</a> (the oldest and best known, very low level which can be good or bad depending on your needs)</li>
<li><a href="http://htmlunit.sourceforge.net/" rel="noreferrer">HtmlUnit</a> (higher level than HttpUnit, which is better for many projects)</li>
<li><a href="http://jwebunit.sourceforge.net/" rel="noreferrer">JWebUnit</a> (sits on top of other testing tools and tries to simplify them - the one I prefer)</li>
<li><a href="http://watij.com/" rel="noreferrer">WatiJ</a> and Selenium (use your browser to do the testing, which is more heavyweight but realistic)</li>
</ul>
<p>This is a JWebUnit test for a simple Order Processing Servlet which processes input from the form 'orderEntry.html'. It expects a customer id, a customer name and one or more order items:</p>
<pre><code>public class OrdersPageTest {
private static final String WEBSITE_URL = "http://localhost:8080/demo1";
@Before
public void start() {
webTester = new WebTester();
webTester.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
webTester.getTestContext().setBaseUrl(WEBSITE_URL);
}
@Test
public void sanity() throws Exception {
webTester.beginAt("/orderEntry.html");
webTester.assertTitleEquals("Order Entry Form");
}
@Test
public void idIsRequired() throws Exception {
webTester.beginAt("/orderEntry.html");
webTester.submit();
webTester.assertTextPresent("ID Missing!");
}
@Test
public void nameIsRequired() throws Exception {
webTester.beginAt("/orderEntry.html");
webTester.setTextField("id","AB12");
webTester.submit();
webTester.assertTextPresent("Name Missing!");
}
@Test
public void validOrderSucceeds() throws Exception {
webTester.beginAt("/orderEntry.html");
webTester.setTextField("id","AB12");
webTester.setTextField("name","Joe Bloggs");
//fill in order line one
webTester.setTextField("lineOneItemNumber", "AA");
webTester.setTextField("lineOneQuantity", "12");
webTester.setTextField("lineOneUnitPrice", "3.4");
//fill in order line two
webTester.setTextField("lineTwoItemNumber", "BB");
webTester.setTextField("lineTwoQuantity", "14");
webTester.setTextField("lineTwoUnitPrice", "5.6");
webTester.submit();
webTester.assertTextPresent("Total: 119.20");
}
private WebTester webTester;
}
</code></pre>
|
<p>Updated Feb 2018: <a href="https://closingbraces.net/openbrace/" rel="nofollow noreferrer">OpenBrace Limited has closed down</a>, and its ObMimic product is no longer supported.</p>
<p>Another solution is to use my <a href="http://www.openbrace.com" rel="nofollow noreferrer">ObMimic</a> library, which is specifically designed for unit testing of servlets. It provides complete plain-Java implementations of all the Servlet API classes, and you can configure and inspect these as necessary for your tests.</p>
<p>You can indeed use it to directly call doGet/doPost methods from JUnit or TestNG tests, and to test any internal methods even if they refer to the ServletContext or use session parameters (or any other Servlet API features).</p>
<p>This doesn't need an external or embedded container, doesn't limit you to broader HTTP-based "integration" tests, and unlike general-purpose mocks it has the full Servlet API behaviour "baked in", so your tests can be "state"-based rather than "interaction"-based (e.g. your tests don't have to rely on the precise sequence of Servlet API calls made by your code, nor on your own expectations of how the Servlet API will respond to each call).</p>
<p>There's a simple example in my answer to <a href="https://stackoverflow.com/questions/5434419/how-to-test-my-servlet-using-junit">How to test my servlet using JUnit</a>. For full details and a free download see the <a href="http://www.openbrace.com" rel="nofollow noreferrer">ObMimic</a> website.</p>
| 11,623
|
<p>When implementing the ViewModel in a Model-View-ViewModel architecture WPF application there seem to be two major choices how to make it databindable. I have seen implementations that use <code>DependencyProperty</code> for properties the View is going to bind against and I have seen the ViewModel implementing <code>INotifyPropertyChanged</code> instead. </p>
<p>My question is when should I prefer one over the other? Are there any performance differences? Is it really a good idea to give the ViewModel dependencies to WPF? What else do I need to consider when make the design decision?</p>
|
<p>Kent wrote an interesting blog about this topic: <a href="http://kent-boogaart.com/blog/view-models-pocos-versus-dependencyobjects" rel="noreferrer">View Models: POCOs versus DependencyObjects</a>.</p>
<p><strong>Short summary:</strong></p>
<ol>
<li>DependencyObjects are not marked as
serializable</li>
<li>The DependencyObject class overrides and seals the Equals() and
GetHashCode() methods</li>
<li>A DependencyObject has thread affinity – it can only be accessed
on the thread on which it was
created</li>
</ol>
<p>I prefer the POCO approach. A base class for PresentationModel (aka ViewModel) which implements INotifyPropertyChanged interface can be found here: <a href="http://compositeextensions.codeplex.com" rel="noreferrer">http://compositeextensions.codeplex.com</a></p>
|
<p>If you want to expose properties to other controls you must use Dependency properties... But good luck because they take a while to figure out...</p>
| 37,179
|
<p>I have a basic C# console application that reads a text file (CSV format) line by line and puts the data into a HashTable. The first CSV item in the line is the key (id num) and the rest of the line is the value. However I've discovered that my import file has a few duplicate keys that it shouldn't have. When I try to import the file the application errors out because you can't have duplicate keys in a HashTable. I want my program to be able to handle this error though. When I run into a duplicate key I would like to put that key into a arraylist and continue importing the rest of the data into the hashtable. How can I do this in C#</p>
<p>Here is my code:</p>
<hr>
<p>private static Hashtable importFile(Hashtable myHashtable, String myFileName)
{</p>
<pre><code> StreamReader sr = new StreamReader(myFileName);
CSVReader csvReader = new CSVReader();
ArrayList tempArray = new ArrayList();
int count = 0;
while (!sr.EndOfStream)
{
String temp = sr.ReadLine();
if (temp.StartsWith(" "))
{
ServMissing.Add(temp);
}
else
{
tempArray = csvReader.CSVParser(temp);
Boolean first = true;
String key = "";
String value = "";
foreach (String x in tempArray)
{
if (first)
{
key = x;
first = false;
}
else
{
value += x + ",";
}
}
myHashtable.Add(key, value);
}
count++;
}
Console.WriteLine("Import Count: " + count);
return myHashtable;
}
</code></pre>
|
<pre><code>if (myHashtable.ContainsKey(key))
duplicates.Add(key);
else
myHashtable.Add(key, value);
</code></pre>
|
<p>Thank you all.
I ended up using the ContainsKey() method. It takes maybe 30 secs longer, which is fine for my purposes. I'm loading about 1.7 million lines and the program takes about 7 mins total to load up two files, compare them, and write out a few files. It only takes about 2 secs to do the compare and write out the files.</p>
| 16,252
|
<p>I'm looking for an overview over different source code control policies. I only came across the Main-Line policy and would like to better know others before committing to one with the team.</p>
<p>Can someone provide a link to an overview or even give me some names of policies so I can launch google on it?</p>
|
<p>The paper <a href="http://www.cmcrossroads.com/bradapp/acme/branching/" rel="noreferrer">"streamed lines: branching patterns for parallel software development" </a> is an excellent discussion on branching patterns such as the "main line" pattern you mention - it lists the options in the form of patterns together with discussion of anti-patterns. One of the authors is Robert Orenstein of Perforce.</p>
|
<p>My favorite policy is "No subversion commits that do not reference tickets + Auto Trac comments for each commit": <a href="http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook" rel="nofollow noreferrer">http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook</a></p>
| 14,521
|
<p>I am totally new to WPF and looking for good quickstart documentation to start with. I will buy the book WPF Unleashed from Adam Nathan, but thats more a reference than a quickstart i think.<br>
I just want you to tell me your favorite links and books and maybe demo applications concerning wpf development. </p>
<p>Focus of answers should be on best practices, good readable introductions (i hate the link farms on msdn ;) and comprehensive references.</p>
<p>EDIT: I will try to assemble all suggestions in a short list sorted by type.
And please try to give a short reason <em>why</em> you suggest especial that link or that book.</p>
<p><strong>Books:</strong> </p>
<ul>
<li><a href="https://rads.stackoverflow.com/amzn/click/com/0672328917" rel="nofollow noreferrer" rel="nofollow noreferrer">WPF Unleashed by Adam Nathan</a> </li>
<li>Pro WPF: Windows Presentation Foundation in .NET 3.0</li>
<li><a href="https://rads.stackoverflow.com/amzn/click/com/0596510373" rel="nofollow noreferrer" rel="nofollow noreferrer">Programming WPF by Chris Sells and Ian Griffiths</a></li>
</ul>
<p><strong>Blogs:</strong></p>
<ul>
<li><a href="http://www.beacosta.com/blog/" rel="nofollow noreferrer">Blog about data binding in WPF by Beatriz Costa</a></li>
<li><a href="http://www.drwpf.com/blog/" rel="nofollow noreferrer">Ask Dr. WPF</a></li>
<li><a href="http://joshsmithonwpf.wordpress.com/a-guided-tour-of-wpf/" rel="nofollow noreferrer">Guided tour on WPF</a></li>
</ul>
<p><strong>Links:</strong> </p>
<ul>
<li><a href="http://www.microsoft.com/switzerland/msdn/de/presentationfinder/detail.mspx?id=104056" rel="nofollow noreferrer">MSDN Hands-on Lab</a> from Microsoft about WPF</li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms742119.aspx" rel="nofollow noreferrer">msdn on getting started with WPF</a></li>
<li><a href="http://windowsclient.net/" rel="nofollow noreferrer">windowsclient.net</a></li>
<li><a href="http://learnwpf.com/" rel="nofollow noreferrer">Lernwpf.com</a></li>
<li><a href="http://www.codeproject.com/KB/WPF/BeginWPF1.aspx" rel="nofollow noreferrer">Series of articles on Codeproject</a></li>
<li><a href="http://windowsclient.net/learn/videos_wpf.aspx" rel="nofollow noreferrer">Some WPF videos on windowsclient.net</a></li>
</ul>
<p><strong>Demo Applications:</strong></p>
<ul>
<li><a href="http://www.vertigo.com/familyshow.aspx" rel="nofollow noreferrer">Family.Show</a> from Vertigo</li>
<li><a href="http://www.hanselman.com/babysmash/" rel="nofollow noreferrer">Babysmash</a></li>
</ul>
|
<p>Check out the Channel9 <a href="http://channel9.msdn.com/Media/Videos/" rel="nofollow noreferrer">Videos</a> and <a href="http://channel9.msdn.com/Media/Screencasts/" rel="nofollow noreferrer">Screencasts</a> about WPF.</p>
<p>Another resource to get started is the official Microsoft WPF site at <a href="http://windowsclient.net" rel="nofollow noreferrer">windowsclient.net</a>.</p>
|
<p>I have read most of the WPF books on the market. Programming WPF by Chris Sells and Ian Griffiths is the best and Pro WPF the second best IMHO. Just my two cents.</p>
| 22,004
|
<p>I am creating a tool that will check dynamically generated XHTML and validate it against expected contents.</p>
<p>I need to confirm the structure is correct and that specific attributes exist/match. There may be other attributes which I'm not interested in, so a direct string comparison is not suitable.</p>
<p>One way of validating this is with XPath, and I have implemented this already, but I would also like something less verbose - I want to be able to use CSS Selectors, like I can with jQuery, but on the server - within CFML code - as opposed to on the client.</p>
<p><strong>Is there a CFML or Java library that allows me to use CSS Selectors against an XHTML string?</strong></p>
|
<p>I've just released an open source project which is a W3C CSS Selectors Level 3 implementation in Java. Please give it a try. I was looking for the same thing and decided to implement my own engine. It's inspired by the code in WebKit etc.</p>
<p><a href="http://github.com/chrsan/css-selectors/tree" rel="nofollow noreferrer">http://github.com/chrsan/css-selectors/tree</a></p>
|
<p>There is a theoretical difference between the server and client. To a web browser, the document is a living DOM hierarchy. To your server code it's merely an XML document of whatever type. XPath is the "correct" way to access elements of an XML document.</p>
<p>So unless you have a serious performance problem with your current XPath solution, or it doesn't actually work correctly, I suggest you stick with it. Trying something too clever brings the risk of breaking something that's working.</p>
<p>If you find the XPath to be <em>too</em> verbose and ugly to leave sitting around, or want more power to re-use the tool in different cases, or just can't resist trying to do something clever, then you could try writing a utility that compiles a given CSS selector into an XPath. You could then call this in one line whenever you needed.</p>
| 23,493
|
<p>I am using Cygwin with a dll version of 1.5.19 (yes, out-of-date, I know, but we're doing it for configuration control reasons). All my files (existing and newly created) show up with permissions 644, despite a umask of 022. Also, using chmod doesn't change the permissions. I have ntsec set in the CYGWIN environment variable. I need to be able to add execute permissions; is there anything I can try to fix this or is it a lost cause?</p>
<hr>
<p>A much later note: I realized that a key part of the problem is that the files I was trying to chmod were in a ClearCase dynamic view, which uses MVFS. I still have not found way to successfully set the execute permissions, though.</p>
|
<p>Edit <code>/etc/passwd</code> to change the default value for GID for your user to 545 (i.e. NT 'Users' group) instead of 513 ('None' group).</p>
<p>Review system-wide <code>/etc/bash.bashrc</code>, <code>$HOME/.bashrc</code> and <code>.bash_profile</code> for default umask settings.</p>
<p>Even if default, do try to set CYGWIN variable in NT system environment to "binmode ntsec".</p>
<p>Let me know if problems disappear.</p>
|
<p>You need <code>/etc/passwd</code> and <code>/etc/group</code> files for permissions to work correctly.</p>
<p>See <a href="https://cygwin.com/faq/faq.html#faq.using.chmod" rel="nofollow noreferrer">Why doesn't <code>chmod</code> work?</a> in the <a href="http://cygwin.com/faq.html" rel="nofollow noreferrer">Cygwin FAQ</a></p>
<p>and</p>
<p><a href="http://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-files" rel="nofollow noreferrer">File Permissions</a> in the <a href="http://cygwin.com/cygwin-ug-net/cygwin-ug-net.html" rel="nofollow noreferrer">Cgywin User's Guide</a></p>
| 46,587
|
<p>I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.)</p>
<p>I've been told you could do some stuff with telneting to port 25, but I'm very fuzzy on the details. Most of the code snippets on Google assume you have a preexisting account, which doesn't work in this situation.</p>
<p>I am using .NET v3.5 (C# in particular), but I would imagine the ideas are similar enough in most languages. As long as you realize I'm doing this for an offline app, and don't supply me with PHP code or something, we should be fine.</p>
|
<p>As long as your account is on gmail.com, set up <strong>gmail-smtp-in.l.google.com</strong> as the outgoing SMTP-server in your program. You do not need to provide a password to send email to gmail-accounts when using that server.</p>
|
<pre><code>MailMessage msg = new MailMessage("someone@foo.com", "someoneelse@bar.com");
msg.Subject = "Check it out!";
msg.Body = "Visit stackoverflow.com!";
SmtpClient client = new SmtpClient("some.smtp.server", 25);
client.Send(msg);
</code></pre>
| 4,981
|
<p>I am trying to quantify "site slowness". In the olden days you just made sure that your HTML was lightweight, images optimized and servers not overloaded. In high end sites built on top of modern content management systems there are a lot more variables: third party advertising, trackers and various other callouts, the performance of CDN (interestingly enough sometimes content delivery networks make things worse), javascript execution, css overload, as well as all kinds of server side issues like long queries.</p>
<p>The obvious answer is for every developer to clear the cache and continuously look at the "net" section of the Firebug plugin. What other ways to measure "site dragging ass" have you used?</p>
|
<p><a href="http://developer.yahoo.com/yslow/" rel="noreferrer">Yslow</a> is a tool (browser extension) that should help you.</p>
<blockquote>
<p>YSlow analyzes web pages and why they're slow based on Yahoo!'s rules for high performance web sites.</p>
</blockquote>
|
<p><a href="http://httpd.apache.org/docs/2.0/programs/ab.html" rel="nofollow noreferrer">Apache Benchmark</a>. Use </p>
<p><code>ab -c <number of CPUs on server> -n 1000 url</code></p>
<p>to get good approximation of how fast your page is. </p>
| 29,749
|
<p>I've encountered a problem when retrieving a JSONP response from a server in a different domain using IE6.</p>
<p>When I make the same AJAX call using JSONP to a server in the same domain as the web page, all goes well in all browsers (including IE6). However, when I make calls between domains (XSS) using JSONP, Internet Explorer 6 locks up. Specifically, the CPU spikes to 100% and the 'success' callback is never reached. The only time I have had success going between domains is when the response is very short (less than 150 bytes typically). The length of the response seems important.</p>
<p>I'm using jQuery 1.2.6. I've tried the $.getJSON() method and the $.ajax(dataType: "jsonp") method without success. This works beautifully in FF3 and IE7. I haven't been able to find anyone else with a similar problem. I thought this type of functionality was fully supported by jQuery in IE6.</p>
<p>Any help is very appreciated,</p>
<p>Andrew</p>
<hr>
<p><strong>Here is the code for the html page making the AJAX call</strong>. Make a local copy of this file (and jquery library) and give it a shot using IE6. For me, it always causes the CPU to spike with no response rendered.</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/javascript" src="Scripts/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="http://devhubplus/portal/search.js"></script>
</head>
<body>
<a href="javascript:test1(500, 'wikiResults');">Test</a>
<div id="wikiResults" style="margin-top: 35px;"></div>
<script type="text/javascript">
function test1(count, targetId)
{
var dataSourceUrl = "http://code.katzenbach.com/Default.aspx?callback=?";
$.getJSON(dataSourceUrl, {c: count, test: "true", nt: new Date().getTime()}, function(results) {
var response = new String();
response += "<div>";
for(i in results)
{
response += results[i];
response += " ";
}
response += "</div>";
$("#" + targetId).html(response);
});
}
</script>
</body>
</html>
</code></pre>
<p>Here is the JSON that comes back in the response. According to JSLint, it is valid JSON (once you remove the method call surrounding it). The real results would be different, but this seemed like that simplest example that would cause this to fail. The server is a ASP.Net application returning a response of type 'application/json.' I've tried changing the response type to 'application/javascript' and 'application/x-javascript' but it didn't have any affect. I really appreciate the help.</p>
<pre><code>jsonp1222350625589(["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"
,"19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38"
,"39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58"
,"59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78"
,"79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98"
,"99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115"
,"116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132"
,"133","134","135","136","137","138","139","140","141","142","143","144","145","146","147","148","149"
,"150","151","152","153","154","155","156","157","158","159","160","161","162","163","164","165","166"
,"167","168","169","170","171","172","173","174","175","176","177","178","179","180","181","182","183"
,"184","185","186","187","188","189","190","191","192","193","194","195","196","197","198","199","200"
,"201","202","203","204","205","206","207","208","209","210","211","212","213","214","215","216","217"
,"218","219","220","221","222","223","224","225","226","227","228","229","230","231","232","233","234"
,"235","236","237","238","239","240","241","242","243","244","245","246","247","248","249","250","251"
,"252","253","254","255","256","257","258","259","260","261","262","263","264","265","266","267","268"
,"269","270","271","272","273","274","275","276","277","278","279","280","281","282","283","284","285"
,"286","287","288","289","290","291","292","293","294","295","296","297","298","299","300","301","302"
,"303","304","305","306","307","308","309","310","311","312","313","314","315","316","317","318","319"
,"320","321","322","323","324","325","326","327","328","329","330","331","332","333","334","335","336"
,"337","338","339","340","341","342","343","344","345","346","347","348","349","350","351","352","353"
,"354","355","356","357","358","359","360","361","362","363","364","365","366","367","368","369","370"
,"371","372","373","374","375","376","377","378","379","380","381","382","383","384","385","386","387"
,"388","389","390","391","392","393","394","395","396","397","398","399","400","401","402","403","404"
,"405","406","407","408","409","410","411","412","413","414","415","416","417","418","419","420","421"
,"422","423","424","425","426","427","428","429","430","431","432","433","434","435","436","437","438"
,"439","440","441","442","443","444","445","446","447","448","449","450","451","452","453","454","455"
,"456","457","458","459","460","461","462","463","464","465","466","467","468","469","470","471","472"
,"473","474","475","476","477","478","479","480","481","482","483","484","485","486","487","488","489"
,"490","491","492","493","494","495","496","497","498","499"])
</code></pre>
|
<p>you're not going to like this response so much, but I'm convinced it's on your server side.</p>
<p>Here's why:</p>
<p>I've recreated your scenario and when I run with your JSONP responder I get IE6 hanging, as you've explained.</p>
<p>However, when I change the JSONP responder to my own code (exactly the same output as you've give above) it works without any issue (in all browsers, but particularly IE6).</p>
<p>Here's the example I mocked together:</p>
<p><a href="http://jsbin.com/udako" rel="noreferrer">http://jsbin.com/udako</a> (to edit <a href="http://jsbin.com/udako/edit" rel="noreferrer">http://jsbin.com/udako/edit</a>)</p>
<p>The callback is hitting <a href="http://jsbin.com/rs.php?callback=" rel="noreferrer">http://jsbin.com/rs.php?callback=</a>?</p>
<p>Small note - I initially suspected the string length: I've read that strings in IE have a maxlength of ~1Mb which is what you were hitting (I'm not 100% sure if this is accurate), but I changed the concatenation to an array push - which is generally faster anyway.</p>
|
<p>Does you json validate at <a href="http://www.jslint.com" rel="nofollow noreferrer">jslint</a>?
If you have a ur and include the full jquery lib I can debug it for you or post the json and I can try to recreate the issue. Just from the info given it is quite hard to tell.
I have seen some odd things before with the actual names of the keys in the json which breaks on ie6.</p>
| 15,703
|
<p>I have a UINavigationController containing an UIViewController initialized with a UIView.</p>
<p>The UINavigationController also has a UINavigationBar as usual.</p>
<p>Previously when I positioned a new element in the UIView at 0,0 using</p>
<pre><code>CGRectMake(0,0,height,width);
</code></pre>
<p>It would position it directly beneath the UINavigationController. However since compiling with 2.2 it now positions 0,0 directly behind the UINavigationBar (where you would expect 0,0 to be normally).</p>
<p>This only happens when the application is recompiled with the 2.2 SDK - the application left on the iPhone from before the upgrade still works as expected.</p>
<p>Thing is, I quite want my application to draw correctly with 2.2 as well as be backwards compatible with 2.1</p>
<p>Has anyone seen this behaviour, or know anything more about this?</p>
<p>Thanks!</p>
|
<p>There is a whole (very useful) thread on things that 2.2 broke over on the Apple dev forums. It includes this issue (though without any fix). I've seen it mentioned elsewhere as well.</p>
<p>It's worth checking it out</p>
<p><a href="https://devforums.apple.com/message/12297#12297" rel="nofollow noreferrer">https://devforums.apple.com/message/12297#12297</a> (link fixed)</p>
|
<p>It appears this new behaviour is the "intended" behaviour, which makes sense.</p>
<p>It's just a shame it'll be difficult to make my app render correctly in 2.1 <em>and</em> 2.2.</p>
<p>It also seems that if I fiddle with my UINavigationBar transparent/opaque setting I will find some right combination of bugs that will make it appear correctly in both.</p>
<p>Will let you know my findings.</p>
| 46,964
|
<p>We have a simple domain model: Contact, TelephoneNumber and ContactRepository. Contact is entity, it has an identity field. TelephoneNumber is typical value object: hasn't any identity and couldn't be loaded separately from the Contact instance.</p>
<p>From other side we have web application for manipulating the contacts. 1st page is "ContactList", next page is "Contact/C0001" which shows the contact details and the list of telephone numbers.</p>
<p>We have to implement telepone numbers edit form. The first approximation thought is to add some page which will be navigable like 'ThelephoneNumber/T0001'. </p>
<p>But ThelephoneNumber is is Value Object class and its instance couldn't be identified this way.</p>
<p>What is the best practice for resolving this issue? How can we identify non-identifieble objects in the stateless applications?</p>
|
<p>Does the value objects state identify that particular instance? If not you could just pass back the old value and the new value when the edit form is submitted, then update any objects with the old state to the new state. </p>
<p>I would rather have a page like Contact/C0001/ThelephoneNumber, and use both the contact id and the value objects class to identify the instance you want to change.</p>
<p>Unless I've completely misunderstood what you're asking.</p>
|
<p>I would make the TelephoneNumber just contain a bunch of numbers (maybe make it plural), and refer to it this way: Contact/C0001/TelephoneNumber(s)</p>
| 9,784
|
<p>I have mixed views about commercial class libraries. Am I better off using a commercial class library or starting from scratch? If buying a library is the way forward which one for a C# developer?</p>
|
<p>Put a value on your time, say $30 an hour. Estimate how long it would take you to write the library, then add two times that for debugging and testing. Subtract the time it's going to take you to learn how to use the commercial library with the given documentation. Multiply by your hourly rate. Compare.</p>
<p>Writing a library can be fun and rewarding, but "not invented here" syndrome keeps a lot of companies from creating anything useful, as they're stuck reinventing the wheel for additional cost. Make sure it is extensible (if you don't get access to the source) and has what you need. Buy it.</p>
<p>As a personal project, it's probably worth writing it from scratch at least once to see what you can learn, but on company dime you need to be productive and efficient.</p>
<p>Or write it from scratch and release it open source ;)</p>
|
<p>That depends on your goals. If you want to experiment and learn about a certain framework feature it makes sense to try to implement it. </p>
<p>However, if you're trying to make money (or fame or whatever) on your software, you should ask yourself how to best spend your time. How much value do you add to the application by implementing yet another Linked List? Probably not a lot, so use whatever good implementations available. On the other hand, you could add value to your application by implementing a very specific graph control (although there are plenty on the market). So look at it from a return on investment point of view. </p>
| 40,092
|
<p>I have a SVN Repository at my main PC, to which only I have access. I also have a Laptop, and I don't want to lose SVN Functionality when I am not connected to my PC. So at the moment, I simply copy accross the whole Repository to the Laptop and copy it back.</p>
<p>That works well of course (I am the only developer, so there is no access to the repo when I am not in anyway), but it is somewhat tedious to do every time.</p>
<p>I wonder if there is a way to check out a Directory from SVN and store it in a (new) repository on the Laptop, work against that, and then merge that repository with the main one later. (Yes, I know that this would be a good case for distributed systems a la git or Mercurial, but I don't want to lose VisualSVN/TortoiseSVN).</p>
<p>I am not really sure what I am looking for, but I guess I am looking for branching and merging between two repositories: Branch the tree off repo1 into repo2, then merge it back. The caveat here: I'd like to keep the history from repo2. So if I made 10 commits against repo2, I'd like to transfer those 10 commits into repo1 as well, so that I am still able to go back.</p>
<p>Is that even possible, or am I better off still copying the whole repository every time? (It sits in a VM anyway, which means that I copy the whole VM every time).</p>
|
<p>Use some network monitoring tool like <a href="http://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a> to see if your problem is network related or server sync related.</p>
<p>If it proves that it is not a network issue, then try to attach a simple custom sync in the chain (just before the channel) to log and get the timing between the hooks.</p>
|
<p>Never. Are you doing something that's causing extra instances of your remoting layer to be registered/instantiated??</p>
| 43,296
|
<p>I have a case where a VB.Net winforms app needs to play WMV files from across the network. The user running the app cannot be given direct access to the network share. Through impersonation, I can see that the files exist (without impersonation, File.Exists returns false for the files on the network share). When I then try to load the file into a Windows Media Player control, the control just remains black. I have deduced that when the Windows Media Player control is loaded into memory, it is running on a separate unmanaged thread than the .Net managed thread. Is there any way to pass that security token from the managed thread to the unmanaged thread? Am I missing something completely?</p>
|
<p>Have you tried using <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.setthreadprincipal.aspx" rel="nofollow noreferrer"><code>SetThreadPrincipal</code></a> method off <code>AppDomain</code>?</p>
<p>Example:</p>
<p><code>IPrinicipal userPrincipal = new MyCustomPrincipal();</code></p>
<p><code>AppDomain currentDomain = AppDomain.CurrentDomain;</code></p>
<p><code>currentDomain.SetThreadPrincipal(userPrincipal);</code></p>
<p>You mentioned in your question, that WMV seems to run unmanaged, so if that premise is correct, this really shouldn't work (see my second answer).</p>
|
<p>I suppose you tried using </p>
<pre><code>[DllImport("advapi32.dll", SetLastError=true)]
public static extern int LogonUser(string pszUsername, string pszDomain, string pszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
</code></pre>
<p>to log in the network share.</p>
<p>In my experience it doesn't care about threads.</p>
<p>I can show you a usage example if you think it can be useful at all. Kind of a long shot to mention it here.</p>
| 8,885
|
<p>I getting the following error when I try to connect to my server app using remoting:</p>
<blockquote>
<p><em>A problem seems to have occured whilst connecting to the remote server:<br>
Server encountered an internal error. For more information, turn off customErrors in the server's .config file.</em></p>
</blockquote>
<p>This is the code on my server app:</p>
<pre><code>TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);
</code></pre>
<p>It seems to work the first time, but unless the server app is restarted the error occurs.</p>
<p>I would guess something isn't being cleaned up properly but I'm not sure what as the customError is still on.</p>
<p>Any ideas where I start. Thanks.</p>
<p>[EDIT] - Thanks to Gulzar, I modified my code above to the following and now the errors are shown:</p>
<pre><code>RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);
</code></pre>
|
<p>For .Net 1.0/1.1 , you need a config file for remoting server</p>
<p>If you don't have a <code><ServerEXE>.config</code> file, create one and have this in it:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<customErrors mode="off" />
</system.runtime.remoting>
</configuration>
</code></pre>
<p>For .Net 2.0, you can use <a href="http://msdn.microsoft.com/en-us/library/system.runtime.remoting.remotingconfiguration.customerrorsmode.aspx" rel="noreferrer">RemotingConfiguration.CustomErrorsMode</a> property</p>
|
<p>To turn off customErrors, open the <code>web.config file</code> on the server. If there is a <code>customErrors</code> tag, change it. If there isn't one, add it. </p>
<p>It should be <code><customErrors mode="Off"/></code> for this purpose.</p>
<p>If you are indeed using a custom error page, you will want to change this setting once you've found your problem.</p>
| 25,681
|
<p>Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI application which uses those and it is based on MFC.
The goal is to replace the GUI app with the one done in C# instead but using all the same static libraries.
The question is if this even possible, and if yes, then what is the right way to accomplish that?</p>
<p>Suggestions, anybody?
Thanks. </p>
|
<p>Yes, it is possible using C++/CLI for managed C++ code. You would write a C++/CLI WinForms app and simply link in your static lib as per normal.</p>
<p>However, if there is a lot of tight coupling between the GUI code and the libraries then this can get a bit messy. You will need to worry about converting some data types between the managed and unmanaged world, particularly strings. If you need to pass managed objects/arrays</p>
<p>There is a good introduction on <a href="http://en.wikipedia.org/wiki/C%2B%2B/CLI" rel="nofollow noreferrer">Wikipedia</a> and lots of documentation on <a href="http://msdn.microsoft.com/en-us/library/xey702bw.aspx" rel="nofollow noreferrer">MSDN</a>.</p>
|
<p>Yes, it is possible using C++/CLI for managed C++ code. You would write a C++/CLI WinForms app and simply link in your static lib as per normal.</p>
<p>However, if there is a lot of tight coupling between the GUI code and the libraries then this can get a bit messy. You will need to worry about converting some data types between the managed and unmanaged world, particularly strings. If you need to pass managed objects/arrays</p>
<p>There is a good introduction on <a href="http://en.wikipedia.org/wiki/C%2B%2B/CLI" rel="nofollow noreferrer">Wikipedia</a> and lots of documentation on <a href="http://msdn.microsoft.com/en-us/library/xey702bw.aspx" rel="nofollow noreferrer">MSDN</a>.</p>
| 21,539
|
<p>Here's the basic idea:</p>
<p>There is a java window (main) that opens another java window (child). When the child is created, part of the initialization sets the focus in the appropriate text field in the child window:</p>
<pre><code>childTextField.requestFocusInWindow();
childTextField.setCaretPosition(0);
</code></pre>
<p>The child is generally opened through a serious of keystrokes via a command line type interface. When the window is requested, 90%ish of the time, the focus correctly goes to the child window text field and the user can type in the box. If the command to open the child is sent off (with a press of the enter key) and the user immediately starts typing before the new window is created, the text is correctly buffered and appears in the new textfield after the window opens. </p>
<p>However, every once in a while when the user requests the child window to open and then starts typing, their text does NOT appear in the text field. Only after they click with the mouse in the field does the text they have typed appear. It's like it's being stored somewhere and doesn't come out until they click.</p>
<p>The real frustrating thing here is that I can't seem to reliably reproduce the issue at all. It definitely happens, but not regularly enough to debug nicely.</p>
<p>There is of course all kinds of other mojo going on behind the scenes, including communication with a server app, but I'm not convinced it's related.</p>
<p>Any thoughts or ideas would be very much appreciated.</p>
|
<p>On first look, that sounds like it might be a bug in the implementation; the key should be in the same event queue as the mouse events. There's another issue possible though: the event queue is running in a thread separate from the program main; without knowing what's going on in the rest of the application, it's tempting to wonder if the event queue thread is getting blocked somehow.</p>
<p>Actually, the difficulty you're having with reproducing it makes that sound even more likely.</p>
<p>Debugging that case will require a little craft and trickery. If you're on Solaris 10 or OS/X, I'd recommend using dtrace; you can easily put a trace point on the event queue. In not, you might want to have another thread that periodically drops something on the event queue.</p>
|
<p>The event queue thread being blocked sounds VERY likely. Unfortunately I'm on windows, so no dtrace for me, but I'm definitely going to explore that more thoroughly.</p>
<p>Of course anybody else who might have other ideas would be very welcome.</p>
| 46,550
|
<p>I am trying to use Validation in WPF. I created a NotNullOrEmptyValidationRule as shown below: </p>
<pre><code>public class NotNullOrEmptyValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
if (String.IsNullOrEmpty(value as String))
return new ValidationResult(false, "Value cannot be null or empty");
return new ValidationResult(true, null);
}
}
</code></pre>
<p>Now, I need to use it in my application. In my App.xaml file I declared the Style for the TextBox. Here is the declaration. </p>
<pre><code> <Style x:Key="textBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="Green"/>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="Background" Value="Red"/>
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</code></pre>
<p>Now, I want to use it on my TextBox so I am using the following code: </p>
<pre><code> <TextBox Style="{StaticResource textBoxStyle}">
<TextBox.Text>
<Binding>
<Binding.ValidationRules>
<NotNullOrEmptyValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</code></pre>
<p>The error comes on the Tag NotNullOrEmptyValidationRule. The XAML syntax checker is not able to resolve the NotNullOrEmptyValidationRule. I have even tried putting the namespace but it does not seem to work. </p>
|
<p>You just need to add the xmlns to your Window, and use that to reference your ValidationRule. </p>
<p>In WPF, the object is perfectly fine to be used from the same assembly.</p>
<p>Since your rule isn't defined in the standard XAML namespace, you have to create a mapping to your clr namespace like so:</p>
<pre><code><Window ...
xmlns:local="clr-namespace:MyNamespaceName">
</code></pre>
<p>And then you would use it like so:</p>
<pre><code><Binding Path=".">
<Binding.ValidationRules>
<local:NotNullOrEmptyValidationRule />
</Binding.ValidationRules>
</Binding>
</code></pre>
<p><em>Edit</em>
I added a Path statement to the Binding. You have to tell the Binding what to bind to :)</p>
|
<p>There is a bug in Visual Studio and Expression Blend that causes this problem. What you need to do is make sure that the Validation rule is in a separately project/assembly that you can reference. This should resolve the problem.</p>
<p>However, you will have to add back the namespace in order for it to work.</p>
| 12,198
|
<p>This is a question not really about "programming" (is not specific to any language or database), but more of design and architecture. It's also a question of the type "What the best way to do X". I hope does no cause to much "religious" controversy.</p>
<p>In the past I have developed systems that in one way or another, keep some form of inventory of items (not relevant what items). Some using languages/DB's that do not support transactions. In those cases I opted not to save item <em>quantity on hand</em> in a field in the item record. Instead the <em>quantity on hand</em> is calculated totaling inventory received - total of inventory sold. This has resulted in almost no discrepancies in inventory because of software. The tables are properly indexed and the performance is good. There is a archiving process in case the amount of record start to affect performance.</p>
<p>Now, few years ago I started working in this company, and I inherited a system that tracks inventory. But the quantity is saved in a field. When an entry is registered, the quantity received is added to the quantity field for the item. When an item is sold, the quantity is subtracted. This has resulted in discrepancies. In my opinion this is not the right approach, but the previous programmers here swear by it.</p>
<p>I would like to know if there is a consensus on what's the right way is to design such system. Also what resources are available, printed or online, to seek guidance on this.</p>
<p>Thanks</p>
|
<p>I have seen both approaches at my current company and would definitely lean towards the first (calculating totals based on stock transactions).</p>
<p>If you are only storing a total quantity in a field somewhere, you have no idea how you arrived at that number. There is no transactional history and you can end up with problems.</p>
<p>The last system I wrote tracks stock by storing each transaction as a record with a positive or negative quantity. I have found it works very well.</p>
|
<p>Is not having one or two columns, what I meant with "totaling inventory received - total of inventory sold" is something like this:</p>
<pre><code>Select sum(quantity) as inventory_received from Inventory_entry
Select sum(quantity) as inventory_sold from Sales_items
</code></pre>
<p>then </p>
<pre><code>Qunatity_on_hand = inventory_received - inventory_sold
</code></pre>
<p>Please keep in mind that I oversimplified this and my initial explanation. I know there is much more to inventory that just keeping track of quantities, but in this case that's were the problem lies and what we want to fix. At this point the reason to change it is preciselly the cost of supporting the problems caused by the current design.</p>
<p>Also I wanted to mention that although this is not a "coding" question is related to algoritms and design which IMHO are very important topics.</p>
<p>Thanks everybody for your answers so far.</p>
<p>Nelson Marmol</p>
| 36,516
|
<p>I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail. The attachment-adding part looks like this:</p>
<pre><code>using (MemoryStream pdfStream = new MemoryStream())
{
pdfStream.Write(pdfData, 0, pdfData.Length);
Attachment a = new Attachment(pdfStream,
string.Format("Receipt_{0}_{1}.pdf", jobId, DateTime.UtcNow.ToString("yyyyMMddHHmm")));
msg.Attachments.Add(a);
SmtpClient smtp = new SmtpClient(serverName, port);
smtp.Credentials = new NetworkCredential(fromEmailName, fromEmailPassword);
smtp.Send(msg);
}
</code></pre>
<p>The problem is that the attachment gets corrupted on the other end. I found some discussion of this problem <a href="http://www.systemwebmail.com/faq/4.4.8.aspx" rel="noreferrer">here</a>, however the solution mentioned on that page used System.Web.Mail.MailAttachment, which was made obsolete in .NET 2.0. </p>
<p>I've tried changing the TransferEncoding in the Attachment class (which replaces MailAttachment), but had no luck. Has anyone solved this on .NET 2.0?</p>
|
<p>Have you tried doing a <code>pdfStream.Seek(0,SeekOrigin.Begin)</code> before creating the attachment to reset the stream to the beginning?</p>
|
<pre><code>using(MemoryStream memoryStream = new MemoryStream())
{
byte[] contentAsBytes = File.ReadAllBytes(EnterFileLocationOnDisk);
memoryStream.Write(contentAsBytes, 0, contentAsBytes.Length);
// Set the position to the beginning of the stream.
memoryStream.Seek(0, SeekOrigin.Begin);
// Create attachment
ContentType contentType = new ContentType();
//Pick correct media type Octet/PDF/Zip etc.
contentType.MediaType = MediaTypeNames.Application.Octet;
contentType.Name = EnterFileName;
Attachment attachment = new Attachment(memoryStream, contentType);
// Add the attachment
message.Attachments.Add(attachment);
// Send Mail via SmtpClient
client.Send(message);
}
</code></pre>
<p>Of course declare MailMessage() and SmtpClient(). My snippet only shows how to add attachment to MailMessage via memory stream. Your problem was not resetting MemoryStream which is memoryStream.Seek(0, SeekOrigin.Begin);</p>
| 39,557
|
<p>I am looking to use a PHP library for uploading pictures to a web server so that I can use something that has been tested and hopefully not have to design one myself. Does anyone know of such a library?</p>
<p>Edit: I am aware that file uploads are built into PHP, I am looking for a library that may make the process simpler and safer.</p>
|
<p>I personally use <a href="http://pear.php.net/package/HTTP_Upload" rel="noreferrer">HTTP_Upload</a> from PEAR. It works pretty well for our purposes (uplaoding media files into a development system and uploading arbitrary files for an educational system)</p>
|
<p>The <a href="http://framework.zend.com/" rel="nofollow noreferrer">Zend Framework</a> has classes for everything under the sun, including file uploads. Check out the <a href="http://framework.zend.com/manual/en/zend.http.html" rel="nofollow noreferrer">Zend_HTTP</a> class for what you want.</p>
| 12,473
|
<p>I've got a Repeater and its SqlDatasource nested inside a Gridview TemplatedField.<br>
The Repeater's datasource SelectCommand is set using the FormatString of an Eval from the Gridview.<br>
The SelectCommand has a WHERE clause which is to compare a string.<br>
Because I have already used the single and double quotes, I am having trouble delimiting the string in the SQL WHERE clause.</p>
<p><strong>How do I add single quotes inside an Eval FormatString?</strong> </p>
<p>I have tried using '<a href="http://forums.asp.net/p/1116668/1732706.aspx#1732706" rel="noreferrer">Replace</a>'.<br>
I have tried using '<a href="http://www.firstobject.com/dn_markspecialchar.htm" rel="noreferrer">Special Characters</a>' (... WHERE StringField = '{0}' ...) </p>
<p>No luck so far. I appreciate any help you may be able to offer. </p>
<pre><code><asp:GridView ID="GridView1" runat="server" DataSourceID="DataSource1" DataKeyNames="Foo" AutoGenerateColumns="False" AllowSorting="true" >
<Columns>
<asp:BoundField DataField="Foo" HeaderText="Foo" SortExpression="Foo" />
<asp:BoundField DataField="Bar" HeaderText="Bar" SortExpression="Bar" />
<asp:TemplateField>
<ItemTemplate>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="DataSourceNested">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Blah") %>'></asp:Label>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="DataSourceNested" runat="server" DataFile="~/App_Data/DatabaseName"
SelectCommand='<%# Eval("Bar", "SELECT Blah FROM TableName WHERE (StringField = {0})") %>' >
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</code></pre>
|
<p>Don't forget that a .aspx page is simply XML. You just escape the quotes as you normally would.</p>
<p>For example:</p>
<pre><code><asp:Repeater ID="repeatTheLabel" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" Text="<%# Eval(&quot;Id&quot;, &quot;This is item '{0}'.&quot;) %>" runat="server" />
</ItemTemplate>
<SeparatorTemplate>
<br />
</SeparatorTemplate>
</asp:Repeater>
</code></pre>
<p>When the above expression is databound the value between <code><%#</code> and <code>%></code> becomes:</p>
<blockquote>
<p><code>Eval("Id", "This is item '{0}'.")</code></p>
</blockquote>
<p>...which produces on the HTML page as output when databound with an array of objects with "Id" property values from 1 to 5:</p>
<blockquote>
<p>This is item '1'.<br />
This is item '2'.<br />
This is item '3'.<br />
This is item '4'.<br />
This is item '5'.</p>
</blockquote>
|
<p>Have you tried escaping the single quote characters?</p>
<pre><code>... WHERE (StringField = \'{0}\') ...
</code></pre>
| 33,121
|
<p>A couple of weeks ago, my piano teacher and I were bouncing ideas off of each other concerning meta-composing music software. The idea was this:</p>
<p>There is a system taking midi input from a bunch of instruments, and pushes output to the speakers and lights. The software running on this system analyzes the midi data it's getting, and determines which sounds to use, based on triggers set up by the composer (when I play an F7 chord 3 times within 2 seconds, switch from the harpsichord sound to the piano sound), pedals, or actual real-time analysis of the music. It would control the lights based on the performance and sounds of the instruments in a similar fashion - the musician would only have to vaguely specify what they wanted - and real time analysis of their playing would do the rest. On the fly procedurally generated music could play along with the musician as well. Essentially, the software would play along with the performer, with one guiding the other. I imagine that it would take some practice to get use to such a system, but that it could have quite incredible results.</p>
<p>I'm a big fan of improv jazz. One characteristic of improv that is lacking from other art forms is the temporalness of it. A painting can be appreciated 10 or 1000 years after it has been painted, but music (especially extemporized music) is about the performance as it is the creation. I think that the software that I described would add a great deal to the performance, as with it, as playing the exact same piece would result in a completely different show each time.</p>
<p>So, now for the questions.</p>
<p>Am I crazy?</p>
<p>Does software to do any or all of this exist yet? I've done some research and haven't turned up anything. The key to this system is that it is running during the performance.</p>
<p>Were I to write something like this, would a scripting language such as Python be fast enough to do the computations that I need? Presumably it'd be running on a fairly quick system, and could take advantage of the 2^n core processors Intel keeps releasing.</p>
<p>Can any of you share your experience and advice concerning interfacing with musical instruments and lights and the like?</p>
<p>Have any ideas or suggestions? Cold and harsh criticism?</p>
<p>Thanks for your time in reading this, and for any and all advice!
(And sorry for the joke in the tags, I couldn't resist.)</p>
|
<p>People have used <a href="http://www.cycling74.com/products/max5" rel="nofollow noreferrer">Max MSP</a> to do this kind of thing with Midi and creating video accompaniment, or just Midi accompaniment. It's a completely domain specific app, that probably was inspired by small talk or something, which barely any real programmer could love, but musician-programmers do.</p>
<p>Despite the text on the site I just linked to, and the fact that 'everyone' uses the commercial version, it wasn't always a commercial product. <a href="http://www.ircam.fr/" rel="nofollow noreferrer">Ircam</a> eventually released it's own <a href="http://freesoftware.ircam.fr/article.php3?id_article=5" rel="nofollow noreferrer">lineage</a>. It's called <a href="http://freesoftware.ircam.fr/rubrique.php3?id_rubrique=14" rel="nofollow noreferrer">jMax</a>. <a href="http://puredata.info/" rel="nofollow noreferrer">PureData</a>, mentioned in another post here is another rewrite of that lineage.</p>
<p>There's also CSound; which wasn't meant to be real-time, but is likely able to be pretty real-time now that you have a decent computer compared to where CSound started.</p>
<p>Some people have also hacked Macromedia Director extensions to allow for doing midi stuff in Lingo... That's very outdated, and hence some of them have moved to <a href="http://www.adobe.com/newsletters/edge/september2007/articles/article2/index.html" rel="nofollow noreferrer">more modern</a> Adobe environments.</p>
|
<p>The answer to your question is no - you're not crazy.
Similar systems exist, but your description is pretty
vague to begin with so it's not much of a spec to judge against.</p>
<p>I suggest you start writing a prototype and see how it does.
Something extremely small and simple.
Existing systems be damned.</p>
<p>I'm using c++ on win32 api (no mfc).
Started writing my sequencer back on the Amiga500.
It doesn't do lights, but there's plenty to do in just music.</p>
<p>Good luck to you.
It's an EXTREMELY fun project.
I'd say -don't- pattern your project on how other projects work.
Because, if you ask me, they don't work so great ;)
And the fun is being able to do something different.</p>
| 29,863
|
<p>I'm using java and referring to the "double" datatype.
To keep it short, I'm reading some values from standard input that I read in my code as doubles (I would much rather use something like BigInteger but right now it's not possible).</p>
<p>I expect to get double values from the user but sometimes they might input things like:
999999999999999999999999999.9999999999
which I think is beyond an accurate representation for double and get's rounded to 1.0E27 (probably).</p>
<p>I would like to get some pointers on how to detect whether a specific value would be unable to be accurately represented in a double and would require rounding (so that I could refuse that value or other such actions).</p>
<p>Thank you very much</p>
|
<p>Most values entered by humans won't be exactly representable with a double.</p>
<p>For instance, do you want to prevent the user from entering 0.1? That's not exactly representable as a double.</p>
<p>To find the scale of the error, you could do something like:</p>
<pre><code>BigDecimal userAsDecimal = new BigDecimal(userInput);
double userAsDouble = double.parseDouble(userInput);
BigDecimal doubleToDecimal = new BigDecimal(userAsDouble);
BigDecimal error = userAsDecimal.subtract(userAsDouble).abs();
</code></pre>
<p>Then check whether "error" is tolerably small.</p>
|
<p>You can't use a double to store something precisely in the way you're asking, very rarely a user may enter a number that a double can perfectly represent, but that would be coincidence only. If you need to store the exact number you could use a string so long as you don't need to do any manipulation. If you need more than that then there are probably libraries that are made for that kind of precise math.</p>
| 33,721
|
<p>How would you render a tag cloud within a .NET 2.0+ WinForm application?</p>
<p>One solution that I am thinking of would be using the WebBrowser control and generating to some ad-hoc HTML, but that seems to be a pretty heavy solution.</p>
<p>Am I missing something more simple?</p>
|
<p>How about creating a user control that implements the Flow layout control? You could have a method for "Add(string tagName)" that would create a link label on the fly and add it to the Flow Layout control. The Flow Layout works just like the web, in that controls added to it are put in the order of creation. </p>
<p>Then you only have to add some logic to resize the Link Label based on hit count for that tag.</p>
|
<p>Well, you'll want a control with these major features:</p>
<ul>
<li>Automatic layout of variable sized string snippets</li>
<li>Automatic mouse hit testing</li>
</ul>
<p>Those are a bit hard to come by in WF controls. A RichTextBox with ReadOnly = true gives you the automatic layout, but not the hit testing. A ListBox with DrawItem can give you variable sized strings and hit testing, but not a natural layout.</p>
<p>I think I would use RTB and make hit testing work with the MouseDown event and GetCharIndexFromPosition(), reading back the tag at the clicked location. You'll need a bit of logic to find the starting and ending white space around the word.</p>
| 35,148
|
<p>Say a development team includes (or makes use of) graphic artists who create all the images that go into a product. Such things include icons, bitmaps, window backgrounds, button images, animations, etc.</p>
<p>Obviously, everything needed to build a piece of software should be under some form of version control. But most version control systems for developers are designed primarily for text-based information. Should the graphics people use the same version-control system and repository that the coders do? If not, what should they use, and what is the best way to keep everything synchronized?</p>
|
<p>Yes, having art assets in version control is very useful. You get the ability to track history, roll back changes, and you have a single source to do backups with. Keep in mind that art assets are MUCH larger so your server needs to have lots of disk space & network bandwidth.</p>
<p>I've had success with using <a href="http://www.perforce.com/" rel="noreferrer">perforce</a> on very large projects (+100 GB), however we had to wrap access to the version control server with something a little more artist friendly.</p>
<p>I've heard some good things about <a href="http://www.alienbrain.com/" rel="noreferrer">Alienbrain</a> as well, it does seem to have a very slick UI.</p>
|
<p>With respect to diff and merging, I think the version control is more critical for graphics and media elements. If you think about it, most designers are going to be the sole owners of a file -- at least in the case of graphics -- or at least I would think that'd be the case. I'd be curious to hear from a designer.</p>
| 4,894
|
<p>It's quite a simple question - how do I sort a collection?</p>
<p>I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary?</p>
<p>I've clearly been spoilt with .NET and Linq, and now I find myself back in the land of classic asp, realising I must have known this 7 years ago, and missing generics immensely. I feel like a complete n00b.</p>
|
<p>In this case I would get help from big brother .net. It's possible to use <strong>System.Collections.Sortedlist</strong> within your ASP app and get your key value pairs sorted. </p>
<pre><code>set list = server.createObject("System.Collections.Sortedlist")
with list
.add "something", "YY"
.add "something else", "XX"
end with
for i = 0 to list.count - 1
response.write(list.getKey(i) & " = " & list.getByIndex(i))
next
</code></pre>
<p>Btw if the following .net classes are available too:</p>
<ul>
<li>System.Collections.Queue</li>
<li>System.Collections.Stack</li>
<li>System.Collections.ArrayList</li>
<li>System.Collections.SortedList</li>
<li>System.Collections.Hashtable</li>
<li>System.IO.StringWriter</li>
<li>System.IO.MemoryStream;</li>
</ul>
<p>Also see: <a href="http://blog.opennetcf.com/afeinman/PermaLink,guid,aa53e23d-b8e5-4015-b00a-0c8ea9bc6dfe.aspx" rel="noreferrer">Marvels of COM .NET interop</a></p>
|
<p>It's been a long time for me too. IIRC you don't have an option out of the box.</p>
<p>If I were you I'd put all the data in an array and then sort the array. I found a QuickSort implementation here: <a href="https://web.archive.org/web/20210125130007/http://www.4guysfromrolla.com/webtech/012799-3.shtml" rel="nofollow noreferrer">https://web.archive.org/web/20210125130007/http://www.4guysfromrolla.com/webtech/012799-3.shtml</a></p>
| 18,922
|
<p>I always tell in c# a variable of type double is not suitable for money. All weird things could happen. But I can't seem to create an example to demonstrate some of these issues. Can anyone provide such an example?</p>
<p>(edit; this post was originally tagged C#; some replies refer to specific details of <code>decimal</code>, which therefore means <a href="http://msdn.microsoft.com/en-us/library/system.decimal.aspx" rel="noreferrer"><code>System.Decimal</code></a>).</p>
<p>(edit 2: I was specific asking for some c# code, so I don't think this is language agnostic only)</p>
|
<p>Very, very unsuitable. Use decimal.</p>
<pre><code>double x = 3.65, y = 0.05, z = 3.7;
Console.WriteLine((x + y) == z); // false
</code></pre>
<p>(example from Jon's page <a href="http://csharpindepth.com/Articles/General/FloatingPoint.aspx" rel="noreferrer">here</a> - recommended reading ;-p)</p>
|
<p>Actually floating-point <strong>double</strong> is perfectly well suited to representing amounts of money as long as you pick a suitable unit. </p>
<p>See <a href="http://www.idinews.com/moneyRep.html" rel="nofollow">http://www.idinews.com/moneyRep.html</a></p>
<p>So is fixed-point <strong>long</strong>. Either consumes 8 bytes, surely preferable to the 16 consumed by a <strong>decimal</strong> item. </p>
<p>Whether or not something works (i.e. yields the expected and correct result) is not a matter of either voting or individual preference. A technique either works or it doesn't. </p>
| 40,897
|
<p>I have a legacy JBoss 4.0.4/EJB 2.1/PostgreSQL system with zillions of "transaction scripted" procedures as server EJB methods, and many of them have very slow and clumsy execution times due to bad programming practices (like creating temporary tables everytime, etc).</p>
<p>Is there something I can plug in JBoss (Aspect-Like) to monitor the executions of remote EJB methods, capturing start time, and end-time, for further profiling later? The idea is to optimize the most executed methods in the system as much as possible, and then investigate alternatives for a new platform.</p>
|
<p>JBoss publishes JSR-77 statistics for all deployed EJBs. They are accessible through JMX. See the JavaDoc for: <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/management/j2ee/statistics/EJBStats.html" rel="nofollow noreferrer" title="javax.management.j2ee.statistics.EJBStats">javax.management.j2ee.statistics.EJBStats</a> The stats will include the number of invocations and total elapsed execution time, and average execution time can be derived. The use a JMX monitor to acquire the data.</p>
|
<p>This looks like a promising solution: <a href="http://www.jboss.org/jbossprofiler/" rel="nofollow noreferrer">http://www.jboss.org/jbossprofiler/</a></p>
<p>It's not exactly an AOP solution, but it appears it would be fairly simple to set up, and would give you the data you're looking for. </p>
| 41,647
|
<p>I need to write a script to make a source safe project ready to be moved to subversion, what do I need to do so far I can think of:</p>
<ul>
<li>remove .scc files</li>
<li>remove .vspcc files</li>
</ul>
<p>Do I need to remove the "read-only" attribute of all the files as well, or will that not matter?</p>
<p>What language would you write this script in, I was planning to do it in python (os.walk is great), but maybe powershell would be more appropriate to chnage file attributes on windows (if I need to)?</p>
<p>Is there anything else you can think of that needs to be done before I move the project to SVN?</p>
|
<p>For a manual migration (or to understand what happens) :</p>
<ul>
<li>remove "read-only" attribute for all files</li>
<li>remove *.scc</li>
<li>remove *.vssscc</li>
<li>remove *.vspscc</li>
<li>delete *.suo</li>
<li>remove "SourceCodeControl..." section from your solution.sln file</li>
<li>remove "SccProjectName..." section from your projects.csproj files</li>
</ul>
|
<p><a href="http://www.poweradmin.com/sourcecode/vssmigrate.aspx" rel="nofollow noreferrer">http://www.poweradmin.com/sourcecode/vssmigrate.aspx</a></p>
| 11,971
|
<p>This is a line drawing and I would like to print it a couple of mm high. I cannot figure out how to get this line drawing filled. I converted to SVG with Inkscape, used GIMP, took it online to TinkerCad and tried it with Onshape but all I ever get is just the line and this does not work well on my printer. What is a smart way to get this filled in and ready to go?</p>
<p>I use TinkerCad to convert to STL and that works fine. So I could also try to edit the STL in stead of the SVG file.</p>
<p>Maybe I should print the original scanned image (TIFF) and then fill it by hand with black ink and then scan it and convert it to SVG but that sounds really dumb.</p>
<p><a href="https://i.stack.imgur.com/qzDoY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qzDoY.png" alt="should be SVG"></a></p>
<p><strong>UPDATE</strong><br>
I went back to the original drawing and using the bucket tool. The result is a rather noisy image and I need it to be sharp and tight to be able to convert it to a good SVG later on.
Looks like it is more of a graphics design question now..<br>
<a href="https://graphicdesign.stackexchange.com/questions/94773/from-drawing-to-3d-print">https://graphicdesign.stackexchange.com/questions/94773/from-drawing-to-3d-print</a></p>
<p><a href="https://i.stack.imgur.com/jakBT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jakBT.png" alt="enter image description here"></a></p>
|
<p>If you don't mind adding another tool to your toolbox, you can use a plug-in for Inkscape called <a href="https://www.thingiverse.com/thing:14221" rel="nofollow noreferrer">Inkscape OpenSCAD DXF Export</a> that will convert your SVG drawing to appropriate code to import to <a href="http://www.openscad.org/" rel="nofollow noreferrer">OpenSCAD</a>. Even if you aren't keen on learning OpenSCAD, once you have the code, press F5 for a preview, F6 for a rendering and then export the STL file.</p>
<p>The link on Thingiverse gives instructions how to add the plug-in (extension) to Inkscape, which is relatively simple. I've been using the extension for applicable projects with great success. Expect minor complications for closed paths within other paths, however. You may have to create separate STL files for those paths and use Boolean subtraction to remove the "holes" as needed.</p>
<p><a href="https://i.stack.imgur.com/NpFF2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NpFF2.jpg" alt="Inkscape OpenSCAD DXF image"></a></p>
<p>The extension is slightly counter-intuitive. Be sure to manually add the .scad extension to the file as it does not perform that task automatically.</p>
<p>UPDATE: I have discovered that the above link is not the one I've been using. I'm leaving it in place as it may be useful to others to have the ability to create .DXF files from Inkscape. The correct one is called <a href="https://www.thingiverse.com/thing:25036" rel="nofollow noreferrer">Inkscape to OpenSCAD converter v6</a> and works as described above.</p>
<p>As always, read and follow all label instructions. Do not operate heavy machinery after using this product.</p>
<p><a href="https://i.stack.imgur.com/rHHru.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rHHru.jpg" alt="Inkscape to OpenSCAD"></a></p>
|
<p>Free 3D printing program <a href="https://www.nanodlp.com" rel="nofollow noreferrer">NanoDLP</a> does support extruding single image frame to 3D object in required height. You can use Windows or Linux version of the program.</p>
| 645
|
<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?</strong> Should I consider other options that may prevent damage to the internal components? Are there any alternatives with cosmetic benefits?</p>
<p>Edit:
Since I was asked, presume I may be willing to buy a new part to upgrade or accommodate a new filament type.</p>
|
<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 it depends on environment.</p>
<p>For a laptop case you'd maybe want to do it the other way around with the outside shell of TPU and inside layers of PETG for rigidity.</p>
|
<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 provides rigidity and avoids breaking easily itself.</p>
<p>If you were doing an old (90s or earlier) style laptop case that's a tank, I'd actually say yeah, go with TPU 95A or higher (98A or so if you could get it) and add some reinforcement ribs/stiffeners. This stuff can be quite rigid at 100% infill, and it will hold up fine to heat, abrasion, even most chemicals. But if this is a modern slim style case, a small amount of material needs to provide a lot of rigidity and that's not going to work.</p>
<p>PLA actually fares really well here in some ways - it's one of the most rigid printable materials, and very easy to get good bonding. If you check for example CNC Kitchen's strength tests, you'll find plain PLA usually coming out on top of most comparisons. However, PLA doesn't handle heat well, which might rule it out.</p>
<p>ASA, ABS, or PC is probably your best bet, but I don't have any experience with them so I'll leave the part about them as something for another answerer to write.</p>
| 2,139
|
<p>I'm practicing for the upcoming ACM programming competition in a week and I've gotten stumped on this programming problem.</p>
<p><strong>The problem is as follows:</strong></p>
<hr>
<p>You have a puzzle consisting of a square grid of size 4. Each grid square holds a single coin; each coin is showing either heads (H) and tails (T). One such puzzle is shown here:</p>
<blockquote>
<p>H H H H<br>
T T T T<br>
H T H T<br>
T T H T </p>
</blockquote>
<p>Any coin that is current showing Tails (T) can be flipped to Heads (H). However, any time we flip a coin, we must also flip the adjacent coins direct above, below and to the left and right in the same row. Thus if we flip the second coin in the second row we must also flip 4 other coins, giving us this arrangment (coins that changed are shown in bold).</p>
<blockquote>
<p>H <strong>T</strong> H H<br>
<strong>H</strong> <strong>H</strong> <strong>H</strong> T<br>
H <strong>H</strong> H T<br>
T T H T </p>
</blockquote>
<p>If a coin is at the edge of the puzzle, so there is no coin on one side or the other, then we flip fewer coins. We do not "wrap around" to the other side. For example, if we flipped the bottom right coin of the arragnement above we would get:</p>
<blockquote>
<p>H T H H<br>
H H H T<br>
H H H <strong>H</strong><br>
T T <strong>T</strong> <strong>H</strong> </p>
</blockquote>
<p>Note: Only coins showing (T) tails can be selected for flipping. However, anytime we flip such a coin, adjacent coins are also flipped, regardless of their state.</p>
<p>The goal of the puzzle is to have all coins show heads. While it is possible for some arragnements to not have solutions, all the problems given will have solutions. The answer we are looking for is, for any given 4x4 grid of coins what is the least number of flips in order to make the grid entirely heads.</p>
<p>For Example the grid:<br>
H T H H<br>
T T T H<br>
H T H T<br>
H H T T </p>
<p>The answer to this grid is: 2 flips.</p>
<hr>
<p>What I have done so far:</p>
<p>I'm storing our grids as two-dimensional array of booleans. Heads = true, tails = false.
I have a <strong>flip(int row, int col)</strong> method that will flip the adjacent coins according the rules above and I have a <strong>isSolved()</strong> method that will determine if the puzzle is in a solved state (all heads). So we have our "mechanics" in place.</p>
<p>The part we are having problems with is how should we loop through, going an the least amount of times deep?</p>
|
<p>Your puzzle is a classic <a href="http://en.wikipedia.org/wiki/Breadth-first_search" rel="noreferrer">Breadth-First Search</a> candidate. This is because you're looking for a solution with the fewest possible 'moves'.</p>
<p>If you knew the number of moves to the goal, then that would be ideal for a <a href="http://en.wikipedia.org/wiki/Depth-first_search" rel="noreferrer">Depth-First Search</a>.</p>
<p>Those Wikipedia articles contain plenty of information about the way the searches work, they even contain code samples in several languages.</p>
<p>Either search can be recursive, if you're sure you won't run out of stack space.</p>
|
<p>It's a <a href="http://en.wikipedia.org/wiki/Finite_state_machine" rel="nofollow noreferrer">finite state machine</a>, where each "state" is the 16 bit integer corresponding the the value of each coin.</p>
<p>Each state has 16 outbound transitions, corresponding to the state after you flip each coin.</p>
<p>Once you've mapped out all the states and transitions, you have to find the shortest path in the graph from your beginning state to state 1111 1111 1111 1111,</p>
| 29,086
|
<p>How can i find out this information?</p>
<hr>
<p>Ie, </p>
<p>I can install boost 1.35 with a command like</p>
<pre><code>sudo port install boost
</code></pre>
<p>only to get boost 1.36 via port i would do something like this? </p>
<pre><code>sudo port install boost-1.36
</code></pre>
<p>Hope that clears up my question</p>
|
<p>If you're talking Microsoft Visual C++ then I think you get the most control by shelling out msbuild.exe from the nant script and passing it your solution file on the command line. This is supported in Visual Studio 2005/.Net Framework 2.0 and above. e.g.:</p>
<pre><code><property name="msbuild.dir" value="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727" />
...
<exec program="${msbuild.dir}\MSBuild.exe"
commandline="/p:Configuration=Release .\MySolution.sln"
/>
</code></pre>
<p>It will build everything in your solution regardless of language (c#, VB, C++, etc)</p>
<p>Mike</p>
|
<p>If the project is in Visual Studio then you can use the <code><Solution></code> task, I think. That's the simplest/ugliest way of doing it.</p>
<p><strong>edit:</strong> Just realised that SO filtered out my little XML tag there. </p>
| 27,236
|
<p>In unmanaged C/C++ code, what are the best practices to detect memory leaks? And coding guidelines to avoid? (As if it's that simple ;)</p>
<p>We have used a bit of a silly way in the past: having a counter increment for every memory allocation call and decrement while freeing. At the end of the program, the counter value should be zero.</p>
<p>I know this is not a great way and there are a few catches. (For instance, if you are freeing memory which was allocated by a platform API call, your allocation count will not exactly match your freeing count. Of course, then we incremented the counter when calling API calls that allocated memory.)</p>
<p>I am expecting your experiences, suggestions and maybe some references to tools which simplify this.</p>
|
<p>If your C/C++ code is portable to *nix, few things are better than <a href="http://valgrind.org/info/about.html" rel="noreferrer">Valgrind</a>.</p>
|
<p><a href="http://en.wikipedia.org/wiki/Mtrace" rel="nofollow noreferrer">Mtrace</a> appears to be the standard built-in one for linux. The steps are :</p>
<ol> <li>set up the environment variable MALLOC_TRACE in bash<br>
<i>MALLOC_TRACE=/tmp/mtrace.dat</i><br>
<i>export MALLOC_TRACE;</i></li>
<li>Add <i>#include <mcheck.h></i> to the top of you main source file</li>
<li>Add <i>mtrace();</i> at the start of main and <i>muntrace();</i> at the bottom (before the return statement)</li>
<li>compile your program with the -g switch for debug information</li>
<li>run your program</li>
<li>display leak info with <br><i>mtrace your_prog_exe_name /tmp/mtrace.dat</i><br>
(I had to install the mtrace perl script first on my fedora system with <i>yum install glibc_utils</i> )</li>
</ol>
| 6,760
|
<p>What is the keyboard-shortcut that expands the menu, from the little red line, and offers the option to have the necessary <code>using</code> statement appended to the top of the file?</p>
|
<p><kbd>Ctrl</kbd> + <kbd>.</kbd> shows the menu. I find this easier to type than the alternative, <kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>F10</kbd>.</p>
<p>This can be re-bound to something more familiar by going to Tools > Options > Environment > Keyboard > Visual C# > View.QuickActions</p>
|
<p>It's <kbd>ctrl</kbd> + <kbd>.</kbd> when, for example, you try to type <code>List</code> you need to type <code><</code> at the end and press <kbd>ctrl</kbd> + <kbd>.</kbd> for it to work.</p>
| 17,951
|
<p>I am looking for the temperature rating for hardboard. I want to use that as the base for my printer enclosure. </p>
<p>It has proven incredible hard get a ball-park figure from Google. </p>
<p>So, what is the maximum safe temperature for a hardboard panel at long term? (considering a print job can easily take 6 hours).</p>
<p>PS: if you have used a hardboard to build your enclosure, your experience might be helpful.</p>
|
<p>Hardboard is called <em>Masonite</em> here in the States because that is the trade name of the product. If you look up the <a href="http://www.gunnersens.co.nz/images/stories/products/Masonite%20Standard/specs/Australian_Hardboards_Masonite_MSDS.pdf" rel="noreferrer">Material Safety Data Sheet</a> you will see Masonite it states the following (Section 5):</p>
<blockquote>
<p>Auto-ignition Temperature (°C): >200 degrees Celsius</p>
</blockquote>
<p>In Section 7, it states:</p>
<blockquote>
<p>These boards are flammable but difficult to ignite.</p>
</blockquote>
<p>Furthermore in Section 10, it states:</p>
<blockquote>
<p><strong>Conditions to avoid:</strong> Avoid sources of radiant heat and flame; and avoid sparks and sources of ignition in all electrical equipment, including dust extraction equipment.
Avoid excessive build up of dust from boards.</p>
</blockquote>
<p>The hot end works of printers are neither radiant heat, nor flames, nor sparks. Yes, you'll have a buildup of heat within the working confines of an enclosure, but if you are only using it for a base there should be absolutely no issues. If you were to build an entire enclosure from hardboard, you could put a thermal probe inside with the printer to ensure it doesn't get too hot, but realistically, it will never get hot enough within the enclosure to light the hardboard on fire.</p>
|
<p>Masonite or hardboard is a high-density board without a resin. It is <a href="https://www.chromaluxe.com/wp-content/uploads/SDS-Hardboard-Universal-Woods.pdf" rel="nofollow noreferrer">listed</a> at around 200 to 275 °C for its autoignition temperature. Just for comparison, let's look at similar products.</p>
<p>Medium-density fiberboard (MDF) is similar to hardboard but bonded with a resin, offering a smoother surface and is <a href="https://www.westfraser.com/sites/default/files/products/MDF/WP-GoldPlus%202013.pdf" rel="nofollow noreferrer">listed</a> at 200 to 275 °C, so pretty close.</p>
<p>The heavier High-density fiberboard variant is <a href="http://www.clarionindustries.com/assets/files/Clarion-msds-hdf.pdf" rel="nofollow noreferrer">listed</a> with about the same temperatures of about 200 to 275 °C.</p>
<p>Oriented Strand Board (OSB) is <a href="http://www.langboard.com/osb/data/osb_msds.pdf" rel="nofollow noreferrer">listed</a> at 200 to 260 °C.</p>
<h2>Conclusion</h2>
<p>All the materials have very similar autoignition temperatures, so none of them particularly shines over the other. Using a proper fire safety procedure is highly encouraged, even though the ambient temperature in the enclosure should not reach even close to the 200 °C unless the printer has a freak accident and catches fire itself.</p>
<ul>
<li>A smoke detector is a must.</li>
<li>Some kind of cooling method that keeps the inside at a temperature down is highly encouraged. A simple temperature activated fan might help in this.</li>
<li>Lining the inside of the box with a thicker aluminium or copper tape can help to even out the temperature over the surfaces faster, preventing the formation of hotspots that might otherwise reach dangerous temperatures. <a href="https://uk.rs-online.com/web/c/adhesives-sealants-tapes/tapes/copper-tapes/" rel="nofollow noreferrer">Copper tapes</a> are more expensive than <a href="https://uk.rs-online.com/web/c/adhesives-sealants-tapes/tapes/aluminium-tapes/" rel="nofollow noreferrer">Aluminium tapes</a> but have a better heat transfer coefficient.<sup>1</sup></li>
<li>Including an automatic fire suppression system could be an option.</li>
</ul>
<p><sup>1 - The RS Catalogue was just chosen for ease of navigation. <a href="https://www.mcmaster.com/" rel="nofollow noreferrer">McMaster Carr</a> does list special <a href="https://www.mcmaster.com/catalog/125/3591" rel="nofollow noreferrer">heat shielding tape</a> in both thin and aluminium as well as <a href="https://www.mcmaster.com/catalog/125/3587" rel="nofollow noreferrer">copper and aluminium foil</a> tapes. I am not affiliated to either.</sup></p>
| 1,239
|
<p>I have several different c# worker applications that run various continuous tasks: sending emails from queue, importing new orders from website database to orders database, making database backups and restores, running data processing for OLTP -> OLAP, and other related tasks. Before, I released these as windows services, but currently I release them as regular console applications. They are all based on a common task runner framework I created, and I am happy with that, however I am not sure what is the best way to deploy these types of applications. I like the console version because it is quick and easy, and it is possible to quickly see program activity and output. The downside is that the worker computer has several console screens running and it gets messy. On the other hand the service method seems to take to long to deploy and I have to go through event logs to see messages. What are some experiences/comments on this?</p>
|
<p>I like the console app approach. I typically have things set up so I can pass a switch like -unattended that suppresses the console screen.</p>
|
<p>I'm not sure if this applies to your applications or not, but when I have some console applications that are not dependent on user input or they are the kind of applications that just do their job and quit, I run such programs on a virtual server, this way I don't see a screen popping up when I'm working, and virtual servers are easy to create and restart.</p>
| 18,756
|
<p>I was recently given an older ASP web application to maintain. I haven't touched it much, from what I understand, the actual VB6 project files are gone, so I only have the ASP files themselves to work with. Recently, users began complaining of being logged off, sometimes after a minute or less. I tried myself, and logged in once, clicked another link which checks authentication before showing page content, but had to log in again before going back to the page and having it show the content. This behavior seems to have just popped up, as no one has touched it, and it hasn't shown this type of behavior before. Any suggestions on where to begin? Thanks.</p>
|
<p>As there are many ways to store user session, it's hard to tell what's happening here without more information.</p>
<p>If users are being logged off "randomly" that suggests to me that you are using the Session object to store authentication information. One of the following may be happening:</p>
<ol>
<li><p>IIS is recycling (restarting) your application. This blows away your Session objects. More info: <a href="http://msdn.microsoft.com/en-us/library/ms525803.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms525803.aspx</a></p></li>
<li><p>This is somewhat basic, but are you using more than one web server in some kind of load-balancing configuration? The session object is machine-specific.</p></li>
</ol>
<p>Another possibility. This would apply even if you are not using the Session object. I have seen this happen many times.</p>
<ol start="3">
<li>Is your application accessible via multiple URLs? In other words, both <a href="http://www.mysite.com" rel="nofollow noreferrer">http://www.mysite.com</a> and <a href="http://mysite.com" rel="nofollow noreferrer">http://mysite.com</a>. Cookies (and sessions) are domain specific and those count as two separate domains. Perhaps they're being bounced around between the two sites thanks to factors such as having pages from both domains bookmarked or because of non-relative links/redirects within your site. </li>
</ol>
|
<p>Is the authentication token being stored in a cookie, and cookies are now turned off in your browser?</p>
| 49,164
|
<p>Currently I'm tasked with doing the daily build. We have an ASP.NET 2005 website with a SQL Server 2005 backend. Our current source control is Visual Source Safe 2005.</p>
<p>At this point, I use the brute-force method of daily builds.</p>
<ol>
<li>Get Latest version of source code</li>
<li>Get Latest version of Database release script</li>
<li>Backup old website files to a directory</li>
<li>Publish new code to my local machine</li>
<li>Run on my server to keep the test/stage site working</li>
<li>Push newly created files to the website</li>
<li>Run SQL Script on test database (assuming updates, otherwise I don't bother)</li>
<li>Test website on the Test Server.</li>
</ol>
<p>Looking at the idea of automated builds intrigues me since it means that I do less each morning. How would you recommend I proceed? I want to have a fully fleshed out idea before I present it to my boss.</p>
|
<p><a href="http://jamesstory.wordpress.com/category/automated-builds/" rel="nofollow noreferrer">Ditch VSS, move to Subversion, and check out CruiseControl.NET.</a> Alternatively, if you have a MSDN developer license, you can run TFS workgroup edition and set up a build server on any old XP box. Its what we do at our shop. </p>
<hr>
<p>As Assaf noted, you can use CC.NET with VSS directly. Nice.</p>
|
<p>I second (or third) the reccomendation for Subversion/CruiseControl.net. Also, if it is appropriate, check out hosted services for SVN like CVSDude. You'll probably become well versed with MSBuild in the process too. Once you get it setup it is great.</p>
<p>The cost doesn't come from licensing of the tools or even hardware necessarily, but from your time building and maintaining the system - and depending on what you are doing, that could become significant. </p>
<p>Start with the basics and incrementally improve it over time. Like anything else, if you try to come out of the gate with lots of automation and functionality you could find yourself mired in it fulltime for weeks.</p>
| 37,024
|
<p>I have a Perl script where I maintain a very simple cache using a hash table. I would like to clear the hash once it occupies more than n bytes, to avoid Perl (32-bit) running out of memory and crashing. </p>
<p>I can do a check on the number of keys-value pairs:</p>
<pre><code>if (scalar keys %cache > $maxSize)
{
%cache = ();
}
</code></pre>
<p>But is it possible to check the actual memory occupied by the hash?</p>
|
<p><a href="http://search.cpan.org/perldoc?Devel::Size" rel="noreferrer">Devel::Size</a> is the answer to your question. (Note that Devel::Size will temporarily allocate a significant amount of memory when processing a large data structure, so it's not really well suited to this purpose.)</p>
<p>However, <a href="http://search.cpan.org/perldoc?Cache::SizeAwareMemoryCache" rel="noreferrer">Cache::SizeAwareMemoryCache</a> and <a href="http://search.cpan.org/perldoc?Tie::Cache" rel="noreferrer">Tie::Cache</a> already implement what you're looking for (with somewhat different interfaces), and could save you from reinventing the wheel.</p>
<p><a href="http://search.cpan.org/perldoc?Memoize" rel="noreferrer">Memoize</a> is a module that makes it simple to cache the return value from a function. It doesn't implement a size-based cache limit, but it should be possible to use Tie::Cache as a backend for Memoize.</p>
|
<p>As others have said, caching is not a wheel you need to re-invent, there's plenty of simple caching solutions on CPAN which will do the job nicely for you.</p>
<p><a href="http://search.cpan.org/perldoc?Cache::SizeAwareMemoryCache" rel="nofollow noreferrer">Cache::SizeAwareMemoryCache</a> can be told the maximum size you want it to use, then you can leave it to care about the cache for you.</p>
| 13,211
|
<p>Is there a way to ensure all created subprocess are dead at exit time of a Python program? By subprocess I mean those created with subprocess.Popen().</p>
<p>If not, should I iterate over all of the issuing kills and then kills -9? anything cleaner?</p>
|
<p>You can use <a href="http://docs.python.org/library/atexit.html" rel="noreferrer"><strong>atexit</strong></a> for this, and register any clean up tasks to be run when your program exits. </p>
<p><strong>atexit.register(func[, *args[, **kargs]])</strong></p>
<p>In your cleanup process, you can also implement your own wait, and kill it when a your desired timeout occurs.</p>
<pre><code>>>> import atexit
>>> import sys
>>> import time
>>>
>>>
>>>
>>> def cleanup():
... timeout_sec = 5
... for p in all_processes: # list of your processes
... p_sec = 0
... for second in range(timeout_sec):
... if p.poll() == None:
... time.sleep(1)
... p_sec += 1
... if p_sec >= timeout_sec:
... p.kill() # supported from python 2.6
... print 'cleaned up!'
...
>>>
>>> atexit.register(cleanup)
>>>
>>> sys.exit()
cleaned up!
</code></pre>
<p><strong>Note</strong> -- Registered functions won't be run if this process (parent process) is killed.</p>
<p><strong>The following windows method is no longer needed for python >= 2.6</strong></p>
<p>Here's a way to kill a process in windows. Your Popen object has a pid attribute, so you can just call it by <strong>success = win_kill(p.pid)</strong> (Needs <a href="http://sourceforge.net/projects/pywin32/" rel="noreferrer">pywin32</a> installed):</p>
<pre><code> def win_kill(pid):
'''kill a process by specified PID in windows'''
import win32api
import win32con
hProc = None
try:
hProc = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, pid)
win32api.TerminateProcess(hProc, 0)
except Exception:
return False
finally:
if hProc != None:
hProc.Close()
return True
</code></pre>
|
<p>This is what I did for my posix app:</p>
<p>When your app exists call the kill() method of this class:
<a href="http://www.pixelbeat.org/libs/subProcess.py" rel="nofollow noreferrer">http://www.pixelbeat.org/libs/subProcess.py</a></p>
<p>Example use here:
<a href="http://code.google.com/p/fslint/source/browse/trunk/fslint-gui#608" rel="nofollow noreferrer">http://code.google.com/p/fslint/source/browse/trunk/fslint-gui#608</a></p>
| 41,420
|
<p>I've tried Red Gate's SQL Prompt and like it, but cannot afford it at the moment. I miss the good code completion that this tool provides. Are there any good free tools out there that have SQL code completion (table and column names, etc)?</p>
<p>I've tried TOAD, but it was quite buggy. It would crash, and would also leave connections open to the database after the app was closed.</p>
<p>I'm also aware that SQL Server 2008 has some form of code completion, but it requires that the database you are connected to be 2008, not just the Management Studio version. My employer will eventually upgrade, but I believe this may be a while in coming, so I'd like a good tool in the interim.</p>
<p>Any good recommendations?</p>
|
<p>Red Gate's <a href="http://www.red-gate.com/products/SQL_Prompt/index.htm" rel="noreferrer">SQL Prompt</a> is what you want. It's not free, but it <strong>is</strong> worth it.</p>
|
<p>When RedGate bought SQL Prompt, they put out the current version at the time for free. That's what I'm still using. It's not as solid as the new one, but it doesn't have issues with remote servers - which is what i use for most of the day. See if you can get your hands on a copy of that. (version 2.0.0.59)</p>
| 27,429
|
<p>While working on a C# app I just noticed that in several places static initializers have dependencies on each other like this:</p>
<pre><code>static private List<int> a = new List<int>() { 0 };
static private List<int> b = new List<int>() { a[0] };
</code></pre>
<p>Without doing anything special that worked. Is that just luck? Does C# have rules to resolve this?</p>
<p><strong>Edit:</strong> (re: Panos) In a file lexical order seems to be king? what about across files?</p>
<p>In looking I tried a cyclical dependency like this:</p>
<pre><code>static private List<int> a = new List<int>() { b[0] };
static private List<int> b = new List<int>() { a[0] };
</code></pre>
<p>and the program didn't run the same (the test suit failed across the board and I didn't look further).</p>
|
<p>It seems to depend on the sequence of lines. This code works:</p>
<pre><code>static private List<int> a = new List<int>() { 1 };
static private List<int> b = new List<int>() { a[0] };
</code></pre>
<p>while this code does not work (it throws a <code>NullReferenceException</code>)</p>
<pre><code>static private List<int> a = new List<int>() { b[0] };
static private List<int> b = new List<int>() { 1 };
</code></pre>
<p>So, obviously no rules for cyclical dependency exist. It's peculiar however that the compiler does not complain...</p>
<hr>
<p>EDIT - What's happening "across files"? If we declare these two classes:</p>
<pre><code>public class A {
public static List<int> a = new List<int>() { B.b[0] };
}
public class B {
public static List<int> b = new List<int>() { A.a[0] };
}
</code></pre>
<p>and try to access them with this code:</p>
<pre><code>try { Console.WriteLine(B.b); } catch (Exception e) { Console.WriteLine(e.InnerException.Message.); }
try { Console.WriteLine(A.a); } catch (Exception e) { Console.WriteLine(e.InnerException.Message); }
try { Console.WriteLine(B.b); } catch (Exception e) { Console.WriteLine(e.InnerException.Message); }
</code></pre>
<p>we are getting this output:</p>
<pre><code>The type initializer for 'A' threw an exception.
Object reference not set to an instance of an object.
The type initializer for 'A' threw an exception.
</code></pre>
<p>So the initialization of <code>B</code> causes an exception in static constructor <code>A</code> and lefts field <code>a</code> with the default value (null). Since <code>a</code> is <code>null</code>, <code>b</code> can not also be initialized properly.</p>
<p>If we do not have cyclical dependencies, everything works fine.</p>
<hr>
<p>EDIT: Just in case you didn't read the comments, <a href="https://stackoverflow.com/users/22656/jon-skeet">Jon Skeet</a> provides a very interesting reading: <a href="http://csharpindepth.com/Articles/General/Beforefieldinit.aspx" rel="nofollow noreferrer">The differences between static constructors and type initializers</a>.</p>
|
<p>Yes, you were lucky. C# appears to execute the code in the order it appears in the class.</p>
<pre><code>static private List<int> a = new List<int>() { 0 };
static private List<int> b = new List<int>() { a[0] };
</code></pre>
<p>Will work but ... </p>
<pre><code>static private List<int> b = new List<int>() { a[0] };
static private List<int> a = new List<int>() { 0 };
</code></pre>
<p>Will fail.</p>
<p>I would recommend putting all your dependencies in one place, the static constructor is the place for this.</p>
<pre><code>static MyClass()
{
a = new List<int>() { 0 };
b = new List<int>() { a[0] };
}
</code></pre>
| 22,417
|
<p>I'm looking for a way to selectively apply a CSS class to individual rows in a <code>GridView</code> based upon a property of the data bound item.</p>
<p>e.g.:</p>
<p>GridView's data source is a generic list of <code>SummaryItems</code> and <code>SummaryItem</code> has a property <code>ShouldHighlight</code>. When <code>ShouldHighlight == true</code> the CSS for the associated row should be set to <code>highlighted</code></p>
<p>any ideas?</p>
|
<p>very easy</p>
<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = e.Row.DataItem as DataRowView;
if (drv["ShouldHighlight"].ToString().ToLower() == "true")
e.Row.CssClass = "highlighted";
}
}
</code></pre>
<p>the code above works if you use a <strong>DataTable as DataSource</strong></p>
<p>change to:</p>
<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
myClass drv = (myClass)e.Row.DataItem;
if (drv.ShouldHighlight)
e.Row.CssClass = "highlighted";
}
}
</code></pre>
<p>just for the example above when using generics:</p>
<pre><code>public class myClass
{
public Boolean ShouldHighlight
{ get; set; }
}
</code></pre>
<p>if you are working with <strong>Generics</strong> (List, Dictionary, etc)</p>
<p>keep in mind:</p>
<pre><code>e.Row.dataItem
</code></pre>
<p>always return the entire object that you are populating the row with, so it is easy from here to manipulate the appearance of the data in the webpage.</p>
<p>you should use RowDataBound event that will trigger after the data is attached to the row object but not yet written the HTML code in the page, in this way you can check the ShouldHighlight value (I converted to a String cause I do not know the type, you can change it if you know it's a boolean value).</p>
<p>this code runs much faster than megakemp code cause you're not creating a List object and populated with the entire data source for each row...</p>
<p><em>P.S. take a <a href="http://gridviewguy.com/Categories/7_GridView_Articles.aspx" rel="noreferrer">look at this website</a>, you can find several tutorials for your project using the GridView object</em></p>
|
<p>One thing you want to keep in mind is that setting the Row.CssClass property in the RowCreated or RowDataBound event handlers will override any default styles you may have applied at the grid level. The GridView gives you easy access to row styles via properties such as:</p>
<pre><code>gvGrid.AlternatingRowStyle.CssClass = ALTROW_CSSCLASS
gvGrid.RowStyle.CssClass = ROW_CSSCLASS
</code></pre>
<p>However, when you assign a CssClass value to a specific row, as is your need in this case, the assignment overrrules any top-level assignment at the grid level. The assignments will not "cascade" as we might like them to. So if you want to preserve the top-level class assignment and also layer on your own, more specific one, then you would need to check the rowState to see what kind of row you are dealing with and concatenate your class names accordingly</p>
<pre><code>If(item.ShouldHighlight)
{
If(e.Row.RowState == DataControlRowState.Alternate)
{
e.Row.CssClass = String.Format("{0} {1}", "highlight", ALTROW_CSSCLASS)
}
else
{
e.Row.CssClass = String.Format("{0} {1}", "highlight", ROW_CSSCLASS)
}
}
</code></pre>
| 25,512
|
<p>Can anyone give me a complete list of string manipulation function in Microsoft SQL Server (2000 or 2005)?</p>
<p>(I don't need a lecture about doing all my string processing in the presentation layer. And, I don't need a list of MySQL string functions.)</p>
<p>Thanks!</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/ms181984.aspx" rel="noreferrer">String Functions (Transact-SQL)</a></p>
|
<p>MSDN and Google are your friends</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms181984.aspx" rel="nofollow noreferrer">here is the 2008 version</a>, drill down to your specific flavor.</p>
| 27,523
|
<p>I have some accesses from 192.168.0.71 on my apache logs. I looked up this IP (because my server almost exclusively takes requests from 127.0.0.1, and I saw that it's reserved for "special purposes." What types of purposes might those be?</p>
<hr>
<p>Edit:</p>
<p>I didn't tell you, typing 192.168.0.71 brings me straight to my site, just as 127.0.0.1 would. I just wonder how this is different, then from 127.0.0.1.</p>
|
<p><a href="http://www.faqs.org/rfcs/rfc1918.html" rel="nofollow noreferrer">RFC 1918</a> reserves addresses starting with 192.168 for private networks. This most likely means that some computer on your local network is accessing the server.</p>
|
<p>The 192.168.0.0 network is defined as being one of the "private" networks.
As <a href="https://stackoverflow.com/questions/145027/192168071-what-is-this-special-address-used-for#145044">Krzysiek Goj</a> has said, check <a href="http://en.wikipedia.org/wiki/Classful_network" rel="nofollow noreferrer">this link</a> for further details.</p>
<p>There are 3 ranges that have been designated as private ip addresses.
- 10.0.0.0/8 (meaning 10.0.0.0 to 10.255.255.255)
- 172.16.0.0/12 (meaning 172.16.0.0 - 172.31.255.255)
- 192.168.0.0/16 (meaning 192.168.0.0 to 192.168.255.255)</p>
<p>Typically a DHCP server on your network (of which most network switches are examples) are configured to dynamically hand out ip addresses in one of the private ranges. The 192.168.0.0/16 range is probably the most popular. Alternatively you may have been statically allocated one of these addresses by your network administrator.</p>
<p>To check the address that you've been allocated you can use one of the following:
- (windows) ipconfig /all
- (unix) ifconfig</p>
<p><a href="https://stackoverflow.com/questions/113293/is-the-host-localhost-always-available-for-the-own-system#113383">By default</a> your machine will also have a loopback interface enabled using the address 127.0.0.1. This can be used to access your own machine.</p>
| 17,489
|
<p>Is there any free tool available for creating and editing PNG Images?</p>
|
<p><a href="http://getpaint.net/" rel="noreferrer">Paint.NET</a> will create and edit PNGs with gusto. It's an excellent program in many respects. It's free as in beer and speech. </p>
|
<p><a href="http://www.imagemagick.org/" rel="nofollow noreferrer">ImageMagick</a> and <a href="http://www.libgd.org/" rel="nofollow noreferrer">GD</a> can handle PNGs too; heck, you could even do stuff with nothing but <a href="http://library.gnome.org/devel/gdk-pixbuf/stable/" rel="nofollow noreferrer">gdk-pixbuf</a>. Are you looking for a graphical editor, or scriptable/embeddable libraries?</p>
| 22,098
|
<p>We have some software we use internally which is released via ClickOnce from VS 2008.</p>
<p>The app needs to run on everyones computer all the time so the obvious solution is to have it in the Start Up folder of their start menu. This works fine on XP machines. But, as was inevitable, people are moving to Vista. Now we're hitting a problem where people who have Vista no longer have the application run on start up.</p>
<p>From what it looks like the problem is caused by the fact that the application isn't digitally signed, unlike other programs in the Start Up.</p>
<p>Do I need to have the app digitally signed? If so how do I go about this?</p>
|
<p>You do need a certificate but there is no need to go to Verisign or any other outside vendor if you are just doing it for your own company.</p>
<p>From within Visual Studio you can create a certificate yourself and add a bootstrap to your ClickOnce application to allow the clients to accept it as a cert from a Trusted Publisher.</p>
<p>MSDN has an <a href="http://msdn.microsoft.com/en-us/library/ms996418.aspx" rel="nofollow noreferrer">excellent article</a> on this whole process.</p>
|
<p>If you buy a certificate, here's a <a href="http://www.softinsight.com/bnoyes/CommentView.aspx?guid=78d107d1-3937-4d8d-81d9-73cb6ae18eee" rel="nofollow noreferrer">great article</a> on how to create the files you will need to sign your assemblies.</p>
<p>Also, you don't <em>have</em> to purchase a cert. You can create a <a href="http://msdn.microsoft.com/en-us/library/bfsktky3.aspx" rel="nofollow noreferrer">self-signed certificate</a> as well. The biggest "downside" to this is that your app's publisher will appear as "Unknown". Not great for a commercial product but probably just fine for an internal app.</p>
| 41,790
|
<p>I need to invoke a VBA macro within an Excel workbook from a python script. Someone else has provided the Excel workbook with the macro. The macro grabs updated values from an external database, and performs some fairly complex massaging of the data. I need the results from this massaging, and I don't really want to duplicate this in my Python script, if I can avoid it. So, it would be great if I could just invoke the macro from my script, and grab the massaged results.</p>
<p>Everything I know about COM I learned from "Python Programming on Win32". Good book, but not enough for my task at hand. I searched, but haven't found any good examples on how to do this. Does anyone have any good examples, or perhaps some skeleton code of how to address/invoke the VBA macro? A general reference (book, web link, etc) on the Excel COM interfaces would also help here. Thanks.</p>
|
<p>OK, I got it! Thanks for the help on the Application.Run method. This info, plus the "Microsoft Excel Visual Basic Reference": <a href="http://msdn.microsoft.com/en-us/library/aa209782(office.10).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa209782(office.10).aspx</a>--as recommended by Hammond & Robinson in "Python Programming on Win32"--was what was needed.</p>
<p>Here's the skeleton code:</p>
<pre><code>import win32com.client
xl=win32com.client.Dispatch("Excel.Application")
xl.Workbooks.Open(Filename="<your Excel File>",ReadOnly=1)
xl.Application.Run("<your macro name>")
#...access spreadsheet data...
xl.Workbooks(1).Close(SaveChanges=0)
xl.Application.Quit()
xl=0
</code></pre>
|
<p>I am sorry, I dont know python enough.
However, the following should help.</p>
<p>Excel's Application object has a Run method - which takes the name of the macro alongwith arguments to it.</p>
<p>Lets assume that the workbook has a macro named test.</p>
<pre>
<code>
Sub test(ByVal i As Integer)
MsgBox "hello world " & i
End Sub
</code>
</pre>
<p>You can call this using Application.Run "test", 1234</p>
<p>This will call the macro and show the messagebox with "hello world 1234".</p>
| 45,007
|
<p>Sign. My tsql kungfu sucks. I have a fee that is of type small money. When I exported as SQL from MS Access the column that represents the fee was stored as text, for example $3.28 was stored as "00000328". When I imported this into MS SQLServer I changed the data type to smallmoney, but it was stored as 328. How do I make all the values on that column to move the "." two digits over to the left. </p>
|
<p>divide by 100</p>
|
<p>If I understood you correctly, this should do the trick. Only run it once, though. Replace "table" with the name of your table and "fee" with the name of your column.</p>
<pre><code>update table
set fee = fee / 100.0
</code></pre>
| 30,340
|
<p>We've been doing some printing with PETG filament on Ender 3 Pro printer and the result were awful:
<a href="https://i.stack.imgur.com/1k0ej.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/1k0ej.jpg" alt="Overview of failed PETG prints"></a></p>
<p>Here are settings we used:</p>
<ul>
<li>Extruder: 240 °C</li>
<li>Bed: ~70 °C (± 10 °C)</li>
<li>Speed: 80 mm/sec</li>
</ul>
<p>There are a few types of problems that we had:</p>
<ol>
<li><strong>Initially filament did not stick to the bed</strong> - those 3 items in the middle of the picture are example of this issue. This got fixed by increasing temperature of bed to 80 °C.</li>
<li><strong>At some point a piece would get dis-attached from the bed and would move around together with the extruder around</strong> - two prints in the upper right corner of the picture were cancelled for this reason.</li>
<li><strong>Models are very rough, like a cheaply made snowball</strong> - that tiny model in the upper left is suppose to be a cattle-bell. Could you tell?</li>
</ol>
<h2>Additional info</h2>
<p>Filament that we used indicated</p>
<ul>
<li>extruder temperature 230-240 °C</li>
<li>printing speed 40-90 mm/sec</li>
<li>no info about bed temperature </li>
</ul>
<h2>Question(s):</h2>
<ul>
<li>What are some optimal, tried and tested options for printing PETG? <sub>(Temperatures, speed, etc)</sub></li>
<li>What are some caveats/difficulties of working with PETG to look out for? <sub>(For example, I've read that PETG likes slower speeds. Is that true?)</sub></li>
<li>Is it possible that the model of 3D printer does not work well with this type of filament? <sub>(I don't have much experience printing so I can't know)</sub></li>
</ul>
|
<p>Slow down! </p>
<p>80 mm/s is much too fast for PETG. Try 45 or 50 mm/s instead, even for infill, supports, and other less-visible areas.</p>
|
<p>55 mm per second is the highest I would go with PETG.
Cleaning the nozzle more often helps.
Also check your PID for the nozzle temp, it could be inconsistent and PETG can be very finicky with temperature.</p>
| 1,359
|
<p>How do you sort an array of strings <a href="http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/" rel="nofollow noreferrer">naturally</a> in different programming languages? Post your implementation and what language it is in in the answer.</p>
|
<p><strong>JavaScript</strong></p>
<pre><code>Array.prototype.alphanumSort = function(caseInsensitive) {
for (var z = 0, t; t = this[z]; z++) {
this[z] = [], x = 0, y = -1, n = 0, i, j;
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
var m = (i == 46 || (i >=48 && i <= 57));
if (m !== n) {
this[z][++y] = "";
n = m;
}
this[z][y] += j;
}
}
this.sort(function(a, b) {
for (var x = 0, aa, bb; (aa = a[x]) && (bb = b[x]); x++) {
if (caseInsensitive) {
aa = aa.toLowerCase();
bb = bb.toLowerCase();
}
if (aa !== bb) {
var c = Number(aa), d = Number(bb);
if (c == aa && d == bb) {
return c - d;
} else return (aa > bb) ? 1 : -1;
}
}
return a.length - b.length;
});
for (var z = 0; z < this.length; z++)
this[z] = this[z].join("");
}
</code></pre>
<p><a href="http://my.opera.com/GreyWyvern/blog/show.dml/1671288" rel="noreferrer">Source</a></p>
|
<p>For Tcl, the -dict (dictionary) option to lsort:</p>
<pre><code>% lsort -dict {a b 1 c 2 d 13}
1 2 13 a b c d
</code></pre>
| 5,481
|
<p>In our database, we have a system set up to keep track of applications. We have a bool column that indicates whether or not the application is approved. Then there's another column that indicates whether or not the application is denied. If neither column is true, then the application is considered to be pending.</p>
<p>Is there any easy way to merge those into one value (like say a tinyint or maybe a string that says "approved", "denied", or "pending") in a view? Or is this going to require something like a Table-valued function?</p>
<p><strong>UPDATE:</strong> It's difficult to choose an answer choose since they were all helpful. I'll go with baldy's since he posted first.</p>
|
<p>you could use a case statement in your query:
select case approved when 1 then 'Approved' else ...</p>
<p>Case statements can be nested so you can delve into the different options. </p>
<p>Why not rather use an int column with 3 distinct values, or you can even go as far as using one bool column, with null enabled. When null it is pending, 1 approved and 0 denied.</p>
|
<p>you could use a case statement in your query:
select case approved when 1 then 'Approved' else ...</p>
<p>Case statements can be nested so you can delve into the different options. </p>
<p>Why not rather use an int column with 3 distinct values, or you can even go as far as using one bool column, with null enabled. When null it is pending, 1 approved and 0 denied.</p>
| 27,875
|
<p>I have from the backend a time on the format 00:12:54 and I display it to the screen. But, I would like to have this time to continue to go down. I have though to create a variable in javascript that will old the time and with <code>setTimeout</code> to loop to display with document.getElementById the new value. I think it can be problematic if I have many time to go down in same time. I might require an array?</p>
<p>How would you do that? If I have no other suggestion, I will try my way, but I am curious to know if it does have a more secure way to do it.</p>
|
<p>General algorithm:</p>
<ol>
<li>Read time from server.</li>
<li>Read the current time.</li>
<li>Call a function.</li>
<li>In your function, read the current time, get the delta from the initial time you read in step 2.</li>
<li>Subtract the delta from the initial time you read from the server in step 1 and display the remainder.</li>
<li>The function should call <code>window.setTimeout</code> to call itself in 1000ms (or adjust according to time elapsed within the function), if you want to continue counting down.</li>
</ol>
<p>Here's a rough cut:</p>
<pre><code>window.onload = function () {
var countdown_start_in_ms = 6000; // from server
function tick() {
var now = new Date().getTime();
var disp = start - now;
if (disp < 0) {
disp = 0;
}
var el = document.getElementById("countdown");
el.innerHTML =
// quick hack to format time
/(\d\d:\d\d:\d\d) ...$/.exec(new Date(disp).toUTCString())[1];
if (disp > 1000) {
var elapsed = new Date().getTime() - now;
window.setTimeout(tick, 1000 - elapsed);
} else {
// stop countdown and set color to light grey
el.style.color = "#ccc";
}
}
var start = new Date().getTime() + countdown_start_in_ms;
tick();
}
</code></pre>
|
<p>Take a look at <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/gfx/demos/clock.html" rel="nofollow noreferrer">Grab hands and set your own time.</a> and inspect its code. While it is written with Dojo, the "clock" part is in plain JavaScript. In your case the only difference is how to advance the counter — decrease rather than increase it.</p>
| 48,767
|
<p>I have used this in my HTML:</p>
<pre><code><q> Hai How r u </q>
</code></pre>
<p>Which shows the text in quotes, like "Hai How r u", for example.</p>
<p>This is working fine in FF but not in IE 6.0.</p>
<p>Please let me know why this happens, and any solutions you might know of. </p>
<p>I don't want to use the quote (") character in my HTML or a separate css file for this.</p>
|
<p>A List Apart had a whole article devoted to the <code><q></code> tag:<br>
<a href="http://www.alistapart.com/articles/qtag" rel="nofollow noreferrer">Long Live The Q Tag</a></p>
<p>The summary is to add CSS to <em>remove</em> the quotes from Firefox and other browsers and then manually encode them in yourself. It's a bit of a pain, but at least it levels the playing field and you know that your content will look the same cross-browser.</p>
<p>If you <em>really</em> don't want to have to type the quotes in yourself, then take a look at these articles:</p>
<ul>
<li><a href="http://simon.incutio.com/archive/2003/04/03/fixingQuotesWithJavascript" rel="nofollow noreferrer">http://simon.incutio.com/archive/2003/04/03/fixingQuotesWithJavascript</a></li>
<li><a href="http://diveintomark.org/archives/2002/05/04/the_q_tag" rel="nofollow noreferrer">http://diveintomark.org/archives/2002/05/04/the_q_tag</a></li>
<li><a href="http://diveintomark.org/archives/2002/08/14/the_q_tag_revisited" rel="nofollow noreferrer">http://diveintomark.org/archives/2002/08/14/the_q_tag_revisited</a></li>
<li><a href="http://www.clagnut.com/blog/157/" rel="nofollow noreferrer">http://www.clagnut.com/blog/157/</a></li>
</ul>
|
<p>Why don't you just use the <code>"</code> characters? Unlike <code><b></code> and <code><i></code> which should be replaced by strong and emphasis respectively, as appropriate, the quote tag has a direct match in meaning to the quote character. There should be no need to use <code><q></code>.</p>
<p><strong>Edit</strong>: Thanks for clarifying the question Yan.
OP: Is there a specific reason you don't want to use the quotes? The stuff I said earlier still holds, but perhaps we can help with the problem preventing you from using quotes.</p>
<p><strong>Edit 2</strong>: :|</p>
| 33,118
|
<p>Are event handlers fired in the order that they attached to the event? If not, can I enforce some kind of order onto the event handlers such that they are called in a specific order?</p>
|
<p>Assuming a simple implementation of the event (using += and -= on a delegate field, which in turn will use <code>Delegate.Combine/Remove</code>) then yes, the event handlers will be called in the order in which they're subscribed. The guarantee is effectively given in the <a href="http://msdn.microsoft.com/en-us/library/aa326800.aspx" rel="noreferrer"><code>Delegate.Combine</code></a> documentation:</p>
<blockquote>
<p><strong>Return value</strong></p>
<p>A new multicast (combinable) delegate
with an invocation list that
concatenates the invocation lists of <em>a</em>
and <em>b</em> in that order.</p>
</blockquote>
<p>See my <a href="http://pobox.com/~skeet/csharp/events.html" rel="noreferrer">article about events</a> for some examples of which <code>Delegate.Combine/Remove</code> do (and what events are like under the covers).</p>
|
<p>Sorry for the late reply.</p>
<hr>
<p>I've come across with a situation that I have to deal with order of eventhandlers.</p>
<p>I have a form, and when I click a button on the form, a object is added into a collection somewhere in my code.</p>
<p>The collection has a "Added" event, and two delegates have been hooked to it. One of the method deletes any item just added into the collection, while the other one shows message to user.</p>
<hr>
<p>If I have some code shows here, a "IndexOutOfRange" exception would be thrown when the event is triggered:</p>
<pre><code>// this methods hooks two delegates to MyCollection.Added event, but the order results in a "IndexOutOfRange" exception after the event is triggered
HookEvents()
{
MyCollection.Added += new CollectionItemAddedHandler(DeleteItem_After_CollectionItemAdded);
MyCollection.Added += new CollectionItemAddedHandler(ShowMessage_After_CollectionItemAdded);
}
// when user click a button on form, add a object to MyCollection
Button_Clicked()
{
MyCollection.Add(new object());
}
// at the moment a object is added into the collection, this method remove it
DeleteItem_After_CollectionItemAdded(NewIndexArgs e)
{
MyCollection.Remove(e.NewIndex); // e.NewIndex represents the newly added item index in current collection
}
// at the moment a object is added into the collection, this method show its information (hey, but remember, I just remove it in the previous method)
ShowMessage_After_CollectionItemAdded(NewIndexArgs e)
{
MessageBox.Show(MyCollection[e.NewIndex]); // tell user what is just added into the current collection
// a "IndexOutOfRange" exception is thrown here....
}
</code></pre>
<hr>
<p>What will make this scenario work <strong>correctly</strong> is that the "ShowMessage_After_CollectionItemAdded" method should be triggered <strong>first</strong>, and then it'd be the "DeleteItem_After_CollectionAdded" method.</p>
<p>Although we can += the "ShowMessage..." method first, there's sometimes <strong>we can't predefine this sequence until runtime</strong>.</p>
| 33,085
|
<p>I'm creating PDFs on-demand with ColdFusion's <a href="http://cfquickdocs.com/cf8/?getDoc=cfdocument" rel="nofollow noreferrer">CFDocument</a> tag, like so:</p>
<pre><code><cfdocument format="PDF" filename="#attributes.fileName#" overwrite="true">
<cfdocumentitem type="footer">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font face="Tahoma" color="black"><strong>My Client's Corporation</strong><br/>Street address<br/>City, ST 55555</font></td>
<td align="right"><font face="Tahoma" color="black">Phone: 555.555.5555<br/>Fax: 555.555.5555<br/>Email: info@domain.com</font></td>
</tr>
</table>
</cfdocumentitem>
<html>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<!--- some content here ... --->
</table>
</body>
</html>
</cfdocument>
</code></pre>
<p>The problem I'm having is that sometimes (actually, most of the time, but not always) <strong><em>some</em></strong> of the footer text is there, but invisible. I can highlight it and copy/paste it into notepad, where I can see it all -- but in the generated PDF only the first line of the left column of the footer is visible, the rest is invisible. Hence why I added the font color of black in the code.</p>
<p><img src="https://i.stack.imgur.com/LHZ96.png" alt="screenshot of problem"></p>
<p>Any ideas on how to correct this?</p>
|
<p>A PDF is what I'm after, so I'm not sure how outputting another format would help.</p>
<p>As it turns out, the footer space just wasn't enough to fit all of this text; verified by the fact that changing the font size to 4pt would fit it all in without a problem.</p>
<p>I spent some time attempting to rewrite the footer code using DDX <a href="http://www.coldfusionjedi.com/index.cfm/2008/6/2/Changing-the-size-of-a-footer-in-CFDOCUMENT" rel="nofollow noreferrer">as outlined here</a> and the <a href="http://cfquickdocs.com/cf8/?getDoc=cfpdf" rel="nofollow noreferrer">CFPDF</a> tag to implement it; but even after several hours of hacking away and finally getting a valid DDX as reported by the new <a href="http://cfquickdocs.com/cf8/?getDoc=IsDDX" rel="nofollow noreferrer">isDDX function</a>, the CFPDF tag reported that it was invalid DDX for some reason.</p>
<p>At this point I decided I had wasted enough of the client's time/money and just reformatted the footer to be 2 lines of centered text, which was good enough.</p>
|
<p>Usually when PDF shows blank text, it's because the font metrics are embedded in the document, but the glyphs are not. I know nothing about ColdFusion, but you might try the following:</p>
<ul>
<li>Try a font other than Tahoma as a test. All PDF readers must support 14 basic fonts, including 4 Helvetica variants, 4 Times variants, 4 Courier variants, Symbol and ZapfDingbats, so those are always safe choices</li>
<li>See if ColdFusion offers any control over font embedding</li>
<li>Try a list of alternatives in your font declaration, like "Tahoma,Helvetica,sans-serif"</li>
</ul>
| 4,621
|
<p>I have had my Ender 3 v2 for just over two months and have had a blast working with it. I have printed some mods to personalize it.</p>
<p>One of the things that I have done to help mitigate the vibrational noise is to place my Ender 3 on a concrete paver that sits on top of 3 inches of upholstery foam. This has made a huge difference.</p>
<p>With the vibration noise down, now I can hear the fan on the extruder like never before.</p>
<p>Both fans are listed as "brushless" EFS-04D24L; of course, they look different in the pictures below:</p>
<p><a href="https://i.stack.imgur.com/3xxsc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3xxsc.jpg" alt="Fans label side" /></a></p>
<p><a href="https://i.stack.imgur.com/CDnem.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CDnem.jpg" alt="Fans back side" /></a></p>
<p>What options are there to help reduce the fan noise? I wasn't sure if a baffle or enclosure would help. Or would it be easier to replace the fans with quieter ones?</p>
|
<p>There are companies making fans with blade design based on owl wings to make the blades quieter. Here's an example <a href="https://www.moduflow.co.uk/owlet-fans/" rel="nofollow noreferrer">https://www.moduflow.co.uk/owlet-fans/</a> and I've seen other designs. I don't know which design ended up being the quietest. First, you would need to find out who makes these fans the right size and flow rate for you, then try to find out which is quietest.</p>
<p>Here is another example: <a href="https://www.bequiet.com/en/casefans/718" rel="nofollow noreferrer">https://www.bequiet.com/en/casefans/718</a></p>
|
<p>Fans driven by brushless (BLDC or BL) motors<sup>1</sup> are the quieter option (when compared to cheaper brushed motors).</p>
<p>Mounting the fans using rubber anti-vibration standoffs/mounts<sup>2</sup>, instead of bolts, would also reduce vibration (and hence noise).</p>
<p><a href="https://i.stack.imgur.com/rRS7h.jpg" rel="nofollow noreferrer" title="Rubber anti-vibration mounts"><img src="https://i.stack.imgur.com/rRS7h.jpg" alt="Rubber anti-vibration mounts" title="Rubber anti-vibration mounts" /></a></p>
<p>Or, failing that, if using bolts, at least use rubber washers/grommets, between the fan case and the frame/mount (maybe on both sides - frame side and bolt head side).</p>
<p>A baffle or enclosure <em>would</em> reduce the noise, but would also reduce airflow, which may not be desirable, and even detrimental to the cooling, and longevity of the electronics (assuming your fans are cooling a RAMPS board, or whatever).</p>
<p>Alternatively (and I don't necessarily recommend these courses of action):</p>
<ul>
<li>Put up with the noise. After a while, you'll get used to it, or become sufficiently deaf, so as not to hear it so much;</li>
<li>Try to reduce the <em>number</em> of fans somehow. Maybe use passive cooling more - using larger heatsinks on active electronic devices maybe remove the requirement for a fan altogether.</li>
</ul>
<hr />
<h3>Footnotes</h3>
<p><sup>1</sup> Also known as electronically commutated (EC) motor and synchronous DC motors. Source: <a href="https://en.wikipedia.org/wiki/Brushless_DC_electric_motor" rel="nofollow noreferrer">Wikipedia</a></p>
<p><sup>2</sup> Also known as pin, rivet, nipple, peg, etc.</p>
| 1,873
|
<p>I am loading JSON data to my page and using <code>appendTo()</code> but I am trying to fade in my results, any ideas?</p>
<pre><code>$("#posts").fadeIn();
$(content).appendTo("#posts");
</code></pre>
<p>I saw that there is a difference between <code>append</code> and <code>appendTo</code>, on the documents.</p>
<p>I tried this as well:</p>
<pre><code>$("#posts").append(content).fadeIn();
</code></pre>
<p><strong><em>I got it, the above did the trick!</em></strong></p>
<p>But I get <code>"undefined"</code> as one of my JSON values.</p>
|
<p>If you hide the content before you append it and chain the fadeIn method to that, you should get the effect that you're looking for.</p>
<pre><code>// Create the DOM elements
$(content)
// Sets the style of the elements to "display:none"
.hide()
// Appends the hidden elements to the "posts" element
.appendTo('#posts')
// Fades the new content into view
.fadeIn();
</code></pre>
|
<p>im have a exprensive,for this:</p>
<pre><code>$("dt").append(tvlst.ddhtml);
$("dd:last").fadeIn(700);
</code></pre>
| 42,474
|
<p>What are the basic steps for <code>Agile software development</code>?<br>
And how you start a new project with agile methodology? </p>
|
<p>Well OP, there isn't a single documented step-by-step guide for 'agile software development' and any procedure that aligns with <a href="http://agilemanifesto.org/" rel="nofollow noreferrer">the manifesto</a> qualifies as agile</p>
<p>But I also understand that to get started, there has to be a 'hand-holding'/'by-the book' phase of learning. So I'd recommend that
- you take a look at your current development process. Find out the 'waste' activities that sink a lot of time and pick up an agile practice that counters/minimizes the time spent in that activity. e.g. if you're routinely fighting build issues, set up a continous integration server first and set up a stringent check-in pre-screening. Instead of changing everything such that everyone feel lost and alienated, </p>
<ul>
<li>pick up <strong>one practice at a time</strong></li>
<li>Invest about 2-3 weeks with it..get comfortable with it</li>
<li>check if everyone in the team feels that it is helpful. If yes, stick with it, make it part of your new process. Else discard and find and replace with another alternative remedy.</li>
</ul>
<p>In case your entire team is new to agile, I'd recommend (in order of intensity)</p>
<ul>
<li>Practices of an Agile Developer (Andy Hunt, Venkat S., thin book, high value-to-page ratio for newbies)</li>
<li>Agile Principles Practices and Patterns (Robert & Micah Martin)</li>
<li>Conduct weekly 'Getting Better' sessions for select practices like TDD (beck, astels, et.all), Refactoring (Fowler, Joshua K.), etc that are bound to have huge payoffs.</li>
<li>a month or so in.. go for the philosophical books like XP Embrace Change - Beck, Lean Books by Poppendieck, Agile S/w Development - Alistair Cockburn, Peopleware - DeMarco, Lister</li>
</ul>
<p>I'd recommend taking a look at the <a href="https://stackoverflow.com/questions/126955/favorite-agile-related-books">books listed here</a></p>
|
<p>I'll second Ilja's recommendation for the book: <a href="https://rads.stackoverflow.com/amzn/click/com/0321514521" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Agile-Adoption-Patterns-Roadmap-Organizational/dp/0321514521</a></p>
<p>I think the single most valuable piece of the book is the description of what practices to adopt first to achieve certain business values (quality, time to market, ...).</p>
<p>Reviews of the book: <a href="https://rads.stackoverflow.com/amzn/click/com/0321514521" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Agile-Adoption-Patterns-Roadmap-Organizational/dp/0321514521</a>
Sample Chapter: <a href="http://www.informit.com/store/product.aspx?isbn=0321514521#info8" rel="nofollow noreferrer">http://www.informit.com/store/product.aspx?isbn=0321514521#info8</a></p>
<p>Finally come join an Agile mailing list at groups.yahoo.com either ScrumDevelopment or AgileProjectManagement will suit your needs well.</p>
| 37,472
|
<p>Whats a good value for an identity increment for an 'Orders' table? (orders as in shopping cart orders)</p>
<p>I want the order numbers to appear so that we have more orders than we really do, plus make it harder for users to guess order numbers of other users in cases where that might be a problem.</p>
<p>I dont want too big a value such that I might run out of values, and i also don't want a noticable sequence to be apparent.</p>
<p>I've settled on 42 for now</p>
|
<p>It is not usually a good (security) idea to expose IDs to end-users.</p>
<p>I would use a normal +1 autoincrement ID column, and have the user-visible order number be a string based off the current date. Maybe use date + number of orders so far today: "20080919336".</p>
|
<p>You could use a non-numerical Order Reference code like "ABC0123". Depends on your platform, but you can either use this as the Primary Key for your table or in addition to the automatically incremented identifier (which would then simply become the internal reference).</p>
<p>Also: if a user guessing an order number is an issue, you really need to think about some security measures.</p>
| 13,242
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.