instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I'm building an application in C# using WPF. How can I bind to some keys?</p>
<p>Also, how can I bind to the <a href="http://en.wikipedia.org/wiki/Windows_key" rel="noreferrer">Windows key</a>?</p>
|
<p>I'm not sure of what you mean by "global" here, but here it goes (I'm assuming you mean a command at the application level, for example, <em>Save All</em> that can be triggered from anywhere by <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>S</kbd>.)</p>
<p>You find the global <code>UIElement</code> of your choice, for example, the top level window which is the parent of all the controls where you need this binding. Due to "bubbling" of WPF events, events at child elements will bubble all the way up to the root of the control tree.</p>
<p>Now, first you need</p>
<ol>
<li>to bind the Key-Combo with a Command using an <code>InputBinding</code> like this</li>
<li>you can then hookup the command to your handler (e.g. code that gets called by <code>SaveAll</code>) via a <code>CommandBinding</code>.</li>
</ol>
<p>For the <kbd>Windows</kbd> Key, you use the right <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.key.aspx" rel="nofollow noreferrer">Key</a> enumerated member, <strong><code>Key.LWin</code></strong> or <strong><code>Key.RWin</code></strong></p>
<pre><code>public WindowMain()
{
InitializeComponent();
// Bind Key
var ib = new InputBinding(
MyAppCommands.SaveAll,
new KeyGesture(Key.S, ModifierKeys.Shift | ModifierKeys.Control));
this.InputBindings.Add(ib);
// Bind handler
var cb = new CommandBinding( MyAppCommands.SaveAll);
cb.Executed += new ExecutedRoutedEventHandler( HandlerThatSavesEverthing );
this.CommandBindings.Add (cb );
}
private void HandlerThatSavesEverthing (object obSender, ExecutedRoutedEventArgs e)
{
// Do the Save All thing here.
}
</code></pre>
|
<p><code>RegisterHotKey()</code> suggested by John could work - the only catch is that it requires an HWND (using <code>PresentationSource.FromVisual()</code>, and casting the result to an HwndSource). </p>
<p>However, you'll also need to respond to the <code>WM_HOTKEY</code> message - I'm not sure if there is a way to get access to the WndProc of a WPF window or not (which can be done for Windows Forms windows).</p>
| 7,138
|
<p>I am getting this error now that I hit version number 1.256.0:
Error 4 Invalid product version '1.256.0'. Must be of format '##.##.####'</p>
<p>The installer was fine with 1.255.0 but something with 256 (2^8) it doesn't like. I found this stated on msdn.com:
The Version property must be formatted as N.N.N, where each N represents at least one and no more than four digits. (<a href="http://msdn.microsoft.com/en-us/library/d3ywkte8(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/d3ywkte8(VS.80).aspx</a>)</p>
<p>Which would make me believe there is nothing wrong 1.256.0 because it meets the rules stated above.</p>
<p>Does anyone have any ideas on why this would be failing now?</p>
|
<p>Change it to:</p>
<pre><code>protected static <T extends Comparable<T>> int nullCompare(T o1, T o2) {
</code></pre>
<p>You need that because Comparable is itself a generic type.</p>
|
<p>I'm not sure that genericizing this method makes sense. Currently the method works on any kind of Comparable; if you genericize it you will have to implement it (with exactly the same code) multiple times. Sometimes it is possible to compare two objects that don't have a common ancestor, and any generic version won't allow this.</p>
<p>By adding generics you won't add any safety to the code; any problems of safety will occur in the call to compareTo. What I would suggest is simply suppressing the warning. It's not really warning you about anything useful.</p>
| 8,359
|
<p>I want to add auto bed leveling before each print. When I enable auto bed level in <code>configuration.h</code>, it only shows <strong>auto bed</strong> in menu. I found this code in <code>cardreader.cpp</code></p>
<pre><code>void CardReader::openAndPrintFile(const char *name) {
char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
sprintf_P(cmd, PSTR("M23 %s"), name);
for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueue_and_echo_command(cmd);
enqueue_and_echo_commands_P(PSTR("M24"));
}
</code></pre>
<p>and changed it to</p>
<pre><code>void CardReader::openAndPrintFile(const char *name) {
char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
sprintf_P(cmd, PSTR("M23 %s"), name);
for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueue_and_echo_command("G28");
enqueue_and_echo_command("G29");
enqueue_and_echo_command(cmd);
enqueue_and_echo_commands_P(PSTR("M24"));
}
</code></pre>
<p>Now before each print, the printer does auto bedding <strong>two</strong> times but when print starts the auto bedding is ignored and printer acts like before doing auto bed.</p>
<p>Please help me solve this.</p>
<p>I'm using Marlin Firmware 1.1.0.</p>
|
<p>Rather than modifying the firmware to handle this, have you considered a pre-processing script on your computer, greping for a <code>G29</code> in the G-code, then adding a <code>G28</code>/<code>G29</code> pair at the start of the file if no <code>G29</code> is found?</p>
|
<p>I'm not that fluent in G-code, but at <a href="https://www.mmsonline.com/columns/understanding-g27-g28-g29-and-g30" rel="nofollow noreferrer">Modern Machine Shop: Understanding G27, G28, G29 and G30</a> I found these descriptions of the <code>G28</code> and <code>G29</code> codes you added:</p>
<ul>
<li><p><code>G28</code>: For any axis letter addresses included in the G28 command, the machine first will move (at rapid) to an intermediate position in those axes. Then, it will rapid to the zero return position in the commanded axes.</p></li>
<li><p><code>G29</code>: G29 is also a two-step command. First, it causes the machine to move (in the axes commanded) to the intermediate position used in the most recent <code>G28</code> command. Second, it causes the machine to move to the position included in the <code>G29</code> command.</p></li>
</ul>
<p>So it sounds to me like you only need one of those two commands. It seems that the code you modified runs separately on startup, rather than for each separate print. I would first try your modification with each G command separately, so you can see exactly what the difference is on your hardware.</p>
<p>I don't know my way around the code involved, but it looks like you'd need to make the modification in another place, such as just before whatever loop sends successive commands to the printer.</p>
<p>Hope that's helpful despite my limited fluency...</p>
| 628
|
<p>Which is the simplest way to check if two integers have same sign? Is there any short bitwise trick to do this?</p>
|
<p>What's wrong with</p>
<pre><code>return ((x<0) == (y<0));
</code></pre>
<p>?</p>
|
<p>Thinking back to my university days, in most machine representations, isn't the left-most bit of a integer a 1 when the number is negative, and 0 when it's positive?</p>
<p>I imagine this is rather machine-dependent, though.</p>
| 9,243
|
<p>Can you suggest some good MVC framework for perl -- one I am aware of is <a href="http://www.catalystframework.org/" rel="noreferrer">catalyst</a></p>
<p>The need is to be able to expose services on the perl infrastructure which can be called by Java/.Net applications seamlessly.</p>
|
<p>I'll tell you right now that Catalyst has by far the best reputation amongst Perl developers in terms of a rapid application development MVC framework. </p>
<p>In terms of "pure" MVC I'm not sure there are even that many "mature" or at least production-ready alternatives.</p>
<p>If Catalyst doesn't seem right to you, then you could build upon the lightweight framework <a href="http://cgi-app.org/" rel="noreferrer">CGI::Application</a> to suit your needs or take a look at some of the lesser known MVC frameworks like <a href="http://pagekit.org/" rel="noreferrer">PageKit</a> and <a href="http://maypole.perl.org/" rel="noreferrer">Maypole</a>.</p>
|
<p>I have built some applications with <a href="https://metacpan.org/pod/Kelp" rel="nofollow">Kelp</a>, it's easy to learn and very helpful.</p>
| 6,734
|
<p>I have a list of 2-item tuples and I'd like to convert them to 2 lists where the first contains the first item in each tuple and the second list holds the second item.</p>
<p><strong>For example:</strong></p>
<pre><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
# and I want to become...
result = (['a', 'b', 'c', 'd'], [1, 2, 3, 4])
</code></pre>
<p>Is there a builtin function that does that?</p>
|
<p><a href="http://docs.python.org/library/functions.html#zip" rel="noreferrer"><code>zip</code></a> is its own inverse! Provided you use the special * operator.</p>
<pre><code>>>> zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])
[('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
</code></pre>
<p>The way this works is by calling <code>zip</code> with the arguments:</p>
<pre><code>zip(('a', 1), ('b', 2), ('c', 3), ('d', 4))
</code></pre>
<p>… except the arguments are passed to <code>zip</code> directly (after being converted to a tuple), so there's no need to worry about the number of arguments getting too big.</p>
|
<p>Here's a simple one-line answer that produces the desired output:</p>
<pre class="lang-py prettyprint-override"><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
list(zip(*original))
# [('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
</code></pre>
| 3,976
|
<p>I need to take a web page and extract the address information from the page. Some are easier than others. I'm looking for a firefox plugin, windows app, or VB.NET code that will help me get this done.</p>
<p>Ideally I would like to have a web page on our admin (ASP.NET/VB.NET) where you enter a URL and it scraps the page and returns a Dataset that I can put in a Grid.</p>
|
<p>I've never done this, but here are a couple things you could try. First, you could implement a custom <a href="http://java.sun.com/javase/6/docs/api/java/awt/Stroke.html" rel="nofollow noreferrer">Stroke</a> that creates skinny trapezoids. The width of the end caps would be a function of the pressure at the end points. If that works, you could try to make the line segments look more natural by using <a href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve" rel="nofollow noreferrer">Bezier curves</a> to form "curvy trapezoids". You might be able to use <a href="http://java.sun.com/javase/6/docs/api/java/awt/geom/QuadCurve2D.html" rel="nofollow noreferrer">QuadCurve2D</a> to help.</p>
|
<p>PostScript RIPs often convert circles to curves and curves to a series of straight line segments. The number of segments depends on the flatness setting which defaults to one suitable for the raster display resolution.</p>
<p>A thick line or thick line segments can be converted to a skinny filled polygon.</p>
| 6,408
|
<p>I'm trying to run a batch file, as another user, from my web app. For some reason, the batch file hangs! I can see "cmd.exe" running in the task manager, but it just sits there forever, unable to be killed, and the batch file is not running. Here's my code:</p>
<pre><code>SecureString password = new SecureString();
foreach (char c in "mypassword".ToCharArray())
password.AppendChar(c);
ProcessStartInfo psi = new ProcessStartInfo();
psi.WorkingDirectory = @"c:\build";
psi.FileName = Environment.SystemDirectory + @"\cmd.exe";
psi.Arguments = "/q /c build.cmd";
psi.UseShellExecute = false;
psi.UserName = "builder";
psi.Password = password;
Process.Start(psi);
</code></pre>
<p>If you didn't guess, this batch file builds my application (a different application than the one that is executing this command).</p>
<p>The Process.Start(psi); line returns immediately, as it should, but the batch file just seems to hang, without executing. Any ideas?</p>
<p><strong>EDIT:</strong> See my answer below for the contents of the batch file.</p>
<ul>
<li>The output.txt never gets created.</li>
</ul>
<p>I added these lines: </p>
<pre><code>psi.RedirectStandardOutput = true;
Process p = Process.Start(psi);
String outp = p.StandardOutput.ReadLine();
</code></pre>
<p>and stepped through them in debug mode. The code hangs on the <code>ReadLine()</code>. I'm stumped!</p>
|
<p>I believe I've found the answer. It seems that Microsoft, in all their infinite wisdom, has blocked batch files from being executed by IIS in Windows Server 2003. Brenden Tompkins has a work-around here:</p>
<p><a href="http://codebetter.com/blogs/brendan.tompkins/archive/2004/05/13/13484.aspx" rel="noreferrer">http://codebetter.com/blogs/brendan.tompkins/archive/2004/05/13/13484.aspx</a></p>
<p>That won't work for me, because my batch file uses IF and GOTO, but it would definitely work for simple batch files.</p>
|
<p>My guess would be that the build.cmd is waiting for some sort of user-interaction/reply. If you log the output of the command with the "<strong>> logfile.txt</strong>" operator at the end, it might help you find the problem.</p>
| 5,437
|
<p>I've always heard that in C you have to really watch how you manage memory. And I'm still beginning to learn C, but thus far, I have not had to do any memory managing related activities at all.. I always imagined having to release variables and do all sorts of ugly things. But this doesn't seem to be the case.</p>
<p>Can someone show me (with code examples) an example of when you would have to do some "memory management" ?</p>
|
<p>There are two places where variables can be put in memory. When you create a variable like this:</p>
<pre><code>int a;
char c;
char d[16];
</code></pre>
<p>The variables are created in the "<strong>stack</strong>". Stack variables are automatically freed when they go out of scope (that is, when the code can't reach them anymore). You might hear them called "automatic" variables, but that has fallen out of fashion.</p>
<p>Many beginner examples will use only stack variables.</p>
<p>The stack is nice because it's automatic, but it also has two drawbacks: (1) The compiler needs to know in advance how big the variables are, and (2) the stack space is somewhat limited. For example: in Windows, under default settings for the Microsoft linker, the stack is set to 1 MB, and not all of it is available for your variables.</p>
<p>If you don't know at compile time how big your array is, or if you need a big array or struct, you need "plan B".</p>
<p>Plan B is called the "<strong>heap</strong>". You can usually create variables as big as the Operating System will let you, but you have to do it yourself. Earlier postings showed you one way you can do it, although there are other ways:</p>
<pre><code>int size;
// ...
// Set size to some value, based on information available at run-time. Then:
// ...
char *p = (char *)malloc(size);
</code></pre>
<p>(Note that variables in the heap are not manipulated directly, but via pointers)</p>
<p>Once you create a heap variable, the problem is that the compiler can't tell when you're done with it, so you lose the automatic releasing. That's where the "manual releasing" you were referring to comes in. Your code is now responsible to decide when the variable is not needed anymore, and release it so the memory can be taken for other purposes. For the case above, with:</p>
<pre><code>free(p);
</code></pre>
<p>What makes this second option "nasty business" is that it's not always easy to know when the variable is not needed anymore. Forgetting to release a variable when you don't need it will cause your program to consume more memory that it needs to. This situation is called a "leak". The "leaked" memory cannot be used for anything until your program ends and the OS recovers all of its resources. Even nastier problems are possible if you release a heap variable by mistake <em>before</em> you are actually done with it.</p>
<p>In C and C++, you are responsible to clean up your heap variables like shown above. However, there are languages and environments such as Java and .NET languages like C# that use a different approach, where the heap gets cleaned up on its own. This second method, called "garbage collection", is much easier on the developer but you pay a penalty in overhead and performance. It's a balance.</p>
<p><em>(I have glossed over many details to give a simpler, but hopefully more leveled answer)</em></p>
|
<p>Sure. If you create an object that exists outside of the scope you use it in. Here is a contrived example (bear in mind my syntax will be off; my C is rusty, but this example will still illustrate the concept):</p>
<pre><code>class MyClass
{
SomeOtherClass *myObject;
public MyClass()
{
//The object is created when the class is constructed
myObject = (SomeOtherClass*)malloc(sizeof(myObject));
}
public ~MyClass()
{
//The class is destructed
//If you don't free the object here, you leak memory
free(myObject);
}
public void SomeMemberFunction()
{
//Some use of the object
myObject->SomeOperation();
}
};
</code></pre>
<p>In this example, I'm using an object of type SomeOtherClass during the lifetime of MyClass. The SomeOtherClass object is used in several functions, so I've dynamically allocated the memory: the SomeOtherClass object is created when MyClass is created, used several times over the life of the object, and then freed once MyClass is freed.</p>
<p>Obviously if this were real code, there would be no reason (aside from possibly stack memory consumption) to create myObject in this way, but this type of object creation/destruction becomes useful when you have a lot of objects, and want to finely control when they are created and destroyed (so that your application doesn't suck up 1GB of RAM for its entire lifetime, for example), and in a Windowed environment, this is pretty much mandatory, as objects that you create (buttons, say), need to exist well outside of any particular function's (or even class') scope.</p>
| 4,453
|
<p>I'm sure most of you are writing lots of automated tests and that you also have run into some common pitfalls when unit testing. </p>
<p>My question is do you follow any rules of conduct for writing tests in order to avoid problems in the future? To be more specific: What are the <strong>properties of good unit tests</strong> or how do you write your tests?</p>
<p>Language agnostic suggestions are encouraged.</p>
|
<p>Let me begin by plugging sources - <a href="http://pragprog.com/titles/utj/pragmatic-unit-testing-in-java-with-junit" rel="nofollow noreferrer">Pragmatic Unit Testing in Java with JUnit</a> (There's a version with C#-Nunit too.. but I have this one.. its agnostic for the most part. Recommended.)</p>
<p>Good Tests should be <strong>A TRIP</strong> (The acronymn isn't sticky enough - I have a printout of the cheatsheet in the book that I had to pull out to make sure I got this right..)</p>
<ul>
<li><strong>Automatic</strong> : Invoking of tests as well as checking results for PASS/FAIL should be automatic</li>
<li><strong>Thorough</strong>: Coverage; Although bugs tend to cluster around certain regions in the code, ensure that you test all key paths and scenarios.. Use tools if you must to know untested regions</li>
<li><strong>Repeatable</strong>: Tests should produce the same results each time.. every time. Tests should not rely on uncontrollable params.</li>
<li><strong>Independent</strong>: Very important.
<ul>
<li>Tests should <strong>test only one thing</strong> at a time. Multiple assertions are okay as long as they are all testing one feature/behavior. When a test fails, it should pinpoint the location of the problem.</li>
<li>Tests <strong>should not rely on each other</strong> - Isolated. No assumptions about order of test execution. Ensure 'clean slate' before each test by using setup/teardown appropriately</li>
</ul></li>
<li><p><strong>Professional</strong>: In the long run you'll have as much test code as production (if not more), therefore follow the same standard of good-design for your test code. Well factored methods-classes with intention-revealing names, No duplication, tests with good names, etc. </p></li>
<li><p>Good tests also run <strong>Fast</strong>. any test that takes over half a second to run.. needs to be worked upon. The longer the test suite takes for a run.. the less frequently it will be run. The more changes the dev will try to sneak between runs.. if anything breaks.. it will take longer to figure out which change was the culprit.</p></li>
</ul>
<p>Update 2010-08:</p>
<ul>
<li><strong>Readable</strong> : This can be considered part of Professional - however it can't be stressed enough. An acid test would be to find someone who isn't part of your team and asking him/her to figure out the behavior under test within a couple of minutes. Tests need to be maintained just like production code - so make it easy to read even if it takes more effort. Tests should be symmetric (follow a pattern) and concise (test one behavior at a time). Use a consistent naming convention (e.g. the TestDox style). Avoid cluttering the test with "incidental details".. become a minimalist.</li>
</ul>
<p>Apart from these, most of the others are guidelines that cut down on low-benefit work: e.g. 'Don't test code that you don't own' (e.g. third-party DLLs). Don't go about testing getters and setters. Keep an eye on cost-to-benefit ratio or defect probability.</p>
|
<p>Often unit tests are based on mock object or mock data.
I like to write three kind of unit tests:</p>
<ul>
<li>"transient" unit tests: they create their own mock objects/data and test their function with it, but destroy everything and leave no trace (like no data in a test database)</li>
<li>"persistent" unit test: they test functions within your code creating objects/data that will be needed by more advanced function later on for their own unit test (avoiding for those advanced function to recreate every time their own set of mock objects/data)</li>
<li>"persistent-based" unit tests: unit tests using mock objects/data that are already there (because created in another unit test session) by the persistent unit tests.</li>
</ul>
<p>The point is to avoid to replay <em>everything</em> in order to be able to test every functions.</p>
<ul>
<li>I run the third kind very often because all mock objects/data are already there.</li>
<li>I run the second kind whenever my model change.</li>
<li>I run the first one to check the very basic functions once in a while, to check to basic regressions.</li>
</ul>
| 8,660
|
<p>How can I use the Prototype library and create unobtrusive javascript to inject the onmouseover and onmouseout events to each row, rather than putting the javascript in each table row tag?</p>
<p>An answer utilizing the Prototype library (instead of mootools, jQuery, etc) would be most helpful.</p>
|
<pre><code><table id="mytable">
<tbody>
<tr><td>Foo</td><td>Bar</td></tr>
<tr><td>Bork</td><td>Bork</td></tr>
</tbody>
</table>
<script type="text/javascript">
$$('#mytable tr').each(function(item) {
item.observe('mouseover', function() {
item.setStyle({ backgroundColor: '#ddd' });
});
item.observe('mouseout', function() {
item.setStyle({backgroundColor: '#fff' });
});
});
</script>
</code></pre>
|
<p>I found ab interesting solution for Rows background, the rows highlighting on mouse over, without JS. Here is <a href="http://www.sopov.com/joomla-wordpress-tips-and-tricks/70-how-highlight-table-row-background.html" rel="nofollow noreferrer">link</a></p>
<p>Works in all browsers. For IE6/7/8 ...</p>
<pre><code>tr{ position: relative; }
td{ background-image: none }
</code></pre>
<p>And for Safari I use negative background position for each TD.</p>
| 7,548
|
<p>a colleague pointed me the other day to <a href="http://jakarta.apache.org/bcel/" rel="nofollow noreferrer">BCEL</a> which , as best I can tell from his explanation and a quick read, a way to modify at run time the byte code. My first thought was that it sounded dangerous, and my second thought was that it sounded cool. Then I gave it some more thought and I recalled the <a href="https://blog.codinghorror.com/monkeypatching-for-humans/" rel="nofollow noreferrer">codinghorror post on monkey-patching</a> and realized that this was basically the same thing. Has anyone ever used BCEL for anything practical? Am I right that this is basically run time monkey patching, or am I missing something?</p>
|
<p>It's a bit more low-level than classic monkey patching, and from what I read, the classes already loaded into the VM are not updated. It only supports saving it to class files again, not modifying run time classes.</p>
|
<p>You might look at it as monkey patching. I prefer not to use it (maybe I never faced a good use case for it?), but be familiar with it (to have an idea how Spring and Hibenrate use it and why).</p>
| 6,393
|
<p>I have upgraded a MS Visual Studio Application from VS 2003 to VS 2008 (Targeting .NET 2.0). As part of the conversion process the wizard said I needed to take the additional step of Converting my Project to a Website by Right-Clicking and blah blah blah...</p>
<p>I didn't follow directions and the web application seems to be working fine.</p>
<p>My question is, should I be concerned about pushing this to a production system? What exactly is going on here?</p>
|
<p>There are two types of web applications in ASP.NET: The Web Site and Web Application Project. The difference between the two are discussed here:</p>
<p><a href="http://www.dotnetspider.com/resources/1520-Difference-between-web-site-web-application.aspx" rel="noreferrer">Difference between web site and web applications in Visual Studio 2005</a></p>
<p>Convert to Website allows you to convert a Web Application Project to a Web Site.</p>
<p>Visual Studio 2003 used the Web Application Project style, but initially VS2005 only supported web sites. VS2005 SP1 brought back Web Applications.</p>
<p>If you don't want to convert your project to a web site, apply SP1 if you're using VS2005. VS2008 can support either.</p>
|
<blockquote>
<p>There are two types of web applications in ASP.NET: The Web Site and Web Application Project.
Convert to Website allows you to convert a Web Application Project to a Web Site.</p>
</blockquote>
<p>As far as I can recall, Convert to a Website does not do this, the Web Application project is a regular application structure with your typical \bin etc.</p>
<p>The WebSite project instead is based upon the concept of an App_Code directory for classes, and an App_Date directory for data, with your regular ASPX files going anywhere. The idea is to avoid having to precompile into DLL's before deployment, which can be easier in some shared hosting situations.</p>
<p>I am not aware of any wizard that will restructure the project between these types, but I may be wrong.</p>
| 6,465
|
<p>I'm using Ruby on Rails for an internal site. Different users of the site have access to a wide variety of data and highly disparate perspectives of the data. Within those different classes of users, there needs to be levels of access. Within the levels of access I need to be able to add features from other classes of users.</p>
<p>In the released "Version 1.0" of the intranet site I have implemented the general classes of users. I am now needed to implement much finer-grained control of a users access.</p>
<p>The question is how?</p>
<p>What is the generally accepted practice for coding up user preferences (display the map (or not); access to this feature, but not this feature) without exploding the database schema and populating the view code with <% if feature_allowed %> tags everywhere.</p>
|
<p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>
<blockquote>
<p>The authorization plugin provides the following:</p>
</blockquote>
<ul>
<li><p>A simple way of checking authorization at either the class or instance method
level using #permit and #permit?</p></li>
<li><p>Authorization using roles for the entire application, a model class, or an
instance of a model (i.e., a particular object).</p></li>
<li><p>Some english-like dynamic methods that draw on the defined roles. You will be
able to use methods like "user.is_fan_of angelina" or "angelina.has_fans?",
where a 'fan' is only defined in the roles table.</p></li>
<li><p>Pick-and-choose a mixin for your desired level of database complexity. For
all the features, you will want to use "object roles table" (see below)</p></li>
</ul>
|
<p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>
<blockquote>
<p>The authorization plugin provides the following:</p>
</blockquote>
<ul>
<li><p>A simple way of checking authorization at either the class or instance method
level using #permit and #permit?</p></li>
<li><p>Authorization using roles for the entire application, a model class, or an
instance of a model (i.e., a particular object).</p></li>
<li><p>Some english-like dynamic methods that draw on the defined roles. You will be
able to use methods like "user.is_fan_of angelina" or "angelina.has_fans?",
where a 'fan' is only defined in the roles table.</p></li>
<li><p>Pick-and-choose a mixin for your desired level of database complexity. For
all the features, you will want to use "object roles table" (see below)</p></li>
</ul>
| 5,296
|
<p>I started an application in Google App Engine right when it came out, to play with the technology and work on a pet project that I had been thinking about for a long time but never gotten around to starting. The result is <a href="http://www.bowlsk.com" rel="noreferrer">BowlSK</a>. However, as it has grown, and features have been added, it has gotten really difficult to keep things organized - mainly due to the fact that this is my first python project, and I didn't know anything about it until I started working.</p>
<p>What I have:</p>
<ul>
<li>Main Level contains:
<ul>
<li>all .py files (didn't know how to make packages work)</li>
<li>all .html templates for main level pages</li>
</ul></li>
<li>Subdirectories:
<ul>
<li>separate folders for css, images, js, etc.</li>
<li>folders that hold .html templates for subdirecty-type urls</li>
</ul></li>
</ul>
<p>Example:<br/>
<a href="http://www.bowlsk.com/" rel="noreferrer">http://www.bowlsk.com/</a> maps to HomePage (default package), template at "index.html"<br/>
<a href="http://www.bowlsk.com/games/view-series.html?series=7130" rel="noreferrer">http://www.bowlsk.com/games/view-series.html?series=7130</a> maps to ViewSeriesPage (again, default package), template at "games/view-series.html"</p>
<p>It's nasty. How do I restructure? I had 2 ideas:</p>
<ul>
<li><p>Main Folder containing: appdef, indexes, main.py?</p>
<ul>
<li>Subfolder for code. Does this have to be my first package?</li>
<li>Subfolder for templates. Folder heirarchy would match package heirarchy</li>
<li>Individual subfolders for css, images, js, etc.</li>
</ul></li>
<li><p>Main Folder containing appdef, indexes, main.py?</p>
<ul>
<li>Subfolder for code + templates. This way I have the handler class right next to the template, because in this stage, I'm adding lots of features, so modifications to one mean modifications to the other. Again, do I have to have this folder name be the first package name for my classes? I'd like the folder to be "src", but I don't want my classes to be "src.WhateverPage"</li>
</ul></li>
</ul>
<p>Is there a best practice? With Django 1.0 on the horizon, is there something I can do now to improve my ability to integrate with it when it becomes the official GAE templating engine? I would simply start trying these things, and seeing which seems better, but pyDev's refactoring support doesn't seem to handle package moves very well, so it will likely be a non-trivial task to get all of this working again.</p>
|
<p>First, I would suggest you have a look at "<a href="http://sites.google.com/site/io/rapid-development-with-python-django-and-google-app-engine" rel="noreferrer">Rapid Development with Python, Django, and Google App Engine</a>"</p>
<p>GvR describes a general/standard project layout on page 10 of his <a href="http://sites.google.com/site/io/rapid-development-with-python-django-and-google-app-engine/rapid_development_with_django_gae.pdf?attredirects=0" rel="noreferrer">slide presentation</a>. </p>
<p>Here I'll post a slightly modified version of the layout/structure from that page. I pretty much follow this pattern myself. You also mentioned you had trouble with packages. Just make sure each of your sub folders has an __init__.py file. It's ok if its empty.</p>
<h2>Boilerplate files</h2>
<ul>
<li>These hardly vary between projects</li>
<li>app.yaml: direct all non-static requests to main.py </li>
<li>main.py: initialize app and send it all requests </li>
</ul>
<h2>Project lay-out</h2>
<ul>
<li>static/*: static files; served directly by App Engine</li>
<li>myapp/*.py: app-specific python code
<ul>
<li>views.py, models.py, tests.py, __init__.py, and more</li>
</ul></li>
<li>templates/*.html: templates (or myapp/templates/*.html)</li>
</ul>
<p>Here are some code examples that may help as well:</p>
<h2>main.py</h2>
<pre><code>import wsgiref.handlers
from google.appengine.ext import webapp
from myapp.views import *
application = webapp.WSGIApplication([
('/', IndexHandler),
('/foo', FooHandler)
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
</code></pre>
<h2>myapp/views.py</h2>
<pre><code>import os
import datetime
import logging
import time
from google.appengine.api import urlfetch
from google.appengine.ext.webapp import template
from google.appengine.api import users
from google.appengine.ext import webapp
from models import *
class IndexHandler(webapp.RequestHandler):
def get(self):
date = "foo"
# Do some processing
template_values = {'data': data }
path = os.path.join(os.path.dirname(__file__) + '/../templates/', 'main.html')
self.response.out.write(template.render(path, template_values))
class FooHandler(webapp.RequestHandler):
def get(self):
#logging.debug("start of handler")
</code></pre>
<h2>myapp/models.py</h2>
<pre><code>from google.appengine.ext import db
class SampleModel(db.Model):
</code></pre>
<p>I think this layout works great for new and relatively small to medium projects. For larger projects I would suggest breaking up the views and models to have their own sub-folders with something like:</p>
<h2>Project lay-out</h2>
<ul>
<li>static/: static files; served directly by App Engine
<ul>
<li>js/*.js</li>
<li>images/*.gif|png|jpg</li>
<li>css/*.css</li>
</ul></li>
<li>myapp/: app structure
<ul>
<li>models/*.py</li>
<li>views/*.py</li>
<li>tests/*.py</li>
<li>templates/*.html: templates</li>
</ul></li>
</ul>
|
<p>I am not entirely up to date on the latest best practices, et cetera when it comes to code layout, but when I did my first GAE application, I used something along your second option, where the code and templates are next to eachother.</p>
<p>There was two reasons for this - one, it kept the code and template nearby, and secondly, I had the directory structure layout mimic that of the website - making it (for me) a bit easier too remember where everything was.</p>
| 7,089
|
<p>I was wondering if anyone that has experience in both this stuff can shed some light on the <em>significant</em> difference between the two if any?</p>
<p>Any specific strength of each that makes it suitable for any specific case?</p>
|
<p>This question is quite dated but as it is still getting traffic and answers I though I state my point here again even so I already did it on some other (newer) questions.</p>
<p>I'm <em><strong>really really</strong></em> baffled that SimpleTest <strong>still</strong> is considered an alternative to phpunit. Maybe i'm just misinformed but as far as I've seen:</p>
<ul>
<li>PHPUnit is the standard; most frameworks use it (like Zend Framework (1&2), Cake, Agavi, even Symfony is dropping their own Framework in Symfony 2 for phpunit).</li>
<li>PHPUnit is integrated in every PHP IDE (Eclipse, Netbeans, Zend Stuide, PHPStorm) and works nicely.</li>
<li>Simpletest has an eclipse extension for PHP 5.1 (a.k.a. old) and nothing else.</li>
<li>PHPUnit works fine with every continuous integration server since it outputs all standard log files for code coverage and test reports.</li>
<li>Simpletest does not. While this is not a big problem to start with it will bite you big time once you stop "just testing" and start developing software (Yes that statement is provocative :) Don't take it too seriously).</li>
<li>PHPUnit is actively maintained, stable and works great for every codebase, every scenario and every way you want to write your tests.</li>
<li>(Subjective) <a href="http://www.phpunit.de/manual/3.6/en/code-coverage-analysis.html" rel="noreferrer">PHPUnit provides much nicer</a> code coverage reports <a href="http://www.simpletest.org/en/reporter_documentation.html" rel="noreferrer">than Simpletest</a></li>
<li>With PHPUnit you also get these reports inside your IDE (<a href="http://netbeans.org/kb/docs/php/phpunit.htm%60" rel="noreferrer">Netbeans</a>, Eclipse, ...)</li>
<li>Also there are a couple of suggestings for a <a href="https://stackoverflow.com/questions/2424457/web-interface-to-phpunit-tests"><strong><code>web interface to phpunit tests</code></strong></a>.</li>
</ul>
<p>I've yet to see any argument in favor of SimpleTest. It's not even simpler to install since PHPUnit is available via pear:</p>
<pre><code>pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
</code></pre>
<p>and the "first test" looks pretty much the same.</p>
<p>As of <code>PHPUnit 3.7</code> it's <strong>even easier to install</strong> it by just using the <a href="http://www.phpunit.de/manual/current/en/installation.html#installation.phar" rel="noreferrer"><strong><code>PHAR Archive</code></strong></a></p>
<pre><code>wget http://pear.phpunit.de/get/phpunit.phar
chmod +x phpunit-3.7.6.phar
</code></pre>
<p>or for windows just <a href="http://pear.phpunit.de/get/phpunit.phar" rel="noreferrer">downloading</a> the phar and running:</p>
<pre><code>php phpunit-.phar
</code></pre>
<p>or when using the <a href="http://www.phpunit.de/manual/current/en/installation.html#installation.composer" rel="noreferrer">supported composer install</a> ways like</p>
<pre><code>"require-dev": {
"phpunit/phpunit": "3.7.*"
}
</code></pre>
<p>to your composer.json.</p>
<hr />
<p>For everything you want to test PHPUnit will have a solution and you will be able to find help pretty much anywhere (SO, #phpunit irc channel on freenode, pretty much every php developer ;) )</p>
<p>Please correct me if I've stated something wrong or forgot something :)</p>
<h1>Overview of PHP Testing tools</h1>
<p>Video: <a href="http://conference.phpnw.org.uk/phpnw11/schedule/sebastian-bergmann/" rel="noreferrer">http://conference.phpnw.org.uk/phpnw11/schedule/sebastian-bergmann/</a></p>
<p>Slides: <a href="http://www.slideshare.net/sebastian_bergmann/the-php-testers-toolbox-osi-days-2011" rel="noreferrer">http://www.slideshare.net/sebastian_bergmann/the-php-testers-toolbox-osi-days-2011</a></p>
<p>It mentions stuff like <a href="https://github.com/mageekguy/atoum" rel="noreferrer">Atoum</a> which calls its self: "A simple, modern and intuitive unit testing framework for PHP!"</p>
<hr />
<h3>Full disclosure</h3>
<p>I've originally written this answer Jan. 2011 where I had no affiliation with any PHP Testing project. Since then I became a contributor to PHPUnit.</p>
|
<p>when there are thousands functions to test at one go, phpunit is way to go, simple test is falling short as it web based. </p>
<p>I am still using simple web to for small scale test . </p>
<p>But both are good</p>
| 5,452
|
<p>I'm working on a .net post-commit hook to feed data into OnTime via their Soap SDK. My hook works on Windows fine, but on our production RHEL4 subversion server, it won't work when called from a shell script.</p>
<pre>
#!/bin/sh
/usr/bin/mono $1/hooks/post-commit.exe "$@"
</pre>
<p>When I execute it with parameters from the command line, it works properly. When executed via the shell script, I get the following error: (looks like there is some problem with the process execution of SVN that I use to get the log data for the revision):</p>
<pre>
Unhandled Exception: System.InvalidOperationException: The process must exit before getting the requested information.
at System.Diagnostics.Process.get_ExitCode () [0x0003f] in /tmp/monobuild/build/BUILD/mono-1.9.1/mcs/class/System/System.Diagnostics/Process.cs:149
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
at SVNLib.SVN.Execute (System.String sCMD, System.String sParams, System.String sComment, System.String sUserPwd, SVNLib.SVNCallback callback) [0x00000]
at SVNLib.SVN.Log (System.String sUrl, Int32 nRevLow, Int32 nRevHigh, SVNLib.SVNCallback callback) [0x00000]
at SVNLib.SVN.LogAsString (System.String sUrl, Int32 nRevLow, Int32 nRevHigh) [0x00000]
at SVNCommit2OnTime.Program.Main (System.String[] args) [0x00000]
</pre>
<p>I've tried using <code>mkbundle</code> and <code>mkbundle2</code> to make a stand alone that could be named <code>post-commit</code>, but I get a different error message:</p>
<pre>
Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: Value cannot be null.
at System.Guid.CheckNull (System.Object o) [0x00000]
at System.Guid..ctor (System.String g) [0x00000]
at SVNCommit2OnTime.Program.Main (System.String[] args) [0x00000]
</pre>
<p>Any ideas why it might be failing from a shell script or what might be wrong with the bundled version?</p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54537">@Herms</a>, I've already tried it with an echo, and it looks right. As for the <code>$1/hooks/post-commit.exe</code>, I've tried the script with and without a full path to the .net assembly with the same results.</p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54545">@Leon</a>, I've tried both <code>$1 $2</code> and <code>"$@"</code> with the same results. It is a subversion post commit hook, and it takes two parameters, so those need to be passed along to the .net assembly. The <code>"$@"</code> was what was recommended at the mono site for calling a .net assembly from a shell script. The shell script <i>is</i> executing the .net assembly and with the correct parameters, but it is throwing an exception that does not get thrown when run directly from the command line.</p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54568">@Vinko</a>, I don't see any differences in the environment other than things like <code>BASH_LINENO</code> and <code>BASH_SOURCE</code></p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54818">@Luke</a>, I tired it, but that makes no difference either. I first noticed the problem when testing from TortoiseSVN on my machine (when it runs as a sub-process of the subversion daemon), but also found that I get the same results when executing the script from the hooks directory (i.e. <code>./post-commit REPOS REV</code>, where <code>post-commit</code> is the above sh script. Doing <code>mono post-commit.exe REPOS REV</code> works fine. The main problem is that to execute, I need to have something of the name <code>post-commit</code> so that it will be called. But it does not work from a shell script, and as noted above, the <code>mkbundle</code> is not working with a different problem.</p>
|
<p>It is normal for some processes to hang around for a while after they close their stdout (ie. you get an end-of-file reading from them). You need to call <code>proc.WaitForExit()</code> after reading all the data but before checking ExitCode.</p>
|
<p>Just a random thought that might help with debugging. Try changing your shell script to:</p>
<pre><code>#!/bin/sh
echo /usr/bin/mono $1/hooks/post-commit.exe "$@"
</code></pre>
<p>Check and see if the line it prints matches the command you're expecting it to run. It's possible your command line argument handling in the shell script isn't doing what you want it to do.</p>
<p>I don't know what your input to the script is expected to be, but the $1 before the path looks a bit out of place to me.</p>
| 7,811
|
<p>Nokia has stopped offering its Developer's Suite, relying on other IDEs, including Eclipse. Meanwhile, Nokia changed its own development tools again and EclipseMe has also changed. This leaves most documentation irrelevant. </p>
<p>I want to know what does it take to make a simple Hello-World?</p>
<p>(I already found out myself, so this is a Q&A for other people to use)</p>
|
<p>Here's what's needed to make a simple hello world -</p>
<ol>
<li>Get <a href="http://www.eclipse.org/downloads/" rel="nofollow noreferrer">Eclipse</a> IDE for Java. I used Ganymede. Set it up.</li>
<li>Get Sun's <a href="http://java.sun.com/products/sjwtoolkit/download.html" rel="nofollow noreferrer">Wireless Toolkit</a>. I used 2.5.2. Install it.</li>
<li>Get Nokia's SDK (<a href="http://developers.nokia.com/info/sw.nokia.com/id/cc48f9a1-f5cf-447b-bdba-c4d41b3d05ce/Series_40_Platform_SDKs.html" rel="nofollow noreferrer">found here</a>), in my case for S40 6230i Edition, and install it choosing the option to <strong>integrate with Sun's WTK</strong></li>
<li>Follow the instructions at <a href="http://www.eclipseme.org/" rel="nofollow noreferrer">http://www.eclipseme.org/</a> to download and install Mobile Tools Java (MTJ). I used version 1.7.9. </li>
<li>When configuring devices profiles in MTJ (inside Eclipse) use the Nokia device from the WTK folder and NOT from Nokia's folder.</li>
<li>Set the WTK root to the main installation folder - for instance c:\WTK2.5.2; Note that the WTK installer creates other folders apparently for backward compatibility.</li>
<li>Get <a href="http://antenna.sourceforge.net/" rel="nofollow noreferrer">Antenna</a> and set its location in MTJ's property page (in Eclipse).</li>
</ol>
<p><a href="http://wiki.forum.nokia.com/index.php/Hello_World_in_Java_ME" rel="nofollow noreferrer">Here's an HelloWorld sample to test the configuration.</a></p>
<p>Note: It worked for me on WindowsXP.
Also note: This should work for S60 as well. Just replace the S40 SDK in phase 3 with S60's.</p>
|
<p>The most annoying issue with EclipseME for me was the "broken" debugger, which just wouldn't start. This is covered in docs, but it took me about an hour to find this tip when I first installed EclipseME, and another hour when I returned to JavaME development a year later, so I decided to share this piece of knowledge here, too.</p>
<p>If the debugger won't start,</p>
<ol>
<li>open "Java > Debug" section in Eclipse "Preferences" menu, and uncheck "Suspend execution on uncaught exceptions" and "Suspend execution on compilation errors" and</li>
<li>increase the "Debugger timeout" near the bottom of the dialog to at least 15000 ms. </li>
</ol>
<p>After that, Eclipse should be able to connect to KVM and run a midlet with a debugger attached.</p>
| 8,792
|
<p>I am new to 3D printing and need to know if I use steel in printing, do I get the same strength (compression and shear) as steel profiles manufactured in a factory?</p>
|
<p>A laser sintered part typically uses what could be described as surface bonding, as it does not melt particularly deeply into the powder. It would not have the same strength characteristics as machined steel or otherwise processed metal. A part constructed from 3d printing using feed metal/welding methods would have more strength, but would not necessarily have un-modified steel strength, due to the heat applied during the process.</p>
<p>Using a metal which responds to post processing, as in tempering, will likely improve the strength, but I believe that one is unlikely to reach the same values as "ordinary" steel. Compression along the lines of the construction layers would be reasonably strong, but forces applied in other directions are likely to match only the characteristics of the bond. The same consideration applies to shear strength.</p>
|
<p>In terms of FFD plastics:</p>
<p>Using metal infused filaments for FFD printing; definitely not. The properties mixed into the filament will have some affect on the final piece, stronger, heavier, etc for BronzeFill, but still the majority of the print material will be plastic.</p>
<p>However, you can use PLA plastics (and new Moldlay wax like filament) for lost wax casting so all of the plastic is replaced with the molten metal.<br>
In this case, yes, all the plastic or filament is replaced with the final casting metal and it's at strong as any other cast item.</p>
| 248
|
<p>What's the best way to specify a proxy with username and password for an http connection in python?</p>
|
<p>This works for me: </p>
<pre><code>import urllib2
proxy = urllib2.ProxyHandler({'http': 'http://
username:password@proxyurl:proxyport'})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
urllib2.install_opener(opener)
conn = urllib2.urlopen('http://python.org')
return_str = conn.read()
</code></pre>
|
<p>Or if you want to install it, so that it is always used with urllib2.urlopen (so you don't need to keep a reference to the opener around):</p>
<pre><code>import urllib2
url = 'www.proxyurl.com'
username = 'user'
password = 'pass'
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
# None, with the "WithDefaultRealm" password manager means
# that the user/pass will be used for any realm (where
# there isn't a more specific match).
password_mgr.add_password(None, url, username, password)
auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
print urllib2.urlopen("http://www.example.com/folder/page.html").read()
</code></pre>
| 5,423
|
<p>As an engineer I was initially interested in making parts. For example I designed and printed a better part for something which wasn't available locally, and even had a client who wanted 150 of them. But print time was 23 hours per part. and I didn't have full confidence in the robustness of the part. The layer lines are a big weakness and anything less than 3 mm is so flimsy that it's a waste of time. So robust performance parts are out. As are high tolerance ones. Build volume makes it even less useful. And the design compromises you have to make are difficult to justify if there are other ways.</p>
<p>Then with other network parts I thought of designing the vast majority needed other bits and pieces, screws, shafts, connectors in metal that I'd need to source and assemble. Enclosures were okay, but weak, and I can fabricate those stronger and faster in other ways.</p>
<p>So now I mainly just print to what I perceive to be 3D printings strengths and have almost given up on parts.</p>
<p>Has anyone had a different experience?</p>
|
<blockquote>
<p>Under what circumstances</p>
</blockquote>
<p>When your part has internal geometry that would be difficult and expensive to reproduce using other methods. For example fishing lures which need internal water channels. Fittings or covers that would normally require several parts to be sealed together could be simplified to a single part and gasket.</p>
<p>When your part is a complex shape but has no need to be particularly robust because it doesn't come under stress.</p>
<p>When you need a part that you can design with a specific weight and shape you can control the weight with the infill percentage and other factors.</p>
<p>When your part is a niche one that goes with 3d printing strengths. Such as short term or single use items like name plates for conferences, key ring giveaways. Items of novelty value etc,.</p>
<p>When the part is not just functional, you may want a simple functionality in an ornate part for promotional, branding, or other reasons. I was tasked to create a container of certain dimensions. I could have done this a number of ways. But they also wanted their logo and a bunch of designs along a particular theme incorporated into it. Only with 3d printing was this able to be accomplished.</p>
|
<p>I've only just started my journey in 3d printing, but I have a little hobbyist experience in other forms of "structural crafting". I can see a few ways you can use 3d printing to enhance other techniques - the main one being that a printed part can be used to make a mold, which you can then use to cast aluminum, bronze, or whatever else.</p>
| 2,128
|
<p>ASP.NET MVC has been <a href="https://stackoverflow.com/questions/tagged/mvc">discussed</a> on this forum a few times. I'm about to do a large <strong>migration</strong> of several websites from classic ASP/ASP.NET WebForms to ASP.NET MVC and was wondering what kind of advice those of you with experience in both technologies have.</p>
<p>What I have: a typical ASP.NET app with heavily coupled presentation/business logic, all sorts of messy ASP.NET-generated Javascript cruft, and so forth.</p>
<p>What I want: clean ASP.NET MVC-generated agnostic markup. 'Nuff said.</p>
<p>Any pointers, tips, tricks, or gotchas to be aware of?</p>
<p>Thanks!</p>
|
<blockquote>
<p>Any pointers, tips, tricks, or
gotchas to be aware of?</p>
</blockquote>
<p>Well, I think you're probably a little ways away from thinking about tricks & gotchas :) As I'm sure you're aware, ASP.NET MVC is not some new version of ASP.NET, but a totally different paradigm from ASP.NET, you won't be migrating, you'll be initiating a brand new development effort to replace an existing system. So maybe you can get a leg up on determining requirements for the app, but the rest will probably re-built from scratch.</p>
<p>Based on the (very common) problems you described in your existing code base you should consider taking this opportunity to learn some of the current best practices in designing loosely coupled systems. This is easy to do because modern "best practices" are easy to understand and easy to practice, and there is enormous community support, and high quality, open source tooling to help in the process.</p>
<p>We are moving an ASP/ASP.NET application to ASP.NET MVC at this time as well, and this is the conclusion my preparatory research has led me to, anyway.</p>
<p><a href="http://www.thefreakparade.com/2008/07/to-aspnetmvc-or-not-to-mvc-or-aspnet-mvc-hyperlink-acupuncture/" rel="nofollow noreferrer">Here is a post to links on using ASP.NET MVC</a>, but I would start by <a href="http://www.thefreakparade.com/2008/07/so-you-want-to-learn-nhibernate-part-12-prerequisites-or-nhibernate-marijuananet/" rel="nofollow noreferrer">reading this post</a>. The post is about NHibernate (an ORM tool) on its surface but the discussion and the links are about getting the foundations right and is the result of preparing to port an ASP.NET site to MVC. Some of the reference architectures linked to in that post are based on ASP.NET MVC. <a href="http://www.thefreakparade.com/2008/07/so-you-want-to-learn-nhibernate-part-1-of-1-the-links/" rel="nofollow noreferrer">Here is another post about NHibernate</a>, but in the "Best Practices & Reference Applications" section most if not all of the reference applications listed are ASP.NET MVC applications also. Reference architectures can be extremely useful for quickly getting a feeling for how an optimal, maintainable ASP.NET MVC site might be designed.</p>
|
<p>My opinion is that the two technologies are so different that if you have tightly coupled code in the original Web Form applications that the best approach is to start by picking one of them and converting it by creating a new ASP.NET MVC application and ripping out code into their respective layers. Which will put you on the trail of reuse for porting the other applications.</p>
| 3,463
|
<p>It's fall of 2008, and I still hear developers say that you should not design a site that requires JavaScript.</p>
<p>I understand that you should develop sites that degrade gracefully when JS is not present/on. But at what point do you not include funcitonality that can only be powered by JS? </p>
<p>I guess the question comes down to demographics. Are there numbers out there of how many folks are browsing without JS? </p>
|
<p>Just as long as you're aware of the accessibility limitations you might be introducing, ie for users of screen-reading software, etc.</p>
<p>It's one thing to exclude people because they choose to turn off JS or use a browser which doesn't support it, it's entirely another to exclude them because of a disability.</p>
|
<p>It's the 21st century. People not permitting JavaScript need to exit the last millennium, posthaste. It's a mature, widely used, and very useful technology that is one of the foundations of the recent expansion in useful web services.</p>
| 8,827
|
<p>Printer: SecKit Go w/ BMG/v6 and SKR v1.3/TMC2130 Drivers</p>
<p>Slicer: Simplify3d or Cura (problem is much worse in Cura?)</p>
<p>Long story short - after getting this printer running, I have noticed that it will underextrude ONLY on corners on an internal perimeter specifically once we're above bottom layers - and nowhere else. See below:</p>
<p><a href="https://i.stack.imgur.com/J9Y3r.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J9Y3r.jpg" alt="enter image description here"></a></p>
<p>E-Steps have been calibrated, extrusion multiplier has been calibrated (single perimeters are 0.48 mm), linear advance has been calibrated, but here it gets weird. Anything resembling a 'standard' value (suggested between 1-2) results in MASSIVE underextrusion after the speed change. I was able to get a good looking line using the linear advance test with a value of 0.15 (which seems very low).</p>
<p><a href="https://i.stack.imgur.com/VvSl7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VvSl7.jpg" alt="enter image description here"></a></p>
<p>Retraction (1 mm @ 30 mm/s), junction deviation (0.02) and all other settings are off the factory Simplify3d profile. Turning linear advance off makes the problem slightly better but doesn't fix it, going to a value of around 1 results in huge underextrusion after any change in direction.</p>
<p>I am absolutely lost as to what to try next.</p>
|
<p>Unsupported parts need to be printed with support. If your supports are too hard to remove, try the Tree Support setting and make sure that your support structure is set up with a gap to the actual print. As we don't know which slier you use, I can't go into more details here.</p>
|
<p>You could try printing slower and/or increase cooling ( possibly even a cooler bed temp) if you absolutely want to avoid supports, or just use supports with a support interface and tweak support distance.</p>
| 1,606
|
<p>The company I used to work with has two developers working fulltime, and a handful of freelancers. They're in the process of hiring a new lead developer to try to bring order and management to the development.</p>
<p>But, currently, one of the developers has seen the light of Django (the company has only developed in PHP to date) while the other developer is concerned that introducing a new language (Python) is a bad idea right now.</p>
<p>How should they approach introducing this new technology? Obviously with only one of the developers actually knowing Python, there will be no redundancy when that dev is away or leaves the company.</p>
<p>Should they bother to introduce Python, or should they look for PHP-only solutions until such a time when the team actually have more than one Pythonion? Without a team leader, the decisions are having to fall to them.</p>
|
<p>I recently introduced Python to my company, which does consulting work for the Post Office. I did this by waiting until there was a project for which I would be the only programmer, then getting permission to do this new project in Python. I then did another small project in Python with similarly impressive results. In addition, I used Python for all of my small throwaway assignments ("can you parse the stats in these files into a CSV file organized by date and site?", etc) and had a quick turnaround time on all of them.</p>
<p>I also evangelized Python a bit; I went out of my way to NOT be obnoxious about it, but I'd occasionally describe why I liked it so much, talked about the personal projects I use it for in my free time and why it's awesome for me, etc.</p>
<p>Eventually we started another project and I convinced everyone to use Python for it. I took care to point everyone to a lot of documentation, including the specific webpages relating to what they were working on, and every time they had a question, I'd explain how to do things properly by explaining the Pythonic approach to things, etc.</p>
<p>This has worked really well. However, this might be somewhat different than what you're describing. In my case I started with moderately small projects and Python is only being used for new projects. Also, none of my co-workers were really Perl or PHP gurus; they all knew those languages and had been using them for awhile, but it didn't take much effort for them to become more productive in Python than they'd been before.</p>
<p>So if you're talking about new projects with people who currently use PHP but aren't super-experts and don't love that language, then I think switching to Python is a no-brainer. However, if you're talking about working with a large existing PHP code base with a lot of very experienced PHP programmers who are happy with their current setup, then switching languages is probably not a good idea. You're probably somewhere in between, so you'll have to weigh the tradeoffs; hopefully my answer will help you do that.</p>
|
<p>Well, python is a high level language.. its not hard to learn and if the guys already have programming knowledge it should be much easier to learn.. i like django.. i think it should be a nice try to use django .. </p>
| 4,006
|
<p>In my job we have to deploy an application on various environments. It's a standard WAR file which needs a bit of configuration, deployed on Tomcat 6.</p>
<p>Is there any way of creating a 'deployment package' with Tomcat so that you just extract it and it sets up Tomcat as well as your application? I'm not sure that creating a .zip file with the Tomcat folder would work! It certainly wouldn't install the service.</p>
<p>Suggestions welcome!</p>
<p>I should note that - at the moment - all apps are deployed on Windows servers.</p>
<p>Thanks,
Phill</p>
|
<p>lex/flex and yacc/bison provide easy-to-use, well-understood lexer- and parser-generators, and I'd really recommend doing something like that as opposed to doing it procedurally in e.g. Perl. Regular expressions are powerful stuff for ripping apart strings with relatively-, but not totally-fixed structure. With any real programming language, the size of your state machine gets to be simply unmanageable with anything short of a Real Lexer/Parser (tm). Imagine dealing with all possible interleavings of keywords, identifiers, operators, extraneous parentheses, extraneous semicolons, and comments that are allowed in something like Verilog AMS, with regular expressions and procedural code alone.</p>
<p>There's no denying that there's a substantial learning curve there, but writing a grammar that you can use for flex and bison, and doing something useful on the syntax tree that comes out of bison, will be a much better use of your time than writing a ton of special-case string-processing code that's more naturally dealt with using a syntax-tree in the first place. Also, what you learn writing it this way will truly broaden your skillset in ways that writing a bunch of hacky Perl code just won't, so if you have the means, I highly recommend it ;-)</p>
<p>Also, if you're lazy, check out the Eclipse plugins that do syntax highlighting and basic refactoring for Verilog and VHDL. They're in an incredibly primitive state, last I checked, but they may have some of the code you're looking for, or at least a baseline piece of code to look at to better inform your approach in rolling your own.</p>
|
<p>In trying to find my answer, I found this on <a href="http://www.ibm.com/developerworks/edu/au-dw-au-parsingwithantlr-i.html" rel="nofollow noreferrer">ANTLR</a> - might be of use</p>
| 9,616
|
<p>How can I test the same regex against different regular expression engines?</p>
|
<p>The most powerful free online regexp testing tool is by far <a href="http://regex101.com/" rel="nofollow noreferrer">http://regex101.com/</a> - lets you select the RE engine (PCRE, JavaScript, Python), has a debugger, colorizes the matches, explains the regexp on the fly, can create permalinks to the regex playground.</p>
<p>Other online tools:</p>
<ul>
<li><a href="http://www.rexv.org/" rel="nofollow noreferrer">http://www.rexv.org/</a> - supports PHP and Perl PCRE, Posix, Python, JavaScript, and Node.js</li>
<li><a href="http://refiddle.com/" rel="nofollow noreferrer">http://refiddle.com/</a> - Inspired by jsfiddle, but for regular expressions. Supports JavaScript, Ruby and .NET expressions.</li>
<li><a href="http://regexpal.com/" rel="nofollow noreferrer">http://regexpal.com/</a> - powered by the <a href="http://xregexp.com/" rel="nofollow noreferrer">XRegExp</a> JavaScript library</li>
<li><a href="http://www.rubular.com/" rel="nofollow noreferrer">http://www.rubular.com/</a> - Ruby-based</li>
<li><a href="http://www.perlfect.com/articles/regextutor.shtml" rel="nofollow noreferrer">Perl Regex Tutor</a> - uses PCRE</li>
</ul>
<p>Windows desktop tools:</p>
<ul>
<li><a href="http://www.weitz.de/regex-coach/" rel="nofollow noreferrer">The Regex Coach</a> - free Windows application</li>
<li><a href="http://www.regexbuddy.com/" rel="nofollow noreferrer">RegexBuddy</a> recommended by most, costs US$ 39.95</li>
</ul>
<p>Jeff Atwood [wrote about regular expressions]( post:).</p>
<p>Other tools recommended by SO users include:</p>
<ul>
<li><a href="http://www.txt2re.com/" rel="nofollow noreferrer"><a href="http://www.txt2re.com/" rel="nofollow noreferrer">http://www.txt2re.com/</a></a> Online free tool to generate regular expressions for multiple language (@<a href="https://stackoverflow.com/questions/4736/learning-regular-expressions#4763">palmsey</a> another thread)</li>
<li>The Added Bytes <a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/" rel="nofollow noreferrer">Regular Expressions Cheat Sheet</a> (@<a href="https://stackoverflow.com/questions/4736/learning-regular-expressions#4739">GateKiller</a> another thread)</li>
<li><a href="http://regexhero.net/" rel="nofollow noreferrer">http://regexhero.net/</a> - The Online .NET Regular Expression Tester. Not free.</li>
</ul>
|
<p>RegExBuddy so far I concur with and endorse.</p>
| 5,221
|
<p>Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?</p>
|
<p>The previously mentioned <code>wmic</code> command is the way to go, as it is installed by default in recent versions of Windows. </p>
<p>Here is my small improvement to generalize it, by retrieving the current name from the environment:</p>
<pre class="lang-dos prettyprint-override"><code>wmic computersystem where name="%COMPUTERNAME%"
call rename name="NEW-NAME"
</code></pre>
<p>NOTE: The command must be given in one line, but I've broken it into two to make scrolling unnecessary. As @rbeede mentions you'll have to reboot to complete the update.</p>
|
<p>If you are looking to do this from Windows 10 IoT, then there is a built in command you can use:</p>
<p><code>setcomputername [newname]</code></p>
<p>Unfortunately, this command does <em>not exist</em> in the full build of Windows 10.</p>
| 7,868
|
<p>Should you set all the objects to <code>null</code> (<code>Nothing</code> in VB.NET) once you have finished with them? </p>
<p>I understand that in .NET it is essential to dispose of any instances of objects that implement the <code>IDisposable</code> interface to release some resources although the object can still be something after it is disposed (hence the <code>isDisposed</code> property in forms), so I assume it can still reside in memory or at least in part?</p>
<p>I also know that when an object goes out of scope it is then marked for collection ready for the next pass of the garbage collector (although this may take time).</p>
<p>So with this in mind will setting it to <code>null</code> speed up the system releasing the memory as it does not have to work out that it is no longer in scope and are they any bad side effects?</p>
<p>MSDN articles never do this in examples and currently I do this as I cannot
see the harm. However I have come across a mixture of opinions so any comments are useful.</p>
|
<p>Karl is absolutely correct, there is no need to set objects to null after use. If an object implements <code>IDisposable</code>, just make sure you call <code>IDisposable.Dispose()</code> when you're done with that object (wrapped in a <code>try</code>..<code>finally</code>, or, a <code>using()</code> block). But even if you don't remember to call <code>Dispose()</code>, the finaliser method on the object should be calling <code>Dispose()</code> for you.</p>
<p>I thought this was a good treatment:</p>
<blockquote>
<p><a href="http://web.archive.org/web/20090311003201/http://msdn.microsoft.com/en-us/magazine/cc163392.aspx" rel="noreferrer">Digging into IDisposable</a></p>
</blockquote>
<p>and this </p>
<blockquote>
<p><a href="http://web.archive.org/web/20090426210049/www.marcclifton.com/tabid/79/Default.aspx" rel="noreferrer">Understanding IDisposable</a></p>
</blockquote>
<p>There isn't any point in trying to second guess the GC and its management strategies because it's self tuning and opaque. There was a good discussion about the inner workings with Jeffrey Richter on Dot Net Rocks here: <a href="http://www.dotnetrocks.com/default.aspx?showNum=361" rel="noreferrer">Jeffrey Richter on the Windows Memory Model</a> and
Richters book <a href="http://amzn.eu/d/aitTG0A" rel="noreferrer">CLR via C#</a> chapter 20 has a great treatment: </p>
|
<p>Some object suppose the <code>.dispose()</code> method which forces the resource to be removed from memory.</p>
| 2,491
|
<p>I am trying to make a structured light 3D scanner using single camera, light projector and a turntable.</p>
<p>After days on Google I did not find any reliable open source project which I can get to work. <a href="https://github.com/jakobwilm/slstudio" rel="noreferrer">SLStudio</a> really seemed a good choice but did not compile properly. </p>
<p>I was wondering if anyone knows a good open source which they have used with the same kind of setup? Any help would be really appreciated. I am blocked here.</p>
|
<p>I did find only one 3d scanner which uses structured light. There is many projects using a laser diode. And these systems are completely opensource.</p>
<h1>Structured Light</h1>
<h2>Structured Light 3D Scanning by kylemcdonald</h2>
<ul>
<li><a href="http://www.instructables.com/id/Structured-Light-3D-Scanning/?ALLSTEPS" rel="noreferrer">http://www.instructables.com/id/Structured-Light-3D-Scanning/?ALLSTEPS</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/vZv6S.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/vZv6S.jpg" alt="enter image description here"></a></p>
<h1>Laser diode</h1>
<h2>Sardauscan</h2>
<ul>
<li><a href="http://www.instructables.com/id/Build-a-30-laser/?ALLSTEPS" rel="noreferrer">http://www.instructables.com/id/Build-a-30-laser/?ALLSTEPS</a></li>
<li><a href="https://github.com/Sardau/Sardauscan" rel="noreferrer">https://github.com/Sardau/Sardauscan</a></li>
<li><a href="http://www.thingiverse.com/thing:702470" rel="noreferrer">http://www.thingiverse.com/thing:702470</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/sB4pN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/sB4pN.jpg" alt="enter image description here"></a></p>
<h2>ATLAS 3D Scanner</h2>
<ul>
<li><a href="http://www.freelss.org" rel="noreferrer">http://www.freelss.org</a></li>
<li><a href="http://www.thingiverse.com/thing:1280901" rel="noreferrer">http://www.thingiverse.com/thing:1280901</a></li>
<li><a href="https://www.kickstarter.com/projects/1545315380/atlas-3d-the-3d-scanner-you-print-and-build-yourse/posts/1475722" rel="noreferrer">https://www.kickstarter.com/projects/1545315380/atlas-3d-the-3d-scanner-you-print-and-build-yourse/posts/1475722</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/ENwwb.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ENwwb.jpg" alt="enter image description here"></a></p>
<h2>Ciclop</h2>
<ul>
<li><a href="http://diwo.bq.com/en/tag/ciclop/" rel="noreferrer">http://diwo.bq.com/en/tag/ciclop/</a></li>
<li><a href="https://github.com/bqlabs/ciclop" rel="noreferrer">https://github.com/bqlabs/ciclop</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/Goheb.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Goheb.jpg" alt="enter image description here"></a></p>
<h2>3D(ollar) Scanner</h2>
<ul>
<li><a href="https://hackaday.io/project/2021-3dollar-scanner" rel="noreferrer">https://hackaday.io/project/2021-3dollar-scanner</a></li>
<li><a href="http://www.instructables.com/id/Lets-cook-3D-scanner-based-on-Arduino-and-Proces/?ALLSTEPS" rel="noreferrer">http://www.instructables.com/id/Lets-cook-3D-scanner-based-on-Arduino-and-Proces/?ALLSTEPS</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/fFKEj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fFKEj.jpg" alt="enter image description here"></a></p>
<h2>"Super Make Something" Tutorial On How To Build a Simple 3D Scanner</h2>
<ul>
<li><a href="https://www.youtube.com/watch?v=-qeD2__yK4c" rel="noreferrer">https://www.youtube.com/watch?v=-qeD2__yK4c</a></li>
<li><a href="http://www.thingiverse.com/thing:1413891" rel="noreferrer">http://www.thingiverse.com/thing:1413891</a></li>
<li><a href="http://diy3dprinting.blogspot.de/2016/04/super-make-something-tutorial-on-how-to.html" rel="noreferrer">http://diy3dprinting.blogspot.de/2016/04/super-make-something-tutorial-on-how-to.html</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/SfQNb.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SfQNb.jpg" alt="enter image description here"></a></p>
<h1>Different method</h1>
<h2>$15 3D scanner consists of a tub of milk and a smartphone</h2>
<p>Interesting idea of using milk and phone.</p>
<ul>
<li><a href="http://www.instructables.com/id/GotMesh-the-Most-Cheap-and-Simplistic-3D-Scanner/" rel="noreferrer">http://www.instructables.com/id/GotMesh-the-Most-Cheap-and-Simplistic-3D-Scanner/</a></li>
<li><a href="http://www.3ders.org/articles/20160423-this-3d-scanner-consists-of-a-tub-of-milk-and-a-smartphone.html" rel="noreferrer">http://www.3ders.org/articles/20160423-this-3d-scanner-consists-of-a-tub-of-milk-and-a-smartphone.html</a></li>
</ul>
<p><a href="https://i.stack.imgur.com/XDoCO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/XDoCO.jpg" alt="enter image description here"></a></p>
|
<p><a href="http://www.makeralot.com/ciclop-3d-scanner-diy-kit-p196/" rel="nofollow noreferrer" title="BQ Ciclop 3D Scanner">BQ Ciclop 3D Scanner</a></p>
<ul>
<li>Scan Volume: Bigger than 5 cm x 5 cm and smaller than 20 cm x 20 cm</li>
<li>Scanning Precision: 0.5 mm</li>
</ul>
<p>All the necessary parts for Ciclop are included in this DIY kit, which comes unassembled.</p>
<p>This Ciclop 3D Scanner Parts List:</p>
<ul>
<li>1 x Plastic parts( 1 set with 11 pcs)</li>
<li>1 x Arduino Uno R3 with USB cable</li>
<li>1 x ZUM Scan Shield</li>
<li>1 x A4988 Stepper Driver</li>
<li>1 x C270 HD camera</li>
<li>1 x Nema17 stepper motor</li>
<li>2 x Laser</li>
<li>1 x Power supply adapter</li>
<li>1 x 16014 ball bearing</li>
<li>1 x M8 threaded rod (9 pcs)</li>
<li>2 x Acrylic panel</li>
<li>1 x 8mm spiral wrapping band</li>
<li>1 x Set of screw and nuts</li>
</ul>
| 285
|
<p>I tried printing from an STL file on the <em>QIDI TECHNOLOGY 3DP-QDA16-01 Dual Extruder Desktop 3D Printer QIDI TECH I</em>. They recommend using the MakerBot software with the <em>Replicator(Dual)</em> profile. The 3D print that I tried is messed up.</p>
<p>The material used is <strong>PLA</strong>.</p>
<p>Could you help me determine the cause? The following pictures give more details:
(<em>All settings which are not shown are Makerware default settings</em>)</p>
<p><a href="https://i.stack.imgur.com/Abvj2m.png" rel="nofollow noreferrer">1</a> <strong>The 3D model</strong></p>
<p><a href="https://i.stack.imgur.com/Abvj2m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Abvj2m.png" alt="The 3D Model"></a></p>
<p><a href="https://i.stack.imgur.com/zmWnrm.jpg" rel="nofollow noreferrer">2</a> <strong>The printed sample</strong></p>
<p><a href="https://i.stack.imgur.com/zmWnrm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zmWnrm.jpg" alt="The printed sample"></a></p>
<p><a href="https://i.stack.imgur.com/viQoPm.png" rel="nofollow noreferrer">3</a> <strong>The Settings</strong></p>
<p><a href="https://i.stack.imgur.com/viQoPm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/viQoPm.png" alt="Settings"></a></p>
<p><a href="https://i.stack.imgur.com/l3b7om.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l3b7om.png" alt="Settings"></a></p>
|
<p>Your print isn't cooling fast enough. With small, thin prints like this, PLA needs a fair bit of airflow to solidify before the next layer goes down. Your printer doesn't appear to have a proper print-cooling fan, so I have two suggestions:</p>
<ul>
<li>Print two or even three of the part at the same time, spaced a fair distance apart on the build plate. This will give each of them time to cool.</li>
<li>Point a box fan into the front of the printer to get good airflow over the print.</li>
</ul>
|
<p>I agree with <a href="https://3dprinting.stackexchange.com/questions/1511/irregular-3d-printed-part/1513#1513">RyanCarlyle</a> on this:</p>
<blockquote>
<p>Your print isn't cooling fast enough.</p>
</blockquote>
<p>Please regard <a href="https://3dprinting.stackexchange.com/questions/540/mushy-small-top-layers/541#541">this answer</a> of mine that covers a few options to help with the issue you're encountering. Pay particular attention to the <em>layer times</em>, and <em>active cooling</em>.</p>
<p>The essential take-away from my answer <sup>(linked above)</sup> is this:</p>
<ul>
<li><strong>Increase Layer Times</strong>. Increasing <strong>Minimum Layer Duration</strong> <sub>(Device Settings -> Minimum Layer Duration)</sub> will provide the material with more time to naturally cool down closer to its environment's temperature. What this does is ensure that the latest layer is <strong><em>mostly</em></strong> solid before the machine begins printing the next molten layer. If you don't let the previous layer of plastic solidify enough, then plastic gets pushed/pulled around when the machine moves, adding more plastic; thus resulting in the issue you see in your images. The caveat with this approach is the obvious impact on the overall runtime of your print and should ideally be done more or less as a last resort.</li>
<li><strong>Active Cooling</strong>. Active cooling is typically done using an additional fan, often times mounted directly in front of the extruder. The act of active cooling provides a quicker and more direct means of cooling the printed plastic. However, depending on machine design, you may see more variability on other places such as dependability in extrusion temperatures. This can be more detrimental with cheaper spools of PLA and especially poorly designed machines that can't properly maintain extruder temperatures. Active cooling is, however, very common and seems to work for the majority of 3D printer enthusiasts and doesn't impede on runtime.</li>
</ul>
| 343
|
<p>I have a web service that queries data from this json file, but I don't want the web service to have to access the file every time. I'm thinking that maybe I can store the data somewhere else (maybe in memory) so the web service can just get the data from there the next time it's trying to query the same data. I kinda understand what needs to be done but I'm just not sure how to actually do it. How do we persist data in a web service? </p>
<p><strong>Update:</strong>
Both suggestions, caching and using static variables, look good. Maybe I should just use both so I can look at one first, and if it's not in there, use the second one, if it's not in there either, then I'll look at the json file.</p>
|
<p>Extending on <a href="https://stackoverflow.com/questions/11761/persisting-data-in-net-web-service-memory#11779">Ice^^Heat</a>'s idea, you might want to think about where you would cache - either cache the contents of the json file in the Application cache like so: </p>
<pre><code>Context.Cache.Insert("foo", _
Foo, _
Nothing, _
DateAdd(DateInterval.Minute, 30, Now()), _
System.Web.Caching.Cache.NoSlidingExpiration)
</code></pre>
<p>And then generate the results you need from that on every hit. Alternatively you can cache the webservice output on the function definition: </p>
<pre><code><WebMethod(CacheDuration:=60)> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
</code></pre>
<p>Info gathered from <a href="http://msdn.microsoft.com/en-us/library/aa480499.aspx" rel="nofollow noreferrer">XML Web Service Caching Strategies</a>.</p>
|
<p>ASP.NET caching works just as well with Web services so you can implement regular caching as explained here: <a href="http://msdn.microsoft.com/en-us/library/aa478965.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa478965.aspx</a></p>
| 3,284
|
<p>I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item?</p>
|
<p>Probably using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.onpaste" rel="nofollow noreferrer"><code>onpaste</code></a> event, and either <code>return false</code> from it or use <code>e.preventDefault()</code> on the Event object.</p>
<p>Note that <code>onpaste</code> is <em>non standard</em>, don't rely on it for production sites, because it will not be there forever.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).on("paste",function(e){
console.log("paste")
e.preventDefault()
return false;
})</code></pre>
</div>
</div>
</p>
|
<p>Even if it is somewhat possible to intercept the paste event in many browsers (but not all as shown at the link on the previous answer), that is quite unreliable and posible not complete (depending on the browser / OS it may be possible to do the paste operation in different ways that may not be trappable by javascript code).</p>
<p><a href="http://discerning.com/topics/software/ttw.html#copy_and_paste" rel="nofollow noreferrer" title="Here">Here</a> is a collection of notes regarding paste (and copy) in the context of rich text editors that may be applied also elsewhere.</p>
| 5,309
|
<p>I'm looking into clustering points on a map (latitude/longitude). Are there any recommendations as to a suitable algorithm that is fast and scalable?</p>
<p>More specifically, I have a series of latitude/longitude coordinates and a map viewport. I'm trying to cluster the points that are close together in order to remove clutter.</p>
<p>I already have a solution to the problem (<a href="http://bouldr.net" rel="noreferrer">see here</a>), only I am wondering if there is any formal algorithm that solves the problem efficiently.</p>
|
<p>For a virtual earth application I've used the clustering described
<a href="https://web.archive.org/web/20130410092213/http://www.soulsolutions.com.au/Articles/ClusteringVirtualEarthPart1.aspx" rel="nofollow noreferrer">here</a>. It's lightning fast and easily extensible.</p>
|
<p>I looked at various libraries and found them so complex couldn't understand a word so I decided to make my own clustering algorithm</p>
<p>Here goes my code in Java</p>
<pre><code>static int OFFSET = 268435456;
static double RADIUS = 85445659.4471;
static double pi = 3.1444;
public static double lonToX(double lon) {
return Math.round(OFFSET + RADIUS * lon * pi / 180);
}
public static double latToY(double lat) {
return Math.round(OFFSET
- RADIUS
* Math.log((1 + Math.sin(lat * pi / 180))
/ (1 - Math.sin(lat * pi / 180))) / 2);
}
</code></pre>
<p>// This calculates the pixel distance between tow lat long points at a particular zoom level </p>
<pre><code> public static int pixelDistance(double lat1, double lon1, double lat2,
double lon2, int zoom) {
double x1 = lonToX(lon1);
double y1 = latToY(lat1);
double x2 = lonToX(lon2);
double y2 = latToY(lat2);
return (int) (Math
.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2))) >> (21 - zoom);
}
</code></pre>
<p>// The main function which actually calculates the clusters
1. ArrayList of lat long points is iterated to length .
2. inner loop a copy of the same arraylist is iterated from i+1 position ie leaving the top loop's index
3. 0th element is taken as the centre of centroid and all other points are compared if their pixel distance is very less add it into cluster
4. remove all elements from top arraylist and copy arraylist which have formed cluster
5 restart the process by reinitializing the index from 0;
6 if the centroid selected has no clusters then that element is not deleted</p>
<pre><code>static ArrayList<Cluster> cluster(ArrayList<Marker> markers, int zoom) {
ArrayList<Cluster> clusterList = new ArrayList<Cluster>();
ArrayList<Marker> originalListCopy = new ArrayList<Marker>();
for (Marker marker : markers) {
originalListCopy.add(marker);
}
/* Loop until all markers have been compared. */
for (int i = 0; i < originalListCopy.size();) {
/* Compare against all markers which are left. */
ArrayList<Marker> markerList = new ArrayList<Marker>();
for (int j = i + 1; j < markers.size();) {
int pixelDistance = pixelDistance(markers.get(i).getLatitude(),
markers.get(i).getLongitude(), markers.get(j)
.getLatitude(), markers.get(j).getLongitude(),
zoom);
if (pixelDistance < 40) {
markerList.add(markers.get(i));
markerList.add(markers.get(j));
markers.remove(j);
originalListCopy.remove(j);
j = i + 1;
} else {
j++;
}
}
if (markerList.size() > 0) {
Cluster cluster = new Cluster(clusterList.size(), markerList,
markerList.size() + 1, originalListCopy.get(i)
.getLatitude(), originalListCopy.get(i)
.getLongitude());
clusterList.add(cluster);
originalListCopy.remove(i);
markers.remove(i);
i = 0;
} else {
i++;
}
/* If a marker has been added to cluster, add also the one */
/* we were comparing to and remove the original from array. */
}
return clusterList;
}
Just pass in your array list here containing latitude and longitude
then to display clusters
here goes the function
@Override
public void onTaskCompleted(ArrayList<FlatDetails> flatDetailsList) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
originalListCopy = new ArrayList<FlatDetails>();
ArrayList<Marker> markersList = new ArrayList<Marker>();
for (FlatDetails detailList : flatDetailsList) {
markersList.add(new Marker(detailList.getLatitude(), detailList
.getLongitude(), detailList.getApartmentTypeString()));
originalListCopy.add(detailList);
builder.include(new LatLng(detailList.getLatitude(), detailList
.getLongitude()));
}
LatLngBounds bounds = builder.build();
int padding = 0; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.moveCamera(cu);
ArrayList<Cluster> clusterList = Utils.cluster(markersList,
(int) googleMap.getCameraPosition().zoom);
// Removes all markers, overlays, and polylines from the map.
googleMap.clear();
// Zoom in, animating the camera.
googleMap.animateCamera(CameraUpdateFactory.zoomTo(previousZoomLevel),
2000, null);
CircleOptions circleOptions = new CircleOptions().center(point) //
// setcenter
.radius(3000) // set radius in meters
.fillColor(Color.TRANSPARENT) // default
.strokeColor(Color.BLUE).strokeWidth(5);
googleMap.addCircle(circleOptions);
for (Marker detail : markersList) {
if (detail.getBhkTypeString().equalsIgnoreCase("1 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk1)));
} else if (detail.getBhkTypeString().equalsIgnoreCase("2 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk_2)));
}
else if (detail.getBhkTypeString().equalsIgnoreCase("3 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk_3)));
} else if (detail.getBhkTypeString().equalsIgnoreCase("2.5 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk2)));
} else if (detail.getBhkTypeString().equalsIgnoreCase("4 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk_4)));
} else if (detail.getBhkTypeString().equalsIgnoreCase("5 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk5)));
} else if (detail.getBhkTypeString().equalsIgnoreCase("5+ BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk_5)));
}
else if (detail.getBhkTypeString().equalsIgnoreCase("2 BHK")) {
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(detail.getLatitude(), detail
.getLongitude()))
.snippet(String.valueOf(""))
.title("Flat" + flatDetailsList.indexOf(detail))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bhk_2)));
}
}
for (Cluster cluster : clusterList) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable = true;
options.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.cluster_marker, options);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.white));
paint.setTextSize(30);
canvas.drawText(String.valueOf(cluster.getMarkerList().size()), 10,
40, paint);
googleMap.addMarker(new MarkerOptions()
.position(
new LatLng(cluster.getClusterLatitude(), cluster
.getClusterLongitude()))
.snippet(String.valueOf(cluster.getMarkerList().size()))
.title("Cluster")
.icon(BitmapDescriptorFactory.fromBitmap(bitmap)));
}
}
ANY QUESTIONS OR DOUBTS PLEASE ASK WILL CLEAR THEM ALL ...........THANKS
</code></pre>
| 9,963
|
<p>I am looking for information on handling search in different ORMs.</p>
<p>Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or even user comments labeled that way.</p>
<p>In environment where everything is searchable ORM need to support this feature in two ways:</p>
<ul>
<li>providing some indexing API on "O" side of ORM</li>
<li>providing means for bulk database retrieval on "R" side</li>
</ul>
<p>Ideal solution would return ready made objects based on searched string.
Do you know any good end-to-end solutions that does the job, not necessarily in PHP?
If you dealt with similar problem it would be nice to listen what your experience is. Something more than <em>Use Lucene</em> or <em>semantic web is the way</em> oneliners, tho ;-)*</p>
|
<p>I have recently integrated the <a href="http://www.compass-project.org/" rel="nofollow noreferrer">Compass</a> search engine into a Java EE 5 application. It is based on <a href="http://lucene.apache.org/java/docs/index.html" rel="nofollow noreferrer">Lucene Java</a> and supports different ORM frameworks as well as other types of models like XML or no real model at all ;)</p>
<p>In the case of an object model managed by an ORM framework you can annotate your classes with special annotations (e.g. @Searchable), register your classes and let Compass index them on application startup and listen to changes to the model automatically.</p>
<p>When it comes to searching, you have the power of Lucene at hand. Compass then gives you instances of your model objects as search result.</p>
<p>It's not PHP, but you said it didn't have to be PHP necessarily ;) Don't know if this helps, though...</p>
|
<p>In a Propel 1.3 schema.xml file, you can specify that you'd like all your models to extend a "BaseModel" class that YOU create.</p>
<p></p>
<p>In that BaseModel, you're going to re-define the save() method to be something like this:</p>
<pre><code>public function save(PropelPDO $con = null)
{
if($this->getIsSearchable())
{
// update your search index here. Lucene, Sphinx, or otherwise
}
return parent::save($conn);
}
</code></pre>
<p>That takes care of keeping everything indexed. As for searching, I'd suggest creating a Search class with a few methods.</p>
<pre><code>class Search
{
protected $_searchableTypes = array('music','video','blog');
public method findAll($search_term)
{
$results = array();
foreach($this->_searchableTypes as $type)
{
$results[] = $this->findType($type, $search_term);
}
return $results;
}
}
</code></pre>
| 4,245
|
<p>I have seen two ways of implementing DAO-DVO design.</p>
<p>1) DVO are objects and DAOs are instantiated using factories i.e DAOs are also objects
2) DVOs are again objects but in this case, DAOs are classes which contain only static methods which accept DVOs to perform tasks.</p>
<p>I was wondering which way is better and more scalable.</p>
|
<p>Try the Spring Framework. DAOs are initialized via Dependency Injection and are just plain 'ole Java objects.</p>
<p>Then, the methods on the DAO should just use Domain Objects that are used at all layers of the Application.</p>
|
<p>I would strongly recommend not using that many layers unless they are really layered physically. eg if you have something like a rich client where you need to send detached objects to update the GUI, otherwise, its a world of pain.</p>
| 4,428
|
<p>I did some tests a while ago and never figured out how to make this work. </p>
<p><strong>The ingredients:</strong></p>
<ul>
<li>COM+ transactional object (developed in VB6) </li>
<li>.Net web application (with transaction) in IIS that...<br>
makes a call to the COM+ component<br>
updates a row in a SQL database</li>
</ul>
<p><strong>Testing:</strong> </p>
<p>Run the .Net application and force an exception. </p>
<p><strong>Result:</strong> </p>
<p>The update made from the .Net application rolls back.<br>
The update made by the COM+ object does not roll back.</p>
<p>If I call the COM+ object from an old ASP page the rollback works.</p>
<p>I know some people may be thinking "what?! COM+ and .Net you must be out of your mind!", but there are some places in this world where there still are a lot of COM+ components. I was just curious if someone ever faced this and if you figured out how to make this work.</p>
|
<p>Because VB and .NET will use different SQL connections (and there is no way to make ADO and ADO.NET share the same connection), your only possibility is to enlist the DTC (Distributed Transaction Coordinator). The DTC will coordinates the two independent transactions so they commit or are rolled-back together.</p>
<p><strong>From .NET</strong>, EnterpriseServices manages COM+ functionality, such as the DTC. In .NET 2.0 and forward, you can use the System.Transactions namespace, which makes things a little nicer. I think something like this should work (untested code):</p>
<pre><code>void SomeMethod()
{
EnterpriseServicesInteropOption e = EnterpriseServicesInteropOption.Full;
using (TransactionScope s = new TransactionScope(e))
{
MyComPlusClass o = new MyComPlusClass();
o.SomeTransactionalMethod();
}
}
</code></pre>
<p>I am not familiar enough with this to give you more advice at this point.</p>
<p><strong>On the COM+ side</strong>, your object needs to be configured to use (most likely "require") a distributed transaction. You can do that from COM+ Explorer, by going to your object's <em>Properties</em>, selecting the <em>Transaction</em> tab, and clicking on "<em>Required</em>". I don't remember if you can do this from code as well; VB6 was created before COM+ was released, so it doesn't fully support everything COM+ does (its transactional support was meant for COM+'s predecessor, called MS Transaction Server).</p>
<p>If everything works correctly, your COM+ object should be enlisting in the existing Context created by your .NET code.</p>
<p>You can use the "Distributed Transaction Coordinator\Transaction List" node in "Component Services" to check and see the distributed transaction being created during the call.</p>
<p>Be aware that you cannot see the changes from the COM+ component reflected on data queries from the .NET side until the Transaction is committed! In fact, it is possible to deadlock! Remember that DTC will make sure that the two transactions are paired, but they are still separate database transactions.</p>
|
<p>How are you implementing this? If you are using EnterpriseServices to manage the .NET transaction, then both transactions should get rolled back, since you're using the same context for them both.</p>
| 4,173
|
<p>I need the month+year from the datetime in SQL Server like 'Jan 2008'. I'm grouping the query by month, year. I've searched and found functions like datepart, convert, etc., but none of them seem useful for this. Am I missing something here? Is there a function for this?</p>
|
<p>If you mean you want them back as a string, in that format;</p>
<pre><code>SELECT
CONVERT(CHAR(4), date_of_birth, 100) + CONVERT(CHAR(4), date_of_birth, 120)
FROM customers
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/ms187928.aspx" rel="noreferrer">Here are the other format options</a></p>
|
<p>The following works perfectly! I just used it, try it out.</p>
<pre><code>date_format(date,'%Y-%c')
</code></pre>
| 6,744
|
<p>Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite text editor UltraEdit32.</p>
<p>Is there any way I can implement MVC without the use of VS?</p>
|
<p>There is nothing VS specific with the MVC framework - it is just a bunch of DLLs that you can use. The wizards in VS just build you a quick-start framework.</p>
<p>ASP.NET MVC is "bin-deployable" - there is nothing too clever to set up on the server either - just point the wildcard ISAPI filter to ASP.NET</p>
|
<p>For small to mid size mvc project <a href="http://www.microsoft.com/web/webmatrix/" rel="nofollow">WebMatrix</a> is not bad at all. Also for simple changes to the projects I often use SublimeText.</p>
| 2,434
|
<p>I have multiple projects in a couple of different workspaces. However, it seems like I can never figure out how to change my current workspace. The result is that files that I have checked out on my machine are shown to be checked out by somebody else and are not accessible.</p>
|
<p>I'm going to assume you mean "workspace", not "workstation", as your question doesn't quite make sense to me otherwise.</p>
<p>In Visual Studio, go to the Source Control Explorer (View->Other Windows->Source Control Explorer). At the top of the source control explorer window you should have a toolbar with a few buttons. Somewhere on that toolbar (for me it's at the right) there should be a Workspace dropdown. Just select the workspace you want to use from that dropdown.</p>
|
<p>I don't entirely understand your question.</p>
<p>Are you saying that files you check out on one machine seems to be unaccessible on another of your machines? I'd say that would be entirely by design, as now you have a file that has local modifications done on one machine, which may or may not be available on your other machines.</p>
<p>When you say <em>checked out by somebody else</em>, what does that mean exactly? How are you verifying this, what are you looking at?</p>
<p>Or do you mean something else? In that case, please elaborate.</p>
| 4,223
|
<p>The most common method for corrupting compressed files is to inadvertently do an ASCII-mode FTP transfer, which causes a many-to-one trashing of CR and/or LF characters.</p>
<p>Obviously, there is information loss, and the best way to fix this problem is to transfer again, in FTP binary mode.</p>
<p>However, if the original is lost, and it's important, how recoverable is the data?</p>
<p>[Actually, I already know what I think is the best answer (it's very difficult but sometimes possible - I'll post more later), and the common non-answers (lots of off-the-shelf programs for repairing CRCs without repairing data), but I thought it would be interesting to try out this question during the stackoverflow beta period, and see if anyone else has gone down the successful-recovery path or discovered tools I don't know about.]</p>
|
<p>From <a href="http://wayback.archive.org/web/jsp/Interstitial.jsp?seconds=5&date=1195189396000&url=http%3A%2F%2Fwww.bukys.com%2Fservices%2Frecovery%2Fexamples%2F&target=http%3A%2F%2Fweb.archive.org%2Fweb%2F20071116050316%2Fhttp%3A%2F%2Fwww.bukys.com%2Fservices%2Frecovery%2Fexamples%2F" rel="nofollow noreferrer">Bukys Software</a></p>
<blockquote>
<p>Approximately 1 in 256 bytes is known
to be corrupted, and the corruption is
known to occur only in bytes with the
value '\012'. So the byte error rate
is 1/256 (0.39% of input), and 2/256
bytes (0.78% of input) are suspect.
But since only three bits per smashed
byte are affected, the bit error rate
is only 3/(256*8): 0.15% is bad, 0.29%
is suspect.</p>
<p>...</p>
<p>An error in the compressed input
disrupts the decompression process for
all subsequent bytes...The fact that
the decompressed output is
recognizably bad so quickly is cause
for hope -- a search for the correct
answer can identify wrong answers
quickly.</p>
<p>Ultimately, several techniques were
combined to successfully extract
reasonable data from these files:</p>
<ul>
<li>Domain-specific parsing of fields and quoted strings</li>
<li>Machine learning from previous data with low probability of damage</li>
<li>Tolerance for file damage due to other causes (e.g. disk full while
logging)</li>
<li>Lookahead for guiding the search along the highest-probability paths</li>
</ul>
<p>These techniques identify 75% of the
necessary repairs with certainty, and
the remainder are explored
highest-probability-first, so that
plausible reconstructions are
identified immediately.</p>
</blockquote>
|
<p>You could try writing a little script to replace all of the CRs with CRLFs (assuming the direction of trashing was CRLF to CR), swapping them randomly per block until you had the correct crc. Assuming that the data wasn't particularly large, I guess that might not use all of your CPU until the heat death of the universe to complete.</p>
<p>As there is definite information loss, I don't know that there is a better way. Loss in the CR to CRLF direction might be slightly easier to roll back.</p>
| 8,442
|
<p>I have decided that all my WPF pages need to register a routed event. Rather than include</p>
<pre><code>public static readonly RoutedEvent MyEvent= EventManager.RegisterRoutedEvent("MyEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BasePage));
</code></pre>
<p>on every page, I decided to create a base page (named BasePage). I put the above line of code in my base page and then changed a few of my other pages to derive from BasePage. I can't get past this error:</p>
<blockquote>
<p>Error 12 'CTS.iDocV7.BasePage' cannot
be the root of a XAML file because it
was defined using XAML. Line 1
Position
22. C:\Work\iDoc7\CTS.iDocV7\UI\Quality\QualityControlQueuePage.xaml 1 22 CTS.iDocV7</p>
</blockquote>
<p>Does anyone know how to best create a base page when I can put events, properties, methods, etc that I want to be able to use from any wpf page?</p>
|
<p>Here's how I've done this in my current project.</p>
<p>First I've defined a class (as @Daren Thomas said - just a plain old C# class, no associated XAML file), like this (and yes, this is a real class - best not to ask):</p>
<pre><code>public class PigFinderPage : Page
{
/* add custom events and properties here */
}
</code></pre>
<p>Then I create a new Page and change its XAML declaration to this:</p>
<pre><code><my:PigFinderPage x:Class="Qaf.PigFM.WindowsClient.PenSearchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Qaf.PigFM.WindowsClient"
/>
</code></pre>
<p>So I declare it as a PigFinderPage in the "my" namespace. Any page-wide resources you need have to be declared using a similar syntax:</p>
<pre><code><my:PigFinderPage.Resources>
<!-- your resources go here -->
</my:PigFinderPage.Resources>
</code></pre>
<p>Lastly, switch to the code-behind for this new page, and change its class declaration so that it derives from your custom class rather than directly from Page, like this:</p>
<pre><code>public partial class EarmarkSearchPage : PigFinderPage
</code></pre>
<p>Remember to keep it as a partial class.</p>
<p>That's working a treat for me - I can define a bunch of custom properties and events back in "PigFinderPage" and use them in all the descendants.</p>
|
<p>Little update : I just tried to do it, and it didn't work. He is what I changed to solve the problem:</p>
<p>1.In many forums, you will read that the sub pages must inherit from a simple cs class, without XAML. Though it works. I do inherit from a normal XAML page without any problem.</p>
<p>2.I replaced the following code :</p>
<pre><code><my:PigFinderPage x:Class="Qaf.PigFM.WindowsClient.PenSearchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Qaf.PigFM.WindowsClient"
/>
</code></pre>
<p>with</p>
<pre><code><my:PigFinderPage x:Class="Qaf.PigFM.WindowsClient.PenSearchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="using:Qaf.PigFM.WindowsClient"
/>
</code></pre>
<p>because when I had "clr-namespace" instead of "using", the Intellisense could recognize PigFinderPage, but not the compiler.</p>
| 6,098
|
<p>We just started running in to an odd problem with a FileSystemWatcher where the call to Dispose() appears to be hanging. This is code that has been working without any problems for a while but we just upgraded to .NET3.5 SP1 so I'm trying to find out if anyone else has seen this behavior. Here is the code that creates the FileSystemWatcher: </p>
<pre><code>if (this.fileWatcher == null)
{
this.fileWatcher = new FileSystemWatcher();
}
this.fileWatcher.BeginInit();
this.fileWatcher.IncludeSubdirectories = true;
this.fileWatcher.Path = project.Directory;
this.fileWatcher.EnableRaisingEvents = true;
this.fileWatcher.NotifyFilter = NotifyFilters.Attributes;
this.fileWatcher.Changed += delegate(object s, FileSystemEventArgs args)
{
FileWatcherFileChanged(args);
};
this.fileWatcher.EndInit();
</code></pre>
<p>The way this is being used is to update the state image of a TreeNode object (adjusted slightly to remove business specific information):</p>
<pre><code>private void FileWatcherFileChanged(FileSystemEventArgs args)
{
if (this.TreeView != null)
{
if (this.TreeView.InvokeRequired)
{
FileWatcherFileChangedCallback d = new FileWatcherFileChangedCallback(FileWatcherFileChanged);
this.TreeView.Invoke(d, new object[]
{
args
});
}
else
{
switch (args.ChangeType)
{
case WatcherChangeTypes.Changed:
if (String.CompareOrdinal(this.project.FullName, args.FullPath) == 0)
{
this.StateImageKey = GetStateImageKey();
}
else
{
projectItemTreeNode.StateImageKey = GetStateImageKey();
}
break;
}
}
}
}
</code></pre>
<p>Is there something we're missing or is this an anomoly from .NET3.5 SP1?</p>
|
<p>Just a thought... Any chance there's a deadlock issue here?</p>
<p>You're calling TreeView.Invoke, which is a blocking call. If a filesystem change happens just as you're clicking whatever button causes the FileSystemWatcher.Dispose() call, your FileWatcherFileChanged method will get called on a background thread and call TreeView.Invoke, which will block until your form thread can process the Invoke request. However, your form thread would be calling FileSystemWatcher.Dispose(), which probably doesn't return until all pending change requests are processed.</p>
<p>Try changing the .Invoke to .BeginInvoke and see if that helps. That may help point you in the right direction.</p>
<p>Of course, it could also be a .NET 3.5SP1 issue. I'm just speculating here based on the code you provided.</p>
|
<p>We are also having this issue. Our application runs on .Net 2.0 but is compiled by VS 2008 SP1. I have .NET 3.5 SP1 installed as well. I've got no idea why this happens either, it doesn't look like a deadlock issue on our end as no other threads are running at this point (it is during application shutdown).</p>
| 9,882
|
<p>If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be?</p>
<p>I expect this list to be varied and to cover a wide range of things.</p>
<p><strong>To search:</strong> Use the search box in the upper-right corner. To search the answers of the current question, use <code>inquestion:this</code>. For example:</p>
<pre><code>inquestion:this "Code Complete"
</code></pre>
|
<ul>
<li><em>Code Complete</em> (2nd edition) by Steve McConnell</li>
<li><em>The Pragmatic Programmer</em></li>
<li><em>Structure and Interpretation of Computer Programs</em></li>
<li><em>The C Programming Language</em> by Kernighan and Ritchie</li>
<li><em>Introduction to Algorithms</em> by Cormen, Leiserson, Rivest & Stein</li>
<li><em>Design Patterns</em> by the Gang of Four</li>
<li><em>Refactoring: Improving the Design of Existing Code</em></li>
<li><em>The Mythical Man Month</em></li>
<li><em>The Art of Computer Programming</em> by Donald Knuth</li>
<li><em>Compilers: Principles, Techniques and Tools</em> by Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman</li>
<li><em>Gödel, Escher, Bach</em> by Douglas Hofstadter</li>
<li><em>Clean Code: A Handbook of Agile Software Craftsmanship</em> by Robert C. Martin</li>
<li><em>Effective C++</em></li>
<li><em>More Effective C++</em></li>
<li><em>CODE</em> by Charles Petzold</li>
<li><em>Programming Pearls</em> by Jon Bentley</li>
<li><em>Working Effectively with Legacy Code</em> by Michael C. Feathers</li>
<li><em>Peopleware</em> by Demarco and Lister</li>
<li><em>Coders at Work</em> by Peter Seibel</li>
<li><em>Surely You're Joking, Mr. Feynman!</em></li>
<li><em>Effective Java</em> 2nd edition</li>
<li><em>Patterns of Enterprise Application Architecture</em> by Martin Fowler</li>
<li><em>The Little Schemer</em></li>
<li><em>The Seasoned Schemer</em></li>
<li><em>Why's (Poignant) Guide to Ruby</em></li>
<li><em>The Inmates Are Running The Asylum: Why High Tech Products Drive Us Crazy and How to Restore the Sanity</em></li>
<li><em>The Art of Unix Programming</em></li>
<li><em>Test-Driven Development: By Example</em> by Kent Beck</li>
<li><em>Practices of an Agile Developer</em></li>
<li><em>Don't Make Me Think</em></li>
<li><em>Agile Software Development, Principles, Patterns, and Practices</em> by Robert C. Martin</li>
<li><em>Domain Driven Designs</em> by Eric Evans</li>
<li><em>The Design of Everyday Things</em> by Donald Norman</li>
<li><em>Modern C++ Design</em> by Andrei Alexandrescu</li>
<li><em>Best Software Writing I</em> by Joel Spolsky</li>
<li><em>The Practice of Programming</em> by Kernighan and Pike</li>
<li><em>Pragmatic Thinking and Learning: Refactor Your Wetware</em> by Andy Hunt</li>
<li><em>Software Estimation: Demystifying the Black Art</em> by Steve McConnel</li>
<li><em>The Passionate Programmer (My Job Went To India)</em> by Chad Fowler</li>
<li><em>Hackers: Heroes of the Computer Revolution</em></li>
<li><em>Algorithms + Data Structures = Programs</em></li>
<li><em>Writing Solid Code</em></li>
<li><em>JavaScript - The Good Parts</em></li>
<li><em>Getting Real</em> by 37 Signals</li>
<li><em>Foundations of Programming</em> by Karl Seguin</li>
<li><em>Computer Graphics: Principles and Practice in C</em> (2nd Edition)</li>
<li><em>Thinking in Java</em> by Bruce Eckel</li>
<li><em>The Elements of Computing Systems</em></li>
<li><em>Refactoring to Patterns</em> by Joshua Kerievsky</li>
<li><em>Modern Operating Systems</em> by Andrew S. Tanenbaum</li>
<li><em>The Annotated Turing</em></li>
<li><em>Things That Make Us Smart</em> by Donald Norman</li>
<li><em>The Timeless Way of Building</em> by Christopher Alexander</li>
<li><em>The Deadline: A Novel About Project Management</em> by Tom DeMarco</li>
<li><em>The C++ Programming Language (3rd edition)</em> by Stroustrup</li>
<li><em>Patterns of Enterprise Application Architecture</em></li>
<li><em>Computer Systems - A Programmer's Perspective</em></li>
<li><em>Agile Principles, Patterns, and Practices in C#</em> by Robert C. Martin</li>
<li><em>Growing Object-Oriented Software, Guided</em> by Tests</li>
<li><em>Framework Design Guidelines</em> by Brad Abrams</li>
<li><em>Object Thinking</em> by Dr. David West</li>
<li><em>Advanced Programming in the UNIX Environment</em> by W. Richard Stevens</li>
<li><em>Hackers and Painters: Big Ideas from the Computer Age</em></li>
<li><em>The Soul of a New Machine</em> by Tracy Kidder</li>
<li><em>CLR via C#</em> by Jeffrey Richter</li>
<li><em>The Timeless Way of Building</em> by Christopher Alexander</li>
<li><em>Design Patterns in C#</em> by Steve Metsker</li>
<li><em>Alice in Wonderland</em> by Lewis Carol</li>
<li><em>Zen and the Art of Motorcycle Maintenance</em> by Robert M. Pirsig</li>
<li><em>About Face - The Essentials of Interaction Design</em></li>
<li><em>Here Comes Everybody: The Power of Organizing Without Organizations</em> by Clay Shirky</li>
<li><em>The Tao of Programming</em></li>
<li><em>Computational Beauty of Nature</em></li>
<li><em>Writing Solid Code</em> by Steve Maguire</li>
<li><em>Philip and Alex's Guide to Web Publishing</em></li>
<li><em>Object-Oriented Analysis and Design with Applications</em> by Grady Booch</li>
<li><em>Effective Java</em> by Joshua Bloch</li>
<li><em>Computability</em> by N. J. Cutland</li>
<li><em>Masterminds of Programming</em></li>
<li><em>The Tao Te Ching</em></li>
<li><em>The Productive Programmer</em></li>
<li><em>The Art of Deception</em> by Kevin Mitnick</li>
<li><em>The Career Programmer: Guerilla Tactics for an Imperfect World</em> by Christopher Duncan</li>
<li><em>Paradigms of Artificial Intelligence Programming: Case studies in Common Lisp</em></li>
<li><em>Masters of Doom</em></li>
<li><em>Pragmatic Unit Testing in C# with NUnit</em> by Andy Hunt and Dave Thomas with Matt Hargett</li>
<li><em>How To Solve It</em> by George Polya</li>
<li><em>The Alchemist</em> by Paulo Coelho</li>
<li><em>Smalltalk-80: The Language and its Implementation</em></li>
<li><em>Writing Secure Code</em> (2nd Edition) by Michael Howard</li>
<li><em>Introduction to Functional Programming</em> by Philip Wadler and Richard Bird</li>
<li><em>No Bugs!</em> by David Thielen </li>
<li><em>Rework</em> by Jason Freid and DHH</li>
<li><em>JUnit in Action</em></li>
</ul>
|
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0201485672" rel="nofollow noreferrer" rel="nofollow noreferrer">Refactoring</a></p>
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0321127420" rel="nofollow noreferrer" rel="nofollow noreferrer">Patterns of Enterprise Application Architecture</a></p>
| 2,403
|
<p>Is there a general rule of thumb to follow when storing web application data to know what database backend should be used? Is the number of hits per day, number of rows of data, or other metrics that I should consider when choosing?</p>
<p>My initial idea is that the order for this would look something like the following (but not necessarily, which is why I'm asking the question).</p>
<ol>
<li>Flat Files</li>
<li>BDB</li>
<li>SQLite</li>
<li>MySQL</li>
<li>PostgreSQL</li>
<li>SQL Server</li>
<li>Oracle</li>
</ol>
|
<p>It's not quite that easy. The only general rule of thumb is that you should look for another solution when the current one can't keep up anymore. That could include using different software (not necessarily in any globally fixed order), hardware or architecture.</p>
<p>You will probably get a lot more benefit out of caching data using something like <a href="http://danga.com/memcached/" rel="nofollow noreferrer">memcached</a> than switching to another random storage backend.</p>
|
<p>I think your list is subjective but I will play your game.</p>
<p>Flat Files </p>
<p>BDB </p>
<p>SQLite</p>
<p>MySQL</p>
<p>PostgreSQL</p>
<p>SQL Server </p>
<p>Oracle</p>
<p>Teradata</p>
| 9,992
|
<p>For certain types of sql queries, an auxiliary table of numbers can be very useful. It may be created as a table with as many rows as you need for a particular task or as a user defined function that returns the number of rows required in each query.</p>
<p>What is the optimal way to create such a function?</p>
|
<p>Heh... sorry I'm so late responding to an old post. And, yeah, I had to respond because the most popular answer (at the time, the Recursive CTE answer with the link to 14 different methods) on this thread is, ummm... performance challenged at best.</p>
<p>First, the article with the 14 different solutions is fine for seeing the different methods of creating a Numbers/Tally table on the fly but as pointed out in the article and in the cited thread, there's a <em>very</em> important quote...</p>
<blockquote>
<p>"suggestions regarding efficiency and
performance are often subjective.
Regardless of how a query is being
used, the physical implementation
determines the efficiency of a query.
Therefore, rather than relying on
biased guidelines, it is imperative
that you test the query and determine
which one performs better."</p>
</blockquote>
<p>Ironically, the article itself contains many subjective statements and "biased guidelines" such as <em>"a recursive CTE can generate a number listing <strong>pretty efficiently</strong>"</em> and <em>"This is <strong>an efficient method</strong> of using WHILE loop from a newsgroup posting by Itzik Ben-Gen"</em> (which I'm sure he posted just for comparison purposes). C'mon folks... Just mentioning Itzik's good name may lead some poor slob into actually using that horrible method. The author should practice what (s)he preaches and should do a little performance testing before making such ridiculously incorrect statements especially in the face of any scalablility.</p>
<p>With the thought of actually doing some testing before making any subjective claims about what any code does or what someone "likes", here's some code you can do your own testing with. Setup profiler for the SPID you're running the test from and check it out for yourself... just do a "Search'n'Replace" of the number 1000000 for your "favorite" number and see...</p>
<pre><code>--===== Test for 1000000 rows ==================================
GO
--===== Traditional RECURSIVE CTE method
WITH Tally (N) AS
(
SELECT 1 UNION ALL
SELECT 1 + N FROM Tally WHERE N < 1000000
)
SELECT N
INTO #Tally1
FROM Tally
OPTION (MAXRECURSION 0);
GO
--===== Traditional WHILE LOOP method
CREATE TABLE #Tally2 (N INT);
SET NOCOUNT ON;
DECLARE @Index INT;
SET @Index = 1;
WHILE @Index <= 1000000
BEGIN
INSERT #Tally2 (N)
VALUES (@Index);
SET @Index = @Index + 1;
END;
GO
--===== Traditional CROSS JOIN table method
SELECT TOP (1000000)
ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS N
INTO #Tally3
FROM Master.sys.All_Columns ac1
CROSS JOIN Master.sys.ALL_Columns ac2;
GO
--===== Itzik's CROSS JOINED CTE method
WITH E00(N) AS (SELECT 1 UNION ALL SELECT 1),
E02(N) AS (SELECT 1 FROM E00 a, E00 b),
E04(N) AS (SELECT 1 FROM E02 a, E02 b),
E08(N) AS (SELECT 1 FROM E04 a, E04 b),
E16(N) AS (SELECT 1 FROM E08 a, E08 b),
E32(N) AS (SELECT 1 FROM E16 a, E16 b),
cteTally(N) AS (SELECT ROW_NUMBER() OVER (ORDER BY N) FROM E32)
SELECT N
INTO #Tally4
FROM cteTally
WHERE N <= 1000000;
GO
--===== Housekeeping
DROP TABLE #Tally1, #Tally2, #Tally3, #Tally4;
GO
</code></pre>
<p>While we're at it, here's the numbers I get from SQL Profiler for the values of 100, 1000, 10000, 100000, and 1000000...</p>
<pre><code>SPID TextData Dur(ms) CPU Reads Writes
---- ---------------------------------------- ------- ----- ------- ------
51 --===== Test for 100 rows ============== 8 0 0 0
51 --===== Traditional RECURSIVE CTE method 16 0 868 0
51 --===== Traditional WHILE LOOP method CR 73 16 175 2
51 --===== Traditional CROSS JOIN table met 11 0 80 0
51 --===== Itzik's CROSS JOINED CTE method 6 0 63 0
51 --===== Housekeeping DROP TABLE #Tally 35 31 401 0
51 --===== Test for 1000 rows ============= 0 0 0 0
51 --===== Traditional RECURSIVE CTE method 47 47 8074 0
51 --===== Traditional WHILE LOOP method CR 80 78 1085 0
51 --===== Traditional CROSS JOIN table met 5 0 98 0
51 --===== Itzik's CROSS JOINED CTE method 2 0 83 0
51 --===== Housekeeping DROP TABLE #Tally 6 15 426 0
51 --===== Test for 10000 rows ============ 0 0 0 0
51 --===== Traditional RECURSIVE CTE method 434 344 80230 10
51 --===== Traditional WHILE LOOP method CR 671 563 10240 9
51 --===== Traditional CROSS JOIN table met 25 31 302 15
51 --===== Itzik's CROSS JOINED CTE method 24 0 192 15
51 --===== Housekeeping DROP TABLE #Tally 7 15 531 0
51 --===== Test for 100000 rows =========== 0 0 0 0
51 --===== Traditional RECURSIVE CTE method 4143 3813 800260 154
51 --===== Traditional WHILE LOOP method CR 5820 5547 101380 161
51 --===== Traditional CROSS JOIN table met 160 140 479 211
51 --===== Itzik's CROSS JOINED CTE method 153 141 276 204
51 --===== Housekeeping DROP TABLE #Tally 10 15 761 0
51 --===== Test for 1000000 rows ========== 0 0 0 0
51 --===== Traditional RECURSIVE CTE method 41349 37437 8001048 1601
51 --===== Traditional WHILE LOOP method CR 59138 56141 1012785 1682
51 --===== Traditional CROSS JOIN table met 1224 1219 2429 2101
51 --===== Itzik's CROSS JOINED CTE method 1448 1328 1217 2095
51 --===== Housekeeping DROP TABLE #Tally 8 0 415 0
</code></pre>
<p>As you can see, <strong>the Recursive CTE method is the second worst only to the While Loop for Duration and CPU and has 8 times the memory pressure in the form of logical reads than the While Loop</strong>. It's RBAR on steroids and should be avoided, at all cost, for any single row calculations just as a While Loop should be avoided. <strong>There are places where recursion is quite valuable but this ISN'T one of them</strong>.</p>
<p>As a side bar, Mr. Denny is absolutely spot on... a correctly sized permanent Numbers or Tally table is the way to go for most things. What does correctly sized mean? Well, most people use a Tally table to generate dates or to do splits on VARCHAR(8000). If you create an 11,000 row Tally table with the correct clustered index on "N", you'll have enough rows to create more than 30 years worth of dates (I work with mortgages a fair bit so 30 years is a key number for me) and certainly enough to handle a VARCHAR(8000) split. Why is "right sizing" so important? If the Tally table is used a lot, it easily fits in cache which makes it blazingly fast without much pressure on memory at all.</p>
<p>Last but not least, every one knows that if you create a permanent Tally table, it doesn't much matter which method you use to build it because 1) it's only going to be made once and 2) if it's something like an 11,000 row table, all of the methods are going to run "good enough". <strong>So why all the indigination on my part about which method to use???</strong></p>
<p>The answer is that some poor guy/gal who doesn't know any better and just needs to get his or her job done might see something like the Recursive CTE method and decide to use it for something much larger and much more frequently used than building a permanent Tally table and I'm trying to <strong>protect those people, the servers their code runs on, and the company that owns the data on those servers</strong>. Yeah... it's that big a deal. It should be for everyone else, as well. Teach the right way to do things instead of "good enough". Do some testing before posting or using something from a post or book... the life you save may, in fact, be your own especially if you think a recursive CTE is the way to go for something like this. ;-)</p>
<p>Thanks for listening...</p>
|
<p>edit: see Conrad's comment below.</p>
<p>Jeff Moden's answer is great ... but I find on Postgres that the Itzik method fails unless you remove the E32 row.</p>
<p>Slightly faster on postgres (40ms vs 100ms) is another method I found on <a href="http://www.sqlservercentral.com/articles/T-SQL/67899/" rel="nofollow">here</a> adapted for postgres:</p>
<pre><code>WITH
E00 (N) AS (
SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL
SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 ),
E01 (N) AS (SELECT a.N FROM E00 a CROSS JOIN E00 b),
E02 (N) AS (SELECT a.N FROM E01 a CROSS JOIN E01 b ),
E03 (N) AS (SELECT a.N FROM E02 a CROSS JOIN E02 b
LIMIT 11000 -- end record 11,000 good for 30 yrs dates
), -- max is 100,000,000, starts slowing e.g. 1 million 1.5 secs, 2 mil 2.5 secs, 3 mill 4 secs
Tally (N) as (SELECT row_number() OVER (ORDER BY a.N) FROM E03 a)
SELECT N
FROM Tally
</code></pre>
<p>As I am moving from SQL Server to Postgres world, may have missed a better way to do tally tables on that platform ... INTEGER()? SEQUENCE()?</p>
| 3,198
|
<p>Jeff covered this a while back <a href="http://www.codinghorror.com/blog/archives/000811.html" rel="nofollow noreferrer">on his blog</a> in terms of 32 bit Vista.</p>
<p>Does the same 32 bit 4 GB memory cap that applies in 32 bit Vista apply to 32 bit Ubuntu? Are there any 32 bit operating systems that have creatively solved this problem?</p>
|
<p>In theory, all 32-bit OSes have that problem. You have 32 bits to do addressing.</p>
<pre><code>2^32 bits / 2^10 (bits per kb) / 2^10 (kb per mb) / 2^10 (mb per gb) = 2^2 = 4gb.
</code></pre>
<p>Although there are some ways around it. (Look up the jump from 16-bit computing to 32-bit computing. They hit the same problem.)</p>
|
<p>Linux supports a technology called PAE that lets you use more than 4GB of memory, however I don't know whether Ubuntu has it on by default. You may need to compile a new kernel.</p>
<p>Edit: Some threads on the Ubuntu forums suggest that the server kernel has PAE on by default, you could try installing that.</p>
| 7,396
|
<p>Essentially I want to know if in VB.NET 2005 if using a sqlcommand and then reusing it by using the NEW is wrong. Will it cause a memory leak.</p>
<p>EG:</p>
<pre><code>try
dim mySQL as new sqlcommand(sSQL, cnInput)
// do a sql execute and read the data
mySQL = new sqlcommand(sSQLdifferent, cnInput)
// do sql execute and read the data
catch ...
finally
if mysql isnot nothing then
mysql.dispose
mysql = nothing
end if
</code></pre>
<p>EDIT: put try catch in to avoid the comments about not using them</p>
|
<p>Just to extend what Longhorn213 said, here's the code for it:</p>
<pre><code>Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)
' do stuff'
End Using
Using mysql as SqlCommand = new SqlCommand(otherSql, cnInput)
' do other stuff'
End Using
</code></pre>
<p>(edit) Just as an FYI, using automatically wraps the block of code around a try/finally that calls the Dispose method on the variable it is created with. Thus, it's an easy way to ensure your resource is released. <a href="http://msdn.microsoft.com/en-us/library/htd05whh(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/htd05whh(VS.80).aspx</a></p>
|
<p>No, the garbage collector will find the old version of mySql and deallocate it in due course.</p>
<p>The garbage collector should pick up anything that's been dereferenced as long as it hasn't been moved into the Large Object Heap.</p>
| 6,388
|
<p>I have a pdf file of a logo, about 1"x2" in dimension. Can anybody provide the code snippet to import that PDF logo into another PDF file using the <a href="http://framework.zend.com/manual/en/zend.pdf.html" rel="nofollow noreferrer">Zend_PDF</a> API's? </p>
<p>Ideally, I'd like to be able to place it like the PNG, TIFF or JPG objects with the Zend_Pdf_Image object. </p>
<p>In other words, I want to be able to place the little 1x2" pdf document on top of a 8.5x11" page, not use the original pdf as a background. </p>
<p>Thanks!</p>
|
<p>It looks like as of this date, there's no way to do it using the Zend_PDF API's. The Zend_Pdf_Page class has a drawContentStream() which looked promising, but when I checked into it, the method body was empty. Maybe a later release of the API will support it. </p>
<p>So, if you want place another PDF inside another dynamically generated PDF document like an image, use <a href="http://www.setasign.de/products/pdf-php-solutions/fpdi/demos/simple-demo/" rel="nofollow noreferrer">FPDI + FPDF/TCPDF</a>.</p>
<pre><code>$pdf = & new FPDI ('P', 'in', 'Letter' );
$pagecount = $pdf->setSourceFile ( APP . 'logo.pdf' );
$tplidx = $pdf->importPage ( 1, '/MediaBox' );
$pdf->addPage ();
$pdf->useTemplate ( $tplidx, 1, 1 );
$pdf->Output ( 'output.pdf', 'F' );
</code></pre>
|
<p>Not what you asked for, but probably what you need (:</p>
<p>Convert the smaller logo pdf to a TIFF/PNG/WhatEver (using, for example, imagemagick's <code>convert</code>, or the GIMP). Then, place this image with the normal Zend API.</p>
<p>This conversion could also be done on the fly, using the Imagick php class, I would imagine.</p>
| 9,034
|
<p>When should you use generator expressions and when should you use list comprehensions in Python?</p>
<pre><code># Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
</code></pre>
|
<p><a href="https://stackoverflow.com/a/47792/4518341">John's answer</a> is good (that list comprehensions are better when you want to iterate over something multiple times). However, it's also worth noting that you should use a list if you want to use any of the list methods. For example, the following code won't work:</p>
<pre><code>def gen():
return (something for something in get_some_stuff())
print gen()[:2] # generators don't support indexing or slicing
print [5,6] + gen() # generators can't be added to lists
</code></pre>
<p>Basically, use a generator expression if all you're doing is iterating once. If you want to store and use the generated results, then you're probably better off with a list comprehension.</p>
<p>Since performance is the most common reason to choose one over the other, my advice is to not worry about it and just pick one; if you find that your program is running too slowly, then and only then should you go back and worry about tuning your code.</p>
|
<p>For functional programming, we want to use as little indexing as possible. For this reason, If we want to continue using the elements after we take the first slice of elements, islice() is a better choice since the iterator state is saved.</p>
<pre><code>from itertools import islice
def slice_and_continue(sequence):
ret = []
seq_i = iter(sequence) #create an iterator from the list
seq_slice = islice(seq_i,3) #take first 3 elements and print
for x in seq_slice: print(x),
for x in seq_i: print(x**2), #square the rest of the numbers
slice_and_continue([1,2,3,4,5])
</code></pre>
<p>output: 1 2 3 16 25</p>
| 7,005
|
<p>Let's say I have a .NET Array of n number of dimensions. I would like to foreach through the elements and print out something like:</p>
<pre><code>[0, 0, 0] = 2
[0, 0, 1] = 32
</code></pre>
<p>And so on. I could write a loop using some the Rank and dimension functions to come up with the indices. Is there a built in function instead?</p>
|
<p>Thanks for the answer, here is what I wrote while I waited:</p>
<pre><code>public static string Format(Array array)
{
var builder = new StringBuilder();
builder.AppendLine("Count: " + array.Length);
var counter = 0;
var dimensions = new List<int>();
for (int i = 0; i < array.Rank; i++)
{
dimensions.Add(array.GetUpperBound(i) + 1);
}
foreach (var current in array)
{
var index = "";
var remainder = counter;
foreach (var bound in dimensions)
{
index = remainder % bound + ", " + index;
remainder = remainder / bound;
}
index = index.Substring(0, index.Length - 2);
builder.AppendLine(" [" + index + "] " + current);
counter++;
}
return builder.ToString();
}
</code></pre>
|
<p><a href="http://forums.msdn.microsoft.com/en-US/csharplanguage/thread/2ca85aa4-0672-40ad-b780-e181b28fcd80/" rel="nofollow noreferrer">Take a look at this:</a> might helpful for you.</p>
| 4,607
|
<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 have a SharePoint virtual machine in one active directory domain (for example domain1) and I want to transfer all the sites it has to another active directory domain (domain2).
I don’t know which could be the best procedure to do this, if I detach and attach my virtual machine from domain1 to domain2 it probably didn’t work since all the accounts used by SharePoint are no longer valid. (Both domain are not in the same network and didn’t trust each other).
Additionally I could export the sites in domain1 and import them on domain2 using stsadm, but if I use this technique I have to manually install all the features, solutions and personalization I made on my original server.
Does anybody know the best approach to “move” the sites from one domain to another? </p>
|
<p>There is a <a href="http://stsadm.blogspot.com/2007/09/move-web.html" rel="nofollow noreferrer">STSADM Custom Extension: move web</a> that should be what you are looking for:</p>
<blockquote>
<p>C:>stsadm -help gl-moveweb</p>
<p>stsadm -o gl-moveweb</p>
<p>Moves a web.</p>
<p>Parameters:
-url
-parenturl
[-haltonwarning (only considered if moving to a new site collection)]
[-haltonfatalerror (only considered if moving to a new site collection)]
[-includeusersecurity (only considered if moving to a new site collection)]
[-retainobjectidentity (only considered if moving to a new site collection)]</p>
</blockquote>
|
<p>You may have some sucess by adding a local account to the administrators group and joining the server to the new domain. Then manualy updateing all of the AD accounts that are used in the server. I sould note that all of your users will then have new accounts that are not related to the old ones.</p>
<p>You sould ask your domain admins about an SID update to the new accounts so they also have the SID's from the old domain.</p>
| 9,920
|
<p>I need to create an Aggregate Field in a TClientDataSet, but as said in the docs:</p>
<blockquote>
<p>Choose OK. The newly defined aggregate
field is automatically added to the
client dataset and its Aggregates
property is automatically updated to
include the appropriate aggregate
specification.</p>
</blockquote>
<p>When I add a new aggregate field, the aggregate specification isn't added to the TClientDataSet's Aggregates, therefore I can't use its OnUpdateMethod.</p>
<p>I also tried handling the OnChange event of my new Aggregate Field, but it isn't fired at all.</p>
<p>Am I doing something wrong? I just want to have an aggregated field and fire an event everything it's value change.</p>
<p>Is this broken on delphi? Because what is in the documentation doesn't reflect the actual behavior.</p>
<p><strong>edit:</strong>
@Michal Sznajder
I'm using Delphi 2007</p>
|
<p>I think you may be getting confused between TAggregate and TAggregateField objects, and the Delphi documentation probably isn't helping.</p>
<p>AFAICT, TAggregateField objects are automatically 'recalculated' and can be bound to data-aware controls like TDBText, but don't have any OnUpdate event. </p>
<p>"TAggregate" objects, on the other hand, do have an OnUpdate event, but can't be bound to data-aware controls.</p>
<p>This may be enlightening: <a href="http://dn.codegear.com/article/29272" rel="nofollow noreferrer">http://dn.codegear.com/article/29272</a></p>
|
<p>Which version of Delphi ? I just tried clean D7 application and TAggregateField was added. </p>
| 4,221
|
<p>What are the most common memory optimizations in csharp, dotnet 2.0. Wanted to see if there common things that people may not be doing by default in winform app</p>
|
<ul>
<li>use structs for small wrapper objects to avoid heap fragmentation</li>
<li>think carefully about object lifetimes, especially for large objects so they do not end up on the LOH unless you intend them to</li>
<li>think about allocations inside of a loop</li>
<li>make sure dynamically sized array will be of reasonable size, otherwise partition the problem</li>
</ul>
|
<p>Sealing as much classes as possible should also help. AFAIK this is one trick that SmartAssembly uses to reduce memory consumption.</p>
| 8,560
|
<p>What's the easiest way to print a stacktrace from a debugging printout? Often during testing you would like to know the callstack leading up to the situation provoking a debug message.</p>
|
<p><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#dumpStack()" rel="noreferrer">Thread.dumpStack();</a></p>
|
<p>Just because I needed it myself:</p>
<p>As inspired by answer <a href="https://stackoverflow.com/questions/421280/in-java-how-do-i-find-the-caller-of-a-method-using-stacktrace-or-reflection">How do I find the caller of a method using stacktrace or reflection?</a> , you can retrieve the call stack using </p>
<pre><code>StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace()
</code></pre>
<p>Then you process and print/log whatever you are interested in. More work than using <code>Thread.dumpStack()</code>, but more flexible.</p>
| 7,854
|
<p>I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is the easiest way to do what I want to do, but before implementing, I wanted to see if anyone had a more elegant solution. Any thoughts?</p>
|
<p>EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters.</p>
<p>To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="noreferrer">serialize the two arrays to JSON</a> and then compare the two JSON strings. That would simply tell you if the arrays are different, obviously you could do this to <em>each</em> of the objects within the arrays as well to see which ones were different.</p>
<p>Another option is to use a library which has some nice facilities for comparing objects - I use and recommend <a href="http://www.mochikit.com/" rel="noreferrer"><strong>MochiKit</strong></a>.</p>
<hr>
<p><strong>EDIT:</strong> <a href="https://stackoverflow.com/questions/27030/comparing-arrays-of-objects-in-javascript#27932">The answer kamens gave</a> deserves consideration as well, since a single function to compare two given objects would be much smaller than any library to do what I suggest (although my suggestion would certainly work well enough).</p>
<p>Here is a naïve implemenation that may do just enough for you - be aware that there are potential problems with this implementation:</p>
<pre><code>function objectsAreSame(x, y) {
var objectsAreSame = true;
for(var propertyName in x) {
if(x[propertyName] !== y[propertyName]) {
objectsAreSame = false;
break;
}
}
return objectsAreSame;
}
</code></pre>
<p>The assumption is that both objects have the same exact list of properties.</p>
<p>Oh, and it is probably obvious that, for better or worse, I belong to the only-one-return-point camp. :)</p>
|
<p>comparing with json is pretty bad. try this package to compare nested arrays and get the difference.</p>
<blockquote>
<p><a href="https://www.npmjs.com/package/deep-object-diff" rel="nofollow noreferrer">https://www.npmjs.com/package/deep-object-diff</a></p>
</blockquote>
| 4,667
|
<p>I have breakpoints set but Xcode appears to ignore them.</p>
|
<p>First of all, I agree 100% with the earlier folks that said turn <strong>OFF</strong> <code>Load Symbols Lazily</code>.</p>
<p>I have two more things to add.</p>
<p>(My first suggestion sounds obvious, but the first time someone suggested it to me, my reaction went along these lines: "come on, please, you really think I wouldn't know better...... oh.")</p>
<ol>
<li><p>Make sure you haven't accidentally set "Active Build Configuration" to "Release."</p></li>
<li><p>Under "Targets" in the graphical tree display of your project, right click on your Target and do "Get Info." Look for a property named "Generate Debug Symbols" (or similar) and make sure this is CHECKED (aka ON). Also, you might try finding (also in Target >> Get Info) a property called "Debug Information Format" and setting it to "Dwarf with dsym file."</p></li>
</ol>
<p>There are a number of other properties under Target >> Get Info that might affect you. Look for things like optimizing or compressing code and turn that stuff OFF (I assume you are working in a debug mode, so that this is not bad advice). Also, look for things like stripping symbols and make sure that is also OFF. For example, "Strip Linked Product" should be set to "No" for the Debug target.</p>
|
<p>I have Xcode Version 4.6.3 and Breakpoints were never working in sub-groups of included projects. The project would compile and run fine; it would even attach to the debugger and spit out NSLog output appropriately.</p>
<p>The issue was related to my Header Search Paths. I had some of them set 'recursive' instead of the default 'non-recursive'. Changing them all to 'non-recursive' and updating all of the related imports appropriately fixed the problem.</p>
| 9,040
|
<p>I'm looking at the <a href="http://www.php.net/manual/en/" rel="noreferrer">PHP Manual</a>, and I'm not seeing a section on data structures that most languages have, such as lists and sets. Am I just blind or does PHP not have anything like this built in?</p>
|
<p>The only native data structure in PHP is array. Fortunately, arrays are quite flexible and can be used as hash tables as well.</p>
<p><a href="http://www.php.net/array" rel="noreferrer">http://www.php.net/array</a></p>
<p>However, there is SPL which is sort of a clone of C++ STL.</p>
<p><a href="http://www.php.net/manual/en/book.spl.php" rel="noreferrer">http://www.php.net/manual/en/book.spl.php</a></p>
|
<p>PHP can also have an <em>array of arrays</em> which is called a "multidimensional array" or "matrix". You can have 2-dimensional arrays, 3-dimensional arrays, etc.</p>
| 4,241
|
<p>I'm trying to do a basic "OR" on three fields using a hibernate criteria query.</p>
<p>Example</p>
<pre><code>class Whatever{
string name;
string address;
string phoneNumber;
}
</code></pre>
<p>I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber".</p>
|
<p>You want to use <code>Restrictions.disjuntion()</code>. Like so</p>
<pre><code>session.createCriteria(Whatever.class)
.add(Restrictions.disjunction()
.add(Restrictions.eq("name", queryString))
.add(Restrictions.eq("address", queryString))
.add(Restrictions.eq("phoneNumber", queryString))
);
</code></pre>
<p>See the Hibernate doc <a href="http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html#querycriteria-narrowing" rel="noreferrer">here</a>.</p>
|
<p>The conditions can be applied using the or / and in different levels of the query
using disjunction</p>
<pre><code>Criteria query = getCriteria("ENTITY_NAME");
query.add(Restrictions.ne("column Name", current _value));
Disjunction disjunction = Restrictions.disjunction();
if (param_1 != null)
disjunction.add(Restrictions.or(Restrictions.eq("column Name", param1)));
if (param_2 != null)
disjunction.add(Restrictions.or(Restrictions.eq("column Name", param_2)));
if (param_3 != null)
disjunction.add(Restrictions.or(Restrictions.eq("column Name", param_3)));
if (param_4 != null && param_5 != null)
disjunction.add(Restrictions.or(Restrictions.and(Restrictions.eq("column Name", param_4 ), Restrictions.eq("column Name", param_5 ))));
if (disjunction.conditions() != null && disjunction.conditions().iterator().hasNext())
query.add(Restrictions.and(disjunction));
return query.list();
</code></pre>
| 8,173
|
<p>My 3D prints shift along the Y-axis on my Ender 3 3D printer. I don't know what to do. My Y-axis belt is tight, So I don't think that is the problem...</p>
<p><a href="https://i.stack.imgur.com/zVtPS.png" rel="nofollow noreferrer" title="Y-axis layer shifting"><img src="https://i.stack.imgur.com/zVtPS.png" alt="Y-axis layer shifting" title="Y-axis layer shifting" /></a></p>
|
<p>8 mm rods and 6 mm GT2 belts are generally accepted as a good tradeoff between price and performance, an exact calculation is possible but might not be very relevant if another part is flexing. Also, generally speaking, the smaller the part the sooner it will wear out of specification. Thus your service interval might be higher compared to an over-engineered printer.</p>
<p>In short, it depends on what your goal is, if you desire low maintenance and accurate machine, you might be better off with heavier gauge parts. Obviously, this will also affect the speed of printing.
A 6 mm GT2 belt might have a higher stretch factor compared to a 10 mm belt, but can be mitigated by adjusting the acceleration. In addition, a 10 mm belt has a larger pulley reducing the number of steps per mm, lowering precision. As such you might be better of using two 6 mm belts.</p>
<p>Increased rod size for the print bed will not affect printing speed much but might help with accuracy since the bending modulus is lower. Play around with the calculators below to get an idea of the force your beam will have to withstand. That said, there are a lot of other factors that will flex under load, for example, the bed leveling springs. You can replace them with solid spacers, but that might warp the bed when it heats up.</p>
<p><a href="https://www.engineering.com/calculators/beams.htm" rel="nofollow noreferrer">https://www.engineering.com/calculators/beams.htm</a></p>
<p><a href="https://www.omnicalculator.com/physics/acceleration" rel="nofollow noreferrer">https://www.omnicalculator.com/physics/acceleration</a></p>
<p>To conclude, I would use the calculators to figure out if the 8 mm rods are within tolerance for the intended speeds and load, but don't forget to look at the overall picture. The quality of parts you choose is one such thing.</p>
|
<p>The 3D printing revolution started out with the idea/community project to build self-replicating machines:</p>
<blockquote>
<p>RepRap was the first of the low-cost 3D printers, and the RepRap Project started the open-source 3D printer revolution. It has become the most widely-used 3D printer among the global members of the Maker Community.
<em>(From RepRap.org)</em></p>
</blockquote>
<p>The main aspects for this project was to build self-replicating machines from cheap and "simple" available materials and making them freely available for the benefit of everyone. The rod solution is a simple and affordable solution for linear motion with fair tolerances.</p>
<p>As far as the rigidity of the X carriage, rods aren't the best solution, increasing rod diameter will surely increase the stiffness, but it will be smaller than a design that uses a (quality) linear rail, these are much stiffer. Note that instead of steel, carbon rods can be used, these are stiff and light and reduce the weight of the carriage, allowing for higher acceleration and speed. The solution of using rods is mainly based on availability and being a cheap solution.</p>
<p>Do note that rods flex much more than linear rails, even when you increase the diameter, this will limit the length of the X-axis.</p>
<p><a href="https://m.all3dp.com/2/linear-rail-3d-printer-really-better-or-just-a-hype/" rel="nofollow noreferrer">From all3Dp</a>:</p>
<blockquote>
<p>Any decent rail will have far less give. In terms of 3D printing, this leads to greatly reduced backlash and ringing artifacts, yielding cleaner print surfaces and edges.</p>
</blockquote>
<p>Belts allow the rotational motion to be transferred into a linear motion. Belt width depends on the force (carriage weight) you need to move. Same as for rods, an increased height will allow for a larger load to be driven/moved, but for a fixed load, the increasing height allows for less stretch and thus less printing defects. Note the different <a href="https://3dprinting.stackexchange.com/a/6714">types of belts</a> are available, all having their own stiffness and load bearing capacity.</p>
| 1,772
|
<p>So like I sayed in the title, Why can't the Anet A6 do .05 layer height? I found that some printers can do .05 layer heights, but the Anet A6 can't? I am interested to know if it is the stepper motors or the threaded rods or something. Maybe this is something I can do a small "test print" on? </p>
|
<p>I'm not familiar with the Anet A6 specifically, but as many other things in a 3D printer, the minimum layer height is co-determined by a number of factors. For the Z-axis the factors I am aware of are:</p>
<ul>
<li>The number of steps in the stepper motor</li>
<li>The geometry of the lead screw</li>
<li>The tolerance with which the lead screw has been machined</li>
<li>The microstep settings</li>
<li>The quality of the stepper drivers</li>
<li>The amount of play and flexibility of the X-axis gantry</li>
<li>The ration between filament and nozzle diameter</li>
<li>The precision of the extruder's stepper motor</li>
<li>...</li>
</ul>
<p>Many printers that claim to have ridiculously low minimum Z-layer height do so by relying on the mathematical model only. It goes something like this: the lead screw has an offset of 1mm per revolution, the stepper motor makes 200 steps and is set for 32 microsteps per step so the minimum resolution should be...</p>
<pre><code>1mm / (200 * 32) = 0.0002mm
</code></pre>
<p>The reality is however different. For example: the lead screw may have been machined with a tolerance of 0.002mm, so to make sure a layer has a thickness >0mm its heigh should be >0.004mm (20 times the theoretical limit computed with the microsteps). But to make sure layers have the same height ±10% you would need to increase the minimum layer heigh of an order of magnitude, bringing it to 0.04mm. A similar reasoning applies for the amount of play in the gantry, while the ratio between filament and nozzle influences the minimum volume of plastic that can be extruded per step (for very thin layers you want to be able to extrude a minimal amount of it).</p>
<p>At the end of the day <strong>this is a typical case of "a chain is only as strong as its weakest link"</strong>: the minimum layer height of a printer is affected much more dramatically by the limitations of the most imprecise component in the printer than by the performance of its best one.</p>
<p>As for your question about breaking the printer by issuing g-code with very thin layers: should you issue gcode that requires layers below that limit, the firmware will simply print at the same z-height (see comments, credits to Tom).</p>
<p>I'm unaware of people having permanently damaged their machines by issuing code with too thin Z-layers. But given how the firmware operates, I'd expect the quality of the print to be negatively affected, the filament to be possibly chewed by the cobbed wheel and in extreme cases cloggig of the printer head.</p>
|
<p>I have an Anet A6 and once you get your settings dialled in, bed level accurate and belt tensioner correct you can do 0.05 mm very well (although I for some reason went with 0.06 mm and never tried the extra 0.01 mm lower but it shouldn't have an issue). Note: I did this using all the stock parts so 0.4 mm brass nozzle.</p>
<p>I highly recommend you print and install a front Y axis frame brace and a Y axis belt tensioning mod as well as an X axis belt tensioner. It will allow you to print at these layer heights much more accurately if you can adjust the tension correctly.</p>
<p>The kit out of the box makes it almost impossible to get good/correct tension on the belts.</p>
| 846
|
<p>What is the best way to disable <kbd>Alt</kbd> + <kbd>F4</kbd> in a c# win form to prevent the user from closing the form?</p>
<p>I am using a form as a popup dialog to display a progress bar and I do not want the user to be able to close it.</p>
|
<p>This does the job:</p>
<pre><code>private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
</code></pre>
<p>Edit: In response to pix0rs concern - yes you are correct that you will not be able to programatically close the app. However, you can simply remove the event handler for the form_closing event before closing the form:</p>
<pre><code>this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Close();
</code></pre>
|
<p>Hide close button on form by using the following in constructor of the form:</p>
<pre><code>this.ControlBox = false;
</code></pre>
| 3,573
|
<p>I have a project that I'm currently working on but it currently only supports the .net framework 2.0. I love linq, but because of the framework version I can't use it. What I want isn't so much the ORM side of things, but the "queryability" (is that even a word?) of Linq. </p>
<p>So far the closest is <a href="http://www.llblgen.com/defaultgeneric.aspx" rel="nofollow noreferrer">llblgen</a> but if there was something even lighter weight that could just do the querying for me that would be even better.</p>
<p>I've also looked at <a href="http://www.hibernate.org/343.html" rel="nofollow noreferrer">NHibernate</a> which looks like it could go close to doing what I want, but it has a pretty steep learning curve and the mapping files don't get me overly excited.</p>
<p>If anyone is aware of something that will give me a similar query interface to Linq (or even better, how to get Linq to work on the .net 2.0 framework) I'd really like to hear about it.</p>
|
<p>Have a look at this:</p>
<p><a href="http://www.albahari.com/nutshell/linqbridge.html" rel="noreferrer">http://www.albahari.com/nutshell/linqbridge.html</a></p>
<p>Linq is several different things, and I'm not 100% sure which bits you want, but the above might be useful in some way. If you don't already have a book on Linq (I guess you don't), then I found "Linq In Action" to be be good.</p>
|
<p>There's a way to reference LINQ in the .NET 2.0 Framework, but I have to warn you that it <em>might</em> be against the terms of use/EULA of the framework:</p>
<p><a href="https://stackoverflow.com/questions/2138/linq-on-the-net-20-runtime#2146">LINQ on the .NET 2.0 Runtime</a></p>
| 2,921
|
<h2>Question</h2>
<p>Alright, I'm confused by all the buzzwords and press release bingo going on.</p>
<ul>
<li>What is the relationship between flash and flex:
<ul>
<li>Replace flash (not really compatible)</li>
<li>Enhance flash</li>
<li>The next version of flash but still basically compatible</li>
<li>Separate technology altogether</li>
<li>???</li>
</ul></li>
<li>If I'm starting out in Flash now, should I just skip to Flex?</li>
</ul>
<h2>Follow up</h2>
<p>Ok, so what I'm hearing is that there's three different parts to the puzzle:</p>
<ul>
<li><strong>Flash</strong>
<ul>
<li>The graphical editor used to make "Flash Movies", ie it's an IDE that focuses on the visual aspect of "Flash" (Officially Flash CS3?)</li>
<li>The official name for the display plugins (ie, "Download Flash Now!")</li>
<li>A general reference to the entire technology stack</li>
<li>In terms of the editor, it's a linear timeline based editor, best used for animations with complex interactivity.</li>
</ul></li>
<li><strong>Actionscript</strong>
<ul>
<li>The "Flash" programming language</li>
</ul></li>
<li><strong>Flex</strong>
<ul>
<li>An Adobe Flash IDE that focuses on the coding/programming aspect of "Flash" (Flex Builder?)</li>
<li>A Flash library that enhances Flash and makes it easier to <em>program</em> for (Flex SDK?)</li>
<li>Is not bound to a timeline (as the Flash IDE is) and so "standard" applications are more easily accomplished.</li>
</ul></li>
</ul>
<p>Is this correct?</p>
<p>-Adam</p>
|
<p>The term <strong>Flash</strong> can include any of the other terms defined below, and I find that saying "Flash" without specifying exactly what you mean can be confusing and misleading. Case in point: I'm not sure what you specifically mean when you say "Flash" in your question. Is it Flash Player? The authoring tool? Or the whole collection of technologies that fall under what Adobe calls the "Flash Platform"? To help clear all this up, let me define the technologies involved in creating Flash and Flex content so that we're all using the same terminology here:</p>
<p><strong>Flash Player</strong> is a runtime for rich media content in the browser. There is also <strong>Flash Lite</strong> to run Flash content on older or low-end mobile devices, and <strong>Adobe AIR</strong> extends Flash Player to allow content authors to publish native desktop and mobile applications that can integrate with things like the file system, windowing systems, and device sensors like the accelerometer and camera. Collectively, Adobe refers to these as the <strong>Flash runtimes</strong>.</p>
<p><strong>Flash Professional</strong> (often called the <strong>Flash authoring tool</strong> or the <strong>Flash IDE</strong>) has traditionally been the primary application used to create content that runs on Flash Player. It is very designer oriented with timelines, layers, and visual drawing tools. Software developers may find this application disorienting and limited compared to other development tools that focus more on code, like Flash Builder (see below). When someone says, "I built something with Flash", they often mean the Flash authoring tool, but that's not always the case. For that reason, it's good to always clarify to avoid any confusion.</p>
<p><strong>ActionScript</strong> is the primary programming language supported by Adobe to target Flash runtimes. The current version is ActionScript 3 (abbreviated as <strong>AS3</strong>), which has been supported since Flash Player 9. Content created with older versions of ActionScript can still be run in the latest versions Flash Player, but new features are only supported when using ActionScript 3 to create new content.</p>
<p><strong>Flex</strong> is a collection of technologies designed to create rich applications that target the Adobe's Flash runtimes. Though saying "Flex" previously had the same ambiguity as "Flash", the Flex brand name is becoming more and more focused on the Flex framework and SDK, described below.</p>
<p>The <strong>Flex SDK</strong> consists of compilers, a command-line debugger, and the Flex framework. The included compilers are:
1. MXMLC, an ActionScript and MXML compiler to output the final SWF file for deployment to Flash Player.
2. COMPC, a static library compiler for ActionScript that outputs SWC files.
3. ASDOC, a documentation generator built on the compiler technology.</p>
<p>The <strong>Flex framework</strong> is a collection of ActionScript classes designed to build Rich Internet Applications. It includes things like user interface controls, web services and other connectivity classes, formatters and validators, drag and drop, modal windowing, and component states. These classes are in the mx.* package. Generally, when developers say "Flex" without any clarifying information, they mean the Flex framework and not the product formerly known as Flex Builder.</p>
<p>In 2011, Adobe donated the Flex SDK to the Apache Software Foundation. It is now called <strong>Apache Flex</strong> and it is fully managed by the community rather than Adobe. However, Adobe employees continue to contribute to the project, and Flash Builder (see below) continues to support new SDKs released by the Apache Flex project.</p>
<p><strong>MXML</strong> is an XML-based markup language used by the Flex compilers to make layout and placing components into containers easier. The tree-like structure of XML make the containment hierarchy easier to visualize. MXML is actually converted to ActionScript during the compilation process.</p>
<p><strong>Flash Builder</strong> (formerly known as <strong>Flex Builder</strong>) is a development environment that allows developers to build different project types to create SWF files that are deployed to Flash runtimes. It is built on the Eclipse platform and is more familiar to software engineers. Flash Builder supports projects built with Flex or pure ActionScript. Flex projects include the Flex framework. ActionScript projects are the most basic you can work with, starting with a single class and an empty canvas, and the Flex framework is not included.</p>
<p>Flash Builder does not replace Flash Professional. Some people who have traditionally used Flash Professional may now choose to use Flash Builder instead. Often, these are software engineers who appreciate or require the advanced development tools offered by Flash Builder or don't work heavily with assets designed in a visual tool. Some developers may write their code in Flash Builder, while choosing to compile their projects in the Flash authoring tool. Often, these developers are also designers, or they are working with other people who are designers. In this situation, there may be many graphical assets created in the Flash authoring tool, and it could be difficult or simply inappropriate to bring them into another environment.</p>
<p>The Flex framework is specifically designed to build applications. It includes many traditional form controls (buttons, lists, datagrids, etc) and much of the code runs on an advanced component framework written in ActionScript. Not everyone is building the sort of content that Flex is designed to create, and Flex does not replace traditional Flash development practices for everyone. It is a better approach for some developers, but may not be right for others. More design-heavy websites, such as those created for movies, music, energy drinks, advertising campaigns, and things like that probably shouldn't use the Flex framework. These types of content might be better suited to Flash Professional or a pure ActionScript project in Flash Builder. Similarly, little widgets you put into the sidebar of your website or on your profile in a social networking website may need to be built with pure ActionScript (without the Flex framework) because they require a smaller file size and they probably don't need a big complex component architecture designed for larger applications. When targeting Flash runtimes, your development environment, frameworks, and workflow should be chosen based on your project's requirements and goals.</p>
|
<p>"Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich Internet applications based on the proprietary Adobe Flash platform."</p>
<p><a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="nofollow noreferrer">Adobe Flex</a></p>
| 8,353
|
<p>I am following the <a href="http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx" rel="noreferrer">M-V-VM</a> pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is to inherit from the TextBox control, and implement ICommandSource. I can then instruct the command to be fired from the TextChanged event. This seems to be too much work for something which appears to be so simple.</p>
<p>Is there an easier way (than subclassing the TextBox and implementing ICommandSource) to hook up the TextChanged event to my ViewModel class?</p>
|
<p>First off, you've surely considered two-way data binding to your viewmodel, with an UpdateSourceTrigger of PropertyChanged? That way the property setter of the property you bind to will be called every time the text is changed?</p>
<p>If that's not enough, then I would tackle this problem using Attached Behaviours. On Julian Dominguez’s Blog you'll find an <a href="http://blogs.southworks.net/jdominguez/2008/08/icommand-for-silverlight-with-attached-behaviors/" rel="noreferrer">article</a> about how to do something very similar in Silverlight, which should be easily adaptable to WPF.</p>
<p>Basically, in a static class (called, say TextBoxBehaviours) you define an Attached Property called (perhaps) TextChangedCommand of type ICommand. Hook up an OnPropertyChanged handler for that property, and within the handler, check that the property is being set on a TextBox; if it is, add a handler to the TextChanged event on the textbox that will call the command specified in the property.</p>
<p>Then, assuming your viewmodel has been assigned to the DataContext of your View, you would use it like:</p>
<pre><code><TextBox
x:Name="MyTextBox"
TextBoxBehaviours.TextChangedCommand="{Binding ViewModelTextChangedCommand}" />
</code></pre>
|
<p>Can you not just handle the TextChanged event and execute the command from there?</p>
<pre><code>private void _textBox_TextChanged(object sender, EventArgs e)
{
MyCommand.Execute(null);
}
</code></pre>
<p>The alternative, as you say, is to create a <code>TextBox</code> that acts as a command source, but that does seem like overkill unless it's something you're planning on sharing and leveraging in many places.</p>
| 7,968
|
<p>I want to make an order with this configuration</p>
<ul>
<li>Arduino MEGA 2650 R3</li>
<li>Ramps 1.6 Plus</li>
<li>2 TMC2130 </li>
<li>2 Stepper motors 17hs3401</li>
<li>1 Fan</li>
</ul>
<p><img src="https://i.stack.imgur.com/Nl0sE.png" alt="stepper_motor"></p>
<p>But I am not sure what voltage and current would be enough to make it work. The Ramps 1.6+ board has an input of 12V as you can see in the picture, but I have read that <a href="https://3dprinting.stackexchange.com/questions/9911/tmc2130-external-vm-ramps1-4">other people</a> had to increase the voltage with a DC-DC converter.</p>
<p><img src="https://i.stack.imgur.com/RtBEr.jpg" alt="ramps_voltage"></p>
<p>So, would be 12V and 15A enough to make work that configuration?</p>
|
<p>The easiest way to know how powerful the PSU should be is to download from <a href="https://github.com/rcarlyle/StepperSim" rel="nofollow noreferrer">https://github.com/rcarlyle/StepperSim</a> the Excel workbook which simulates the power absorbed by the stepper motor. Input the motor specifications, check in the graph the max speed at which you plan to run it, check the absorbed power, add 20% for the various losses. Once you know the absorbed power, you can multiply by the number of stepper motors and obtain the current required, add 20% not to stress the PSU too much.</p>
<p>In you case, this is the result</p>
<p><a href="https://i.stack.imgur.com/yoKsG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yoKsG.jpg" alt="enter image description here"></a></p>
<p>Your motor will never absorb more than 7 W, 14 W for the two motors, around 20 W considering losses in the motors and overcapacity of the PSU. This means that around 2 A PSU will be perfect for your setup.</p>
<hr>
<p><em>Previous answer, which may not be completely correct but still provides a useful background knowledge:</em></p>
<p>The TMC drivers limit the current to the value you set, which is most of the time lower than the datasheet. In no case you will need more than 1.3 A * sqrt(2) * 2 motors = 3.6 A. In fact, you won't need this much either.</p>
<p>When there is no field in a coil, the driver applies full voltage, but the current is low (initially zero) so you don't hit the 1.3 A per coil.</p>
<p>The current increases (the higher the maximum voltage available to the driver, the faster it increases) and the driver (probably) keeps the full voltage until the preset current is reached. Just a moment before that, the current is almost there, but you still have full voltage from the power supply. This is the theoretical worst case, but it applies only for a very short amount of time.</p>
<p>As soon as the current reaches the preset, the driver "cuts the voltage" to keep 2.4 ohm * 1.3 A = 3.2 V (because V = R * I). This means that the power supply sees 3.2 A/12 V*1.3 A = 0.35 A.</p>
<p>When running, the motors almost never start from zero to max current: both coils are powered and when one increases, the other one decreases.</p>
<p>In fact, the microstepping makes the steppers act more or less like AC motors with two phases. This means that overall the current is the max current per phase multipled by sqrt(2). Also, when using microstepping one phase (coil) is not completely shut off, but two of them work at the same time (with different current levels). This means that in total one compensates the other, and the power supply only provides, more or less, 0.35 * 1.4 = 0.5 A per stepper. You have two, so it's 1 A total, therefore 2 A PSU considering the inefficiencies.</p>
<p>A very easy and complete explanation is provided <a href="https://www.njr.com/semicon/PDF/application_notes/Drive_circuit_basics_APP_E.pdf" rel="nofollow noreferrer">here</a>:</p>
<blockquote>
<p>By controlling the duty cycle of the chopper, an average voltage and
an average current equal to the nominal motor voltage and current are
created. </p>
<p>...</p>
<p>As the current increases, a voltage develops across the
sensing resistor, which is fed back to the comparator. At the
predetermined level, defined by the voltage at the reference input,
the comparator resets the flipflop, which turns off the output
transistor. The current decreases until the clock oscillator triggers
the flip-flops, which turns on the output transistor again, and the
cycle is repeated</p>
</blockquote>
<p>So you never have coming out of the PSU more than the preset current.</p>
<blockquote>
<p><strong>Supply current is not the same as the motor current in a copper drive</strong>. It is the motor current multiplied by the dutycycle, at
standstill typically Isupply = IM · ( VM ⁄ Vsupply ) </p>
<p>...</p>
<p>Depending on
how the H-bridge is switched during the turn-off period, the current
will either recirculate through one transistor and one diode (path 2),
giving the slow current decay, or recirculate back through the power
supply (path 3). The advantage of <strong>feeding the power back to the
power supply</strong> is the fast current decay and the ability to quickly
reduce to a lower current level.</p>
</blockquote>
|
<p>Yes, A power supply that can deliver 12 volts and up to 15 Amps will work. Since that board says 12 V, that means it is designed to work at 12V. The components on the board might not survive 24V. The TMC stepper motor drivers specified can tolerate a max of 2.5 amps. That current draw is dependent on the per phase winding impedance of the motors that are used. @2.4 ohms phase resistance, that 12 volts could generate a max of 5 amps (more than the Trinamic can tolerate). Therefore, if you configure the stepper drivers to operate at more than 50% power, they will overheat and shutdown.</p>
| 1,617
|
<p>My goal is to have a speaker inside a PLA casing to produce a nice hearable sound from a submersible item.</p>
<p>I intended to produce that sound from a Piezo buzzer stuck on a membrane held tight in hollow place between two pieces, but the result is unsatisfactory as the sound gets muffled to inaudible levels.</p>
<p>Is there any known 3D printable methods to permit for a sound to be heard from PLA?</p>
<p><a href="https://i.stack.imgur.com/TLaB3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TLaB3.jpg" alt="enter image description here" /></a></p>
|
<p>In space, no one can hear you scream. That's because there's no air to be vibrated, which is part of the definition of sound.</p>
<p>In the case of your model, the described diaphragm will generate sound because it is surrounded by air. The vibrations in the air will transfer (and reflect) from the PLA shell you've created.</p>
<p>In order to hear as much sound as possible, you have to have as thin a shell as possible and only one of them. It would be more effective if you could incorporate the membrane into the shell, which eliminates the sound damping effect of the plastic sphere.</p>
<p>Barring that option, one layer (vase mode, but probably not) would present the created sound with a much less massive amount of plastic to vibrate.</p>
<p>Additionally, PLA is not known for being water tight. One can apply epoxy or other sealants to make it so, but that will add mass to the overall equation.</p>
|
<p>I did a lot of experimentation in this a couple years ago. The limitation on the sound is the amount of energy you can apply to the plastic, and the ability of the plastic to respond (move to) that energy. I ended up using epoxy to fasten a transducer directly to the plastic wall, and while the sound quality was not great (I could not have used it for speech or music) it was adequate to make the alarm sound, 50% PWM @ 3.3V and I controlled the frequency using the Arduino 'tone' library to control the frequency. I printed that side solid (no infill) and a bit thinner than the other sides (2mm instead of 4mm), printed it separately and then used epoxy to glue in (and its attached transducer) to the cube I was using for the rest of the circuitry.</p>
| 1,757
|
<p>If i have a simple named query defined, the preforms a count function, on one column:</p>
<pre><code> <query name="Activity.GetAllMiles">
<![CDATA[
select sum(Distance) from Activity
]]>
</query>
</code></pre>
<p>How do I get the result of a sum or any query that dont return of one the mapped entities, with NHibernate using Either IQuery or ICriteria?</p>
<p>Here is my attempt (im unable to test it right now), would this work?</p>
<pre><code> public decimal Find(String namedQuery)
{
using (ISession session = NHibernateHelper.OpenSession())
{
IQuery query = session.GetNamedQuery(namedQuery);
return query.UniqueResult<decimal>();
}
}
</code></pre>
|
<p>Sorry! I actually wanted a sum, not a count, which explains alot. Iv edited the post accordingly</p>
<p>This works fine:</p>
<pre><code>var criteria = session.CreateCriteria(typeof(Activity))
.SetProjection(Projections.Sum("Distance"));
return (double)criteria.UniqueResult();
</code></pre>
<p>The named query approach still dies, "Errors in named queries: {Activity.GetAllMiles}":</p>
<pre><code> using (ISession session = NHibernateHelper.OpenSession())
{
IQuery query = session.GetNamedQuery("Activity.GetAllMiles");
return query.UniqueResult<double>();
}
</code></pre>
|
<p>I think in your original example, you just need to to query.UniqueResult(); the count will return an integer.</p>
| 9,078
|
<p>Are there any useful techniques for reducing the repetition of constants in a CSS file?</p>
<p>(For example, a bunch of different selectors which should all apply the same colour, or the same font size)?</p>
|
<p>Recently, <a href="https://www.w3.org/TR/css-variables/" rel="nofollow noreferrer"><strong>variables have been added</strong></a> to the official CSS specs.</p>
<p>Variables allow you to so something like this :</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body, html {
margin: 0;
height: 100%;
}
.theme-default {
--page-background-color: #cec;
--page-color: #333;
--button-border-width: 1px;
--button-border-color: #333;
--button-background-color: #f55;
--button-color: #fff;
--gutter-width: 1em;
float: left;
height: 100%;
width: 100%;
background-color: var(--page-background-color);
color: var(--page-color);
}
button {
background-color: var(--button-background-color);
color: var(--button-color);
border-color: var(--button-border-color);
border-width: var(--button-border-width);
}
.pad-box {
padding: var(--gutter-width);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="theme-default">
<div class="pad-box">
<p>
This is a test
</p>
<button>
Themed button
</button>
</div>
</div></code></pre>
</div>
</div>
</p>
<p>Unfortunately, browser support is still very poor. <a href="http://caniuse.com/#feat=css-variables" rel="nofollow noreferrer"><strong>According to CanIUse</strong></a>, the only browsers that support this feature today (march 9th, 2016), are Firefox 43+, Chrome 49+, Safari 9.1+ and iOS Safari 9.3+ :</p>
<p><a href="https://i.stack.imgur.com/nRzFd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nRzFd.png" alt="enter image description here" /></a></p>
<hr />
<h3>Alternatives :</h3>
<p>Until CSS variables are widely supported, you could consider using a CSS pre-processor language like <a href="http://lesscss.org/" rel="nofollow noreferrer"><strong>Less</strong></a> or <a href="http://sass-lang.com/" rel="nofollow noreferrer"><strong>Sass</strong></a>.</p>
<p>CSS pre-processors wouldn't just allow you to use variables, but pretty much allow you to do anything you can do with a programming language.</p>
<p>For example, in Sass, you could create a function like this :</p>
<pre><code>@function exponent($base, $exponent) {
$value: $base;
@if $exponent > 1 {
@for $i from 2 through $exponent {
$value: $value * $base;
}
}
@if $exponent < 1 {
@for $i from 0 through -$exponent {
$value: $value / $base;
}
}
@return $value;
}
</code></pre>
|
<p>You can use multiple inheritance in your html elements (e.g. <code><div class="one two"></code>) but I'm not aware of a way of having constants in the CSS files themselves.</p>
<p>This link (the first found when googling your question) seems to have a fairly indepth look at the issue:</p>
<p><a href="http://icant.co.uk/articles/cssconstants/" rel="nofollow noreferrer">http://icant.co.uk/articles/cssconstants/</a></p>
| 5,004
|
<p>I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it.<br>
What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?</p>
|
<p>Have you looked at <a href="https://linux.die.net/man/8/logrotate" rel="noreferrer">logrotate</a> - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.</p>
|
<p>I have a module that does this for you without the need for external pipes etc :</p>
<p><a href="http://www.poptart.org/bin/view/Poptart/ModAutorotate" rel="nofollow">http://www.poptart.org/bin/view/Poptart/ModAutorotate</a></p>
<p>I've tried to add it to the Apache modules collection but that seems to have been broken for a while now.</p>
| 6,568
|
<p>I have a laptop running Ubuntu that I would like to act as a Subversion server. Both for myself to commit to locally, and for others remotely. What are the steps required to get this working? Please include steps to:</p>
<ul>
<li>Get and configure Apache, and necessary modules (I know there are other ways to create a SVN server, but I would like it Apache-specific)</li>
<li>Configure a secure way of accessing the server (SSH/HTTPS)</li>
<li>Configure a set of authorised users (as in, they must authorised to commit, but are free to browse)</li>
<li>Validate the setup with an initial commit (a "Hello world" of sorts)</li>
</ul>
<p>These steps can involve any mixture of command line or GUI application instructions. If you can, please note where instructions are specific to a particular distribution or version, and where a users' choice of a particular tool can be used instead (say, <a href="https://en.wikipedia.org/wiki/GNU_nano" rel="noreferrer">nano</a> instead of <a href="http://en.wikipedia.org/wiki/Vi" rel="noreferrer">vi</a>).</p>
|
<p>Steps I've taken to make my laptop a Subversion server. Credit must go to <a href="http://alephzarro.com/blog/" rel="noreferrer">AlephZarro</a> for his directions <a href="http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth/" rel="noreferrer">here</a>. I now have a working SVN server (which has currently only been tested locally).</p>
<p>Specific setup:
Kubuntu 8.04 Hardy Heron</p>
<p>Requirements to follow this guide:</p>
<ul>
<li>apt-get package manager program</li>
<li>text editor (I use kate)</li>
<li>sudo access rights</li>
</ul>
<p>1: Install Apache HTTP server and required modules:</p>
<pre><code>sudo apt-get install libapache2-svn apache2
</code></pre>
<p>The following extra packages will be installed:</p>
<pre><code>apache2-mpm-worker apache2-utils apache2.2-common
</code></pre>
<p>2: Enable SSL</p>
<pre><code>sudo a2enmod ssl
sudo kate /etc/apache2/ports.conf
</code></pre>
<p>Add or check that the following is in the file:</p>
<pre><code><IfModule mod_ssl.c>
Listen 443
</IfModule>
</code></pre>
<p>3: Generate an SSL certificate:</p>
<pre><code>sudo apt-get install ssl-cert
sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
</code></pre>
<p>4: Create virtual host</p>
<pre><code>sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/svnserver
sudo kate /etc/apache2/sites-available/svnserver
</code></pre>
<p>Change (in ports.conf):</p>
<pre><code>"NameVirtualHost *" to "NameVirtualHost *:443"
</code></pre>
<p>and (in svnserver)</p>
<pre><code><VirtualHost *> to <VirtualHost *:443>
</code></pre>
<p>Add, under ServerAdmin (also in file svnserver):</p>
<pre><code>SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM
</code></pre>
<p>5: Enable the site:</p>
<pre><code>sudo a2ensite svnserver
sudo /etc/init.d/apache2 restart
</code></pre>
<p>To overcome warnings:</p>
<pre><code>sudo kate /etc/apache2/apache2.conf
</code></pre>
<p>Add:</p>
<pre><code>"ServerName $your_server_name"
</code></pre>
<p>6: Adding repository(ies):
The following setup assumes we want to host multiple repositories.
Run this for creating the first repository:</p>
<pre><code>sudo mkdir /var/svn
REPOS=myFirstRepo
sudo svnadmin create /var/svn/$REPOS
sudo chown -R www-data:www-data /var/svn/$REPOS
sudo chmod -R g+ws /var/svn/$REPOS
</code></pre>
<p>6.a. For more repositories: do step 6 again (changing the value of REPOS), skipping the step <code>mkdir /var/svn</code></p>
<p>7: Add an authenticated user</p>
<pre><code>sudo htpasswd -c -m /etc/apache2/dav_svn.passwd $user_name
</code></pre>
<p>8: Enable and configure WebDAV and SVN:</p>
<pre><code>sudo kate /etc/apache2/mods-available/dav_svn.conf
</code></pre>
<p>Add or uncomment:</p>
<pre><code><Location /svn>
DAV svn
# for multiple repositories - see comments in file
SVNParentPath /var/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL
</Location>
</code></pre>
<p>9: Restart apache server:</p>
<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>
<p>10: Validation:</p>
<p>Fired up a browser:</p>
<pre><code>http://localhost/svn/$REPOS
https://localhost/svn/$REPOS
</code></pre>
<p>Both required a username and password. I think uncommenting:</p>
<pre><code><LimitExcept GET PROPFIND OPTIONS REPORT>
</LimitExcept>
</code></pre>
<p>in <code>/etc/apache2/mods-available/dav_svn.conf</code>, would allow anonymous browsing. </p>
<p>The browser shows "Revision 0: /"</p>
<p>Commit something:</p>
<pre><code>svn import --username $user_name anyfile.txt https://localhost/svn/$REPOS/anyfile.txt -m “Testing”
</code></pre>
<p>Accept the certificate and enter password.
Check out what you've just committed:</p>
<pre><code>svn co --username $user_name https://localhost/svn/$REPOS
</code></pre>
<p>Following these steps (assuming I haven't made any error copy/pasting), I had a working SVN repository on my laptop.</p>
|
<p>For Apache:</p>
<pre><code>sudo apt-get -yq install apache2
</code></pre>
<p>For SSH:</p>
<pre><code>sudo apt-get -yq install openssh-server
</code></pre>
<p>For Subversion:</p>
<pre><code>sudo apt-get -yq install subversion subversion-tools
</code></pre>
<p>If you'd like you can combine these into one command like:</p>
<pre><code>sudo apt-get -yq install apache2 openssh-server subversion subversion-tools
</code></pre>
<p>I can't help with the rest...</p>
| 8,571
|
<p>In Flex, I have an xml document such as the following:</p>
<pre><code>var xml:XML = <root><node>value1</node><node>value2</node><node>value3</node></root>
</code></pre>
<p>At runtime, I want to create a TextInput control for each node under root, and have the values bound to the values in the XML. As far as I can tell I can't use BindingUtils to bind to e4x nodes at runtime (please tell me if I'm wrong here!), so I'm trying to do this by hand:</p>
<pre><code>for each (var node:XML in xml.node)
{
var textInput:TextInput = new TextInput();
var handler:Function = function(event:Event):void
{
node.setChildren(event.target.text);
};
textInput.text = node.text();
textInput.addEventListener(Event.CHANGE, handler);
this.addChild(pileHeightEditor);
}
</code></pre>
<p>My problem is that when the user edits one of the TextInputs, the node getting assigned to is always the last one encountered in the for loop. I am used to this pattern from C#, where each time an anonymous function is created, a "snapshot" of the values of the used values is taken, so "node" would be different in each handler function.</p>
<p>How do I "take a snapshot" of the current value of node to use in the handler? Or should I be using a different pattern in Flex?</p>
|
<h2>Windows</h2>
<p>Some of the above values are easily available from the appropriate Win32 API, I just list them here for completeness. Others, however, need to be obtained from the Performance Data Helper library (PDH), which is a bit "unintuitive" and takes a lot of painful trial and error to get to work. (At least it took me quite a while, perhaps I've been only a bit stupid...)</p>
<p>Note: for clarity all error checking has been omitted from the following code. Do check the return codes...!</p>
<ul>
<li><p>Total Virtual Memory:</p>
<pre><code>#include "windows.h"
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
DWORDLONG totalVirtualMem = memInfo.ullTotalPageFile;
</code></pre>
<p>Note: The name "TotalPageFile" is a bit misleading here. In reality this parameter gives the "Virtual Memory Size", which is size of swap file plus installed RAM.</p>
</li>
<li><p>Virtual Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code> DWORDLONG virtualMemUsed = memInfo.ullTotalPageFile - memInfo.ullAvailPageFile;
</code></pre>
</li>
<li><p>Virtual Memory currently used by current process:</p>
<pre><code>#include "windows.h"
#include "psapi.h"
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
SIZE_T virtualMemUsedByMe = pmc.PrivateUsage;
</code></pre>
</li>
<li><p>Total Physical Memory (RAM):</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>DWORDLONG totalPhysMem = memInfo.ullTotalPhys;
</code></pre>
</li>
<li><p>Physical Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>DWORDLONG physMemUsed = memInfo.ullTotalPhys - memInfo.ullAvailPhys;
</code></pre>
</li>
<li><p>Physical Memory currently used by current process:</p>
<p>Same code as in "Virtual Memory currently used by current process" and then</p>
<pre><code>SIZE_T physMemUsedByMe = pmc.WorkingSetSize;
</code></pre>
</li>
<li><p>CPU currently used:</p>
<pre><code>#include "TCHAR.h"
#include "pdh.h"
static PDH_HQUERY cpuQuery;
static PDH_HCOUNTER cpuTotal;
void init(){
PdhOpenQuery(NULL, NULL, &cpuQuery);
// You can also use L"\\Processor(*)\\% Processor Time" and get individual CPU values with PdhGetFormattedCounterArray()
PdhAddEnglishCounter(cpuQuery, L"\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
PdhCollectQueryData(cpuQuery);
}
double getCurrentValue(){
PDH_FMT_COUNTERVALUE counterVal;
PdhCollectQueryData(cpuQuery);
PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, NULL, &counterVal);
return counterVal.doubleValue;
}
</code></pre>
</li>
<li><p>CPU currently used by current process:</p>
<pre><code>#include "windows.h"
static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
static int numProcessors;
static HANDLE self;
void init(){
SYSTEM_INFO sysInfo;
FILETIME ftime, fsys, fuser;
GetSystemInfo(&sysInfo);
numProcessors = sysInfo.dwNumberOfProcessors;
GetSystemTimeAsFileTime(&ftime);
memcpy(&lastCPU, &ftime, sizeof(FILETIME));
self = GetCurrentProcess();
GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
memcpy(&lastSysCPU, &fsys, sizeof(FILETIME));
memcpy(&lastUserCPU, &fuser, sizeof(FILETIME));
}
double getCurrentValue(){
FILETIME ftime, fsys, fuser;
ULARGE_INTEGER now, sys, user;
double percent;
GetSystemTimeAsFileTime(&ftime);
memcpy(&now, &ftime, sizeof(FILETIME));
GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
memcpy(&sys, &fsys, sizeof(FILETIME));
memcpy(&user, &fuser, sizeof(FILETIME));
percent = (sys.QuadPart - lastSysCPU.QuadPart) +
(user.QuadPart - lastUserCPU.QuadPart);
percent /= (now.QuadPart - lastCPU.QuadPart);
percent /= numProcessors;
lastCPU = now;
lastUserCPU = user;
lastSysCPU = sys;
return percent * 100;
}
</code></pre>
</li>
</ul>
<hr />
<h2>Linux</h2>
<p>On Linux the choice that seemed obvious at first was to use the POSIX APIs like <code>getrusage()</code> etc. I spent some time trying to get this to work, but never got meaningful values. When I finally checked the kernel sources themselves, I found out that apparently these APIs are not yet completely implemented as of Linux kernel 2.6!?</p>
<p>In the end I got all values via a combination of reading the pseudo-filesystem <code>/proc</code> and kernel calls.</p>
<ul>
<li><p>Total Virtual Memory:</p>
<pre><code>#include "sys/types.h"
#include "sys/sysinfo.h"
struct sysinfo memInfo;
sysinfo (&memInfo);
long long totalVirtualMem = memInfo.totalram;
//Add other values in next statement to avoid int overflow on right hand side...
totalVirtualMem += memInfo.totalswap;
totalVirtualMem *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Virtual Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>long long virtualMemUsed = memInfo.totalram - memInfo.freeram;
//Add other values in next statement to avoid int overflow on right hand side...
virtualMemUsed += memInfo.totalswap - memInfo.freeswap;
virtualMemUsed *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Virtual Memory currently used by current process:</p>
<pre><code>#include "stdlib.h"
#include "stdio.h"
#include "string.h"
int parseLine(char* line){
// This assumes that a digit will be found and the line ends in " Kb".
int i = strlen(line);
const char* p = line;
while (*p <'0' || *p > '9') p++;
line[i-3] = '\0';
i = atoi(p);
return i;
}
int getValue(){ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];
while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmSize:", 7) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result;
}
</code></pre>
</li>
<li><p>Total Physical Memory (RAM):</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>long long totalPhysMem = memInfo.totalram;
//Multiply in next statement to avoid int overflow on right hand side...
totalPhysMem *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Physical Memory currently used:</p>
<p>Same code as in "Total Virtual Memory" and then</p>
<pre><code>long long physMemUsed = memInfo.totalram - memInfo.freeram;
//Multiply in next statement to avoid int overflow on right hand side...
physMemUsed *= memInfo.mem_unit;
</code></pre>
</li>
<li><p>Physical Memory currently used by current process:</p>
<p>Change getValue() in "Virtual Memory currently used by current process" as follows:</p>
<pre><code>int getValue(){ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];
while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmRSS:", 6) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result;
}
</code></pre>
</li>
</ul>
<p></p>
<ul>
<li><p>CPU currently used:</p>
<pre><code>#include "stdlib.h"
#include "stdio.h"
#include "string.h"
static unsigned long long lastTotalUser, lastTotalUserLow, lastTotalSys, lastTotalIdle;
void init(){
FILE* file = fopen("/proc/stat", "r");
fscanf(file, "cpu %llu %llu %llu %llu", &lastTotalUser, &lastTotalUserLow,
&lastTotalSys, &lastTotalIdle);
fclose(file);
}
double getCurrentValue(){
double percent;
FILE* file;
unsigned long long totalUser, totalUserLow, totalSys, totalIdle, total;
file = fopen("/proc/stat", "r");
fscanf(file, "cpu %llu %llu %llu %llu", &totalUser, &totalUserLow,
&totalSys, &totalIdle);
fclose(file);
if (totalUser < lastTotalUser || totalUserLow < lastTotalUserLow ||
totalSys < lastTotalSys || totalIdle < lastTotalIdle){
//Overflow detection. Just skip this value.
percent = -1.0;
}
else{
total = (totalUser - lastTotalUser) + (totalUserLow - lastTotalUserLow) +
(totalSys - lastTotalSys);
percent = total;
total += (totalIdle - lastTotalIdle);
percent /= total;
percent *= 100;
}
lastTotalUser = totalUser;
lastTotalUserLow = totalUserLow;
lastTotalSys = totalSys;
lastTotalIdle = totalIdle;
return percent;
}
</code></pre>
</li>
<li><p>CPU currently used by current process:</p>
<pre><code>#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "sys/times.h"
#include "sys/vtimes.h"
static clock_t lastCPU, lastSysCPU, lastUserCPU;
static int numProcessors;
void init(){
FILE* file;
struct tms timeSample;
char line[128];
lastCPU = times(&timeSample);
lastSysCPU = timeSample.tms_stime;
lastUserCPU = timeSample.tms_utime;
file = fopen("/proc/cpuinfo", "r");
numProcessors = 0;
while(fgets(line, 128, file) != NULL){
if (strncmp(line, "processor", 9) == 0) numProcessors++;
}
fclose(file);
}
double getCurrentValue(){
struct tms timeSample;
clock_t now;
double percent;
now = times(&timeSample);
if (now <= lastCPU || timeSample.tms_stime < lastSysCPU ||
timeSample.tms_utime < lastUserCPU){
//Overflow detection. Just skip this value.
percent = -1.0;
}
else{
percent = (timeSample.tms_stime - lastSysCPU) +
(timeSample.tms_utime - lastUserCPU);
percent /= (now - lastCPU);
percent /= numProcessors;
percent *= 100;
}
lastCPU = now;
lastSysCPU = timeSample.tms_stime;
lastUserCPU = timeSample.tms_utime;
return percent;
}
</code></pre>
</li>
</ul>
<hr />
<h2>TODO: Other Platforms</h2>
<p>I would assume, that some of the Linux code also works for the Unixes, except for the parts that read the /proc pseudo-filesystem. Perhaps on Unix these parts can be replaced by <code>getrusage()</code> and similar functions?</p>
|
<p>I used this following code in my C++ project and it worked fine:</p>
<pre><code>static HANDLE self;
static int numProcessors;
SYSTEM_INFO sysInfo;
double percent;
numProcessors = sysInfo.dwNumberOfProcessors;
//Getting system times information
FILETIME SysidleTime;
FILETIME SyskernelTime;
FILETIME SysuserTime;
ULARGE_INTEGER SyskernelTimeInt, SysuserTimeInt;
GetSystemTimes(&SysidleTime, &SyskernelTime, &SysuserTime);
memcpy(&SyskernelTimeInt, &SyskernelTime, sizeof(FILETIME));
memcpy(&SysuserTimeInt, &SysuserTime, sizeof(FILETIME));
__int64 denomenator = SysuserTimeInt.QuadPart + SyskernelTimeInt.QuadPart;
//Getting process times information
FILETIME ProccreationTime, ProcexitTime, ProcKernelTime, ProcUserTime;
ULARGE_INTEGER ProccreationTimeInt, ProcexitTimeInt, ProcKernelTimeInt, ProcUserTimeInt;
GetProcessTimes(self, &ProccreationTime, &ProcexitTime, &ProcKernelTime, &ProcUserTime);
memcpy(&ProcKernelTimeInt, &ProcKernelTime, sizeof(FILETIME));
memcpy(&ProcUserTimeInt, &ProcUserTime, sizeof(FILETIME));
__int64 numerator = ProcUserTimeInt.QuadPart + ProcKernelTimeInt.QuadPart;
//QuadPart represents a 64-bit signed integer (ULARGE_INTEGER)
percent = 100*(numerator/denomenator);
</code></pre>
| 8,875
|
<p>We are currently looking at the scope definition on the Arts & Crafts site. Some 3D subject matter could be on-topic there, and we don't want to steal any thunder from the 3D Printing site. Your "what's on topic" discussion in the Help section covers a lot of subject matter beyond 3D printing per se. It also lists a curious off-topic example (assembling 3D printed parts), although it isn't clear whether that would still be considered off-topic.</p>
<ol>
<li><p>It would be nice to be able to succinctly describe what would be off-topic on A&C by virtue of being on-topic here. Does the following accurately summarize what's on-topic here (not a complete scope for this site, just a boundary for A&C)?</p>
<blockquote>
<p>Computer-driven creation of 3D objects, and components for creating 3D objects, (e.g., 3D printing, cutting of flat components used to build 3D objects via equipment like CNC, laser cutters, hobby cutters like Cricut, etc.).</p>
</blockquote></li>
<li><p>Would this site include non-computer-driven 3D printing via handheld technology? For example there are novelty pens that take a filament and create hand-drawn 3D objects, and a common hobby theme is creating 3D objects using a hot glue gun. My assumption is that this site is only concerned with computer-controlled equipment.</p></li>
<li><p>My reading is that this site's focus ends with the production of the parts, possibly with a few extensions, like joining parts into a whole if technology limitations require producing it in sections, or smoothing the surface of the produced part. Would I be correct that the following kinds of things would not be on-topic?</p>
<ul>
<li>assembling a wooden object made from laser-cut parts (although producing the parts would be on-topic)</li>
<li>decorating the finished item (or would finishes that bond with the filament material be on-topic? Would surface prep for finishing be on-topic?)</li>
</ul></li>
</ol>
<p>Any further guidance you can provide to help us define what not to ask on Art & Crafts because it's covered here?</p>
|
<p>This answer addresses some of the things that came to mind based on your question.</p>
<ul>
<li>Post processing 3D printed objects is on topic, this includes surface treatment, weathering, annealing and connecting parts (the topic <a href="/q/276">"Game plan - What is on-topic?"</a> suggests connecting parts is off-topic, but questions on this topic have been allowed since that old referenced question).</li>
<li>It appears that handheld 3D pens (no novelty IMHO) share some topics
with this site. E.g. material printing temperatures, cooling,
adhesion to build platform, and maybe more related questions, e.g. clogging?</li>
<li>Assembly of laser cut parts would not be on-topic, unless the parts are a frame of a 3D printing/cutting machine.</li>
</ul>
|
<p>We don't get a lot of traffic here on 3D Printing (Beta). I check every day, and often don't find questions to respond to -- and I am prone to over-responding.</p>
<p>Is the intention of SE that questioners (within one particular activity they undertake) will tend to ask questions on one site, or do we expect sites to have very narrow, non-overlapping scopes and place the onus on questioners to determine the correct site?</p>
<p>In other words, if I cross-country ski and also 3D Print, clearly questions about each activity should go to different sites. But, within cross-country skiing, would questions about waxing be directed to a materials science site, questions about packing the snow be directed to a landscaping site? Or, would they all fit within cross-country skiing?</p>
<p>I know this isn't a clear answer. To the extent that I may take a position, I would encourage someone who has found this site to stick here until they clearly can be better served elsewhere.</p>
| 72
|
<p>Does anyone know of a good Command Prompt replacement? I've tried bash/Cygwin, but that does not really meet my needs at work because it's too heavy. I'd like a function-for-function identical wrapper on cmd.exe, but with highlighting, intellisense, and (critically) a tabbed interface. Powershell is okay, but the interface is still lacking.</p>
|
<p><em>Edited</em>: I've been using <strong>ConEmu</strong> (<a href="http://conemu.github.io/" rel="noreferrer">http://conemu.github.io/</a>) for quite some time now. This one is a wrapper too, since it is not really possible to replace the Windows console without rewriting the whole command interpreter. Below the line is my original answer for an earlier alternative.</p>
<hr>
<p>Not exactly a replacement (actually, it's a prettifying wrapper) but you might try <strong>Console</strong> (<a href="http://sourceforge.net/projects/console/" rel="noreferrer">http://sourceforge.net/projects/console/</a>)</p>
|
<p>Nick, I know you asked this a long while ago but I've just found it while searching for something related. I have been using <a href="http://www.promptpal.com/" rel="nofollow noreferrer">PromptPal</a> and its been great. I got it about a year ago, early 2008, and it was through this discount software thing called BitsDujour. I just went there and noticed they had a deal for 51% off that product only a <a href="http://www.bitsdujour.com/software/promptpal/" rel="nofollow noreferrer">few days ago</a>. Keep your eyes on that site and maybe the discount will come up again soon. Its well worth the $30 but I got 2 licenses for 1/2 off, one for each of my PCs...</p>
| 4,015
|
<p>I've used several modules to make EXEs for Python, but I'm not sure if I'm doing it right.</p>
<p>How should I go about this, and why? Please base your answers on personal experience, and provide references where necessary.</p>
|
<p><a href="https://pypi.org/project/auto-py-to-exe/" rel="noreferrer">Auto PY to EXE</a> - A .py to .exe converter using a simple graphical interface built using Eel and PyInstaller in Python.</p>
<hr>
<p><a href="http://www.py2exe.org/" rel="noreferrer">py2exe</a> is probably what you want, but it only works on Windows.<br>
<a href="http://www.pyinstaller.org/" rel="noreferrer">PyInstaller</a> works on Windows and Linux.<br>
<a href="http://pypi.python.org/pypi/py2app/" rel="noreferrer">Py2app</a> works on the Mac.</p>
|
<p><a href="http://www.py2exe.org/" rel="nofollow noreferrer">py2exe</a>:</p>
<blockquote>
<p>py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.</p>
</blockquote>
| 7,157
|
<p>What are the differences between these two and which one should I use?</p>
<pre><code>string s = "Hello world!";
String s = "Hello world!";
</code></pre>
|
<p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/string" rel="noreferrer"><code>string</code></a> is an alias in C# for <a href="https://learn.microsoft.com/en-us/dotnet/api/system.string" rel="noreferrer"><code>System.String</code></a>.<br />
So technically, there is no difference. It's like <a href="https://stackoverflow.com/questions/62503/c-int-or-int32-should-i-care"><code>int</code> <em>vs.</em> <code>System.Int32</code></a>.</p>
<p>As far as guidelines, it's generally recommended to use <code>string</code> any time you're referring to an object.</p>
<p>e.g.</p>
<pre><code>string place = "world";
</code></pre>
<p>Likewise, I think it's generally recommended to use <code>String</code> if you need to refer specifically to the class.</p>
<p>e.g.</p>
<pre><code>string greet = String.Format("Hello {0}!", place);
</code></pre>
<h3>This is the style that Microsoft tends to use in <a href="https://learn.microsoft.com/en-us/dotnet/api/system.string.format#examples" rel="noreferrer">their examples</a>.</h3>
<p>It appears that the guidance in this area may have changed, as <a href="https://github.com/StyleCop" rel="noreferrer">StyleCop</a> now enforces the use of the C# specific aliases.</p>
|
<p>There are at least 4 differences:</p>
<p>1- string is a reserved word, but String is just a class name. This means that string cannot be used as a variable name by itself.</p>
<p>2- you can't use String without "using System".so you write less code by using "string".</p>
<p>3- 'String' is better naming convention than 'string', as it is a type not variable.</p>
<p>4- "string" is a C# keyword and syntax highlighted in most coding editors, but not "String".</p>
| 2,871
|
<p>I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial . </p>
<p>When i do this everything seems to be hunky-dory:</p>
<pre><code>stty -f /dev/cu.usbserial
speed 9600 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb
</code></pre>
<p>Everything also works when I use the <a href="http://www.versiontracker.com/dyn/moreinfo/macosx/24024" rel="noreferrer">serial port tool</a> to talk to it.</p>
<p>If I run this piece of code while the above mentioned serial port tool, everthing also works. But as soon as I disconnect the tool the connection gets lost. </p>
<pre><code>#!/usr/bin/python
import serial
ser = serial.Serial('/dev/cu.usbserial', 9600, timeout=10)
ser.write("<ID01><PA> \r\n")
read_chars = ser.read(20)
print read_chars
ser.close()
</code></pre>
<p>So the question is, what magicks do I need to perform to start talking to the serial port without the serial port tool? Is that a permissions problem? Also, what's the difference between /dev/cu.usbserial and /dev/tty.usbserial?</p>
<hr>
<p>Nope, no serial numbers. The thing is, the problem persists even with sudo-running the python script, and the only thing that makes it go through if I open the connection in the gui tool that I mentioned.</p>
|
<p><code>/dev/cu.xxxxx</code> is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. <code>/dev/tty.xxxxx</code> is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.</p>
|
<p>have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Python is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed your quote changes for the strings and in some languages that actually is the difference between ASCII and UTF-8.</p>
| 2,599
|
<p>Recently, I have heard people talking about masterspool, when talking about 3D printing filament.</p>
<ul>
<li>What <em>exactly</em> is master spool?</li>
<li>Where did the idea come from and when?</li>
<li>Is it being widely adopted? Or to be specific, how many distributors/manufacturers have adopted this already, and is it gaining traction?</li>
<li><strike>Is this something that I should get excited by?</strike></li>
<li><strike>If so, why is it such a good idea?</strike></li>
</ul>
|
<p>A masterspool is the practice of printing your own spool out of filament, which will then be used to support your filament you purchase without a spool attached. The main idea is to create a reusable spool and create less waste. </p>
<p>(<em>NOTE: I'm in no way affiliated with MatterHackers.com, nor am I an endorser of their products.</em> There is also a version which <a href="https://www.villageplastics.com/the-filament-koil/" rel="nofollow noreferrer">Village Plastics</a> has created.)</p>
<p>On <a href="https://www.matterhackers.com/articles/tech-breakdown-the-master-spool" rel="nofollow noreferrer">MatterHackers.com</a> website, they state:</p>
<blockquote>
<p>Filament without a spool? Why are we making this? The short answer: because the community wants it. We had enough questions, comments and plenty of tweets asking if we had plans to pick up the Master Spool concept. Seeing the response and interest within the community made it clear to us: we needed to bring this idea to the States. With a joint effort between MatterHackers and Village Plastics, you can now purchase Master Spool refills from within the US.</p>
</blockquote>
<p>They are tying to apply the <em>Reduce, Reuse, Recycle</em> mantra to create a cleaner environment for the rest of the world. While they are not the first to create or use a printable spool, they are pretty happy to be pressing forward with the idea of having a reusable spool and selling filament without a spool attached.</p>
<p>MatterHackers go on to state:</p>
<blockquote>
<p>What are the benefits of the Master Spool? Not only is there the benefit of reducing plastic waste, using a Master Spool will also reduces shipping costs for new spools, and limits the clutter from amassing of a huge collection of used or empty spools. Rather than throwing away, trying to recycle dozens of spools, or trying to come up with a way to reuse them in some (like the Spool Tool), using the Master Spool means you can use all those filament scraps you have laying around on something useful and have one spool for all of your filament.</p>
</blockquote>
<p>As far as where it started, it appears to have originated with <a href="https://www.thingiverse.com/thing:1738730" rel="nofollow noreferrer">this print on Thiniverse</a> created by <a href="https://www.thingiverse.com/Dingoboy71/about" rel="nofollow noreferrer">Dingoboy71</a>. A well known 3D printer named <em>RichRap</em> created the reusable spool which MatterHacker promotes, though they say there are several which will work with their product (Village Plastic says pretty much the same). </p>
<p>If you get excited about saving the planet, then you should be excited about this. If you are a robust printer, going through tons (hopefully not literally) of filament per year, this method will save a lot of waste in the long run.</p>
<p>Realize there are (as of this writ) only limited suppliers of spool-less filament, though I think the trend for this type of product will increase in the future as the idea catches on. I guess time will tell. </p>
|
<p>One key difference between a 'masterspool' and any old spare empty reel you have left over is that the masterspool is a 2-part design which can be fitted over an existing roll of filament without needing to un-spool and re-spool the whole roll.</p>
<p>The idea being that filament can be packaged and secured for shipment (with cable ties or the like) without needing to include a whole spool every time. The end user can buy/print only as many spools as they need.</p>
<p>This concept also allows for 'extra' features to be included in the spool (such as retention for loose ends) without these features being wasted on every discarded spool.</p>
| 991
|
<p>I've been aware ever since I got it that my Ender 3's X-axis isn't level. Measuring from the top of it to the top of the frame, the right-hand (positive) side is about 4.7mm higher than the left.</p>
<p>During assembly, the vertical rails were not entirely parallel, and had to be pulled together to get the X axis on and to bolt the cross beam on the top. I suspect this is related, but I'm not sure.</p>
<p>Anyway, aside from the bed having to be tilted to be level with respect to the X axis, this never seemed to cause any problem, so I've left it alone until now. However I have measured almost exactly a 1% dimensional error in the X direction that I've now compensated for by setting the steps per mm, and wonder if the tilted axis could be the cause. Doing the trig, that doesn't make sense - a 4.7 mm error across the width of the bed should translate to something like one part in 2000, not 1%. But maybe something's wrong in my analysis so I'd like second opinions.</p>
<p>Aside from that, is this something I should try to correct, or just let be? I suspect it's the base that's warped or tapped/cut incorrectly where the vertical rails bolt on, in which case it seems unlikely there's any way to fix it without replacing that part, which is something I'd rather not get into as long as the printer is working. But if there are other possibilities that are non-invasive to try, I might.</p>
<p><img src="https://i.stack.imgur.com/mLJ7a.jpg" alt="whole printer with x axis at low z"></p>
<p><img src="https://i.stack.imgur.com/AGc09.jpg" alt="x axis raised to top of frame"></p>
<p>Further update: if this is the cause of the dimensional error (which turned out to be more like 0.41% than 1%, thus closer to plausible) I probably need to fix it. Using firmware steps/mm adjustment is not viable because it produces aliasing patterns in skin layers presumably due to step width no longer dividing nozzle size/line width.</p>
|
<p>i've just bought an Ender 3 Pro and on assembly I carefully checked and deburred the uprigh rails on their bottom faces to ensure they did not splay out or in etc.</p>
<p>Once the 2 uprights are loosely attached to the base rails I laid the assembly flat onto a table on the uprights to ensure the uprights were square to one another and tightened the screws.</p>
<p>Check the uprights are parallel to one another by placing the top crossbeam on the top of the uprights and check if the screw holes are alligned...….if the screws are tight to enter their holes the uprights are splayed out or in and need correcting etc......a small amount of pressure "can" make them line up. </p>
<p>The X axis rail slides up and down on the two uprights with two 3 wheeled brackets, one either side, that have 3 wheels on them, one wheel on each bracket is the adjuster and it is easy to have the X axis cross beam out of square if you tighten the one bracket to the rail before you test the rail for squareness.</p>
<p>Firstly, place only the 2 wheel brackets on their uprights and adjust the wheels for smooth running, then attach the X axis rail to each wheel bracket and just nip up the 2 screws loosely to hold them to the cross beam.</p>
<p>Now, check the cross beam for squareness by running it to the top of the uprights and measuring the gap left to right between the X axis rail and the top rail, then tighten the left hand wheel bracket screws to the X axis rail......and then tighten the right hand wheel bracket to the cross beam.</p>
<p>Leave the Z axis leadscrew off for the moment and run the crossbeam up and down on the uprights making sure there are no tight spots due to out of squareness.</p>
<p>if it's all freely moving.....fit the Z axis leadscrew.</p>
<p>The bed plate can only be set once you have the machine itself squared up.
Ian.</p>
|
<p>i've just bought an Ender 3 Pro and on assembly I carefully checked and deburred the uprigh rails on their bottom faces to ensure they did not splay out or in etc.</p>
<p>Once the 2 uprights are loosely attached to the base rails I laid the assembly flat onto a table on the uprights to ensure the uprights were square to one another and tightened the screws.</p>
<p>Check the uprights are parallel to one another by placing the top crossbeam on the top of the uprights and check if the screw holes are alligned...….if the screws are tight to enter their holes the uprights are splayed out or in and need correcting etc......a small amount of pressure "can" make them line up. </p>
<p>The X axis rail slides up and down on the two uprights with two 3 wheeled brackets, one either side, that have 3 wheels on them, one wheel on each bracket is the adjuster and it is easy to have the X axis cross beam out of square if you tighten the one bracket to the rail before you test the rail for squareness.</p>
<p>Firstly, place only the 2 wheel brackets on their uprights and adjust the wheels for smooth running, then attach the X axis rail to each wheel bracket and just nip up the 2 screws loosely to hold them to the cross beam.</p>
<p>Now, check the cross beam for squareness by running it to the top of the uprights and measuring the gap left to right between the X axis rail and the top rail, then tighten the left hand wheel bracket screws to the X axis rail......and then tighten the right hand wheel bracket to the cross beam.</p>
<p>Leave the Z axis leadscrew off for the moment and run the crossbeam up and down on the uprights making sure there are no tight spots due to out of squareness.</p>
<p>if it's all freely moving.....fit the Z axis leadscrew.</p>
<p>The bed plate can only be set once you have the machine itself squared up.
Ian.</p>
| 1,328
|
<p>Scenario: I'm cruising <a href="https://www.thingiverse.com/" rel="nofollow noreferrer">Thingiverse</a>, and I find the awesomest thing. I NEED THIS IN MY LIFE. I download it, print it, and for whatever reason, it doesn't work quite right. OK, no big deal, I'll just download the source because the maker was so kind, modify it ever so slightly, and I will have the most awesomest thing evar!</p>
<p>Several hours later, I realized that I could have designed it from scratch in a software that is way more user friendly, deterministic, simpler, etc.</p>
<p>And then I <strong>do</strong> redesign it. From scratch. Maybe taking a measurement or two from the thing, or something related to the thing. And I refine it, and it turns out better than the original was.</p>
<p>Did I make a new thing? Did I only draw inspiration from the previous thing? Did I make a derivative work? Using Thingiverse's terminology, did I remix it?</p>
<p>I'm looking for some canonical guidelines to refer to for the US. Thingiverse can be an example, but god answers should not be limited to Thingiverse, nor my specific example.</p>
<p>I ran into this issue while trying to print out a case for a Raspberry Pi Zero. I'm not done redesigning it, but I've been wondering how I could share it on Thingiverse, and if any restrictions from the original model's licensing might affect me when I post my thing.</p>
|
<p>I should start by saying that I am not a lawyer. I have been both the complainant and defendant in patent cases, and have had the role of observing copyright compliance for a performing arts organization. With that in mind, the following is my own opinion and information.</p>
<hr>
<p>Ultimately, there is no simple answer to your question. It would depend on the case law that applies to 3D printed objects, which is not very clear. You are venturing into Copyright law, which is very different than Patent law.</p>
<p>For example, if someone had a patent on "A Raspberry PI case with a <describe a novel, special, functional feature>", and you made a case with that feature, you would be in infringement. It wouldn't matter if the case looked like the original, or was completely different. If it included that patented invention, you would be more likely to lose if challenged in court. The one thing about patent court prosecutions is that it is really rare that anyone actually "wins". The cost to put forward a case is very high, and usually someone runs out of money (sometimes even the "good guy") before a decision is reached. </p>
<p>Copyright is much harder and softer at the same time. Copyright can relate to the design feel of an object -- such as rounded vs. square, or using a trash can vs recycle bin icon. Prosecuting a copyright violation of this kind would require that the aggrieved rights holder demonstrate that the design was copied, or at least derived in an unpermitted way, from the original work. This is often more a matter of opinion than law, which is why the lawyers matter, as well as the judge and potential jury.</p>
<p>Technically, you are not free to do whatever you wish in the privacy of your own home. You are much less like to be detected and then prosecuted, and the penalties would be lower, but you are just as much in violation if you make one for your own use or sell them by the millions.</p>
<p>The best way to handle it, if you are prepared for possible adverse reaction from the original designer, is to ask them for permission. You can say ask for clearance to use, such as by saying:</p>
<blockquote>
<blockquote>
<p>I loved your object <thing> on Thingiverse. I plan to <put in your plans here -- make a few for me and my friends -- sell further varieties online -- whatever>. Although I didn't copy your design, I would like to acknowledge that I saw your design before doing my own. How shall I do that?</p>
</blockquote>
</blockquote>
<p>Your next steps will depend on how they respond. Most likely, they will either give you free leave to do as you wish, or they will ask for something.</p>
<p>This happens a great deal in music, and expensive and acromonious problems have developed over who actually composed a particular guitar riff. You can pick up the <a href="https://www.google.com/search?q=stairway%20to%20heaven%20copyright%20case&rlz=1C1CHBF_enUS753US753&oq=stairway%20to%20heaven%20copyright%20case&aqs=chrome..69i57.5643j0j7&sourceid=chrome&ie=UTF-8" rel="nofollow noreferrer">"Stairway to Heaven" case here</a>. If you are doing this commercially, it is better to negotiate ahead of time. If you are putting your object back on Thingiverse for sharing, I'd just identify it as derivative an get on with life. </p>
|
<p>When you remix, either by modifying the existing CAD files (STL or sCAD or whatever), or by rebuilding essentially the same item from scratch, that <strong>is</strong> a remix and subject to whatever restrictions the original author put on his work. </p>
<p>So the critical issue so far as copyright is concerned is whether the output is a clear copy or remix. No different from taking someone's novel and rewriting it using Notepad++ and LaTeX instead of the original Microsoft World. </p>
<p>Now, when remix or reuse is allowed by the originator, it is still incumbent upon you to provide proper attribution, just as you would provide footnotes and bibliography so as to avoid plagiarism in a research paper. </p>
<p>All that said, you are free to do whatever you wish in "the privacy of your own home" (IANAL and laws vary by location, but the chance that the copyright holder will track you down because you have a widget in your bedroom are nil). You can't publish or sell, of course w/o permission. </p>
| 965
|
<p>Has anybody managed to get the Android Emulator working behind a proxy that requires authentication?</p>
<p>I've tried setting the -http-proxy argument to</p>
<pre><code>http://DOMAIN/USERNAME:PASSWORD@IP:PORT
</code></pre>
<p>but am having no success.</p>
<p>I've tried following the docs to no avail. I've also tried the <code>-verbose-proxy</code> setting but this no longer seems to exist.</p>
<p>Any pointers?</p>
|
<p>I Managed to do it in the Adndroid 2.2 Emulator.</p>
<pre><code>Go to "Settings" -> "Wireless & Networks" -> "Mobile Networks" -> "Access Point Names" -> "Telkila"
</code></pre>
<p>Over there set the proxy host name in the property "Proxy"
and the Proxy port in the property "Port"</p>
|
<p>I had the same problem when i use the following command:</p>
<pre><code>emulator-x86.exe -http-proxy domain\user:password@proxyIP:port -avd MyAVD
</code></pre>
<p>I got the proxy authentication error.</p>
<p>Finally, I had to bypass the proxy NTLM authentication by using the Cntlm here:</p>
<p><a href="http://sourceforge.net/projects/cntlm/" rel="nofollow">http://sourceforge.net/projects/cntlm/</a></p>
<p>And then after simply configuring the cntlm.ini, I use the following command instead:</p>
<pre><code>emulator-x86.exe -http-proxy 127.0.0.1:3128 -avd MyAVD
</code></pre>
<p>and it works :)</p>
| 4,804
|
<p>I want to put in a date and serial number that would be difficult to erase or change. Is it better to print in the number or engrave it in with a laser engraver.</p>
<p>Material will be anti-bacterial PLA.</p>
<p>It will be on free masks donated to schools, I want to make sure we can identify them when they show up at the market or in shops.</p>
|
<p>For this specific application, it may be better to think in terms of a <strong>Lot Number</strong> for each batch instead of individual serial numbers. This will still let you trace back an item for where it was originally allocated, and greatly simplify your processing.</p>
<p>Under this plan, you create the STL file for the basic part and before each printing batch open the base file in even a simple tool like MS 3D Builder or TinkerCAD to emboss your number and the date, re-slice, and print.</p>
<p>I actually recommend a <strong>deboss</strong> here, where the text is recessed into the piece instead of extended outward. In this way it will be more difficult to file away without damaging the part, and again, even the basic modelling tools can quickly customize an STL file in this way.</p>
<p>If you really need individual serial numbers, design the part with a basic recessed rectangular cutout and print these in bulk. Then print individual plates the exact size (very slightly smaller) than the cutout with the serial number and date debossed, and superglue the plates down.</p>
<p>Finally, be aware there's a limit to how small the text can be, based on the size of the nozzle and the capabilities of the printer, and you may find it difficult to print very small text.</p>
|
<p>Have you considered using a barcode rather than text. It would be easier to print clearly as there are no curves, and would be machine readable.</p>
| 2,058
|
<p>I have two programs. One is in C# and another one in Java.
Those programs will, most probably, always run on the same machine.</p>
<p>What would be the best way to let them talk to each other?</p>
<p>So, to clarify the problem:</p>
<p>This is a personal project (so professional/costly libraries are a no go).
The message volume is low, there will be about 1 to 2 messages per second.
The messages are small, a few primitive types should do the trick.
I would like to keep the complexity low.
The java application is deployed as a single jar as a plugin for another application. So the less external libraries I have to merge, the better.
I have total control over the C# application.
As said earlier, both application have to run on the same computer.
Right now, my solution would be to use sockets with some sort of csv-like format.</p>
|
<p>I am author of <a href="http://jni4net.sf.net/" rel="noreferrer">jni4net</a>, open source interprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.</p>
|
<p>If they are separate programs and running as independent applications,you may use sockets. I know it's bit complex to define communication protocol but it'll be quite straight-forward.</p>
<p>However if you have just two separate programs but want to run them as single application, then I guess IKVM is a better approach as suggested by marxidad.</p>
| 3,739
|
<p>I am running MAMP locally on my laptop, and I like to test as much as I can locally. Unfortunately, since I work on e-commerce stuff (PHP), I normally force ssl in most of the checkout forms and it just fails on my laptop. Is there any easy configuration that I might be missing to allow "https" to run under MAMP? Please note, I know that I <strong>could</strong> configure Apache by hand, re-compile PHP, etc. but I'm just wondering if there's an easier way for a lazy programmer.</p>
<p>Thanks</p>
|
<p>First, make a duplicate of /Applications/MAMP.</p>
<p>Open /Applications/MAMP/conf/apache/httpd.conf<br>
Below the line<br>
<code># LoadModule foo_module modules/mod_foo.so</code><br>
you add<br>
<code>LoadModule ssl_module modules/mod_ssl.so</code><br>
Remove all lines <code><IfDefine SSL></code> as well as <code></IfDefine SSL></code>.<br></p>
<p>Open /Applications/MAMP/conf/apache/ssl.conf<br>
Remove all lines <code><IfDefine SSL></code> as well as <code></IfDefine SSL></code>.<br>
Find the line defining <code>SSLCertificateFile</code> and <code>SSLCertificateKeyFile</code>, set it to<br>
<code>SSLCertificateFile /Applications/MAMP/conf/apache/ssl/server.crt</code>
<code>SSLCertificateKeyFile /Applications/MAMP/conf/apache/ssl/server.key</code></p>
<p>Create a new folder /Applications/MAMP/conf/apache/ssl<br>
Drop into the terminal an navigate to the new folder<br>
<code>cd /Applications/MAMP/conf/apache/ssl</code><br>
Create a private key, giving a password<br>
<code>openssl genrsa -des3 -out server.key 1024</code><br>
Remove the password<br>
<code>cp server.key server-pw.key</code><br>
<code>openssl rsa -in server-pw.key -out server.key</code><br>
Create a certificate signing request, pressing return for default values<br>
<code>openssl req -new -key server.key -out server.csr</code><br>
Create a certificate<br>
<code>openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt</code></p>
<p>Restart your server. If you encounter any problems check the system log file. The first time you visit <code>https://localhost/</code> you will be asked to accept the certificate.</p>
|
<p>There doesn't seem to be an easier way, <a href="http://www.rocketwerx.com/blog/8-apple/34-getting-ssl-to-work-with-mamp-pro" rel="nofollow noreferrer">unless you're willing to buy MAMP Pro</a>.</p>
<p>As far as I know, the only way to use SSL with MAMP is to <a href="http://www.macosxhints.com/article.php?story=20041129143420344" rel="nofollow noreferrer">configure mod_ssl for Apache</a>. mod_ssl is bundled with MAMP, and I found configuration to be pretty straightforward. Note that you'll probably have to start Apache from the command line to use it:</p>
<pre><code>/Applications/MAMP/bin/apache2/bin$ ./apachectl stop
/Applications/MAMP/bin/apache2/bin$ sudo ./apachectl startssl
</code></pre>
| 6,251
|
<p>What is the difference between <a href="https://3dprinting.stackexchange.com/questions/tagged/post-production" class="post-tag" title="show questions tagged 'post-production'" rel="tag">post-production</a> and <a href="https://3dprinting.stackexchange.com/questions/tagged/post-processing" class="post-tag" title="show questions tagged 'post-processing'" rel="tag">post-processing</a>, or are they synonyms? Should they be merged?<sup>1</sup></p>
<p><a href="https://3dprinting.stackexchange.com/questions/tagged/post-production" class="post-tag" title="show questions tagged 'post-production'" rel="tag">post-production</a> has no description whatsoever.</p>
<p>After looking at <a href="https://meta.stackexchange.com/questions/70710/what-are-tag-synonyms-and-merged-tags-how-do-they-work">What are tag synonyms and merged tags? How do they work?</a>, We can make <a href="https://3dprinting.stackexchange.com/questions/tagged/post-processing" class="post-tag" title="show questions tagged 'post-processing'" rel="tag">post-processing</a> the master and <a href="https://3dprinting.stackexchange.com/questions/tagged/post-production" class="post-tag" title="show questions tagged 'post-production'" rel="tag">post-production</a> the slave <strong>synonym</strong>. This would seem to be a logical relationship given the number of questions tagged respectively. This relationship can be easily removed, if deemed to be incorrect.</p>
<p>If, after some time, everyone is happy with this arrangement, then the two will be <strong>merged</strong>.</p>
<p>Does that sound like a plan and does anyone have any objections..?</p>
<hr>
<p><sup>1</sup> This question was moved from my answer to <a href="https://3dprinting.meta.stackexchange.com/questions/151/naming-convention-for-tags-with-camelcase-or-pre-fix#answer-269">Naming convention for tags with CamelCase or Pre-Fix</a></p>
|
<p>These are <strong>NOT</strong> the same in a manufacturing, which 3D printing is primarily considered a part of.</p>
<p>Post-Processing typically refers to additional steps that must/can be done to produce the nominally desired part. These steps can include deburr, grind, and other additive/subtractive processing on the physical part.</p>
<p>Post-Production typically refers to any steps that typically do not "produce" or alter the dimensions of the product. These steps can include final visual and dimensional inspection, packaging, and sometimes even shipment.</p>
<p>I would not recommend creating a synonym, but merely updating the definition of both terms.</p>
|
<p>Post Processing VS Post Production
<strong><a href="http://fixthephoto.com/blog/retouch-tips/editing-retouching-post-processing-post-production-difference.html" rel="nofollow noreferrer">These terms are absolute synonyms. At the same time they can be interchangeable.</a></strong></p>
<hr>
<p>In digital video, photography, television and film, post-production refers to the tasks that must be completed or executed after the filming or shooting ends. This includes tasks such as the editing of raw footage to cut scenes, insert transition effects, working with voice and sound actors, and dubbing, to name a few of the many pre-production tasks. Post-production is the third and final step in film creation. It follows the pre-production and production phases. (<a href="https://www.webopedia.com/TERM/P/post_production.html" rel="nofollow noreferrer">source</a>)</p>
| 48
|
<p>I have a web application that generates a medium sized XML dataset to be consumed by a third party.<br>
I thought it would be a good idea to provide some form of schema document for the XML that I generate so I pasted the XML into Visual Studio and got it to generate an XSD.<br>
The annoying thing is that my XML doesn't validate to the XSD that was generated!</p>
<p>Is it better to roll your own XSD?<br>
What about different schema docs like DTDs, Relax NG, or Schematron? </p>
<p>The key is that I would like to be able to validate my document using C#. </p>
<p>What are your XML validation strategies?</p>
|
<p>Whether you choose XSD and/or Schematron depends on what you are trying to validate. XSD is probably the most common validation strategy, but there are limits on what it can validate. If all you want to do is ensure that the right type of data is in each field, XSD should work for you. If you need to assert, for example, that the value of the <small> element is less than the value of the <big> element, or even more complex business rules involving multiple fields, you probably want Schematron or a hybrid approach.</p>
|
<p>You will be able to validate your XML with either an XML Schema or a DTD using C#. DTDs are older standards as compared to XML Schemas.</p>
<p>So, I recommend an XML Schema approach.</p>
| 3,732
|
<p>C++ just sucks too much of my time by making me micro-manage my own memory, making me type far too much (hello <code>std::vector<Thingy>::const_iterator it = lotsOfThingys.begin()</code>), and boring me with long compile times. What's the single best alternative for serious real-time graphics programming? Garbage collection is a must (as is the ability to avoid its use when necessary), and speed must be competitive with C++. A reasonable story for accessing C libs is also a must.</p>
<p>(Full disclosure: I have my own answer to this, but I'm interested to see what others have found to be good alternatives to C++ for real-time graphics work.)</p>
<p><strong>Edit:</strong> Thanks everyone for the thoughtful replies. Given that there's really no "right" answer to this question I won't be selecting any particular answer. Besides I'd just pick the language I happen to like as a C++ alternative, which wouldn't really be fair.</p>
|
<p>C# is a nice language that fits your requirements, and it is definitely suited for graphics, thanks to the efforts of Microsoft to provide it with great tools and libraries like Visual Studio and XNA.</p>
|
<p>If your target is a PC, I think you can try C#, or embed <strong>Lua</strong> in your C++ app and run scripts for 'high-level' stuff. However if your target is a console, you <strong>must</strong> manage your own memory!</p>
| 9,853
|
<p>I need to <code>ShellExecute</code> something as another user, currently I start a helper process with <code>CreateProcessAsUser</code> that calls <code>ShellExecute</code>, but that seems like too much of a hack (Wrong parent process etc.) Is there a better way to do this?</p>
<p>@PabloG: ImpersonateLoggedOnUser does not work:</p>
<pre>
HANDLE hTok;
VERIFY(LogonUser("otheruser",0,"password",LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&hTok));
VERIFY(ImpersonateLoggedOnUser(hTok));
ShellExecute(0,0,"calc.exe",0,0,SW_SHOW);
RevertToSelf();
CloseHandle(hTok);
</pre>
<p>will just start calc as the logged in user, not "otheruser"</p>
<p>@1800 INFORMATION: <code>CreateProcess</code>/<code>CreateProcessAsUser</code> is not the same as <code>ShellExecute</code>, with UAC on Vista, <code>CreateProcess</code> is useless when you don't have control over what program the user is executing (<code>CreateProcess</code> will return with a error if you give it a exe file with a manifest marked as requireAdmin)</p>
<p>@Brian R. Bondy: I already know this info (And don't get me wrong, its good stuff), but it is off topic (IMHO) I am asking for a <code>ShellExecuteAsUser</code>, not about starting processes as another user, I already know how to do that.</p>
|
<p>The solution really depends on what your needs are, and can be pretty complex (Thanks fully to Windows Vista). This is probably going to be beyond your need, but this will help others that find this page via search.</p>
<ol>
<li>If you do not need the process to run with a GUI and you do not require elevation</li>
<li>If the user you want to run as is already logged into a session</li>
<li>If you need to run the process with a GUI, and the user may, or may not be logged in</li>
<li>If you need to run the process with elevation</li>
</ol>
<p><strong>Regarding 1:</strong>
In windows Vista there exists something called session 0 isolation. All services run as session 0 and you are not supposed to have a GUI in session 0. The first logged on user is logged into session 1. In previous versions of windows (pre Vista), the first logged on user was also ran fully in session 0. </p>
<p>You can run several different processes with different usernames in the same session. You can find a good document about session 0 isolation <a href="http://www.microsoft.com/whdc/system/vista/services.mspx" rel="noreferrer">here</a>.</p>
<p>Since we're dealing with option 1), you don't need a GUI. Therefore you can start your process in session 0. </p>
<p>You'll want a call sequence something like this:
LogonUser, ExpandEnvironmentStringsForUser, GetLogonSID, LoadUserProfile, CreateEnvironmentBlock, CreateProcessAsUser. </p>
<p>Example code for this can be found via any search engine, or via <a href="http://www.google.com/codesearch" rel="noreferrer">Google code search</a></p>
<p><strong>Regarding 2:</strong> If the user you'd like to run the process as is already logged in, you can simply use: WTSEnumerateSessions, and WTSQuerySessionInformation to get the session ID, and then WTSQueryUserToken to get the user token. From there you can just use the user token in the CreateProcessAsUser Win32 API.</p>
<p>This is a great method because you don't even need to login as the user nor know the user's username/password. I believe this is only possible via a service though running as local system account. </p>
<p>You can get the current session via WTSGetActiveConsoleSessionId.</p>
<p><strong>Regarding 3:</strong>
You would follow the same steps as #1, but in addition you would use the STARTUPINFO's lpDesktop field. Set this to winsta0\Default. You will also need to try to use the OpenDesktop Win32 API and if this fails you can CreateDesktop. Before using the station and desktop handles you should use SetSecurityInfo on each of them with SE_WINDOW_OBJECT, and GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION.</p>
<p>If the user in question later tries to login, he will actually see the running process. </p>
<p><strong>Regarding 4:</strong>
This can be done as well, but it requires you to already be running an elevated process. A service running as local system account does run as elevated. I could also only get it to work by having an authenticode signed process that I wanted to start. The process you want to start also must have a manifest file associated with it with the requestedExecutionLevel level="requireAdministrator"</p>
<p>Other notes:</p>
<ul>
<li>You can set a token's session via SetTokenInformation and TokenSessionId</li>
<li>You cannot change the session ID of an already running process. </li>
<li>This whole process would be drastically more simple if Vista was not in the equation. </li>
</ul>
|
<p>You can wrap the ShellExecute between ImpersonateLoggedOnUser / RevertToSelf</p>
<p>links:
ImpersonateLoggedOnUser: <a href="http://msdn.microsoft.com/en-us/library/aa378612(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa378612(VS.85).aspx</a>
RevertToSelf: <a href="http://msdn.microsoft.com/en-us/library/aa379317.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa379317.aspx</a></p>
<p>sorry, cannot hyperlink URLs with "()"</p>
| 5,368
|
<p>I'm toying with the idea of phasing in an ORM into an application I support. The app is not very structured with no unit tests. So any change will be risky. I'm obviously concerned that I've got a good enough reason to change. The idea is that there will be less boiler plate code for data access and there for greater productivity.</p>
<p>Do this ring true with your experiences?<br>
Is it possible or even a good idea to phase it in?<br>
What are the downsides of an ORM?</p>
|
<p>I would strongly recommend getting a copy of Michael Feather's book <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="nofollow noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code</a> (by "Legacy Code" Feathers means any system that isn't adequately covered by unit tests). It is full of good ideas which should help you with your refactoring and phasing in of best practices.</p>
<p>Sure, you could phase in the introduction of an ORM, initially using it for accessing some subset of your domain model. And yes, I have found that use of an ORM speeds up development time - this is one of the key benefits and I certainly don't miss the days when I used to laboriously hand-craft data access layers.</p>
<p>Downsides of ORM - from experience, there is inevitably a bit of a learning curve in getting to grips with the concepts, configuration and idiosyncracies of the chosen ORM solution.</p>
<p><em>Edit: corrected author's name</em></p>
|
<p>The rule for refactoring is. Do unit tests.</p>
<p>So maybe first you should place some unittests at least for the core/major things.</p>
<p>The ORM should be designed for decreasing boilerplate code. The time/trouble vs. ROI to be enterprisy is up to you to estimate :)</p>
| 4,204
|
<p>I'm pretty new to 3D printing, got my printer about 5 days ago and spent most of my time with it.</p>
<p>First off, it is an Ender 3 Pro with everything stock, haven't made any upgrades except I run it with OctoPrint from a Raspberry Pi Zero but I have determined that's not the source of the problem as it's well within 80 % idle on its CPU.</p>
<p>The issue I'm experiencing is that the extruder starts slipping at some point along the print. It's not the clicky type of slipping that appears to be the common issue but rather it's just spinning and grinding on the filament which is remaining stationary. When this happens the printer continues on about its business as it's unaware that filament is not coming out. I move the Z-axis up, squeeze the extruder lever and try to push on the filament which is not budging, which made me think I had a clogged nozzle. I was surprised as it's a brand new printer but the internet says that nozzles clog up so I disassembled and cleaned it just to find that it happens again on my very next print. I noticed that when I pull or push on the filament by hand while squeezing the extruder lever - relieving pressure from the gear, it is quite hard to do so, even partly impossible as my fingers start to slip, I have to squeeze extremely hard or use pliers. I pulled the filament out using quite a bit of force, then snapped off the piece that was already in the tubing and inserted fresh filament which slid very easily through the white tubing to the hot end and when reaching it by pushing very gently I start to see filament coming out as opposed to pushing really hard and barely anything coming out previously. If I do that and return the Z-axis to its position then resume the print it continues until that happens again.</p>
<p>My bed is leveled as best as I can, I downloaded the bed leveling G-codes that help a lot to achieve good adhesion, my prints look pretty much perfect, smooth lines very pleasing to the look and touch, until what I mentioned above happens.</p>
<p>I don't understand what could be the reason that my filament would just bind up like that and snipping it off and inserting a new piece there's no sign of the issue whatsoever.</p>
<p>Notes for what it's worth:</p>
<ul>
<li>I'm using cheap black PLA 1.75 mm</li>
<li>Hotend temperature 200 °C</li>
<li>Bed temperature 60 °C</li>
<li>Printing speed 50 mm/s</li>
<li>The extruder pulley (white wheel with the bearing) bolt is not tightened to the end as recommended on the internet</li>
<li>The spring bolt on the extruder is not tightened also, as I see there are marks on the filament that went past the extruder wheel, anyway I tried tightening it for the sake of it and it didn't help</li>
<li>My extruder arm is not cracked</li>
<li>The gear (brass wheel) doesn't seem to be damaged</li>
</ul>
|
<blockquote>
<p>I have heard that it is best to use a raft</p>
</blockquote>
<p>Actually, it is not best to use a raft, a raft is an aid that can best be used in special cases, e.g. for filaments that shrink reasonably (PLA is not such a filament).</p>
<p>A raft always caused a rough bottom of your print and is frequently difficult to remove. A raft is an aid for adhesion if your print object geometry or choice of filament requires you to use it, but as far as printing PLA, a raft is generally not needed. You need to spend some time to level the bed properly and dial in the best nozzle to bed distance (the thickness of a sheet of plain printing paper like A4 or US Letter will work fine).</p>
<p>There are usually options available in slicer software to control the distance between the raft and the first layer of the print object. It is also reported that inserting a wait time to solidify/cool the raft is beneficial for creating less strong bonds between the raft and the print object.</p>
|
<p>Rafts fuse with models because the filament gets overheated. To avoid this, keep the temperature in the room between between 23 and 28 °C. Malfunctioning extruder fans, a heater & thermocouple, extruder printed circuit board (PCB), extruder cable, and motherboard can be also to blame.</p>
| 2,163
|
<p>I'm working on a boot loader on an x86 machine.</p>
<p>When the BIOS copies the contents of the MBR to 0x7c00 and jumps to that address, is there a standard meaning to the contents of the registers? Do the registers have standard values?</p>
<p>I know that the segment registers are typically set to 0, but will sometimes be 0x7c0. What about the other hardware registers?</p>
|
<blockquote>
<p>This early execution environment is highly implementation defined, meaning the implementation of your particular BIOS. Never make any assumptions on the contents of registers. They might be initialized to 0, but they might contain a random value just as well. </p>
</blockquote>
<p>from the <a href="http://wiki.osdev.org/Boot_sequence" rel="nofollow noreferrer">OS dev Wiki</a>, which is where I get information when I'm playing with my toy OS's</p>
|
<p>Best option would be to assume nothing. If they have meaning, you will find that from the other side when you need the information they provide.</p>
| 4,071
|
<p>I am creating a Windows Service in C# that processes messages from a queue. I want to give ops the flexibility of partitioning the service in production according to properties of the message. For example, they should be able to say that one instance processes web orders from Customer A, another batch orders from Customer A, a third web or batch orders from Customer B, and so on.</p>
<p>My current solution is to assign separate queues to each customer\source combination. The process that puts orders into the queues has to make the right decision. My Windows Service can be configured to pull messages from one or more queues. It's messy, but it works.</p>
|
<p>No, but you can <strong>PEEK</strong> into the queue and decide if you really want to consume the message.</p>
|
<p>Use <em>GetMessageEnumerator2()</em> like this:</p>
<pre><code>MessageEnumerator en = q.GetMessageEnumerator2();
while (en.MoveNext())
{
if (en.Current.Label == label)
{
string body = ((XmlDocument)en.Current.Body).OuterXml;
en.RemoveCurrent();
return body;
}
}
</code></pre>
| 8,970
|
<p>Some 4 years back, I followed this <a href="http://msdn.microsoft.com/en-us/library/ms973825.aspx" rel="noreferrer">MSDN article</a> for DateTime usage best practices for building a .Net client on .Net 1.1 and ASMX web services (with SQL 2000 server as the backend). I still remember the serialization issues I had with DateTime and the testing effort it took for servers in different time zones.</p>
<p>My questions is this: Is there a similar best practices document for some of the new technologies like WCF and SQL server 2008, especially with the addition of new datetime types for storing time zone aware info.</p>
<p>This is the environment:</p>
<ol>
<li>SQL server 2008 on Pacific Time.</li>
<li>Web Services layer on a different time zone.</li>
<li>Clients could be using .Net 2.0 or .Net 3.5 on different time zones. If it makes it easy, we can force everyone to upgrade to .Net 3.5. :)</li>
</ol>
<p>Any good suggestions/best practices for the data types to be used in each layer?</p>
|
<p>I think the best way of doing this is to always pass the object as UTC, and convert to local time on the clients. By doing so, there is a common reference point for all clients.</p>
<p>To convert to UTC, call ToUniversalTime on the DateTime object. Then, on the clients, call ToLocalTime to get it in their current time zone.</p>
|
<p>For cases where the datetime object should simply stay the same use JsonConvert:</p>
<pre><code>DateTime now = DateTime.Now;
string json = JsonConvert.SerializeObject(now);
DateTime nowJson = JsonConvert.DeserializeObject<DateTime>(json);
</code></pre>
| 9,093
|
<p>Embedded custom-tag in dynamic content (nested tag) not rendering.</p>
<p>I have a page that pulls dynamic content from a javabean and passes the list of objects to a custom tag for processing into html. Within each object is a bunch of html to be output that contains a second custom tag that I would like to also be rendered. The problem is that the tag invocation is rendered as plaintext.</p>
<p>An example might serve me better.</p>
<p>1 Pull information from a database and return it to the page via a javabean. Send this info to a custom tag for outputting.</p>
<pre><code><jsp:useBean id="ImportantNoticeBean" scope="page" class="com.mysite.beans.ImportantNoticeProcessBean"/> <%-- Declare the bean --%>
<c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}"> <%-- Get the info --%>
<mysite:notice importantNotice="${noticeBean}"/> <%-- give it to the tag for processing --%>
</c:forEach>
</code></pre>
<p>this tag should output a box div like so</p>
<pre><code>*SNIP* class for custom tag def and method setup etc
out.println("<div class=\"importantNotice\">");
out.println(" " + importantNotice.getMessage());
out.println(" <div class=\"importantnoticedates\">Posted: " + importantNotice.getDateFrom() + " End: " + importantNotice.getDateTo()</div>");
out.println(" <div class=\"noticeAuthor\">- " + importantNotice.getAuthor() + "</div>");
out.println("</div>");
*SNIP*
</code></pre>
<p>This renders fine and as expected</p>
<pre><code><div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it.</p>
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
</code></pre>
<p>2 If, in the above example, for instance, I were to have a custom tag in the importantNotice.getMessage() String:</p>
<pre><code>*SNIP* "This is a very important message. Everyone should pay attenton to it. <mysite:quote author="Some Guy">Quote this</mysite:quote>" *SNIP*
</code></pre>
<p>The important notice renders fine but the quote tag will not be processed and simply inserted into the string and put as plain text/html tag.</p>
<pre><code><div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it. <mysite:quote author="Some Guy">Quote this</mysite:quote></p>
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
</code></pre>
<p>Rather than </p>
<pre><code><div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it. <div class="quote">Quote this <span class="authorofquote">Some Guy</span></div></p> // or wahtever I choose as the output
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
</code></pre>
<p>I know this has to do with processors and pre-processors but I am not to sure about how to make this work.</p>
|
<p>Just using </p>
<pre><code><bodycontent>JSP</bodycontent>
</code></pre>
<p>is not enough. You should do soimething like </p>
<pre><code>JspFragment body = getJspBody();
StringWriter stringWriter = new StringWriter();
StringBuffer buff = stringWriter.getBuffer();
buff.append("<h1>");
body.invoke(stringWriter);
buff.append("</h1>");
out.println(stringWriter);
</code></pre>
<p>to get inner tags rendered (example is for SimpleTag doTag method). </p>
<p>However, in the question's code I see that inner tag is comming from a string which is not rendered as a part of JSP, but just some random string. I do not think you can force JSP translator to parse it.</p>
<p>You can use regexp in your case or try to redesign your code in a way to have a jsp like this:</p>
<pre><code><jsp:useBean id="ImportantNoticeBean" scope="page class="com.mysite.beans.ImportantNoticeProcessBean"/>
<c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}">
<mysite:notice importantNotice="${noticeBean}">
<mysite:quote author="Some Guy">Quote this</mysite:quote>
<mysite:messagebody author="Some Guy" />
</mysite:notice>
</c:forEach>
</code></pre>
<p>I whould go with regexp.</p>
|
<p>I would be inclined to change the "architecture of your tagging" in that the data you wish to achieve should not be by tag on the inside of the class as it is "markup" designed for a page(<em>though in obscurity</em> it is possible to get the evaluating program thread of the JSP Servlet engine).</p>
<p>What you would probably find better and more within standard procedure would be using "cooperating tags" with <code>BodyTagSupport</code> class extension and return <code>EVAL_BODY_BUFFERED</code> in doStartTag() method to repeat process the body <strong>and/or</strong> object sharing such as storing retrived data in the application hierarchy of the session or on the session for the user.</p>
<p>See <a href="http://download.oracle.com/javaee/1.4/tutorial/doc/JSPAdvanced8.html" rel="nofollow">oracle j2ee custom tags tutorial</a> for more information.</p>
| 7,177
|
<p>As an extension from <a href="https://3dprinting.stackexchange.com/questions/264/when-to-use-1-75mm-vs-3mm-filament">this</a> question, is there any reason that you would not be able to use 1.75 mm filament in a printer that takes 3mm filament? I know you would have to change the filament size in the slicing of prints but would there be any other problems?</p>
<p>Also, would using 1.75 mm filament be possible if the nozzle diameter was greater than 1.75 mm but less than 3 mm?</p>
|
<p>Typically an extruder and hot end are designed for one or the other, and cannot support the other without mechanical changes.</p>
<p>The extruder may not be able to grip a smaller diameter filament with enough force to assure even feeding and retraction.</p>
<p>The hot end, however, is much more complex. The filament has to be pushed with force into the melting zone, which means the filament has to slide along an area inside the hot end where the filament is plastic but still put pressure on the filament ahead of it.</p>
<p>When you put filament into a hot end, the filament softens before the melt zone, but since the walls of the hot end are just barely larger than the filament it has no choice but to continue pressing down on the liquid filament below.</p>
<p>With a narrower diameter filament, though, the filament can heat, soften, then travel <em>backwards</em> along the sides of the hot end and cool in place, jamming the hot end, or at least preventing an even continuous flow of plastic.</p>
<p>Some hot ends will accept a small Teflon tube that takes this space up and allows you to do this with fewer issues, and if you like to tinker you can experiment with this, but be prepared to learn a lot and fail a lot as you find out the hard lessons of hot end design.</p>
<p>Generally you should upgrade your entire extruder and hot end setup to the size you want to use.</p>
|
<ol>
<li><p>It may work for a short time but you're going to fill the melt chamber quickly and possibly overflow to a point where the filament isn't constrained causing a messy jam. All the molten plastic will likely flow backwards to a point where the diameter isn't 3mm any longer (probably next to your drive gear) but depending on the length it may just flow up, cool down and jam the extruder.</p></li>
<li><p>No, the filament would just pass through unheated and not do anything.</p></li>
</ol>
| 145
|
<p>What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework?</p>
|
<p>I've had good success using <a href="https://github.com/mockito/mockito" rel="noreferrer">Mockito</a>.</p>
<p>When I tried learning about JMock and EasyMock, I found the learning curve to be a bit steep (though maybe that's just me).</p>
<p>I like Mockito because of its simple and clean syntax that I was able to grasp pretty quickly. The minimal syntax is designed to support the common cases very well, although the few times I needed to do something more complicated I found what I wanted was supported and easy to grasp.</p>
<p>Here's an (abridged) example from the Mockito homepage:</p>
<pre><code>import static org.mockito.Mockito.*;
List mockedList = mock(List.class);
mockedList.clear();
verify(mockedList).clear();
</code></pre>
<p>It doesn't get much simpler than that.</p>
<p>The only major downside I can think of is that it won't mock static methods.</p>
|
<p>I started using mocks through JMock, but eventually transitioned to use EasyMock. EasyMock was just that, --easier-- and provided a syntax that felt more natural. I haven't switched since.</p>
| 4,273
|
<p>I have always used <code>||</code> (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: <code>|</code>. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable?</p>
|
<p>Just like the <code>&</code> and <code>&&</code> operator, the double Operator is a "short-circuit" operator.</p>
<p>For example:</p>
<pre><code>if(condition1 || condition2 || condition3)
</code></pre>
<p>If condition1 is true, condition 2 and 3 will NOT be checked.</p>
<pre><code>if(condition1 | condition2 | condition3)
</code></pre>
<p>This will check conditions 2 and 3, even if 1 is already true. As your conditions can be quite expensive functions, you can get a good performance boost by using them.</p>
<p>There is one big caveat, NullReferences or similar problems. For example:</p>
<pre><code>if(class != null && class.someVar < 20)
</code></pre>
<p>If class is null, the if-statement will stop after <code>class != null</code> is false. If you only use &, it will try to check <code>class.someVar</code> and you get a nice <code>NullReferenceException</code>. With the Or-Operator that may not be that much of a trap as it's unlikely that you trigger something bad, but it's something to keep in mind.</p>
<p>No one ever uses the single <code>&</code> or <code>|</code> operators though, unless you have a design where each condition is a function that HAS to be executed. Sounds like a design smell, but sometimes (rarely) it's a clean way to do stuff. The <code>&</code> operator does "run these 3 functions, and if one of them returns false, execute the else block", while the <code>|</code> does "only run the else block if none return false" - can be useful, but as said, often it's a design smell.</p>
<p>There is a Second use of the <code>|</code> and <code>&</code> operator though: <a href="http://www.c-sharpcorner.com/UploadFile/chandrahundigam/BitWiserOpsInCS11082005050940AM/BitWiserOpsInCS.aspx" rel="noreferrer">Bitwise Operations</a>.</p>
|
<p>The | operator performs a bitwise OR of its two operands (meaning both sides must evaluate to false for it to return false) while the || operator will only evaluate the second operator if it needs to.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/kxszd0kx(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/kxszd0kx(VS.71).aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/6373h346(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/6373h346(VS.71).aspx</a></p>
| 5,574
|
<p>Example: You have a shortcut <code>s</code> to <code>SomeProgram</code> in the current directory.</p>
<p>In <code>cmd.exe</code>, you can type <code>s</code> and it will launch the program.</p>
<p>In PowerShell, typing <code>s</code> gives:</p>
<blockquote>
<p><code>The term 's' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.</code></p>
</blockquote>
<p>If you type <code>s.lnk</code> or <code>SomeProgram</code>, it runs the program just fine.</p>
<p>How can I configure PowerShell to execute shortcuts just like programs?</p>
|
<p>On my Vista system typing S won't launch a lnk file unless I have the environment variable PATHEXT set with .lnk in the list. When I do. S will work in cmd.exe and I have to do .\S in powershell.</p>
|
<p>You can always use tab completion to type "s[TAB]" and press ENTER and that will execute it.</p>
| 4,257
|
<p>When 3D-printing on an 20*20cm, I've heard that the quality of the printings get worse if I fill out the board... Is it true? Should I keep it to small amounts at the time or doesn't it matter?</p>
|
<p>No, that's not (entirely) true. There might be some loss of quality if you print multiple objects at once, because when the printhead "hops" from one object to another it might leave a mark or ooze out some material. Also, a large number of retractions in a short period of time might lead to inconsistent extrusion.</p>
<p>However, none of this is particular to "filling out the board" as it happens even if you print only two objects at a time (or even when you're printing only one object with multiple islands).</p>
<p>It all depends on your printer (and in particular how well it handles retractions). If you're willing to do a small amount of cleanup afterwards (to remove the strings and blobs) then printing multiple objects at a time is completely viable.</p>
|
<p>Just to add to the other answers already here, I've also had problems with layer adhesion when filling up the print bed on an extrusion printer. The longer the print head spends working on details around a single layer, the more chance the layer has to cool off before the next layer gets started. I've started to suspect that layers that take longer to print end up with less adhesion to the next layer.</p>
| 424
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.