instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I am new to C# and am doing some work in an existing application. I have a DirectX viewport that has components in it that I want to be able to position using arrow keys.</p>
<p>Currently I am overriding ProcessCmdKey and catching arrow input and send an OnKeyPress event. This works, but I want to be able to use modifiers(<strong><kbd>ALT</kbd>+<kbd>CTRL</kbd>+<kbd>SHIFT</kbd></strong>). As soon as I am holding a modifier and press an arrow no events are triggered that I am listening to.</p>
<p>Does anyone have any ideas or suggestions on where I should go with this?</p>
|
<p>Within your overridden ProcessCmdKey how are you determining which key has been pressed?</p>
<p>The value of keyData (the second parameter) will change dependant on the key pressed and any modifier keys, so, for example, pressing the left arrow will return code 37, shift-left will return 65573, ctrl-left 131109 and alt-left 262181.</p>
<p>You can extract the modifiers and the key pressed by ANDing with appropriate enum values:</p>
<pre><code>protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
bool shiftPressed = (keyData & Keys.Shift) != 0;
Keys unmodifiedKey = (keyData & Keys.KeyCode);
// rest of code goes here
}
</code></pre>
|
<p>I upvoted <a href="https://stackoverflow.com/questions/4850/c-and-arrow-keys/5026#5026">Tokabi's answer</a>, but for comparing keys there is some additional advice on <a href="https://stackoverflow.com/questions/1369312/c-keys-enumeration-confused-keys-alt-or-keys-rbutton-keys-shiftkey-keys-alt/2033796#2033796">StackOverflow.com here</a>. Here are some functions which I used to help simplify everything.</p>
<pre><code> public Keys UnmodifiedKey(Keys key)
{
return key & Keys.KeyCode;
}
public bool KeyPressed(Keys key, Keys test)
{
return UnmodifiedKey(key) == test;
}
public bool ModifierKeyPressed(Keys key, Keys test)
{
return (key & test) == test;
}
public bool ControlPressed(Keys key)
{
return ModifierKeyPressed(key, Keys.Control);
}
public bool AltPressed(Keys key)
{
return ModifierKeyPressed(key, Keys.Alt);
}
public bool ShiftPressed(Keys key)
{
return ModifierKeyPressed(key, Keys.Shift);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (KeyPressed(keyData, Keys.Left) && AltPressed(keyData))
{
int n = code.Text.IndexOfPrev('<', code.SelectionStart);
if (n < 0) return false;
if (ShiftPressed(keyData))
{
code.ExpandSelectionLeftTo(n);
}
else
{
code.SelectionStart = n;
code.SelectionLength = 0;
}
return true;
}
else if (KeyPressed(keyData, Keys.Right) && AltPressed(keyData))
{
if (ShiftPressed(keyData))
{
int n = code.Text.IndexOf('>', code.SelectionEnd() + 1);
if (n < 0) return false;
code.ExpandSelectionRightTo(n + 1);
}
else
{
int n = code.Text.IndexOf('<', code.SelectionStart + 1);
if (n < 0) return false;
code.SelectionStart = n;
code.SelectionLength = 0;
}
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
</code></pre>
| 2,683
|
<p>I quite like the drag and drop pluggable programming blocks in scratch ( <a href="http://scratch.mit.edu/" rel="nofollow noreferrer">http://scratch.mit.edu/</a> )</p>
<p>I'd like to be able to get users to create their own mini scripts using the same kind of technique...</p>
<p>just wondering if anyone knows of anything similar I could utilise in .NET? ideally in WPF.</p>
|
<p>Maybe <a href="http://msdn.microsoft.com/en-us/netframework/aa663328.aspx" rel="nofollow noreferrer">Windows Workflow Foundation</a> is something for you. You can <a href="http://msdn.microsoft.com/nl-be/library/cc835242(en-us).aspx" rel="nofollow noreferrer">host the designer</a> in your own application. So end-user can change the logic.</p>
|
<p>It's not .NET, but have you looked at Alice? (<a href="http://www.alice.org/" rel="nofollow noreferrer">http://www.alice.org/</a>)</p>
| 9,441
|
<p>Is there some rare language construct I haven't encountered (like the few I've learned recently, some on Stack Overflow) in C# to get a value representing the current iteration of a foreach loop?</p>
<p>For instance, I currently do something like this depending on the circumstances:</p>
<pre><code>int i = 0;
foreach (Object o in collection)
{
// ...
i++;
}
</code></pre>
|
<p>The <code>foreach</code> is for iterating over collections that implement <a href="http://msdn.microsoft.com/en-us/library/9eekhta0%28v=vs.110%29.aspx" rel="noreferrer"><code>IEnumerable</code></a>. It does this by calling <a href="http://msdn.microsoft.com/en-us/library/s793z9y2(v=vs.110).aspx" rel="noreferrer"><code>GetEnumerator</code></a> on the collection, which will return an <a href="http://msdn.microsoft.com/en-us/library/78dfe2yb(v=vs.110).aspx" rel="noreferrer"><code>Enumerator</code></a>.</p>
<p>This Enumerator has a method and a property:</p>
<ul>
<li><code>MoveNext()</code></li>
<li><code>Current</code></li>
</ul>
<p><code>Current</code> returns the object that Enumerator is currently on, <code>MoveNext</code> updates <code>Current</code> to the next object.</p>
<p>The concept of an index is foreign to the concept of enumeration, and cannot be done.</p>
<p>Because of that, most collections are able to be traversed using an indexer and the for loop construct.</p>
<p>I greatly prefer using a for loop in this situation compared to tracking the index with a local variable.</p>
|
<p>i want to discuss this question more theoretically (since it has already enough practical answers)</p>
<p>.net has a very nice abstraction model for groups of data (a.k.a. collections) </p>
<ul>
<li>At the very top, and the most abstract, you have an <code>IEnumerable</code> it's just a group of data that you can enumerate. It doesn't matter HOW you enumerate, it's just that you can enumerate some data. And that enumeration is done by a completely different object, an <code>IEnumerator</code></li>
</ul>
<p>these interfaces are defined is as follows:</p>
<pre><code>//
// Summary:
// Exposes an enumerator, which supports a simple iteration over a non-generic collection.
public interface IEnumerable
{
//
// Summary:
// Returns an enumerator that iterates through a collection.
//
// Returns:
// An System.Collections.IEnumerator object that can be used to iterate through
// the collection.
IEnumerator GetEnumerator();
}
//
// Summary:
// Supports a simple iteration over a non-generic collection.
public interface IEnumerator
{
//
// Summary:
// Gets the element in the collection at the current position of the enumerator.
//
// Returns:
// The element in the collection at the current position of the enumerator.
object Current { get; }
//
// Summary:
// Advances the enumerator to the next element of the collection.
//
// Returns:
// true if the enumerator was successfully advanced to the next element; false if
// the enumerator has passed the end of the collection.
//
// Exceptions:
// T:System.InvalidOperationException:
// The collection was modified after the enumerator was created.
bool MoveNext();
//
// Summary:
// Sets the enumerator to its initial position, which is before the first element
// in the collection.
//
// Exceptions:
// T:System.InvalidOperationException:
// The collection was modified after the enumerator was created.
void Reset();
}
</code></pre>
<ul>
<li><p>as you might have noticed, the <code>IEnumerator</code> interface doesn't "know" what an index is, it just knows what element it's currently pointing to, and how to move to the next one.</p></li>
<li><p>now here is the trick: <code>foreach</code> considers every input collection an <code>IEnumerable</code>, even if it is a more concrete implementation like an <code>IList<T></code> (which inherits from <code>IEnumerable</code>), it will only see the abstract interface <code>IEnumerable</code>.</p></li>
<li><p>what <code>foreach</code> is actually doing, is calling <code>GetEnumerator</code> on the collection, and calling <code>MoveNext</code> until it returns false.</p></li>
<li><p>so here is the problem, you want to define a concrete concept "Indices" on an abstract concept "Enumerables", the built in <code>foreach</code> construct doesn't give you that option, so your only way is to define it yourself, either by what you are doing originally (creating a counter manually) or just use an implementation of <code>IEnumerator</code> that recognizes indices AND implement a <code>foreach</code> construct that recognizes that custom implementation.</p></li>
</ul>
<p>personally i would create an extension method like this</p>
<pre><code>public static class Ext
{
public static void FE<T>(this IEnumerable<T> l, Action<int, T> act)
{
int counter = 0;
foreach (var item in l)
{
act(counter, item);
counter++;
}
}
}
</code></pre>
<p>and use it like this</p>
<pre><code>var x = new List<string>() { "hello", "world" };
x.FE((ind, ele) =>
{
Console.WriteLine($"{ind}: {ele}");
});
</code></pre>
<p>this also avoids any unnecessary allocations seen in other answers.</p>
| 6,466
|
<p>After successfully building dblink on solaris 10 using Sun C 5.9
SunOS_sparc 2007/05/03 and gmake.</p>
<p>I ran gmake installcheck and got the following output:</p>
<pre><code>========== running regression test queries ==========
test dblink ... FAILED
======================
1 of 1 tests failed.
</code></pre>
<p>The differences that caused some tests to fail can be viewed in the
file "./regression.diffs". A copy of the test summary that you see
above is saved in the file "./regression.out".</p>
<p>First error in regression.diffs file:</p>
<blockquote>
<p>psql:dblink.sql:11: ERROR: could not load library "/apps/postgresql/
lib/dblink.so": ld.so.1: postgre
s: fatal: relocation error: file /apps/postgresql/lib/dblink.so:
symbol PG_GETARG_TEXT_PP: referenced symbol not found</p>
</blockquote>
<p>I am running postgreSQL version 8.2.4 with the latest dblink source.</p>
<p>Has anyone got any idea what I need to do to solve this problem.
Thanks. </p>
|
<p>To solve this issue I tried using the 8.2 dblink sources, instead of the latest version.</p>
<p>You also need to make sure you use gnu make not the sun make.</p>
|
<p>Does the file it is looking for actually exist? Is it in that location?</p>
<p>It may be one of a few things I can think of:
1) The thing did not compile, and therefore does not exist.
2) It exists, but somewhere else, and the environment variable that tells it where to find it is set wrong.
3) The permissions are such that the ID that the postmaster is running as cannot traverse to that directory.</p>
<p>To check if it is somewhere else:</p>
<pre><code>find / -type f|grep dblink.so
</code></pre>
<p>To check the permissions:</p>
<pre><code>su -
su - postgres
less /apps/postgresql/ lib/dblink.so
</code></pre>
| 9,539
|
<p>We are custom building a Cartesian 3D printer to be used in a production 3D printing environment, with the following requirements:</p>
<ul>
<li>Intended Z resolution 0.13mm;</li>
<li>Dual extruders (primary + support material);</li>
<li>Four spools (two per material with y connector, perhaps add auto switch-over functionality later);</li>
<li>Camera;</li>
<li>Onboard 11" touchscreen for control & interaction, run by a Raspberry Pi 3;</li>
<li>Custom board based on ATMega2560 to control the printer; </li>
<li>Printer should gracefully handle conditions like "out of material", etc.</li>
</ul>
<p>Question: How to select firmware? </p>
<p>Are there notable differences between the primary firmware options (Marlin/Repetier) for this setup? From the google code groups, I understand the Repetier has a much cleaner code base, and apparently gives smoother physical performance. Yet, from what I can gather, 95% of the community uses Marlin - is that correct?</p>
<p>Given that this printer will have the Pi3 to control "higher functions", is it worth considering a compact firmware like Teacup?</p>
<p>Edit 12/April/2017:</p>
<p>For others looking: After much review, Klipper was selected as the most forward firmware - all kinematic calculations are done on the host computer, instead of on the microprocessor, resulting is significantly faster/smoother stepper movement.</p>
|
<p>Your choice of firmware depends on a lot of factors, but to name a few important ones: features, your driver board (RAMPS vs Sanguinololu vs Gen..etc), and G-code support.</p>
<p>Smooth/quiet operation is dependent on the motors and the driver chip's micro-stepping capabilities. The way the firmware interfaces with the driver chip plays a very minor factor in that.</p>
<p>Check this page for a list of firmware, their capabilities and compatible electronics (driver board):</p>
<p><a href="http://www.reprap.org/wiki/List_of_Firmware" rel="nofollow noreferrer">http://www.reprap.org/wiki/List_of_Firmware</a></p>
<p>Would be useful to check G-code support of various firmwares also:</p>
<p><a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">http://reprap.org/wiki/G-code</a></p>
<p>Also, as a note, a lot of the community uses Marlin, but for a lot of the commercial printers, the code has been modified slightly to fit their needs. </p>
<p>There is no perfect answer to this. Check the links and compare against your needs. Marlin is the safest bet since it has the most support, though you may need to modify or reconfigure it slightly for your custom board.</p>
|
<blockquote>
<p>Given that this printer will have the Pi3 to control "higher functions", is it worth considering a compact firmware like Teacup?</p>
</blockquote>
<p>A few days ago I came across <a href="https://github.com/KevinOConnor/klipper" rel="noreferrer">klipper</a>.</p>
<p>It seems to do exactly that functionality split you mention</p>
| 430
|
<p>I have a fairly small MySQL database (a Textpattern install) on a server that I do not have SSH access to (I have FTP access only). I need to regularly download the live database to my local dev server on demand; i.e., I would like to either run a script and/or have a cron job running. What are some good ways of doing this?</p>
<p>Some points to note:</p>
<ul>
<li>Live server is running Linux, Apache 2.2, PHP 5.2 and MySQL 4.1</li>
<li>Local server is running the same (so using PHP is an option), but the OS is Windows</li>
<li>Local server has Ruby on it (so using Ruby is a valid option)</li>
<li>The live MySQL db <em>can</em> accept remote connections from different IPs</li>
<li>I cannot enable replication on the remote server</li>
</ul>
<p><strong><em>Update:</em></strong> I've accepted BlaM's answer; it is beautifully simple. Can't believe I didn't think of that. There was one problem, though: I wanted to automate the process, but the proposed solution prompts the user for a password. Here is a slightly modified version of the mysqldump command that passes in the password:</p>
<p><code>mysqldump -u USER --password=MYPASSWORD DATABASE_TO_DUMP -h HOST > backup.sql</code></p>
|
<p>Since you can access your database remotely, you can use mysqldump from your windows machine to fetch the remote database. From commandline:</p>
<pre><code>cd "into mysql directory"
mysqldump -u USERNAME -p -h YOUR_HOST_IP DATABASE_TO_MIRROR >c:\backup\database.sql
</code></pre>
<p>The program will ask you for the database password and then generate a file c:\backup\database.sql that you can run on your windows machine to insert the data.</p>
<p>With a small database that should be fairly fast.</p>
|
<p>I would create a (Ruby) script to do a <code>SELECT * FROM ...</code> on all the databases on the server and then do a <code>DROP DATABASE ...</code> followed by a series of new <code>INSERT</code>s on the local copy. You can do a <code>SHOW DATABASES</code> query to list the databases dynamically. Now, this assumes that the table structure doesn't change, but if you want to support table changes also you could add a <code>SHOW CREATE TABLE ...</code> query and a corresponding <code>CREATE TABLE</code> statement for each table in each database. To get a list of all the tables in a database you do a <code>SHOW TABLES</code> query.</p>
<p>Once you have the script you can set it up as a scheduled job to run as often as you need.</p>
| 6,062
|
<p>As a programmer I have no idea how one would go about programming menus for a DVD, I have heard that this is possible, and even seen basic games using DVD menus - although it may very well be a closed-system. Is it even possible and if so, what language, compilers etc exist for this?</p>
|
<p>There are a couple of open source projects that can create DVDs plus menus. I recently used <a href="https://web.archive.org/web/20201109023628/http://dvd-slideshow.sourceforge.net/wiki/Main_Page" rel="nofollow noreferrer">dvd-slideshow</a> to create a simple dvd with menus etc. Another one is <a href="http://www.dvdstyler.de/" rel="nofollow noreferrer">DVD Styler</a>. All of these programs are basically a front-end for various command-line tools for encoding, menu creation etc. Since these are open source projects you can have a look at the source and check out how they accomplish this.</p>
|
<p>Looks like <a href="http://dvdauthor.sourceforge.net/" rel="nofollow">http://dvdauthor.sourceforge.net/</a> is able to help here since you can use command line interface and feed xml files. </p>
<p>You may need to write a framework which can generate xml files (and other content) from your game authoring tool.</p>
| 8,930
|
<p>I own a spool of PETG and I have been having major print quality issues: layer offsets, chunks of 3d print strewn across the buildplate and other things. I traced these effects to a single culprit: rough layers. I don't know how to fix this. I haven't had this issue at all with all of my other PETG filament colors. And the buildplate height is just where it needs to be, so why is this happening?</p>
<h3>Print settings</h3>
<ul>
<li>Layer height: 0.23 mm</li>
<li>Extruder: 235 °C</li>
<li>Bed: 80 °C</li>
<li>Retraction length: 6 mm</li>
<li>Retraction extra restart length: 0.3 mm</li>
<li>Z-Hop height: 0.25 mm</li>
<li>Base print speed: 45 mm/s</li>
<li>Extrusion ratio: 106%</li>
</ul>
|
<h2>Make sure to set the scale properly for your use case!</h2>
<p>In CAD, you define your measurement space in either Inch or in Millimeter units, and that is your grid. In blender, the native unit is the meter.</p>
<p>This can be easily converted in exporting (remember to set it to scale!), but it is best to just set the measurement scale to actually match what you design: if you want to design a 5 mm hole, set your scale to Millimeters and make sure you export in millimeters. If you want to design in meters (maybe you design a building), then work in meters, and set your export scale in the end so that 1 meter actually is represented as 1 meter - or rather as 1000 millimeters.</p>
<p><a href="https://3dprinting.stackexchange.com/a/7561/8884">The STL in the end will not know the difference</a>: it all is defined in scales of <em>unitary units</em>, and it doesn't even know if it was originally designed in meters, inch or angström. The typical slicer expects the unit to be either millimeters or inch, so any scaling of the exported model that does not result in units equivalent to 1 mm or 24.5 mm is bad procedure - converting between these two types is just scaling the model by 2450%.</p>
<h2>Make sure to design closed manifolds made up of triangles!</h2>
<p>When working with blender, it is very easy to leave the item in a shape that contains multiple intersecting, non-manifold surfaces and areas of inverted surfaces. While <em>interecting shells</em> is not a problem (the slicers can handle those by unionizing the item), the intersection usually covers up the non-manifold areas, making them hard to spot.</p>
<p>As a result, before finalizing your project, I suggest follow this procedure:</p>
<ul>
<li>In Blender, turn on the visual for the normals of surfaces. If an area does not look like a hedgehog after that, the normals in that area are reversed and you need to flip the surfaces there or re-mesh it.</li>
<li>Triangulate the surface using the triangulate modifier. This is to spot artifacts from conversion to STL early and be able to fix them: STL only knows triangles, while blender knows <em>bent</em> n-gons.</li>
<li>Add a new object. A cube with side length 1.</li>
<li>Do a test export to STL with scale 1, which also contains the 1-unit cube as an extra shell.</li>
<li>Import the model into a software such as meshmixer, that has a command to separate shells.</li>
<li>Separate the item to all shells. In Meshmixer this is in analyze, separate shells.</li>
<li>After separating the shells, measure your 1-unit cube. If it is not 1 mm, calculate your scaling factor. It should be a multiple of 10.</li>
<li>Next, you should check each shell for gaps or other errors. In meshmixer, the automatic analyze feature points to these areas with red, blue and magenta lines.</li>
<li>Fix the marked errors in blender, then return to the test export. This time use the proper scaling factor. Repeat until no errors remain.</li>
</ul>
|
<p>It doesn't matter, you scale it in the slicer or elsewhere. You're not going to slice the STL file in Blender. You'll probably need to do more work to get things print ready outside blender anyway.</p>
<p>So when I use blender I don't even bother checking what units it's using. I don't use it for parts design or tech drawing.</p>
| 2,124
|
<p>I'm using <a href="http://en.wikipedia.org/wiki/Windows_Script_Host#Usage" rel="noreferrer">WScript</a> to automate some tasks, by using WScript.Shell to call external programs.</p>
<p>However, right now it does not wait for the external program to finish, and instead moves on. This causes issues because I have some tasks dependent on others finishing first.</p>
<p>I am using code like:</p>
<pre><code>ZipCommand = "7za.exe a -r -y " & ZipDest & BuildLabel & ".zip " & buildSourceDir
Set wshShell = WScript.CreateObject("Wscript.Shell")
wshShell.run ZipCommand
</code></pre>
<p>Is there a way to do this so it blocks until the shell executed program returns?</p>
|
<p>Turns out, that while loop is severe CPU hog :P</p>
<p>I found a better way:</p>
<pre><code>ZipCommand = "7za.exe a -r -y " & ZipDest & BuildLabel & ".zip " & buildSourceDir
Set wshShell = WScript.CreateObject("Wscript.Shell")
wshShell.Run ZipCommand,1,1
</code></pre>
<p>The last two arguments are Show window and Block Execution :)</p>
|
<p>If you use the "Exec" method, it returns a reference, so you can poll the "Status" property to determine when it is complete. Here is a sample from <a href="http://msdn.microsoft.com/en-us/library/ateytk4a(VS.85).aspx" rel="noreferrer">msdn</a>:</p>
<pre><code>Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(ZipCommand)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
</code></pre>
| 7,315
|
<p>Is <em>CompileAssemblyFromDom</em> faster than <em>CompileAssemblyFromSource</em>?</p>
<p>It <em>should</em> be as it presumably bypasses the compiler front-end.</p>
|
<p>CompileAssemblyFromDom compiles to a .cs file which is then run through the normal C# compiler.</p>
<p>Example:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CSharp;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
using System.Reflection;
namespace CodeDomQuestion
{
class Program
{
private static void Main(string[] args)
{
Program p = new Program();
p.dotest("C:\\fs.exe");
}
public void dotest(string outputname)
{
CSharpCodeProvider cscProvider = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters();
cp.MainClass = null;
cp.GenerateExecutable = true;
cp.OutputAssembly = outputname;
CodeNamespace ns = new CodeNamespace("StackOverflowd");
CodeTypeDeclaration type = new CodeTypeDeclaration();
type.IsClass = true;
type.Name = "MainClass";
type.TypeAttributes = TypeAttributes.Public;
ns.Types.Add(type);
CodeMemberMethod cmm = new CodeMemberMethod();
cmm.Attributes = MemberAttributes.Static;
cmm.Name = "Main";
cmm.Statements.Add(new CodeSnippetExpression("System.Console.WriteLine('f'zxcvv)"));
type.Members.Add(cmm);
CodeCompileUnit ccu = new CodeCompileUnit();
ccu.Namespaces.Add(ns);
CompilerResults results = cscProvider.CompileAssemblyFromDom(cp, ccu);
foreach (CompilerError err in results.Errors)
Console.WriteLine(err.ErrorText + " - " + err.FileName + ":" + err.Line);
Console.WriteLine();
}
}
}
</code></pre>
<p>which shows errors in a (now nonexistent) temp file:</p>
<blockquote>
<p>) expected - c:\Documents and Settings\jacob\Local Settings\Temp\x59n9yb-.0.cs:17</p>
<p>; expected - c:\Documents and Settings\jacob\Local Settings\Temp\x59n9yb-.0.cs:17</p>
<p>Invalid expression term ')' - c:\Documents and Settings\jacob\Local Settings\Tem p\x59n9yb-.0.cs:17</p>
</blockquote>
<p>So I guess the answer is "no"</p>
|
<p>I've tried finding the ultimate compiler call earlier and I gave up. There's quite a number of layers of interfaces and virtual classes for my patience.</p>
<p>I don't think the source reader part of the compiler ends up with a DOM tree, but intuitively I would agree with you. The work necessary to transform the DOM to IL should be much less than reading C# source code.</p>
| 2,659
|
<p>I need a Regex that will match a java method declaration. I have come up with one that will match a method declaration, but it requires the opening bracket of the method to be on the same line as the declaration. If you have any suggestions to improve my regex or simply have a better one then please submit an answer.</p>
<p>Here is my regex: <code>"\w+ +\w+ *\(.*\) *\{"</code></p>
<p>For those who do not know what a java method looks like I'll provide a basic one:</p>
<pre><code>int foo()
{
}
</code></pre>
<p>There are several optional parts to java methods that may be added as well but those are the only parts that a method is guaranteed to have.</p>
<p>Update:
My current Regex is <code>"\w+ +\w+ *\([^\)]*\) *\{"</code> so as to prevent the situation that Mike and adkom described.</p>
|
<pre><code>(public|protected|private|static|\s) +[\w\<\>\[\]]+\s+(\w+) *\([^\)]*\) *(\{?|[^;])
</code></pre>
<p>I think that the above regexp can match almost all possible combinations of Java method declarations, even those including generics and arrays are return arguments, which the regexp provided by the original author did not match.</p>
|
<p>I built a vim regex to do this for <a href="https://github.com/pydave/ctrlp-funky/blob/master/autoload/ctrlp/funky/java.vim" rel="nofollow">ctrlp/funky</a> based on Georgios Gousios's answer.</p>
<pre><code> let regex = '\v^\s+' " preamble
let regex .= '%(<\w+>\s+){0,3}' " visibility, static, final
let regex .= '%(\w|[<>[\]])+\s+' " return type
let regex .= '\w+\s*' " method name
let regex .= '\([^\)]*\)' " method parameters
let regex .= '%(\w|\s|\{)+$' " postamble
</code></pre>
<p>I'd guess that looks like this in Java:</p>
<pre><code>^\s+(?:<\w+>\s+){0,3}(?:[\w\<\>\[\]])+\s+\w+\s*\([^\)]*\)(?:\w|\s|\{)+$
</code></pre>
| 9,418
|
<p>I've heard of a few ways to implement tagging; using a mapping table between TagID and ItemID (makes sense to me, but does it scale?), adding a fixed number of possible TagID columns to ItemID (seems like a bad idea), Keeping tags in a text column that's comma separated (sounds crazy but could work). I've even heard someone recommend a sparse matrix, but then how do the tag names grow gracefully?</p>
<p>Am I missing a best practice for tags?</p>
|
<p>Three tables (one for storing all items, one for all tags, and one for the relation between the two), properly indexed, with foreign keys set running on a proper database, should work well and scale properly. </p>
<pre><code>Table: Item
Columns: ItemID, Title, Content
Table: Tag
Columns: TagID, Title
Table: ItemTag
Columns: ItemID, TagID
</code></pre>
|
<p>I would suggest following design :
Item Table:
Itemid, taglist1, taglist2<br>
this will be fast and make easy saving and retrieving the data at item level. </p>
<p>In parallel build another table:
Tags
tag
do not make tag unique identifier and if you run out of space in 2nd column which contains lets say 100 items create another row. </p>
<p>Now while searching for items for a tag it will be super fast.</p>
| 4,123
|
<p>My wife wants me to use an FFM 3d printer to make custom stamps for her to use on paper (scrap books, letters, etc.). She is convinced, however, that they will be too rigid to make good stamps. A quick google search showed ones made from <a href="https://3dprint.com/110918/3d-printed-stamp-collection/" rel="noreferrer">PLA</a> and <a href="http://www.thingiverse.com/thing:3669" rel="noreferrer">ABS</a>. Logically, though, a TPU or similar would address her concerns. A good quality stamp needs to hold ink and make good, even contact with the paper. It would probably need to be able to be sanded or smoothed in some way.</p>
<p>I am supposed to receive my printer next week or so and am trying to get some filaments, STL files, and accessories I will need ready in advance so I can rapidly learn how to use it.</p>
|
<p>I see three options...</p>
<p><strong>1. Print with a flexible filament:</strong></p>
<ul>
<li>Many options: TPU as you pointed out, the flexible PLA that Tom mentioned, and others. Here's an article with a few options from <a href="https://3dprintingindustry.com/news/which-flexible-3d-printing-filament-should-you-choose-61961/" rel="noreferrer">Matter Hackers</a></li>
<li>I'd suggest printing the stamp side down so you get a nice flat stamp with no post processing. For any wide gaps, mind your bridging...use fillets or chamfers so the "roof" of the gap is an upside down V or U shape.</li>
</ul>
<p><strong>2. Print with any hard filament, but use a rubber mat under the paper.</strong></p>
<ul>
<li>The idea here is to use a semi-flexible surface under the paper to help get uniform contact pressure between the paper and the hard stamp. As long as your stamp holds ink, this should work okay.</li>
</ul>
<p><strong>3. Print your stamp shape, then use it to make a rubber stamp.</strong></p>
<ul>
<li>Making a model and then copying it with your desired non-printable material is a common manufacturing technique that can be used in many situations. Use of molds for casting and related processes can really expand your possibilities. Check out <a href="https://www.smooth-on.com/" rel="noreferrer">Smooth On</a>. They have several rubber and flexible compounds that you could use for stamps.</li>
</ul>
|
<p>Recently I've experimented with printing some <a href="http://rads.stackoverflow.com/amzn/click/B00TOOBPNO" rel="nofollow">Nylon 618 filament</a> after <a href="http://www.matterhackers.com/articles/printing-with-nylon" rel="nofollow">reading stuff online</a> about it. I'm using a Craftbot original with the stock hotend, keeping the Nylon dry in a ziploc bag. It prints really well, just tricky to get it to stick to the bed (I'm still working on that), but otherwise it's great.</p>
<p>Once printed, the main difference from PLA prints is the nylon remains more flexible. If you bend a thin nylon print, it tends to just spring back to the shape that came off the printer. That's very different from my PLA prints, which will either stay bent or break apart.</p>
<p>I believe that nylon would be a good material for you to try for stamps, because of this flexibility and shape-preserving quality. The comments show some other materials to try, but I'm limiting my answer here to my own personal experience.</p>
| 389
|
<p><strong>Given the emissions that 3d printing gives off (ABS = styrene and other chemicals, PLA give some off, etc), what options are there to filter the air in the enclosure other than venting the air out of a window?</strong></p>
<p>More information on the chemicals 3d printing emit:</p>
<ul>
<li><a href="http://built-envi.com/portfolio/ultrafine-particle-emissions-from-3d-printers/" rel="nofollow noreferrer">http://built-envi.com/portfolio/ultrafine-particle-emissions-from-3d-printers/</a></li>
</ul>
<p>It looks like activated carbon filters would be a strong performer for ABS (styrene) and PLA (lactide):</p>
<ul>
<li><a href="https://www.sentryair.com/activated-carbon-filter.htm" rel="nofollow noreferrer">https://www.sentryair.com/activated-carbon-filter.htm</a></li>
</ul>
<p><strong>Are there better filtering materials or processes for filtering the air in an enclosure?</strong></p>
<p>Here's an example filter setup:</p>
<ul>
<li>This fan mount: <a href="https://www.thingiverse.com/thing:780001" rel="nofollow noreferrer">https://www.thingiverse.com/thing:780001</a></li>
<li>60mm fans and this filter: <a href="https://rads.stackoverflow.com/amzn/click/com/B00XNI5SY4" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/gp/product/B00XNI5SY4</a></li>
<li>And sandwich the filter on the fan using this fan grill: <a href="https://www.thingiverse.com/thing:11906" rel="nofollow noreferrer">https://www.thingiverse.com/thing:11906</a></li>
</ul>
|
<p>My residential materials expert referred me to these links (<a href="http://www.bofaamericas.com/3D-printing-fume-extraction.asp" rel="noreferrer">3D Printing Fume Extraction Solutions</a>, and <a href="http://www.3dprintfilemarket.com/140629194058.html" rel="noreferrer">ABS 3d Printer Nanoparticle and Chemical Exhaust Air Filter</a>) and thinks that you're pretty much on track with the idea of using activated carbon.</p>
<p>We both primarily print with ABS with my Replicator Dual and what's worked enough for me (in the past 5 years) is to keep my printer next to a window or vent in my den at home. The window is obviously a good ventilation option, but the variability that it creates in the ambient temperature screwed with my prints. Later, I moved my machine into its own hutch, which, if it is an option, would greatly help the overall environment for both the machine and any stored filament.</p>
<p>We'll keep poking around, but hopefully that helps in the mean time.</p>
|
<p>Anybody consider using a Grow Box Fan and filter inside an enclosure. They come cheap with 180 cfm fan and / carbon filters.</p>
<p><a href="https://i.stack.imgur.com/16XP7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/16XP7.jpg" alt="https://www.amazon.com/iPower-Inline-Variable-Controller-Ventilation/dp/B07D8TZ2KV/ref=sr_1_17?dchild=1&keywords=low+noise+grow+box+fan+kit&qid=1593395416&sr=8-17" /></a></p>
<p>Seems like it would work well, just wondering if they are really noisy.</p>
| 188
|
<p>I have recently been doing a bit of investigation into the different types of Model View architectures, and need to decide which one to pursue for future in-house development. As I'm currently working in a Microsoft shop that has ASP.NET skills, it seems my options are between ASP.NET MVC and WCSF (Monorail is probably out of the as it wouldn't be supported by Microsoft).</p>
<p>After reading <a href="http://blogs.msdn.com/simonince/archive/2007/11/22/the-asp-net-mvc-framework-using-the-wcsf-as-a-yardstick.aspx" rel="noreferrer">the ASP.NET MVC framework, using the WCSF as a yardstick</a>, I picked up the following points: </p>
<ul>
<li>ASP.NET MVC cannot use web controls that rely on postbacks, whereas WCSF can.</li>
<li>You have more control over the urls in an ASP.NET MVC site as opposed to a WCSF site.</li>
<li>An ASP.NET MVC site will probably be easier to test than an equivalent WCSF version.</li>
<li>It seems that the WCSF still uses the code behind to control UI events under some circumstances, but ASP.NET MVC doesn't allow this. </li>
</ul>
<p>What are some of the other considerations?<br/>
What have I misunderstood?<br/>
Is there anybody out there who has used both frameworks and has advice either way?</p>
|
<blockquote>
<p>ASP.NET MVC cannot use web controls that rely on postbacks, whereas WCSF can.</p>
</blockquote>
<p>You should think of WCSF as guidance about how to use the existing WebForms infrastructure, especially introducing Model-View-Presenter to help enforce separation of concerns. It also increases the testability of the resulting code.</p>
<blockquote>
<p>You have more control over the urls in an ASP.NET MVC site as opposed to a WCSF site.</p>
</blockquote>
<p>If you can target 3.5 SP1, you can use the new Routing system with a traditional WebForms site. Routing is not limited to MVC. For example, take a look at Dynamic Data (which also ships in 3.5 SP1).</p>
<blockquote>
<p>An ASP.NET MVC site will probably be easier to test than an equivalent WCSF version.</p>
</blockquote>
<p>This is true because it uses the new abstractions classes for HttpContext, HttpRequest, HttpResponse, etc. There's nothing inherently more testable about the MVC pattern than the MVP pattern. They're both instances of "Separated Presentation", and both increase testability.</p>
<blockquote>
<p>It seems that the WCSF still uses the code behind to control UI events under some circumstances, but ASP.NET doesn't allow this.</p>
</blockquote>
<p>In Model-View-Presenter, since the outside world interacts with views (i.e., the URL points to the view), the views will naturally be responding to these events. They should be as simple as possible, either by calling the presenter or by offering events that the presenter can subscribe to.</p>
<p>Model-View-Controller overcomes this limitation by having the outside world interact with controllers. This means your views can be a lot "dumber" about non-presentation things.</p>
<p>As for which you should use, I think the answer comes down to which one best suits your project goals. Sometimes WebForms and the rich third party control vendor availability will be preferable, and in some cases, raw simplicity and fine-grained HTML control will favor MVC.</p>
|
<p>Why not attach both to Northwind and see which fits best for you and your situation?</p>
| 7,694
|
<p>I need to print a thin piece.
Theoretically, it could work, but Cura prints the walls as single lines.
In my case, it is just this line that breaks apart as you can see here.</p>
<p>Is there a setting that would instruct Cura to avoid creating such a line as the outer wall, or how else could I resolve this problem?</p>
<ul>
<li>Printer: Kobra Max</li>
<li>Material: PETG / PLA</li>
<li>Temperature: 250 °C / 65 °C</li>
</ul>
<p>Speeds:</p>
<ul>
<li>Print speed: 80 mm/s</li>
<li>Outer Wall Speed: 45 mm/s</li>
<li>Inner Wall Speed: 80 mm/s</li>
<li>Top/Bottom Speed: 45 mm/s</li>
<li>Travel Speed: 100 mm/s</li>
<li>Initial layer speed 45 mm/s</li>
<li>Travel retraction speed: 40 mm/s</li>
</ul>
<p><a href="https://i.stack.imgur.com/nwP2L.png" rel="nofollow noreferrer" title="Photos and graphic showing the point of failure of a 3D printed model"><img src="https://i.stack.imgur.com/nwP2L.png" alt="Photos and graphic showing the point of failure of a 3D printed model" title="Photos and graphic showing the point of failure of a 3D printed model" /></a></p>
<p><a href="https://i.stack.imgur.com/F0Scr.png" rel="nofollow noreferrer" title="Screenshot of Cura's Print Preview of a 3D printed model showing where the failure happens"><img src="https://i.stack.imgur.com/F0Scr.png" alt="Screenshot of Cura's Print Preview of a 3D printed model showing where the failure happens" title="Screenshot of Cura's Print Preview of a 3D printed model showing where the failure happens" /></a></p>
|
<p>The raft still needs to fit on the bed, and it counts as a print, because, it is printed. You want the raft for better adhesion, so that means that you need more contact with the bed. If you’re not, your basically wasting filament. Its kinda logical actually.</p>
|
<h2>Adjusted model Dimensions</h2>
<p>The model has the size determined by the base area of the bounding box, in this case, <span class="math-container">$\pu{190 \times 200 mm }$</span>. The raft as told by OP adds 15mm on <strong>all</strong> sides of the model, and thus adds 30 mm in total on both the X and Y dimensions. This gets us a bounding box floor area of <span class="math-container">$\pu{220 \times 230 mm}$</span>.</p>
<p>The model's bounding box has a height of <span class="math-container">$\pu{200 mm}$</span>. Add to that the thickness of the raft. This is not mentioned, but in the worst case, this is about 3 mm, and so you get <span class="math-container">$\pu{203 mm}$</span> as the maximum. Our model's Bounding Box thus is <span class="math-container">$\pu{220\times 230\times 203 mm}$</span></p>
<p>The smaller scale model (<span class="math-container">$\pu{171 \times 183 \times 180 mm}$</span>) results in an adjusted area of <span class="math-container">$\pu{201 \times 213 \times 183 mm}$</span>.</p>
<h2>Printer dimensions</h2>
<p>The standard Creality Ender3 v2 is set up with a build volume of (<span class="math-container">$\pu{220\times 220\times 250 mm}$</span>) As your base area is 230 mm in one dimension, it just can't fit. The slightly scaled item is <em>just</em> under that dimension and thus fits.</p>
<h2>Solutions</h2>
<p>With a firmware update, the printer can be told to use all of the bed, and then Cura's printer settings can be adjusted accordingly.</p>
<p>Sometimes, but not in this case, rotating the model can result in a model that doesn't fit in normal orientation to fit: A line of 240 mm doesn't fit along the X or Y axis, but easily along the diagonal of the printer. In fact, it is enough to turn the model by about 23.3° and the line fits:</p>
<p><a href="https://i.stack.imgur.com/rP9Ab.png" rel="nofollow noreferrer" title="Graphic showing a 240 mm line at a 23.3-degree angle fitting inside a gray box"><img src="https://i.stack.imgur.com/rP9Ab.png" alt="Graphic showing a 240 mm line of 0.45 mm width first at horizontal orientation and then at a 23.3-degree angle fitting inside a gray box of 220 mm width" title="Graphic showing a 240 mm line at a 23.3-degree angle fitting inside a gray box" /></a></p>
| 2,224
|
<p>I started using IRC at a young age, and I have always been fascinated with it. As a language exercise, I was thinking about programming a simple IRC client in Ruby with <a href="http://www.shoooes.net/" rel="noreferrer">Shoes</a> as a graphical front-end. My question to you, kind-sirs, what do I need to become familiar with to start on this great adventure (besides shoes and Ruby of course)? I imagine there is some-sort of specification on IRC Protocol. Any pointers?</p>
|
<p>An earlier post mentioned RFC1459. While it is a very good introduction to IRC, it has actually been superseded by RFCs 2810-2813. Here is a more complete list of documentation you need to program anything IRC-related:</p>
<ul>
<li><a href="https://www.rfc-editor.org/rfc/rfc1459" rel="nofollow noreferrer">RFC1459</a> (original RFC; superseded, but still useful)</li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2810" rel="nofollow noreferrer">RFC2810</a> (IRC architecture)</li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2811" rel="nofollow noreferrer">RFC2811</a> (IRC channel management)</li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2812" rel="nofollow noreferrer">RFC2812</a> (IRC client protocol)</li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2813" rel="nofollow noreferrer">RFC2813</a> (IRC server protocol)</li>
<li><a href="http://www.irchelp.org/irchelp/rfc/ctcpspec.html" rel="nofollow noreferrer">CTCP specification</a></li>
<li><a href="http://www.irchelp.org/irchelp/rfc/dccspec.html" rel="nofollow noreferrer">DCC specification</a></li>
<li><a href="http://www.invlogic.com/irc/ctcp.html" rel="nofollow noreferrer">Updated CTCP specification</a> (not all clients support this)</li>
<li><a href="http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt" rel="nofollow noreferrer">ISupport (response code 005) draft</a> (almost all servers support this nowadays)</li>
<li><a href="http://www.leeh.co.uk/draft-mitchell-irc-capabilities-02.html" rel="nofollow noreferrer">Client capabilities (CAP command) draft</a> (supported by some servers/clients)</li>
<li><a href="http://ircv3.org/" rel="nofollow noreferrer">IRCv3 standards and proposals</a> (the future features of IRC, some of which are already widely supported)</li>
</ul>
|
<p>Not exactly an answer to your question, but it may be helpful. If you are using Ruby, I have found the Autumn Leaves project to be a great way to build an IRC bot using Ruby:</p>
<p><a href="http://github.com/RISCfuture/autumn/tree/master" rel="nofollow noreferrer">http://github.com/RISCfuture/autumn/tree/master</a></p>
<p>It is pretty much the Jibble of the Ruby world.</p>
| 4,403
|
<p>Is it possible, in Windows XP, to copy files to a Network Place from the command line, a batch file or, even better, a PowerShell script?</p>
<p>What sent me down this road of research was trying to publish files to a WSS 3.0 document library from a user's machine. I can't map a drive to the library in question because the WSS site is only available to authenticate via NTLM on a port other than 80 or 443. I suppose I could alternately use the WSS web services to push the files out, but I'm really curious about the answer to this question now.</p>
|
<p>Using a batch file, you can both log on to the resource and copy the file: </p>
<p>The Batch File would contain the following: </p>
<pre><code>net use \\{dest-machine}\{destfolder} {password} /user:{username}
copy {file} \\{dest-machine}\{destfolder}
</code></pre>
<p>e.g.</p>
<pre><code>net use \\Development\myfolder mypassword /user:Administrator
copy newfile.c \\development\myfolder
</code></pre>
|
<p>Yes you can. I suggest using a tool like robocopy.</p>
| 3,154
|
<p>I'm going to be working on some iPhone apps so I've been given a golden ticket to buy a Mac. However the golden ticket isn't worth that much, and I'm thinking iMac. Now, Macs are great, I love 'em and use 'em at home, but I know that the iMac is geared more towards the average consumer than the professional. Is an iMac going to be powerful enough to do iPhone development on?</p>
<p>If it helps any, the only thing I envision doing on the Mac is running XCode and maybe a web browser.</p>
<p>Is there anybody out there doing iPhone development and having trouble running the required tools on their machine? If so, what do you have?</p>
|
<p>Any modern Mac will be fine. I work on a two year old MacBook (2GHz) with 2Gb of memory and its perfectly usable. The biggest constraint I find it screen real-estate. I am <em>way</em> more productive on my 22" external screen. Go big if you get an iMac or consider adding an external monitor to the base model.</p>
|
<p>As with all development, screen size is paramount so I would suggest the 24" iMac if your golden ticket stretches that far or a mac mini with a large (probably non-Apple) monitor if it doesn't.</p>
| 4,250
|
<p>I like the status email sent by TFS's alerts mechanism when a build breaks.
However I would like to send such an email to the entire team and not rely on the team to subscribe to the alert...</p>
<p>Having a hard time producing a nice and detailed enough message by myself when overriding the "OnBuildBreak" and using the MSBuildCommunityTasks EMail task.</p>
<p>Is there a way to force a TFS alert to be sent to a list of emails?
Can you recommend of a way to send such status notifications?</p>
|
<p>You could try.</p>
<p><a href="http://www.woodwardweb.com/gadgets/000434.html" rel="nofollow noreferrer">Brian the build bunny</a></p>
<p>:-)</p>
|
<p>In my mind, a open source project named 'Web Deployment Projects' can do this. your can search for it.</p>
| 5,886
|
<p>I need to display some interactive (attaching with DOM listeners etc. and event handling) vector graphics in web site I am working on. There is a W3C recommendation for SVG though this format is still not recognized by Internet Explorer support of which is a must (for a public website). IE handles VML though and there are even javascript libraries that do some canvas-like drawing depending on a browser (SVG vs. VML) - <a href="http://excanvas.sourceforge.net/" rel="noreferrer" title="excanvas">excanvas</a>, <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/drawing-gfx" rel="noreferrer">GFX of Dojo Toolkit</a> and more. That would be nice and acceptable though none of them can display an SVG image from the given markup.</p>
<p>So the question actually consists of several parts:</p>
<ol>
<li>Are there any cross-browser Javascript libraries that display vector graphics from given markup (not obligatory SVG) and offer availability to attach to DOM events?</li>
<li>If there are not, which of the most pupular browser-embedded technologies would be most suitable for doing such a task? I can choose from Flex/Flash, Java applet. Silverlight is not an option because of Windows lock-in.</li>
</ol>
<p>[<strong>EDIT</strong>] Thank you all for your comments/suggestions. Below are just some my random notes/conclusions on this matter:</p>
<ul>
<li>The level of interactivity I need is ability to detect DOM events on the vector image being displayed - mouseover, mouseout, click etc. - and ability to react on them like changing background color, displaying dialog etc.</li>
<li>The idea of sticking with SVG format is quite well as it is native on many browsers except the most popular one - IE. After some experimenting with displaying dynamic SVG I realized that IE version 7 the most problematic. There's too much hassle because of browser incompatibilities.</li>
<li>Cake seems a great Javascript framework, though I could not get the examples working on IE7.</li>
<li>Java Applets - I liked that idea the most as I though I could use the Apache Batik library, a quality SVG renderer. However, Batik is very big library and I cannot afford deploying an applet that weights few megabytes.</li>
<li>I decided to stick with the Flex option. I found a nice vector graphics library <a href="http://www.degrafa.com/" rel="noreferrer">Degrafa</a>. It uses its own markup format however it recognizes SVG path notation, so in my case it is going to be quite easy to transform my SVGs using XSLT or just parsing them.</li>
</ul>
<p>[<strong>EDIT 2</strong>] Some more comments appeared. I'd like to clarify that by "Windows lock-in" I mean the situation that Silverlight would normally run on Windows, more specifically, IE. I doubt it is an accepted solution (like Flash or Java Applet, for instance) on other systems. Yes, I have no doubt that one <em>is able to</em> launch Silverlight app on any system though I fear it would be too much effort for an average user.</p>
<p>@Akira: Have you had any problems with those "SVG renderers" on IE7? I get thrown Javascript errors all the time.</p>
|
<p>Safari, Opera and Firefox all support SVG natively (eg. without plugins) to varying degrees of completeness and correctness, including the ability to script the svg from javascript.</p>
<p>There's also the canvas element which is now being standardised in html5, and is already supported in the above browsers as well (with various quirks in certain edge cases due to relatively recent changes in the html5 draft).</p>
<p>Unfortunately any standards based approach is kind of destroyed by IE's willful disregard of what is happening outside its own ecosystem, however there are a number of libraries that try to convert canvas/svg into VML (IE's proprietary vector language) such as <a href="http://sourceforge.net/projects/iecanvas" rel="noreferrer">iecanvas</a>.</p>
<p>[Edit: whoops, i forgot my favourite js library -- <a href="http://glimr.rubyforge.org/cake/canvas.html#SVGParserTest" rel="noreferrer">Cake</a>! which can parse and display svg in canvas, and believe supports IE as well]</p>
<p>[Yet another edit: Cake actually has a <a href="http://glimr.rubyforge.org/cake/canvasmage.html" rel="noreferrer">demo</a> doing what i think you want to do]</p>
|
<p>Go for SVG - and just tell the users to get the ADOBE SVG plug in for IE.</p>
<p>See this excellent site - which is a UK Government Site (public service)</p>
<p><a href="http://www.elgin.gov.uk" rel="nofollow noreferrer">ELGIN</a></p>
| 3,100
|
<p>I recently changed filament and for starters it worked perfectly well, but quickly I got some problems with my first layer. It's like droplets are forming on the surface (finished item + 3 undersides):</p>
<p><a href="https://i.stack.imgur.com/qgPyl.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qgPyl.jpg" alt="enter image description here"></a></p>
<p>The final part is (for me) okay but I'd like to get rid of those pesky 'drops'.</p>
<p><strong>As the defect is quite stable and quite recognizable and it happens all the time, I bet somebody more experienced than me knows what's going on!</strong></p>
<p>Info:</p>
<p>I'm using a 1 week old eSun filament, a E3D V6 Hotend 1.75mm on my scratch CoreXY printer, short Bowden direct drive, Repetier, Marlin, Linear advance (M900 K60 so quite low).</p>
<p>The print is done using a 0.4mm diameter nozzle at 0.2mm height at:</p>
<p>50°C(122°F) heat-bed and 214°C(417°C) hot-end for first layer, then lower a bit to</p>
<p>40°C(104°F) heat-bed and 211°C(412°F) hot-end.</p>
<p>I use Blue-painter tape.</p>
<p>Worked perfectly well with my black eSun and my white eSun.</p>
<p><strong>What's my problem?</strong></p>
<p>Thank you all!</p>
<p>[Edit]</p>
<p>Tried about everything (more temp, less temp, fan on item, more / less bed temp, underextrude, moving around z delta, removing linear advance, radically lowering speed) but the only thing that worked about okay (problem was quite reduced but didn't go away totally) was to bump up the layer thickness to 0.3mm</p>
<p>[Edit 2] Finally it seems it was, as it usually is, a conjuncture of several problems that I will list here:</p>
<ul>
<li>The bed was not perfectly flat</li>
<li>The heatbed moved/bended when going from a hot first layer to a colder second (and on) layer</li>
<li>Maybe the speed was a bit high for the first layer (25mm/s)</li>
</ul>
<p>I fixed this by installing a borosilicate glass bed on top of the heat bed which ensures a perfect flatness.</p>
<p>I had to change my inductive sensor to an 8mm one (insteéad of the 4mm I had previously added) to make this function. I think it is not as good as it can be as it detects the heatbed under the glass (which is not perfectly flat), but it's enough for now. I'm thinking about how to make the glass conductive, like aluminium or something, but that's for another day/post.</p>
<p>I also put blue tape on the glass because the first layer was tricky. This might be because the inductive sensor doesn't do its job that well (see above).</p>
<p>Heatbed temperature for first layer: 70°C</p>
<p>Extruder temperature anywhere from 190°C to 220°C works fine, that was not the problem, or it is no longer a problem.</p>
<p>I also lowered the first layer speed to 20mm/s because the first layer didn't stick easily directly onto the glass, with blue painters tape it sticks even too much so I'll try higher speeds. It did mitigate problems though so it might be a path to try if you run into similar problems.</p>
<p>And now it seems that it works even amazingly well, I just have to print something really big to see!</p>
<p>---------------Old:</p>
<p>Moving z up made spaghetti :-) and different temperatures made quite extreme warping:</p>
<p><a href="https://i.stack.imgur.com/eV7UJ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/eV7UJ.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/7VeCT.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/7VeCT.jpg" alt="enter image description here"></a></p>
|
<p>Mine is more of an educated guess than a definitive diagnosis, but <strong>it looks to me like if your printer may be overextruding</strong> (it's difficult to say with certainty with this particular picture, but your top layers too do not look as good as they should).</p>
<p><strong>I wonder if you have <a href="https://www.matterhackers.com/articles/how-to-calibrate-your-extruder" rel="noreferrer">calibrated your extrusion</a> for this particular spool of filament</strong>? This is something that you should do for each and every new spool of filament, regardless of whether you have already used the same brand and material, as different batches and colours may differ slightly in diameter or hardness, and both factors can lead to a different overall flow out of your nozzle (I just checked eSun website, and they state "Accuracy:1.7-1.8mm", and 6% variance is quite a lot).</p>
<p>Possibly unrelated, but <strong>211+°C is also quite on the high end of the correct temperature for printing PLA</strong> (if that is what you are using). Still in the range recommended by the manufacturer - so it should be ok - but you may wish to try bringing it down a notch (205°C perhaps?).</p>
|
<p>Mine is more of an educated guess than a definitive diagnosis, but <strong>it looks to me like if your printer may be overextruding</strong> (it's difficult to say with certainty with this particular picture, but your top layers too do not look as good as they should).</p>
<p><strong>I wonder if you have <a href="https://www.matterhackers.com/articles/how-to-calibrate-your-extruder" rel="noreferrer">calibrated your extrusion</a> for this particular spool of filament</strong>? This is something that you should do for each and every new spool of filament, regardless of whether you have already used the same brand and material, as different batches and colours may differ slightly in diameter or hardness, and both factors can lead to a different overall flow out of your nozzle (I just checked eSun website, and they state "Accuracy:1.7-1.8mm", and 6% variance is quite a lot).</p>
<p>Possibly unrelated, but <strong>211+°C is also quite on the high end of the correct temperature for printing PLA</strong> (if that is what you are using). Still in the range recommended by the manufacturer - so it should be ok - but you may wish to try bringing it down a notch (205°C perhaps?).</p>
| 804
|
<p>The Python docs say:</p>
<blockquote>
<p>re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By default, '^' matches only at the beginning of the string...</p>
</blockquote>
<p>So what's going on when I get the following unexpected result?</p>
<pre><code>>>> import re
>>> s = """// The quick brown fox.
... // Jumped over the lazy dog."""
>>> re.sub('^//', '', s, re.MULTILINE)
' The quick brown fox.\n// Jumped over the lazy dog.'
</code></pre>
|
<p>Look at the definition of <a href="http://docs.python.org/library/re.html#re.sub" rel="noreferrer"><code>re.sub</code></a>:</p>
<pre><code>re.sub(pattern, repl, string[, count, flags])
</code></pre>
<p>The 4th argument is the count, you are using <code>re.MULTILINE</code> (which is 8) as the count, not as a flag.</p>
<p>Either use a named argument:</p>
<pre><code>re.sub('^//', '', s, flags=re.MULTILINE)
</code></pre>
<p>Or compile the regex first:</p>
<pre><code>re.sub(re.compile('^//', re.MULTILINE), '', s)
</code></pre>
|
<p>The full definition of <a href="http://docs.python.org/library/re.html#re.sub" rel="noreferrer"><code>re.sub</code></a> is:</p>
<pre><code>re.sub(pattern, repl, string[, count, flags])
</code></pre>
<p>Which means that if you tell Python what the parameters are, then you can pass <code>flags</code> without passing <code>count</code>:</p>
<pre><code>re.sub('^//', '', s, flags=re.MULTILINE)
</code></pre>
<p>or, more concisely:</p>
<pre><code>re.sub('^//', '', s, flags=re.M)
</code></pre>
| 6,413
|
<p><strong>Is there a way in PHP to overwrite a method declared by one interface in an interface extending that interface?</strong></p>
<p>The Example:</p>
<p>I'm probably doing something wrong, but here is what I have:</p>
<pre><code>interface iVendor{
public function __construct($vendors_no = null);
public function getName();
public function getVendors_no();
public function getZip();
public function getCountryCode();
public function setName($name);
public function setVendors_no($vendors_no);
public function setZip($zip);
public function setCountryCode($countryCode);
}
interface iShipper extends iVendor{
public function __construct($vendors_no = null, $shipment = null);
public function getTransitTime($shipment = null);
public function getTransitCost($shipment = null);
public function getCurrentShipment();
public function setCurrentShipment($shipment);
public function getStatus($shipment = null);
}
</code></pre>
<p>Normally in PHP, when you extend something, you can overwrite any method contained therein (right?). However, when one interface extends another, it won't let you. Unless I'm thinking about this wrong... When I implement the iShipper interface, I don't have to make the Shipper object extend the Vendor object (that implements the iVendor interface). I just say:</p>
<pre><code>class FedEx implements iShipper{}
</code></pre>
<p>and make FedEx implement all of the methods from iVendor and iShipper. However, I need the <code>__construct</code> functions in iVendor and iShipper to be unique. I know I could take out the <code>$shipment = null</code>, but then it wouldn't be as convenient to create Shippers (by just passing in the vendors_no and the shipment while instantiating).</p>
<p>Anyone know how to make this work? My fallback is to have to set the shipment by calling <code>$shipper->setShipment($shipment);</code> on the Shipper after I instantiate it, but I'm hoping for a way to get around having to do that...</p>
<p><em>A little more explanation for the curious:</em><br>
<em>The FedEx Object has methods that go to the FedEx site (using cURL) and gets an estimate for the Shipment in question. I have a UPS Object, a BAXGlobal Object, a Conway Object, etc. Each one has COMPLETELY different methods for actually getting the shipping estimate, but all the system needs to know is that they are a "shipper" and that the methods listed in the interface are callable on them (so it can treat them all exactly the same, and loop through them in a "shippers" array calling <code>getTransitX()</code> to find the best shipper for a shipment).</em> </p>
<p><em>Each "Shipper" is also a "Vendor" though, and is treated as such in other parts of the system (getting and putting in the DB, etc. Our data design is a pile of crap, so FedEx is stored right alongside companies like Dunder Mifflin in the "Vendors" table, which means it gets to have all the properties of every other Vendor, but needs the extra properties and methods supplied by iShipper).</em></p>
|
<p><a href="https://stackoverflow.com/questions/16155/making-one-interface-overwrite-a-method-it-inherits-from-another-interface-in-p#16196">@cmcculloh</a> Yeah, in Java you don't define constructors in Interfaces. This allows you to both extend interfaces and also have a class that implements multiple interfaces (both allowed, and very useful in many cases) without worrying about having to satisfy a particular constructor.</p>
<p><em>EDIT:</em></p>
<p><em>Here's my new model:</em></p>
<p><em>A. Each interface no longer has a constructor method.</em><br>
<em>B. All Shippers (UPS, FedEx, etc) now implement iShipper (which extends iVendor) and extend the abstract class Shipper (which has all common non-abstract methods for shippers defined in it, getName(), getZip() etc).</em><br>
<em>C. Each Shipper has it's own unique _construct method which overwrites the abstract __construct($vendors_no = null, $shipment = null) method contained in Shipper (I don't remember why I'm allowing those to be optional now though. I'd have to go back through my documentation...).</em></p>
<p>So:</p>
<pre><code>interface iVendor{
public function getName();
public function getVendors_no();
public function getZip();
public function getCountryCode();
public function setName($name);
public function setVendors_no($vendors_no);
public function setZip($zip);
public function setCountryCode($countryCode);
}
interface iShipper extends iVendor{
public function getTransitTime($shipment = null);
public function getTransitCost($shipment = null);
public function getCurrentShipment();
public function setCurrentShipment($shipment);
public function getStatus($shipment = null);
}
abstract class Shipper implements iShipper{
abstract public function __construct($vendors_no = null, $shipment = null);
//a bunch of non-abstract common methods...
}
class FedEx extends Shipper implements iShipper{
public function __construct($vendors_no = null, $shipment = null){
//a bunch of setup code...
}
//all my FedEx specific methods...
}
</code></pre>
<p><em>Thanks for the help!</em><br>
<em>ps. since I have now added this to "your" answer, if there is something about it you don't like/think should be different, feel free to change it...</em></p>
|
<p>You could drop off the constructor and just put them in each individual class. Then what you have is each class has its own __construct, which is probably the same depending on if it is a shipper or vendor. If you want to only have those constructs defined once I don't think you want to go down that route. </p>
<p>What I think you want to do is make an abstract class that implements vendor, and one that implements shipper. There you could define the constructors differently. </p>
<pre><code>abstract class Vendor implements iVendor {
public function __construct() {
whatever();
}
}
abstract class Shipper implements iShipper {
public function __construct() {
something();
}
}
</code></pre>
| 3,689
|
<p>Sadly, I am not able to "repair" my 3D printer. Every time, I want to print something that takes a bit longer to print, the extrusion stops at some point during the print (the first few layers are great), no under-extrusion whatsoever before that critical point.</p>
<p>I already tried temperature variation (185-220 °C) with about 5 different brands of 1.75 mm PLA.</p>
<p>I tried printing without <em>any</em> retraction, but failed (I also experimented with flow rate a lot and calculated the perfect percentage etc.)</p>
<p>Everytime a print fails, it is a nightmare to remove the PLA filament from my Bowden tube (because it expanded near the nozzle and is stuck in the Bowden tube). I have to pull with so much force, that I already cut myself several times because I slipped off my pliers.</p>
<p>As I know for sure (I already wasted almost 1kg of PLA for my testing) the problem is heat creep = heat travelling from the heat block to the PLA above because the heat break or fan seem to be broken.</p>
<p>So my question is: "Will it be enough to buy a new cooling fan (as the standard fan doesnt seem to be powerful enough)?" </p>
<p><em>I have to add that I already bought the original hotend long time ago and I tried printing with the "fan of the first hotend" and with the "fan of the second hotend" (the fan that blows air towards the cold end) so that might not be the problem.</em></p>
<p>Or do I need a totally new hotend? (with heatbreak etc.)</p>
<p>My printer is a Creality CR 10, and I'm using Ultimaker Cura 3.6.</p>
<p>Or is it enough to buy a new heating block + heat break? (I don't know if the cooling fan is the problem or the heat break).</p>
|
<p>To fight heat creep, you must understand why this is happening.</p>
<p>Heat creeps up the hotend assembly (into the cold end) as a result of incorrect settings or hardware setup causing the filament to prematurely soften and swell.</p>
<p>It is important to reduce the heat travelling upwards in the first place rather than fighting the result. Too high print temperatures are an obvious culprit, but also print speed and retraction length are important. These need to be dialed in in perfect harmony.</p>
<p>Even when you buy a complete new hotend or parts for the hotend, incorrect settings may lead to the same results. It is known that all-metal hotends (due to the lacking of a thermal barrier PTFE liner in the heat break shielding the filament of excessive heat input) are more susceptible to encounter heat creep and should generally be avoided by less experienced makers.</p>
<p>Whether or not you should buy new parts depends on the current extruder, your ability to fix it (and the willingness to put in more effort to try) and the knowledge to install new parts and find the correct settings for optimal printing. There is no unambiguous answer to this question.</p>
|
<p>Cooling the hot-end heat sink may be the key. My first step would be to try ducting so the all the air from the fan flows through the fins of the heatsink. To keep it easy and be a quick experiment, use cardboard (or business cards) and tape. Check the controls to be sure the fan is running at full power. You should feel air passing theough the fins. You can not cool it too much.</p>
<p>For cleaning out pla from tubes, nozzles, and hot ends, I use a hot-air heat gun.</p>
| 1,211
|
<p>I'm making an example for someone who hasn't yet realized that controls like <code>ListBox</code> don't have to contain strings; he had been storing formatted strings and jumping through complicated parsing hoops to get the data back out of the <code>ListBox</code> and I'd like to show him there's a better way.</p>
<p>I noticed that if I have an object stored in the <code>ListBox</code> then update a value that affects <code>ToString</code>, the <code>ListBox</code> does not update itself. I've tried calling <code>Refresh</code> and <code>Update</code> on the control, but neither works. Here's the code of the example I'm using, it requires you to drag a listbox and a button onto the form:</p>
<pre><code>Public Class Form1
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
For i As Integer = 1 To 3
Dim tempInfo As New NumberInfo()
tempInfo.Count = i
tempInfo.Number = i * 100
ListBox1.Items.Add(tempInfo)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each objItem As Object In ListBox1.Items
Dim info As NumberInfo = DirectCast(objItem, NumberInfo)
info.Count += 1
Next
End Sub
End Class
Public Class NumberInfo
Public Count As Integer
Public Number As Integer
Public Overrides Function ToString() As String
Return String.Format("{0}, {1}", Count, Number)
End Function
End Class</code></pre>
<p>I thought that perhaps the problem was using fields and tried implementing <em>INotifyPropertyChanged</em>, but this had no effect. (The reason I'm using fields is because it's an example and I don't feel like adding a few dozen lines that have nothing to do with the topic I'm demonstrating.)</p>
<p>Honestly I've never tried updating items in place like this before; in the past I've always been adding/removing items, not editing them. So I've never noticed that I don't know how to make this work.</p>
<p>So what am I missing?</p>
|
<p>BindingList handles updating the bindings by itself.</p>
<pre><code>using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace TestBindingList
{
public class Employee
{
public string Name { get; set; }
public int Id { get; set; }
}
public partial class Form1 : Form
{
private BindingList<Employee> _employees;
private ListBox lstEmployees;
private TextBox txtId;
private TextBox txtName;
private Button btnRemove;
public Form1()
{
InitializeComponent();
FlowLayoutPanel layout = new FlowLayoutPanel();
layout.Dock = DockStyle.Fill;
Controls.Add(layout);
lstEmployees = new ListBox();
layout.Controls.Add(lstEmployees);
txtId = new TextBox();
layout.Controls.Add(txtId);
txtName = new TextBox();
layout.Controls.Add(txtName);
btnRemove = new Button();
btnRemove.Click += btnRemove_Click;
btnRemove.Text = "Remove";
layout.Controls.Add(btnRemove);
Load+=new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, EventArgs e)
{
_employees = new BindingList<Employee>();
for (int i = 0; i < 10; i++)
{
_employees.Add(new Employee() { Id = i, Name = "Employee " + i.ToString() });
}
lstEmployees.DisplayMember = "Name";
lstEmployees.DataSource = _employees;
txtId.DataBindings.Add("Text", _employees, "Id");
txtName.DataBindings.Add("Text", _employees, "Name");
}
private void btnRemove_Click(object sender, EventArgs e)
{
Employee selectedEmployee = (Employee)lstEmployees.SelectedItem;
if (selectedEmployee != null)
{
_employees.Remove(selectedEmployee);
}
}
}
}
</code></pre>
|
<p>I don't know much about vb.net but in C# you should use datasource and then bind it by calling <code>listbox.bind()</code> would do the trick.</p>
| 8,665
|
<p>I have a Linq query that I want to call from multiple places:</p>
<pre><code>var myData = from a in db.MyTable
where a.MyValue == "A"
select new {
a.Key,
a.MyValue
};
</code></pre>
<p>How can I create a method, put this code in it, and then call it?</p>
<pre><code>public ??? GetSomeData()
{
// my Linq query
}
</code></pre>
|
<p>IQueryable and IEnumerable both work. But you want to use a type specific version, IQueryable<code><</code>T<code>></code> or IEnumerable <code><</code>T<code>></code>.</p>
<p>So you'll want to create a type to keep the data.</p>
<pre><code>var myData = from a in db.MyTable
where a.MyValue == "A"
select new MyType
{
Key = a.Key,
Value = a.MyValue
};
</code></pre>
|
<p>If you want to return, you need a type.</p>
<p>Instead of <code>var</code>, declare using <code>IEnumerable<></code> and return that variable. Iterating through it actually executes the query.</p>
| 7,883
|
<p>If I'm working with standard PLA, and I want to print a box that I can stand on without any risk of it breaking, is there any good way to calculate the appropriate print settings?</p>
<p>I know that structural strength comes from the infill. Knowing this, and knowing the dimensions of the box, the weight of my body, the surface area of my shoes, and the material I'm working with, is there any good way to determine the minimum infill percentage I'd want to use in order to safely bear my weight?</p>
|
<p>Strictly speaking, it is difficult to do calculations on these materials, but not impossible (I've heard about a few commercial analysis tools that do that). The FDM process (Fused Deposition Modeling) creates a product based of fused slices of material causing an anisotropic material (this means that the properties of the material are different in different dimensions). Basically, your product will be quite strong and similar in the X and Y directions, but fragile in the Z direction (layering direction). You can imagine that every layer may be a seed for cracks to grow when you're pulling at the part. </p>
<p>When applying a compression load on a product like in your example, the walls need to be strong enough to hold the pressure (not all of the load as, based on the type of infill, the infill also can/should take part of the load!) and need to be of sufficiently high percentage, not only to take part of the load, but also support the walls to prevent buckling. I remember that stress calculations for buckling are difficult and require FEA (Finite Element Analysis) for more complex objects other than bars or beams. </p>
<p>I think it is difficult to determine or calculate the infill percentage based on the compression load beforehand as you do not know the exact material properties and the buckling behavior. You do know that a 100% infill will give you enough strength and support, you could try to print at a lower infill, e.g. 75%, and test if that works for you. </p>
|
<p>A fast way to do this is by using SolidWorks. </p>
<p>You can draw the box in it and run a simulation test with the max load expected. </p>
<p>Here is a link on how to make dynamic load simulations work in SolidWorks, <a href="https://forum.solidworks.com/thread/72005" rel="nofollow noreferrer">How to apply dynamic load in solidworks simulation ?</a></p>
<p>The catch in the process is that SolidWorks takes cubes and most objects as complete solids, i.e. 100% infill in 3D printer terms. </p>
<p>You would have to actually design your infill pattern into the cube so as to get the best and most accurate result. </p>
| 932
|
<p>I'm tasked with building a .NET client app to detect silence in a WAV files.</p>
<p>Is this possible with the built-in Windows APIs? Or alternately, any good libraries out there to help with this?</p>
|
<p>Audio analysis is a difficult thing requiring a lot of complex math (think Fourier Transforms). The question you have to ask is "what is silence". If the audio that you are trying to edit is captured from an analog source, the chances are that there isn't any silence... they will only be areas of soft noise (line hum, ambient background noise, etc).</p>
<p>All that said, an algorithm that should work would be to determine a minimum volume (amplitude) threshold and duration (say, <10dbA for more than 2 seconds) and then simply do a volume analysis of the waveform looking for areas that meet this criteria (with perhaps some filters for millisecond spikes). I've never written this in C#, but this <a href="http://www.codeproject.com/Articles/20025/Sound-visualizer-in-C" rel="noreferrer">CodeProject article</a> looks interesting; it describes C# code to draw a waveform... that is the same kind of code which could be used to do other amplitude analysis.</p>
|
<p>See code below from <a href="http://alvas.net/alvas.audio,tips.aspx#tip117" rel="nofollow">Detecting audio silence in WAV files using C#</a></p>
<pre><code>private static void SkipSilent(string fileName, short silentLevel)
{
WaveReader wr = new WaveReader(File.OpenRead(fileName));
IntPtr format = wr.ReadFormat();
WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"),
AudioCompressionManager.FormatBytes(format));
int i = 0;
while (true)
{
byte[] data = wr.ReadData(i, 1);
if (data.Length == 0)
{
break;
}
if (!AudioCompressionManager.CheckSilent(format, data, silentLevel))
{
ww.WriteData(data);
}
}
ww.Close();
wr.Close();
}
</code></pre>
| 3,979
|
<p>What would be the best way to do an <code>scp</code> or <code>sftp</code> copy in a Unix environment using C?</p>
<p>I'm interested in knowing the best library to use and an example if at all possible. I'm working on a <a href="https://en.wikipedia.org/wiki/Solaris_%28operating_system%29" rel="nofollow noreferrer">Solaris</a> server with the <em><a href="https://en.wikipedia.org/wiki/Sun_Microsystems" rel="nofollow noreferrer">Sun</a> tools</em> installed.</p>
|
<p>Try <a href="http://curl.haxx.se/libcurl/" rel="nofollow noreferrer">Libcurl</a></p>
<blockquote>
<p>libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, > FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling and more!</p>
<p>libcurl is highly portable, it builds and works identically on numerous platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HPUX, IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, BeOs, Mac OS X, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS and more...</p>
</blockquote>
|
<p>In the past, I've simply called a shell script that contained the file transfer code.</p>
<pre><code>int transferFile()
{
// Declare the transfer command
char transferCommand[50] = "/home/tyler/transferFile.shl";
// Execute the command
return system(transferCommand);
}
</code></pre>
<p>This will return 1 if the transfer command returns successfully.</p>
| 6,422
|
<p>I want to create a Java program that can be extended with plugins. How can I do that and where should I look for?</p>
<p>I have a set of interfaces that the plugin must implement, and it should be in a jar. The program should watch for new jars in a relative (to the program) folder and registered them somehow.</p>
<hr>
<p>Although I do like Eclipse RCP, I think it's too much for my simple needs.</p>
<p>Same thing goes for Spring, but since I was going to look at it anyway, I might as well try it.</p>
<p>But still, I'd prefer to find a way to create my own plugin "framework" as simple as possible.</p>
|
<p>I've done this for software I've written in the past, it's very handy. I did it by first creating an Interface that all my 'plugin' classes needed to implement. I then used the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html" rel="noreferrer">ClassLoader</a> to load those classes and create instances of them.</p>
<p>One way you can go about it is this:
</p>
<pre><code>File dir = new File("put path to classes you want to load here");
URL loadPath = dir.toURI().toURL();
URL[] classUrl = new URL[]{loadPath};
ClassLoader cl = new URLClassLoader(classUrl);
Class loadedClass = cl.loadClass("classname"); // must be in package.class name format
</code></pre>
<p>That has loaded the class, now you need to create an instance of it, assuming the interface name is MyModule:
</p>
<pre><code>MyModule modInstance = (MyModule)loadedClass.newInstance();
</code></pre>
|
<p>Have you considered building on top of Eclipse's Rich Client Platform, and then exposing the Eclipse extension framework?</p>
<p>Also, depending on your needs, the Spring Framework might help with that and other things you might want to do: <a href="http://www.springframework.org/" rel="nofollow noreferrer">http://www.springframework.org/</a></p>
| 4,506
|
<p>Why do concrete 3D printers lay the concrete in a zigzag shape? I know pouring it in a straight line makes it unstable, but the zigzag shape reduces the contact of the top layer to the layer below. What is the advantage?</p>
|
<p>According to <a href="https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382" rel="nofollow noreferrer">'The-EG' comment</a> in this GitHub issue, <a href="https://github.com/MarlinFirmware/Configurations/pull/633" rel="nofollow noreferrer">Add Creality Ender 2 Pro config #633</a>, you can often determine the stepper drivers by one of a few ways:</p>
<ol>
<li><p>Listen to the sound. The 'TMC22**' will sound much quieter</p>
</li>
<li><p>Look for a marking in Sharpie on the SD Card reader</p>
<pre><code>C = HR4998
E = A4988
A = TMC2208
B = TMC2209
H = TMC2225
</code></pre>
</li>
<li><p>Remove the heat sync</p>
<p><a href="https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995480295" rel="nofollow noreferrer">https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995480295</a></p>
<p>After removing the heat sync, it appears that the Chip is actually a <code>MS35775</code></p>
<p><a href="https://i.stack.imgur.com/0o5mK.jpg" rel="nofollow noreferrer" title="Closeup of MS35775 on board"><img src="https://i.stack.imgur.com/0o5mK.jpg" alt="Closeup of MS35775 on board" title="Closeup of MS35775 on board" /></a></p>
</li>
</ol>
|
<p>MS35775 appears to be TMC208 compatible. You can find the data sheet on relmon.com here is the overview:</p>
<ul>
<li>2-Phase stepping motor peak current of 2A</li>
<li>Step / dir interface 2, 4, 8, 16, or 32 microstep</li>
<li>Internal 256 micro steps</li>
<li>Quiet mode</li>
<li>Fast mode</li>
<li>HS Rdson 0.29 Ω ,LS Rdson 0.28 Ω</li>
<li>Voltage range 4.75 ~ 36V</li>
<li>When the motor is still, it will enter into the power saving mode automatically</li>
<li>Internal resistor mode is optional (no need for external sense resistor)</li>
<li>Single wire UART bus and OTP control</li>
<li>QFN28 package</li>
</ul>
| 2,072
|
<p>I am looking for a solution to export Shared Outlook Calendars (yes, I'm using exchange server and yes I can copy calendar to my local folders, which would allow me to export. However, what if there are more than 50 calendars, which I need to export? Is there a way of automating the process?). </p>
<p>I am interested in using C# for accomplish this task. Has anyone ever tried to do that?</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/bb204119(EXCHG.80).aspx" rel="nofollow noreferrer">Exchange Web Services (EWS)</a> allows you to do this</p>
|
<p><a href="http://sourceforge.net/projects/outlook2ical/" rel="nofollow noreferrer"><H2>outlook2ical</h2></a> has a VBMacro to export outlook calendar to iCal format.</p>
<p>You might check if its worth the time to port to C#.</p>
| 7,710
|
<p>What would cause this effect, and how can it be avoided? </p>
<p>This is a PLA print, and it should look like <a href="http://www.thingiverse.com/thing:1560347" rel="noreferrer">this</a>. I tried 215 and 225°C and both had the same effect. An earlier similar print at 220°C was not as bad but it still had some catching- it seems hit and miss and not strongly related to extrusion temperature. </p>
<p>Outside: </p>
<p><a href="https://i.stack.imgur.com/nlRb8.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/nlRb8.jpg" alt="enter image description here"></a></p>
<p>Inside: </p>
<p><a href="https://i.stack.imgur.com/PQtTj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/PQtTj.jpg" alt="enter image description here"></a></p>
<p>I'm using a QIDI dual extruder printer with Makerware 2.2.2.89 software and these parameters: </p>
<p><a href="https://i.stack.imgur.com/6FJLL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6FJLL.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/Ge9ZK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ge9ZK.png" alt="enter image description here"></a></p>
<p>Speed is 60/80mm/s. </p>
|
<p>I think that you should first verify that you have the latest firmware and a newer version of MakerWare. I experienced similar issues around that version of MakerWare and remember a lot of print errors came with it.</p>
<p>I believe the MakerBot Dual firmware is somewhere around 7.? and is no longer in development.</p>
<p>MakerWare is also no longer in development as a standalone application and seems to have been ported over to the MakerBot Desktop. However I've personally found v2.4.1 to be substantially more stable than v2.2.</p>
<p>I have not tested it, but supposedly the new MakerBot Desktop (v3.10) is compatible with the Replicator Dual "Original". I had tried an earlier version of MakerBot Desktop and reverted back to MakerWare 2.4 because I ran into issues with connectivity. However, I'm not certain it was an issue with software so much as the exploding voltage regulator...</p>
<p>It might be best to give the new software a shot and/or try v2.4 of MakerWare, if you can find it.</p>
<p>Here's the link to the latest <a href="https://www.makerbot.com/download-desktop/" rel="nofollow noreferrer">MakerBot Desktop</a></p>
<p>Here's the release notes for <a href="https://support.makerbot.com/learn/makerbot-desktop-software/release-notes/makerbot-desktop-release-notes_13520" rel="nofollow noreferrer">MakerWare/MakerBot Desktop</a> v1.0-latest (v3.10+)</p>
|
<p>As pointed out in the comments, what you are seeing could very well be related to <em>lack of cooling</em>: </p>
<p>You may notice that the irregularity in the print become more and more pronounced the further up you see. I believe this happens because <em>the area that is printed is reduced gradually closer to the top</em>, which in turn will give each printed layer <em>less time to cool</em>. (The frequent revisits of the hot nozzle will not allow the top layer to cool naturally.)</p>
<p>This problem is very common when printing models with small cross-sections, and are typically solved by:</p>
<ul>
<li>Installing additional print cooling fans (cooling the actual print, not the hotend/heat sink)</li>
<li>Printing several items at the same time (to increase the cross-section)</li>
<li>Reducing print speed (gives more time to cool, but might not work for very small models)</li>
<li>Reduce printing temperature</li>
</ul>
<p>If you can, installing additional fans and/or printing multiple objects at the same time are probably the most efficient solutions - in my opinion. However, either method would be worth exploring. </p>
<p><strong>PS:</strong> When printing PLA, set your fans to full. ABS, on the other hand, does not like cooling.</p>
| 433
|
<p>I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?</p>
|
<p>IDLE provides Emacs keybindings without having to install other software. </p>
<ol>
<li>Open up the menu item Options -> Configure IDLE...</li>
<li>Go to Keys tab</li>
<li>In the drop down menu on the right
side of the dialog change the select
to "IDLE Classic Unix"</li>
</ol>
<p>It's not the true emacs key bindings but you get the basics like movement, saving/opening, ...</p>
|
<p><a href="http://www.python.org/doc/2.5/lib/module-readline.html" rel="nofollow noreferrer">'readline' module</a> supposedly provides Emacs like key bindings and even functionality. However, it is not available on Windows but on Unix. Therefore, this might be a viable solution if you are not using Windows.</p>
<pre><code>import readline
</code></pre>
<p>Since I am running IDLE on Windows it is unfortunately not an option for me.</p>
| 7,910
|
<p>The turntable support part in my microwave has broken. It is a three armed part, with small wheels at the end of each arm. </p>
<p><a href="https://i.stack.imgur.com/qza6i.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qza6i.jpg" alt="support part"></a></p>
<p>I'm confident I could print a replacement, and reuse the existing wheels (since they can be removed). </p>
<p>The heat of the food would be unlikely to conduct through to the PLA, but I'm concerned that it might get heated up by the microwave radiation. I can't find any clear information online about whether PLA absorbs microwaves, or if it is in any other way unsuitable for this. </p>
<p>Will this be a disaster, or should I give it a go?</p>
|
<p>I would say PLA itself should not be heated up by microwave. It's because microwave oven creates oscilations which excites water particles <a href="https://en.wikipedia.org/wiki/Microwave_oven" rel="nofollow">(see microwave explanation here)</a> <s>so assuming PLA doesn't contain water, it won't heat up.</s> <em>(removed to not mislead as the water is not only material which heats up by microwaves. Thanx to Tom van der Zanden for being vigilant)</em></p>
<p>But as usual, it's more complicated.</p>
<p>First. PLA can contain water as while producing it can be cooled down in water bath. Of course well made PLA will have as less water as possible as water has an influence on printing process.</p>
<p>Second. PLA is absorbing humidity so in fact it gets water inside right from the air. This unfortunately causes problems in microwave oven.</p>
<p>Water can be overheated and oven can overheat water above 100C. But even at 100C, PLA will not be hard anymore so your 3 arm star would "collapse". Wheels could get oval or start sticking to their axis.</p>
<p>Eventually if high power is delivered to very "wet" PLA, I think it can... well maybe not explode but break.</p>
<p>Here goes a test which shows it can be used to <a href="https://www.youtube.com/watch?v=LpRIhqxVgug" rel="nofollow">defrost things on PLA plate in microwave</a></p>
<p>But here Daan Snijders <a href="https://brazenartifice.wordpress.com/2011/11/02/reprap-3d-printers-pla-and-moisture-problems/" rel="nofollow">claims PLA gets soft in microwave during the test</a></p>
<p><strong>Will it be a disaster?</strong></p>
<p>In my opinion it will work only for short uses of MW. Heating up a glass of milk or so. But for longer sessions when there will be much more heat (out of heating dish) it won't work.</p>
<p><strong>SHORT TEST</strong></p>
<ul>
<li>20sec and 950W gives no effect on my sample (hotend cooling fan duct)</li>
<li>40sec and 950W caused the sample became a bit warm</li>
</ul>
<p>Inspite that it's not a good idea to run MW without "proper-absorber" this little test confirmes my suspisious - short sessions are ok.</p>
|
<p>Yes. You can.
I would think ABS would be a better idea, as it melts at a higher temp.
<a href="http://www.thingiverse.com/thing:385288" rel="nofollow">http://www.thingiverse.com/thing:385288</a></p>
| 368
|
<p>Do you know of any differences in handling HTML tags/properties in different browsers? For example, I once saw a page with a input tag with a maxlength field set to "2o". Firefox and Opera ignore the "o", and set the max length to 2, while Internet Explorer ignores the field altogether. Do you know of any more?</p>
<p>(Note: seeing as this will probably be a list, it would be great if the general name of the difference was in bold text, like: <strong>Different erratic value handling in tag properties</strong>)</p>
|
<p>Check out <a href="http://www.quirksmode.org/" rel="nofollow noreferrer">http://www.quirksmode.org/</a></p>
|
<p>The one that really annoys me is IE's broken document.getElementById javascript function - in most browsers this will give you something that has the id you specify, IE is happy to give you something that has the value in the name attribute, even if there is something later in the document with the id you asked for.</p>
| 3,454
|
<p>I know that CoreXY kinematics is very complex and hard to calculate for the firmware making it better to use a 32-bit board. For some reason, I can't use any 32-bit board. What problems will occur if I use an 8-bit board like Arduino Mega with a CoreXY 3D printer?</p>
<p>Everything that I wrote in this question about hard kinematic calculations was referenced from this video, <a href="https://www.youtube.com/watch?v=ySqj3gPqfrs" rel="nofollow noreferrer">HyperCube 3D Printer 8-Bit Speed Wall</a>, by Tech2c (the designer and builder of hypercube). After watching the video I doubted using an 8-bit board.</p>
|
<p>The tradeoffs in these systems are all about quality achievable at particular speed and acceleration profiles. If you really don't care about speed at all and want maximum accuracy, you probably want some type of Cartesian setup with no belts, only rigid lead screws which you can take to as fine a pitch as you like, and you can make all the parts as rigid as you like because mass doesn't matter (since acceleration doesn't).</p>
<p>Note however that extrusion accuracy is the limiting factor to quality and dimensional accuracy in even a half-decent printer. Rather than trying to design something with "perfect" spatial kinematics for quality from the outset, I think you should look at existing printers, figure out what about them isn't meeting your quality needs, and start from there to improve. You should also figure out what your speed constraints will be, even if they're only minimal.</p>
|
<p>The tradeoffs in these systems are all about quality achievable at particular speed and acceleration profiles. If you really don't care about speed at all and want maximum accuracy, you probably want some type of Cartesian setup with no belts, only rigid lead screws which you can take to as fine a pitch as you like, and you can make all the parts as rigid as you like because mass doesn't matter (since acceleration doesn't).</p>
<p>Note however that extrusion accuracy is the limiting factor to quality and dimensional accuracy in even a half-decent printer. Rather than trying to design something with "perfect" spatial kinematics for quality from the outset, I think you should look at existing printers, figure out what about them isn't meeting your quality needs, and start from there to improve. You should also figure out what your speed constraints will be, even if they're only minimal.</p>
| 1,718
|
<p>What are the available libraries for creating pretty charts and graphs in a Python application?</p>
|
<p>I'm the one supporting CairoPlot and I'm very proud it came up here.
Surely matplotlib is great, but I believe CairoPlot is better looking.
So, for presentations and websites, it's a very good choice.</p>
<p>Today I released version 1.1. If interested, check it out at <a href="http://linil.wordpress.com/2008/09/16/cairoplot-11/" rel="nofollow noreferrer">CairoPlot v1.1</a></p>
<p>EDIT: After a long and cold winter, CairoPlot is being developed again. Check out the new version on <a href="https://github.com/rodrigoaraujo01/cairoplot" rel="nofollow noreferrer">GitHub</a>.</p>
|
<p>You could also consider <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">google charts</a>.</p>
<p>Not technically a python API, but you can use it from python, it's reasonably fast to code for, and the results tend to look nice. If you happen to be using your plots online, then this would be an even better solution.</p>
| 7,589
|
<p>I'm looking for a library to handle <a href="http://en.wikipedia.org/wiki/ICalendar" rel="noreferrer">iCalendar</a> data in Java.</p>
<p>Open source, well-documented implementations with a good object model are preferred. iCal parsing capabilities are less important to me, but still nice to have.</p>
<p>Does anyone have any recommendations?</p>
|
<p>I had limited success with <a href="https://github.com/ical4j/ical4j" rel="noreferrer">iCal4j</a> (<a href="http://ical4j.sourceforge.net/introduction.html" rel="noreferrer">intro</a>) on a project last year.</p>
<p>It seems to be a fairly popular choice for ical work in the java community. </p>
<p>If I remember correctly the API can be slightly confusing at first glance.
However It's pretty solid in the long run.</p>
<p>Good luck,
Brian </p>
|
<p>A challenger appears! Please give <a href="https://github.com/mangstadt/biweekly">biweekly</a> a try. I'm looking for lots of feedback on how it can be improved.</p>
| 5,402
|
<p>I'm working on a WinForm .Net application with the basic UI that includes toolbar buttons, menu items and keystrokes that all initiate the same underlying code. Right now the event handlers for each of these call a common method to perform the function.</p>
<p>From what I've read this type of action could be handled by the <a href="http://www.dofactory.com/Patterns/PatternCommand.aspx" rel="noreferrer">Command design pattern</a> with the additional benefit of automatically enabling/disabling or checking/unchecking the UI elements.</p>
<p>I've been searching the net for a good example project, but really haven't found one. Does anyone have a good example that can be shared?</p>
|
<p>Let's first make sure we know what the Command pattern is:</p>
<blockquote>
<p>Command pattern encapsulates a request
as an object and gives it a known
public interface. Command Pattern
ensures that every object receives its
own commands and provides a decoupling
between sender and receiver. A sender
is an object that invokes an
operation, and a receiver is an object
that receives the request and acts on
it.</p>
</blockquote>
<p>Here's an example for you. There are many ways you can do this, but I am going to take an interface base approach to make the code more testable for you. I am not sure what language you prefer, but I am writing this in C#.</p>
<p>First, create an interface that describes a Command.</p>
<pre><code>public interface ICommand
{
void Execute();
}
</code></pre>
<p>Second, create command objects that will implement the command interface.</p>
<pre><code>public class CutCommand : ICommand
{
public void Execute()
{
// Put code you like to execute when the CutCommand.Execute method is called.
}
}
</code></pre>
<p>Third, we need to setup our invoker or sender object.</p>
<pre><code>public class TextOperations
{
public void Invoke(ICommand command)
{
command.Execute();
}
}
</code></pre>
<p>Fourth, create the client object that will use the invoker/sender object.</p>
<pre><code>public class Client
{
static void Main()
{
TextOperations textOperations = new TextOperations();
textOperation.Invoke(new CutCommand());
}
}
</code></pre>
<p>I hope you can take this example and put it into use for the application you are working on. If you would like more clarification, just let me know.</p>
|
<p>I can't help you with example link, but can provide example by myself.</p>
<p>1) Define ICommand interface:</p>
<pre><code>public interface ICommand {
void Do();
void Undo();
}
</code></pre>
<p>2) Do your ICommand implementations for concrete commands, but also define abstract base class for them:</p>
<pre><code>public abstract class WinFormCommand : ICommand {
}
</code></pre>
<p>3) Create command invoker:</p>
<pre><code>public interface ICommandInvoker {
void Invoke(ICommand command);
void ReDo();
void UnDo();
}
public interface ICommandDirector {
void Enable(ICommand);
void Disable(ICommand);
}
public class WinFormsCommandInvoker : ICommandInvoker, ICommandDirector {
private readonly Dictionary<ICommand, bool> _commands;
private readonly Queue<ICommand> _commandsQueue;
private readonly IButtonDirector _buttonDirector;
// you can define additional queue for support of ReDo operation
public WinFormsCommandInvoker(ICommandsBuilder builder, IButtonDirector buttonDirector) {
_commands = builder.Build();
_buttonDirector = buttonDirector;
_commandsQueue = new Queue<ICommand>();
}
public void Invoke(ICommand command) {
command.Do();
__commandsQueue.Enqueue(command);
}
public void ReDo() {
//you can implement this using additional queue
}
public void UnDo() {
var command = __commandsQueue.Dequeue();
command.Undo();
}
public void Enable(ICommand command) {
_commands.[command] = true;
_buttonDirector.Enable(command);
}
public void Disable(ICommand command) {
_commands.[command] = false;
_buttonDirector.Disable(command);
}
}
</code></pre>
<p>4) Now you can implement your ICommandsBuilder, IButtonDirector and add other interfaces such as ICheckBoxDirector to WinFormsCommandInvoker.</p>
| 3,582
|
<p>Is there a good way to adjust the size of a <code>UITextView</code> to conform to its content? Say for instance I have a <code>UITextView</code> that contains one line of text:</p>
<pre><code>"Hello world"
</code></pre>
<p>I then add another line of text:</p>
<pre><code>"Goodbye world"
</code></pre>
<p>Is there a good way in Cocoa Touch to get the <code>rect</code> that will hold all of the lines in the text view so that I can adjust the parent view accordingly?</p>
<p>As another example, look at the notes' field for events in the Calendar application - note how the cell (and the <code>UITextView</code> it contains) expands to hold all lines of text in the notes' string.</p>
|
<p>This works for both iOS 6.1 and iOS 7:</p>
<pre><code>- (void)textViewDidChange:(UITextView *)textView
{
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
textView.frame = newFrame;
}
</code></pre>
<p>Or in Swift (Works with Swift 4.1 in iOS 11)</p>
<pre><code>let fixedWidth = textView.frame.size.width
let newSize = textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.greatestFiniteMagnitude))
textView.frame.size = CGSize(width: max(newSize.width, fixedWidth), height: newSize.height)
</code></pre>
<p>If you want support for iOS 6.1 then you should also:</p>
<pre><code>textview.scrollEnabled = NO;
</code></pre>
|
<p>Not sure why people always over complicate things:
here it is :</p>
<pre><code>- (void)textViewDidChange:(UITextView *)textView{ CGRect frame = textView.frame;
CGFloat height = [self measureHeightOfUITextView:textView];
CGFloat insets = textView.textContainerInset.top + textView.textContainerInset.bottom;
height += insets;
frame.size.height = height;
if(frame.size.height > textView.frame.size.height){
CGFloat diff = frame.size.height - textView.frame.size.height;
textView.frame = CGRectMake(5, textView.frame.origin.y - diff, textView.frame.size.width, frame.size.height);
}
else if(frame.size.height < textView.frame.size.height){
CGFloat diff = textView.frame.size.height - frame.size.height;
textView.frame = CGRectMake(5, textView.frame.origin.y + diff, textView.frame.size.width, frame.size.height);
}
[textView setNeedsDisplay];
}
</code></pre>
| 7,325
|
<p>Is it possible to to take a screenshot of a webpage with JavaScript and then submit that back to the server?</p>
<p>I'm not so concerned with browser security issues. etc. as the implementation would be for <a href="http://msdn.microsoft.com/en-us/library/ms536471(vs.85).aspx" rel="noreferrer">HTA</a>. But is it possible?</p>
|
<p>Google is doing this in Google+ and a talented developer reverse engineered it and produced <a href="http://html2canvas.hertzen.com/" rel="noreferrer">http://html2canvas.hertzen.com/</a> . To work in IE you'll need a canvas support library such as <a href="http://excanvas.sourceforge.net/" rel="noreferrer">http://excanvas.sourceforge.net/</a></p>
|
<p>A great solution for screenshot taking in Javascript is the one by <a href="https://grabz.it" rel="nofollow noreferrer">https://grabz.it</a>. </p>
<p>They have a flexible and simple-to-use screenshot API which can be used by any type of JS application.</p>
<p>If you want to try it, at first you should get the authorization <a href="https://grabz.it/api/#Key" rel="nofollow noreferrer">app key + secret</a> and the <a href="https://grabz.it/api/javascript/download.ashx" rel="nofollow noreferrer">free SDK</a></p>
<p>Then, in your app, the implementation steps would be:</p>
<pre><code>// include the grabzit.min.js library in the web page you want the capture to appear
<script src="grabzit.min.js"></script>
//use the key and the secret to login, capture the url
<script>
GrabzIt("KEY", "SECRET").ConvertURL("http://www.google.com").Create();
</script>
</code></pre>
<p>Screenshot could be customized with different <a href="https://grabz.it/api/javascript/parameters.aspx" rel="nofollow noreferrer">parameters</a>. For example:</p>
<pre><code>GrabzIt("KEY", "SECRET").ConvertURL("http://www.google.com",
{"width": 400, "height": 400, "format": "png", "delay", 10000}).Create();
</script>
</code></pre>
<p>That's all.
Then simply wait a short while and the image will automatically appear at the bottom of the page, without you needing to reload the page.</p>
<p>There are other functionalities to the screenshot mechanism which you can explore <a href="https://grabz.it/api/javascript/" rel="nofollow noreferrer">here</a>.</p>
<p>It's also possible to save the screenshot locally. For that you will need to utilize GrabzIt server side API. For more info check the detailed guide <a href="https://grabz.it/support/?uniqueId=SaveJavaScriptScreenshot" rel="nofollow noreferrer">here</a>.</p>
| 8,532
|
<p>Is there a way to access file system info via some type of Windows API? If not what other methods are available to a user mode developer?</p>
|
<p>Not very clean, but you can use <code>DeviceIoControl()</code>
Open volume as a file, pass resulting handle to <code>DeviceIoControl()</code> together with control code. Check MSDN for control codes, there is something like "read journal record".</p>
|
<p>In another post, someone recommended this : <a href="http://www.microsoft.com/msj/0999/journal/journal.aspx" rel="nofollow noreferrer">Keeping an Eye on Your NTFS Drives: the Windows 2000 Change Journal Explained</a>.</p>
<p>It explains how to use the NTFS Filesystem with C++ through Windows 2000.
The implementation might have changed.</p>
| 8,082
|
<p>When java was young, people were excited about writing applets. They were cool and popular, for a little while. Now, I never see them anymore. Instead we have flash, javascript, and a plethora of other web app-building technologies.</p>
<p>Why don't sites use java applets anymore?</p>
<p>I'm also curious: historically, why do you think this occurred? What could have been done differently to keep Java applets alive?</p>
|
<p>I think Java applets were overshadowed by Flash and ActionScript (pun unintended), being much easier to use for what Java Applets were being used at the time (animations + stateful applications). </p>
<p>Flash's success in this respect in turn owes to its much smaller file sizes, as well as benefiting from the Sun vs. Microsoft suit that resulted in Microsoft removing the MSJVM from Internet Explorer, at a time of Netscape's demise and IE's heavy dominance.</p>
|
<p>The JVM is very widespread, especially in the coorporate world, at least where I've worked, there was always a JVM installed.</p>
<p>I'm currently working on a Java Applet, but in general, I would never an applet unless I had to. But then again, I wouldn't use Flash or Silverlight, either. Applets have a slow load time, and look out of place in webpages. Also, Macromedia/Adobe have outmarketed the good ol' applets.</p>
| 7,444
|
<p>I'm having trouble reading a "chunked" response when using a StreamReader to read the stream returned by GetResponseStream() of a HttpWebResponse:</p>
<pre><code>// response is an HttpWebResponse
StreamReader reader = new StreamReader(response.GetResponseStream());
string output = reader.ReadToEnd(); // throws exception...
</code></pre>
<p>When the <code>reader.ReadToEnd()</code> method is called I'm getting the following System.IO.IOException: <strong>Unable to read data from the transport connection: The connection was closed.</strong></p>
<p>The above code works just fine when server returns a "non-chunked" response.</p>
<p>The only way I've been able to get it to work is to use HTTP/1.0 for the initial request (instead of HTTP/1.1, the default) but this seems like a lame work-around.</p>
<p>Any ideas?</p>
<hr>
<p>@Chuck</p>
<p>Your solution works pretty good. It still throws the same IOExeception on the last Read(). But after inspecting the contents of the StringBuilder it looks like all the data has been received. So perhaps I just need to wrap the Read() in a try-catch and swallow the "error".</p>
|
<p>Haven't tried it this with a "chunked" response but would something like this work? </p>
<pre><code>StringBuilder sb = new StringBuilder();
Byte[] buf = new byte[8192];
Stream resStream = response.GetResponseStream();
string tmpString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if(count != 0)
{
tmpString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tmpString);
}
}while (count > 0);
</code></pre>
|
<p>I've had the same problem (which is how I ended up here :-). Eventually tracked it down to the fact that the chunked stream wasn't valid - the final zero length chunk was missing. I came up with the following code which handles both valid and invalid chunked streams.</p>
<pre><code>using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
StringBuilder sb = new StringBuilder();
try
{
while (!sr.EndOfStream)
{
sb.Append((char)sr.Read());
}
}
catch (System.IO.IOException)
{ }
string content = sb.ToString();
}
</code></pre>
| 3,771
|
<p>This is an open-ended question. What approaches should I consider?</p>
|
<p>There are some parallel extensions to .NET that are currently in testing and available at Microsoft's <a href="http://msdn.microsoft.com/en-us/concurrency/default.aspx" rel="noreferrer">Parallel Computing Developer Center</a>. They have a few interesting items that you would expect like Parallel foreach and a parallel version of LINQ called PLINQ. Some of the best information about the extensions is on <a href="http://channel9.msdn.com/tags/Parallel+Extensions/" rel="noreferrer">Channel 9</a>.</p>
|
<p>There are many options and the best solution will depend on the nature of the problem you are trying to solve. If you are trying to solve an <a href="http://en.wikipedia.org/wiki/Embarrassingly_parallel" rel="nofollow noreferrer">embarassingly parallel</a> problem then dividing and parallelising the tasks will be trivial. In that case the challenge will come in distributing and managing the data used. </p>
<p>Some suggestions would be:</p>
<ul>
<li><a href="http://www.zeroc.com/icegrid/index.html" rel="nofollow noreferrer">ICE Grid</a> which has bindings for .Net and other common languages</li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B24C3708-EEFF-4055-A867-19B5851E7CD2&displaylang=en" rel="nofollow noreferrer">Velocity</a> which is Microsoft's version of Oracle (Tangersol) Coherence</li>
<li>The forthcoming HPC offering from Microsoft <a href="http://www.microsoft.com/HPC/" rel="nofollow noreferrer">Compute Cluster Server</a></li>
<li><a href="http://www.datasynapse.com/" rel="nofollow noreferrer">Data Synapse Grid Server</a></li>
</ul>
| 2,378
|
<p>You should be able to create a generic form:</p>
<pre><code>public partial class MyGenericForm<T> :
Form where T : class
{
/* form code */
public List<T> TypedList { get; set; }
}
</code></pre>
<p>Is valid C#, and compiles. However the designer won't work and the form will throw a runtime exception if you have any images stating that it cannot find the resource.</p>
<p>I think this is because the windows forms designer assumes that the resources will be stored under the simple type's name.</p>
|
<p>Yes you can! Here's a blog post I made a while ago with the trick:</p>
<p><a href="http://www.madprops.org/blog/designing-generic-forms/" rel="noreferrer">Designing Generic Forms</a></p>
<p>Edit: Looks like you're already doing it this way. This method works fine so I wouldn't consider it too hacky.</p>
|
<p>I have a hack to workaround this, which works but isn't ideal:</p>
<p>Add a new class to the project that inherits the form with its simple name.</p>
<pre><code>internal class MyGenericForm:
MyGenericForm<object> { }
</code></pre>
<p>This means that although the designer is still wrong the expected simple type (i.e without <code><></code>) is still found.</p>
| 3,210
|
<p>I have a JavaScript method that I need to run on one of my pages, in particular, the <code>onresize</code> event. </p>
<p>However, I don't see how I can set that event from my content page. I wish I could just put it on my master page, but I don't have the need for the method to be called on all pages that use that master page.</p>
<p>Any help would be appreciated.</p>
|
<p>Place the following in your content page:</p>
<pre><code><script type="text/javascript">
// here is a cross-browser compatible way of connecting
// handlers to events, in case you don't have one
function attachEventHandler(element, eventToHandle, eventHandler) {
if(element.attachEvent) {
element.attachEvent(eventToHandle, eventHandler);
} else if(element.addEventListener) {
element.addEventListener(eventToHandle.replace("on", ""), eventHandler, false);
} else {
element[eventToHandle] = eventHandler;
}
}
attachEventHandler(window, "onresize", function() {
// the code you want to run when the browser is resized
});
</script>
</code></pre>
<hr>
<p>That code should give you the basic idea of what you need to do. Hopefully you are using a library that already has code to help you write up event handlers and such.</p>
|
<p>How about use code like the following in your Content Page (C#)?</p>
<pre><code>Page.ClientScript.RegisterStartupScript(this.GetType(), "resizeMyPage", "window.onresize=function(){ resizeMyPage();}", true);
</code></pre>
<p>Thus, you could have a <code>resizeMyPage</code> function defined somewhere in the Javascript and it would be run whenever the browser is resized!</p>
| 5,334
|
<p>I have a self referencing Categories table. Each Category has a CategoryID, ParentCategoryID, CategoryName, etc. And each category can have any number of sub categories, and each of those sub categories can have any number of sub categories, and so and and so forth. So basically the tree can be X levels deep.</p>
<p>Then Products are associated to leaf (sub) Categories. Is there a way to get all the Products for any given Category (which would be all the products associated to all its leaf descendants) using LINQ to SQL? </p>
<p>This feels like a recursive problem. Is it better to used a Stored Procedure instead?</p>
|
<p>I don't think linq-to-sql has a good answer to this problem. Since you are using sql server 2005 you can use CTEs to do hierarchical queries. Either a stored procedure or an inline query (using DataContext.ExecuteQuery) will do the trick. </p>
|
<p>The performant approach is to create an insert/modify/delete trigger which maintains an entirely different table which contains node-ancestor pairs for all ancestors of all nodes. This way, the lookup is O(N).</p>
<p>To use it for getting all products belonging to a node and all of its descendants, you can just select all category nodes which have your target node as an ancestor. After this, you simply select any products belonging to any of these categories.</p>
| 6,470
|
<p>I've got a menu in Python. That part was easy. I'm using <code>raw_input()</code> to get the selection from the user. </p>
<p>The problem is that <code>raw_input</code> (and input) require the user to press <kbd>Enter</kbd> after they make a selection. Is there any way to make the program act immediately upon a keystroke? Here's what I've got so far:</p>
<pre><code>import sys
print """Menu
1) Say Foo
2) Say Bar"""
answer = raw_input("Make a selection> ")
if "1" in answer: print "foo"
elif "2" in answer: print "bar"
</code></pre>
<p>It would be great to have something like</p>
<pre><code>print menu
while lastKey = "":
lastKey = check_for_recent_keystrokes()
if "1" in lastKey: #do stuff...
</code></pre>
|
<p><strong>On Windows:</strong></p>
<pre><code>import msvcrt
answer=msvcrt.getch()
</code></pre>
|
<p>The reason msvcrt fails in IDLE is because IDLE is not accessing the library that runs msvcrt. Whereas when you run the program natively in cmd.exe it works nicely. For the same reason that your program blows up on Mac and Linux terminals.</p>
<p>But I guess if you're going to be using this specifically for windows, more power to ya.</p>
| 2,409
|
<p>I'm building a C++/MFC program in a multilingual environment. I have one main (national) language and three international languages. Every time I add a feature to the program I have to keep the international languages up-to-date with the national one. The resource editor in Visual Studio is not very helpful because I frequently end up leaving a string, dialog box, etc., untranslated.</p>
<p>I wonder if you guys know of a program that can edit resource (.rc) files and</p>
<ul>
<li>Build a file that includes only the strings to be translated and their respective IDs and accepts the same (or similar) file in another language (this would be helpful since usually the translation is done by someone else), or</li>
<li>Handle the translations itself, allowing to view the same string in different languages at the same time.</li>
</ul>
|
<p>In my experience, internationalization requires a little more than translating strings. Many strings when translated, require more space on a dialog. Because of this it's useful to be able to customize the dialogs for each language. Otherwise you have to create dialogs with extra space for the translated strings which then looks less than optimal when displayed in English.</p>
<p>Quite a while back I was using a translation tool for an MFC application but the company that produced the software stopped selling it. When I tried to find a reasonably priced replacement I did not find one.</p>
|
<p><a href="http://resxcrunch.com" rel="nofollow noreferrer">ResxCrunch</a> will be out soon, it will edit multiple resource files in multiple languages in one single table.</p>
| 7,517
|
<p>On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine. </p>
|
<p>My understanding is that it is approximately the following from another <a href="https://stackoverflow.com/questions/24066/what-formula-should-be-used-to-determine-hot-questions">Jeff Atwood</a> post</p>
<pre><code>t = (time of entry post) - (Dec 8, 2005)
x = upvotes - downvotes
y = {1 if x > 0, 0 if x = 0, -1 if x < 0)
z = {1 if x < 1, otherwise x}
log(z) + (y * t)/45000
</code></pre>
|
<p><a href="http://www.mt-soft.com.ar/wordpress/wp-content/plugins/wp-o-matic/cache/0ad4d_reddit_cf_algorithm.png">alt text http://www.mt-soft.com.ar/wordpress/wp-content/plugins/wp-o-matic/cache/0ad4d_reddit_cf_algorithm.png</a></p>
| 5,232
|
<p>I would like to have a reference for the pros and cons of using include <strong>files vs objects(classes)</strong> when developing PHP applications.</p>
<p>I know I would benefit from having one place to go for this answer...I have a few opinions of my own but I look forward to hearing others.</p>
<p><strong>A Simple Example:</strong></p>
<p>Certain pages on my site are only accessible to logged in users. I have two options for implementation (there are others but let's limit it to these two)</p>
<ol>
<li><p><em>Create an authenticate.php file and include it on every page. It holds the logic for authentication.</em></p></li>
<li><p><em>Create a user object, which has an authenticate function, reference the object for authentication on every page.</em> </p></li>
</ol>
<p><strong>Edit</strong>
I'd like to see some way weigh the benefits of one over the other.
My current (and weak reasons) follow:</p>
<p>Includes - Sometimes a function is just easier/shorter/faster to call
Objects - Grouping of functionality and properties leads for longer term maintenance.</p>
<p><strong>Includes</strong> - Less code to write (no constructor, no class syntax) call me lazy but this is true.</p>
<p><strong>Objects</strong> - Force formality and a single approach to functions and creation. </p>
<p><strong>Includes</strong> - Easier for a novice to deal with
Objects - Harder for novices, but frowned upon by professionals.</p>
<p>I look at these factors at the start of a project to decide if I want to do includes or objects.
Those are a few pros and cons off the top of my head.</p>
|
<p>These are not really opposite choices. You will have to include the checking code anyway. I read your question as procedural programming vs. OO programming.</p>
<p>Writing a few lines of code, or a function, and including it in your page header was how things were done in PHP3 or PHP4. It's simple, it works (that's how we did it in <a href="http://www.oscommerce.com/" rel="noreferrer">osCommerce</a>, for example, an eCommerce PHP application).</p>
<p>But it's not easy to maintain and modify, as many developers can confirm.</p>
<p>In PHP5 you'd write a user object which will carry its own data and methods for authentication. Your code will be clearer and easier to maintain as everything having to do with users and authentication will be concentrated in a single place.</p>
|
<p>Can you be a bit more specific? For the example you give you need to use include in both ways.
In case 1 you only include a file, in case 2 you need to include the class file (for instance user.class.php) to allow instantiation of the User class.</p>
<p>It depends how the rest of the application is built, is it OO? Use OO.</p>
| 4,258
|
<p>What Windows code editors allow the use of <a href="https://en.wikipedia.org/wiki/Tab_stop#Elastic_tabstops" rel="nofollow noreferrer">elastic tabstops</a>, either natively or through a plugin?</p>
<p>I know about a gedit plugin, but it only works on Linux.</p>
|
<p><a href="http://code-browser.sourceforge.net/news.html#link" rel="noreferrer">Code Browser</a> may be the first for windows. I would love to see this feature as a plugin for other editors as well.</p>
|
<p>The problem is that only a few toolkits/platforms have text widgets that offer the ability to set non-uniform tabstops on different lines. To my knowledge, those toolkits/platforms are Java Swing (used by the demo on the elastic tabstops page), GTK (used by Gedit and the Gedit plugin), and apparently the new version of Visual Studio (VS 2010).</p>
<p>Expect to (eventually) see more developments on all of those platforms.</p>
| 4,826
|
<p>What would be the best algorithm for finding a number that occurs only once in a list which has all other numbers occurring exactly twice.</p>
<p>So, in the list of integers (lets take it as an array) each integer repeats exactly twice, except one. To find that one, what is the best algorithm.</p>
|
<p>The fastest (O(n)) and most memory efficient (O(1)) way is with the XOR operation.</p>
<p>In C:</p>
<pre><code>int arr[] = {3, 2, 5, 2, 1, 5, 3};
int num = 0, i;
for (i=0; i < 7; i++)
num ^= arr[i];
printf("%i\n", num);
</code></pre>
<p>This prints "1", which is the only one that occurs once.</p>
<p>This works because the first time you hit a number it marks the num variable with itself, and the second time it unmarks num with itself (more or less). The only one that remains unmarked is your non-duplicate.</p>
|
<p>You could simply put the elements in the set into a hash until you find a collision. In ruby, this is a one-liner.</p>
<pre><code>def find_dupe(array)
h={}
array.detect { |e| h[e]||(h[e]=true; false) }
end
</code></pre>
<p>So, <code>find_dupe([1,2,3,4,5,1])</code> would return 1. </p>
<p>This is actually a common "trick" interview question though. It is normally about a list of consecutive integers with one duplicate. In this case the interviewer is often looking for you to use the Gaussian sum of <em>n</em>-integers trick e.g. <code>n*(n+1)/2</code> subtracted from the actual sum. The textbook answer is something like this. </p>
<pre><code>def find_dupe_for_consecutive_integers(array)
n=array.size-1 # subtract one from array.size because of the dupe
array.sum - n*(n+1)/2
end
</code></pre>
| 5,561
|
<p>I found this in Handbook of Compliant Mechanisms (2013), page 162, or at the start of "Chapter 11, Elements of Mechanisms," subsection 11.1.2 Revolute</p>
<p>I don't understand how it's supposed to go from 1 to 2 when b rotates around c.</p>
<p>The description reads:</p>
<blockquote>
<p>This element is a rotational flexural pivot constructed by three
curved beams to achieve a large range of motion. Theoretically, this
element will rotate without axial-drift motion, because of the
symmetric arrangement about the axis.</p>
<p>(1) Rigid body a is fixed. Rigid body b rotates about c-axis.<br />
(2) Deformed configuration<br />
(3) Photo of the device.</p>
</blockquote>
<p>It's unclear which part of the beam is attached to what. I can understand how one curved beam could switch its curvature (in general, like they do in bi-stable latches), but I don't see how they could both at the end of of the rotation end up curved in a way that's opposite to how they started.</p>
<p>How could c2/c3 go from the configuration in 1 to the configuration in 2 ?</p>
<p>Or could they be two different iterations of the same idea ? I can see how (1) or (2) would resist rotation of c around b, and snap it back to its original position. The text claims (2) is the deformed configuration though. I can also see how (1) with just c1, c3, c5 would deform to (1) with c0, c2, c4 if (b) was turning anti clockwise.</p>
<p>Also, what would be an ideal material to print this kind of compliant mechanism ?</p>
<p><a href="https://i.stack.imgur.com/f9Vka.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f9Vka.jpg" alt="enter image description here" /></a></p>
|
<p>The picture looks as if there is a printed back surface to which the central part is attached. This can not be the case, since otherwise the curved members would not be able to flex. Everything inside the outer ring must be detached from the back shell.</p>
<p>Like all couplers, especially flexible couplers, there is a limit to the amount of torque the coupler can transmit. Within the elastic limits of the material this looks like a good design, and a good match for 3D printing. The forces are along the layers, not across the layers.</p>
<p>This looks like a good design for a rotary coupler. I'm resisting calling it a "shaft" coupler since neither side is equipped with any connection to a shaft. One could modify the design to have a larger central hub with a shaft hole (and set screw(s)). As it is, there is an implied method to hold the outer ring, and a fairly explicit three-pin adapter to drop into the open slots in the arms which connect to the center.</p>
<p>I would use ABS rather than PLA, although it depends on the stiffness you require and ability to sustein abuse. PLA is stiller than ABS, while ABS, within the elastic limits, is more compliant. I am not confident that either of these plastics would stand up to thousands of millions of flexures.</p>
<p>I would prefer to print this of TPU or Nylon. Both of these are tougher than ABS and PLA. They withstand greater flex with fewer problems with micro cracks and degradation. I have printed another shaft coupler of TPU, and it was both compliant and still.</p>
<p>It isn't possible to really nail down a material without knowing the application.</p>
<p>As to your question about one example being a transform of the other, I don't thing they are. The A and B drawings are similar in function, but are not stressed and unstressed versions of the same part. Either will work as a coupler.</p>
|
<p>I would try and print it in PLA because it is quite flexible.
ABS is harder in my experience and breaks more easily.
If you are able to print PET, you should also try that for the same reasons.
There might also be better materials I've never heard of, also please leave a comment if I'm wrong with anything.</p>
| 1,711
|
<p>What is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is:</p>
<pre><code>git log $(git merge-base HEAD branch)..branch
</code></pre>
<p>The documentation for <a href="http://git-scm.com/docs/git-diff" rel="noreferrer">git-diff</a> indicates that <code>git diff A...B</code> is equivalent to <code>git diff $(git-merge-base A B) B</code>. On the other hand, the documentation for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html" rel="noreferrer">git-rev-parse</a> indicates that <code>r1...r2</code> is defined as <code>r1 r2 --not $(git merge-base --all r1 r2)</code>.</p>
<p>Why are these different? Note that <code>git diff HEAD...branch</code> gives me the diffs I want, but the corresponding git log command gives me more than what I want.</p>
<p>In pictures, suppose this:</p>
<pre>
x---y---z---branch
/
---a---b---c---d---e---HEAD
</pre>
<p>I would like to get a log containing commits x, y, z.</p>
<ul>
<li><code>git diff HEAD...branch</code> gives these commits</li>
<li>however, <code>git log HEAD...branch</code> gives x, y, z, c, d, e.</li>
</ul>
|
<p>In the context of a revision list, <code>A...B</code> is how <code>git-rev-parse</code> defines it. git-log takes a revision list. <code>git-diff</code> does not take a list of revisions - it takes one or two revisions, and has defined the <code>A...B</code> syntax to mean how it's defined in the <code>git-diff</code> manpage. If <code>git-diff</code> did not explicitly define <code>A...B</code>, then that syntax would be invalid. Note that the <code>git-rev-parse</code> manpage describes <code>A...B</code> in the "Specifying Ranges" section, and everything in that section is only valid in situations where a revision range is valid (i.e. when a revision list is desired).</p>
<p>To get a log containing just x, y, and z, try <code>git log HEAD..branch</code> (two dots, not three). This is identical to <code>git log branch --not HEAD</code>, and means all commits on branch that aren't on HEAD.</p>
|
<p>With Git 2.30 (Q1 2021), "git diff A...B(man)" learned "git diff --merge-base A B(man), which is a longer short-hand to say the same thing.</p>
<p>Thus you can do this using <code>git diff --merge-base <branch> HEAD</code>. This should be equivalent to <code>git diff <branch>...HEAD</code> but without the confusion of having to use range-notation in a diff.</p>
| 7,708
|
<p>When I create a new project (or even when I edit the Sample Project) there is no way to add Description to the project.</p>
<p>Or am I blind to the obvious?</p>
|
<p>There's no such thing as a project description, really. There's a column in the Projects page which is used so you can see which project is the default, built-in inbox, and we couldn't think of anything better to put as the column header for that column.</p>
|
<p>The description is mostly for system projects, like e-mail inbox.</p>
<p>You might be able to set one in the underlying DB table.</p>
| 3,545
|
<p>I'm working on an app that grabs and installs a bunch of updates off an an external server, and need some help with threading. The user follows this process:</p>
<ul>
<li>Clicks button</li>
<li>Method checks for updates, count is returned.</li>
<li>If greater than 0, then ask the user if they want to install using MessageBox.Show().</li>
<li>If yes, it runs through a loop and call BeginInvoke() on the run() method of each update to run it in the background.</li>
<li>My update class has some events that are used to update a progress bar etc. </li>
</ul>
<p>The progress bar updates are fine, but the MessageBox is not fully cleared from the screen because the update loop starts right after the user clicks yes (see screenshot below).</p>
<ul>
<li>What should I do to make the messagebox disappear instantly before the update loop starts?</li>
<li>Should I be using Threads instead of BeginInvoke()?</li>
<li>Should I be doing the initial update check on a separate thread and calling MessageBox.Show() from that thread?</li>
</ul>
<p><strong>Code</strong></p>
<pre><code>// Button clicked event handler code...
DialogResult dlgRes = MessageBox.Show(
string.Format("There are {0} updates available.\n\nInstall these now?",
um2.Updates.Count), "Updates Available",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2
);
if (dlgRes == DialogResult.Yes)
{
ProcessAllUpdates(um2);
}
// Processes a bunch of items in a loop
private void ProcessAllUpdates(UpdateManager2 um2)
{
for (int i = 0; i < um2.Updates.Count; i++)
{
Update2 update = um2.Updates[i];
ProcessSingleUpdate(update);
int percentComplete = Utilities.CalculatePercentCompleted(i, um2.Updates.Count);
UpdateOverallProgress(percentComplete);
}
}
// Process a single update with IAsyncResult
private void ProcessSingleUpdate(Update2 update)
{
update.Action.OnStart += Action_OnStart;
update.Action.OnProgress += Action_OnProgress;
update.Action.OnCompletion += Action_OnCompletion;
//synchronous
//update.Action.Run();
// async
IAsyncResult ar = this.BeginInvoke((MethodInvoker)delegate() { update.Action.Run(); });
}
</code></pre>
<p><strong>Screenshot</strong></p>
<p><a href="http://www.flickr.com/photos/brianly/2760435228/" rel="nofollow noreferrer" title="Windows Mobile Bug by BrianLy, on Flickr"><img src="https://farm4.static.flickr.com/3043/2760435228_1af7dbf365_o.gif" width="233" height="266" alt="Windows Mobile Bug" /></a></p>
|
<p>Your UI isn't updating because all the work is happening in the user interface thread.
Your call to: </p>
<pre><code>this.BeginInvoke((MethodInvoker)delegate() {update.Action.Run(); })
</code></pre>
<p>is saying invoke update.Action.Run() on the thread that created "this" (your form), which is the user interface thread.</p>
<pre><code>Application.DoEvents()
</code></pre>
<p>will indeed give the UI thread the chance to redraw the screen, but I'd be tempted to create new delegate, and call BeginInvoke on that. </p>
<p>This will execute the update.Action.Run() function on a seperate thread allocated from the thread pool. You can then keep checking the IAsyncResult until the update is complete, querying the update object for its progress after every check (because you can't have the other thread update the progress bar/UI), then calling Application.DoEvents(). </p>
<p>You also are supposed to call EndInvoke() afterwards otherwise you may end up leaking resources</p>
<p>I would also be tempted to put a cancel button on the progress dialog, and add a timeout, otherwise if the update gets stuck (or takes too long) then your application will have locked up forever.</p>
|
<p>Have you tried putting a </p>
<pre><code>Application.DoEvents()
</code></pre>
<p>in here</p>
<pre><code>if (dlgRes == DialogResult.Yes)
{
Application.DoEvents();
ProcessAllUpdates(um2);
}
</code></pre>
| 3,134
|
<p>I was asked this question during an interview. They're both O(nlogn) and yet most people use Quicksort instead of Mergesort. Why is that?</p>
|
<p>Quicksort has O(<i>n</i><sup>2</sup>) worst-case runtime and O(<i>n</i>log<i>n</i>) average case runtime. However, it’s superior to merge sort in many scenarios because many factors influence an algorithm’s runtime, and, when taking them all together, quicksort wins out.</p>
<p>In particular, the often-quoted runtime of sorting algorithms refers to the number of comparisons or the number of swaps necessary to perform to sort the data. This is indeed a good measure of performance, especially since it’s independent of the underlying hardware design. However, other things – such as locality of reference (i.e. do we read lots of elements which are probably in cache?) – also play an important role on current hardware. Quicksort in particular requires little additional space and exhibits good cache locality, and this makes it faster than merge sort in many cases.</p>
<p>In addition, it’s very easy to avoid quicksort’s worst-case run time of O(<i>n</i><sup>2</sup>) almost entirely by using an appropriate choice of the pivot – such as picking it at random (this is an excellent strategy).</p>
<p>In practice, many modern implementations of quicksort (in particular libstdc++’s <code>std::sort</code>) are actually <a href="http://en.wikipedia.org/wiki/Introsort" rel="noreferrer">introsort</a>, whose theoretical worst-case is O(<i>n</i>log<i>n</i>), same as merge sort. It achieves this by limiting the recursion depth, and switching to a different algorithm (<a href="http://en.wikipedia.org/wiki/Heapsort" rel="noreferrer">heapsort</a>) once it exceeds log<i>n</i>.</p>
|
<p>In c/c++ land, when not using stl containers, I tend to use quicksort, because it is built
into the run time, while mergesort is not.</p>
<p>So I believe that in many cases, it is simply the path of least resistance.</p>
<p>In addition performance can be much higher with quick sort, for cases where the entire dataset does not fit into the working set.</p>
| 9,579
|
<p>I am currently in an operating systems class and my teacher spent half of the class period talking about PIDs. She mentioned, as many know, that processes know their parent's ID.</p>
<p>My question is this:</p>
<p>Does a process's PCB know its child's ID? If so, what is the way to go about it obtaining it?</p>
|
<p>As far as I know a process doesn't have an explicit list of its children's PIDs, but it can easily be built, since a process should know which child processes it spawns. For example the UNIX fork() call returns the child PID in the parent process and 0 in the child process, CreateProcess() on Windows returns (IIRC) the PID of the new process created.</p>
|
<p>Process's PCB know its child's ID.</p>
<p>As we know the Fork() is used to create processes.It takes no arguments and returns a process ID.After a new child process is created both parent and child will execute the next instruction following the fork().
There we have to distinguish the parent from the child.This can be done by testing the return value of fork().</p>
<p>If Fork() returns a negative value, the creation of child process is unsuccessful.
If Fork() returns a Zero to the newly created child process.
If Fork() returns a positive value as a process ID of the child process to the parent process.</p>
| 8,487
|
<p>I already found this article:</p>
<p><a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1" rel="nofollow noreferrer">http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1</a></p>
<p>But I've got a different situation. I am embedding some hiddenFields inside of the master page and trying to store the position of the dragPanel in those. </p>
<p>I am using javascript to store the position of the dragPanel and then when the user clicks on a link, the new page is loaded, but the dragPanel is reset into the starting position.</p>
<p><strong>Is there any easy way to do this?</strong> </p>
<p>Pseudocode:</p>
<pre><code>**this is in MasterPage.master**
function pageLoad()
{
// call the savePanelPosition when the panel is moved
$find('DragP1').add_move(savePanelPosition);
var elem = $get("<%=HiddenField1.ClientID%>");
if(elem.value != "0")
{
var temp = new Array();
temp = elem.value.split(';');
// set the position of the panel manually with the retrieve value
$find('<%=Panel1_DragPanelExtender.BehaviorID%>').set_location(new
Sys.UI.Point(parseInt(temp[0]),parseInt(temp[1])));
}
}
function savePanelPosition()
{
var elem = $find('DragP1').get_element();
var loc = $common.getLocation(elem);
var elem1 = $get("<%=HiddenField1.ClientID%>");
// store the value in the hidden field
elem1.value = loc.x + ';' + loc.y;
}
<asp:Button ID="Button1" runat="server" Text="Button"/>
<asp:HiddenField ID="HiddenField1" runat="server" Value="0"
</code></pre>
<p>However, <strong>HiddenField</strong> is not visible in the redirected page, foo.aspx</p>
|
<p>Rather than storing the position information in a hidden field, store it in a cookie. The information is small, so it will have minimal effect on the page load performance.</p>
|
<p>ok so I got the drag stuff to work, saves in a database and all, brings up cool on my one monitor 1600X1050 all good, fine and dandy! BUT WAIT! I bring up the same page on my other monitor 1366x768 and the panels are all off.</p>
<p>The save function saves in pixels, so when you move over to another "resolution" the panels are off. ya know?</p>
<p>P.S. I could pop up a message stating the user to change their monitor settings, lol...</p>
| 7,906
|
<p>I'm using the Repeater control on my site to display data from the database. I need to do pagination ("now displaying page 1 of 10", 10 items per page, etc) but I'm not sure I'm going about it the best way possible.</p>
<p>I know the Repeater control doesn't have any built-in pagination, so I'll have to make my own. Is there a way to tell the DataSource control to return rows 10-20 of a much larger result set? If not, how do I write that into a query (SQL Server 2005)? I'm currently using the TOP keyword to only return the first 10 rows, but I'm not sure how to display rows 10-20.</p>
|
<p>This isn't a way to page the data, but have you looked into the <a href="http://msdn.microsoft.com/en-us/library/bb398790.aspx" rel="nofollow noreferrer">ListView</a> control? It gives the flexibility of repeater / data list but with built in paging like the grid view.</p>
<p>And for paging in sql, you would want to do something like <a href="http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx" rel="nofollow noreferrer">this</a></p>
|
<p>This was answered <a href="https://stackoverflow.com/questions/2840/paging-sql-server-2005-results">here</a>.</p>
| 4,298
|
<p>The e3D volcano features an extended heater block of length 20 mm with the cartridge heater running parallel to the filament.</p>
<p>The purpose of this is to increase the speeds at which filament can be printed (of course the extruder and other factors may still be limiting factors).</p>
<p>My question is how capable would this heat block be of printing at slow speeds with a 0.4 mm nozzle?</p>
<p>Is printing still possible at lower speeds or is the filament heated too much that jams occur? Is the retraction performance okay?</p>
|
<p>Speaking from first hand experience running a Volcano hotend, mostly using a 0.6 mm nozzle, but I have used 0.4 mm as well. I can't really complain about any lower printing speed limit (low speeds are usually a solution to high speeds problems for me).</p>
<p>Just for completeness: I am using a DaVinci 1.1 Plus with custom firmware (modified Marlin) and an E3D Volcano hotend. No problems with the nozzle, clean prints! Note: I am using the Titan Aero as extruder but not using the included pancake motor! Went with the original motor of the DaVinci.</p>
<p>And as always: the parameters are key! Given a bit of tuning you can get amazing results! For PLA and ABS I can work without stringing. Although ABS seems to be prone to pitting (slight underextrusion at start of path). TPU and other flex are sometimes a bit of a challenge, but that's mainly due to my own lack of experience there.</p>
<p>The one important caveat here would be to also reduce the nozzle temperature. A possible theory here might be that the filament has more time and surface to heat up.</p>
<p><em>(Sometimes I go as much as 15 °C lower as compared to normal/high speeds! Usually lower speeds means small pieces for me and in term means a limit to the layer cooling time.)</em></p>
|
<p>The worry must be about oozing and stringing. In general, no worries! Nothing a bit of tuning would not fix.</p>
<p>I have experience printing with Volcano with 0.4, 0.6, 0.8, and 1.0 mm diameter.
PLA, PETG, Nylon, TPE, and TPU. (Volcano nozzles have been my default style for several years now. I don't even own a 10 mm heat block anymore (ok, maybe one)).</p>
<p>And yes, speaking of the classic 0.4 mm nozzle, you get higher stringing and oozing compared to 10 mm meltzone. You'll need to tune your retraction - it will be significatnly higher than 10 mm meltzone (I'm not giving numbers because it depends on printer style, material, nozzle diameter, temperature, and even slicer and slicer settings...).</p>
<p>I do like to print quite hot though with lots of cooling (PLA 220 °C for example) to increase layer adhesion and strength - so I experience this more. </p>
<p>For oozing, you may need to experiment with XY travel speeds, wiping settings, coasting settings, and similar (this also will help with stringing). </p>
<p>Also, keep in mind that the bigger the nozzle diameter, the more cooling you'll need (coupled with slower print) just to solidify that massive extrusion flow/mass. </p>
| 1,582
|
<p>I'm trying to access a data source that is defined within a web container (JBoss) from a fat client outside the container.</p>
<p>I've decided to look up the data source through JNDI. Actually, my persistence framework (Ibatis) does this.</p>
<p>When performing queries I always end up getting this error:</p>
<pre><code>java.lang.IllegalAccessException: Method=public abstract java.sql.Connection java.sql.Statement.getConnection() throws java.sql.SQLException does not return Serializable
Stacktrace:
org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.doStatementMethod(WrapperDataSourceS
ervice.java:411),
org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.invoke(WrapperDataSourceService.java
:223),
sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source),
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25),
java.lang.reflect.Method.invoke(Method.java:585),
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155),
org.jboss.mx.server.Invocation.dispatch(Invocation.java:94),
org.jboss.mx.server.Invocation.invoke(Invocation.java:86),
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264),
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659),
</code></pre>
<p>My Datasource:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/xxxxxDS</jndi-name>
<connection-url>jdbc:oracle:thin:@xxxxxxxxx:1521:xxxxxxx</connection-url>
<use-java-context>false</use-java-context>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>xxxxxxxx</user-name>
<password>xxxxxx</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
</local-tx-datasource>
</datasources>
</code></pre>
<p>Does anyone have a clue where this could come from? </p>
<p>Maybe someone even knows a better way how to achieve this.
Any hints are much appreciated!</p>
<p>Cheers,</p>
<p>Michael</p>
|
<p>Not sure if this is the same issue?</p>
<p><a href="http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/Connectors_on_JBoss-Configuring_JDBC_DataSources.html" rel="nofollow noreferrer">JBoss DataSource config</a></p>
<blockquote>
<p>DataSource wrappers are not usable outside of the server VM</p>
</blockquote>
|
<p>I think the exception indicates that the SQLConnection object you're trying to retrieve doesn't implement the Serializable interface, so it can't be passed to you the way you asked for it.</p>
<p>From the limited work I've done with JDNI, if you're asking for an object via JNDI it must be serializable. As far as I know, there's no way round that - if I think of a better way I'll post it up...</p>
<p>OK, one obvious option is to provide a serializable object local to the datasource that uses it but doesn't have the datasource as part of its serializable object graph. The fat client could then look up that object and query it instead.</p>
<p>Or create a (web?) service through which to access the datasource is governed - again your fat client would hit the service - this would probably be better encapsulated and more reuseable approach if those are concerns for you.</p>
| 6,006
|
<p>Suppose we have two stacks and no other temporary variable.</p>
<p>Is to possible to "construct" a queue data structure using only the two stacks?</p>
|
<p>Keep 2 stacks, let's call them <code>inbox</code> and <code>outbox</code>.</p>
<p><strong>Enqueue</strong>:</p>
<ul>
<li>Push the new element onto <code>inbox</code></li>
</ul>
<p><strong>Dequeue</strong>:</p>
<ul>
<li><p>If <code>outbox</code> is empty, refill it by popping each element from <code>inbox</code> and pushing it onto <code>outbox</code></p></li>
<li><p>Pop and return the top element from <code>outbox</code></p></li>
</ul>
<p>Using this method, each element will be in each stack exactly once - meaning each element will be pushed twice and popped twice, giving amortized constant time operations.</p>
<p>Here's an implementation in Java:</p>
<pre class="lang-java prettyprint-override"><code>public class Queue<E>
{
private Stack<E> inbox = new Stack<E>();
private Stack<E> outbox = new Stack<E>();
public void queue(E item) {
inbox.push(item);
}
public E dequeue() {
if (outbox.isEmpty()) {
while (!inbox.isEmpty()) {
outbox.push(inbox.pop());
}
}
return outbox.pop();
}
}
</code></pre>
|
<pre class="lang-java prettyprint-override"><code>public class QueueUsingStacks<T>
{
private LinkedListStack<T> stack1;
private LinkedListStack<T> stack2;
public QueueUsingStacks()
{
stack1=new LinkedListStack<T>();
stack2 = new LinkedListStack<T>();
}
public void Copy(LinkedListStack<T> source,LinkedListStack<T> dest )
{
while(source.Head!=null)
{
dest.Push(source.Head.Data);
source.Head = source.Head.Next;
}
}
public void Enqueue(T entry)
{
stack1.Push(entry);
}
public T Dequeue()
{
T obj;
if (stack2 != null)
{
Copy(stack1, stack2);
obj = stack2.Pop();
Copy(stack2, stack1);
}
else
{
throw new Exception("Stack is empty");
}
return obj;
}
public void Display()
{
stack1.Display();
}
}
</code></pre>
<p>For every enqueue operation, we add to the top of the stack1. For every dequeue, we empty the content's of stack1 into stack2, and remove the element at top of the stack.Time complexity is O(n) for dequeue, as we have to copy the stack1 to stack2. time complexity of enqueue is the same as a regular stack</p>
| 9,463
|
<p>A number of forms in my project inherit from a base form. It is easy to get at the Controls collection of the derived forms, but I have not found a simple way to access the Components collection, since VS marks this as private. </p>
<p>I assume this could be done with reflection, but I'm not really sure how best to go about it, not having worked with reflection before.</p>
<p>Right now, I'm using a sort of clunky workaround, in which I override a function GetComponents and return an array of the components I'm interested in. This is obviously prone to errors, since it's easy to forget to implement the overridden function or update it when components are added.</p>
<p>If anyone has any tips or can suggest a better way, I'd be glad to hear.</p>
|
<p>If you set the Modifiers property of your components to strict protected makes them accessible without the use of a components collection. </p>
<p>Edit:
Discoverability could be done using reflection to walk over each field. Although that might be suboptimal in your case.</p>
|
<p>If you're worried about forgetting to override the function, then make it abstract.</p>
| 5,104
|
<p>I have some code that modifies a value that several controls in other update panels are bound to. When this event handler fires, I'd like it to force the other update panels to refresh as well, so they can rebind.</p>
<p>Is this possible?</p>
<p>Edit: </p>
<p>To clarify, I have an update panel in one user control, the other update panels are in other user controls, so they can't see each other unless I were to expose some custom properties and use findControl etc etc...</p>
<p>Edit Again:</p>
<p>Here is what I came up with:</p>
<pre><code>public void Update()
{
recursiveUpdate(this);
}
private void recursiveUpdate(Control control)
{
foreach (Control c in control.Controls)
{
if (c is UpdatePanel)
{
((UpdatePanel)c).Update();
}
if (c.HasControls())
{
recursiveUpdate(c);
}
}
}
</code></pre>
<p>I had 3 main user controls that were full of update panels, these controls were visible to the main page, so I added an Update method there that called Update on those three.</p>
<p>In my triggering control, I just cast this.Page into the currentpage and called Update.</p>
<p>Edit:</p>
<p>AARRGGGG!</p>
<p>While the update panels refresh, it does not call Page_Load within the subcontrols in them...What do I do now!</p>
|
<p>You can set triggers on the events in the update panel you want updated or you can explicitly say updatepanel.update() in the code behind.</p>
|
<p>This is a good technique if you want to refresh updatepanel from <a href="http://encosia.com/2007/07/13/easily-refresh-an-updatepanel-using-javascript/" rel="nofollow noreferrer">client side Javascript</a>.</p>
| 7,898
|
<p>I understand the main function of the lock key word from MSDN</p>
<blockquote>
<p>lock Statement (C# Reference)</p>
<p>The lock keyword marks a statement
block as a critical section by
obtaining the mutual-exclusion lock
for a given object, executing a
statement, and then releasing the
lock.</p>
</blockquote>
<p>When should the lock be used? </p>
<p>For instance it makes sense with multi-threaded applications because it protects the data. But is it necessary when the application does not spin off any other threads?</p>
<p>Is there performance issues with using lock?</p>
<p>I have just inherited an application that is using lock everywhere, and it is single threaded and I want to know should I leave them in, are they even necessary?</p>
<p>Please note this is more of a general knowledge question, the application speed is fine, I want to know if that is a good design pattern to follow in the future or should this be avoided unless absolutely needed.</p>
|
<blockquote>
<p>When should the lock be used?</p>
</blockquote>
<p>A lock should be used to protect shared resources in multithreaded code. Not for anything else.</p>
<blockquote>
<p>But is it necessary when the application does not spin off any other threads?</p>
</blockquote>
<p>Absolutely not. It's just a time waster. However do be sure that you're not implicitly using system threads. For example if you use asynchronous I/O you may receive callbacks from a random thread, not your original thread.</p>
<blockquote>
<p>Is there performance issues with using lock?</p>
</blockquote>
<p>Yes. They're not very big in a single-threaded application, but why make calls you don't need?</p>
<blockquote>
<p>...if that is a good design pattern to follow in the future[?]</p>
</blockquote>
<p>Locking everything willy-nilly is a terrible design pattern. If your code is cluttered with random locking and then you do decide to use a background thread for some work, you're likely to run into deadlocks. Sharing a resource between multiple threads requires careful design, and the more you can isolate the tricky part, the better.</p>
|
<p>There is no point in having locks in the app if there is only one thread and yes, it is a performance hit although it does take a fair number of calls for that hit to stack up into something significant. </p>
| 8,422
|
<p>In a follow-up to a <a href="https://stackoverflow.com/questions/54789/what-is-the-correct-net-exception-to-throw-when-try-to-insert-a-duplicate-objec">previous question</a> regarding exceptions, what are best practices for creating a custom exception in .NET? </p>
<p>More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception?</p>
|
<p>Inherit from <code>System.Exception</code>. <code>System.ApplicationException</code> is useless and the design guidelines say "<strong>Do not</strong> throw or derive from <code>System.ApplicationException</code>." </p>
<p>See <a href="http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx</a></p>
|
<p>I think the single most important thing to remember when dealing with exceptions at any level (making custom, throwing, catching) is that exceptions are only for exceptional conditions.</p>
| 7,848
|
<p>The following code illustrates an object literal being assigned, but with no semicolon afterwards:</p>
<pre><code>var literal = {
say: function(msg) { alert(msg); }
}
literal.say("hello world!");
</code></pre>
<p>This appears to be legal, and doesn't issue a warning (at least in Firefox 3). Is this completely legal, or is there a strict version of JavaScript where this is not allowed?</p>
<p>I'm wondering in particular for future compatibility issues... I would like to be writing "correct" JavaScript, so if technically I need to use the semicolon, I would like to be using it.</p>
|
<p>Not technically, JavaScript has semicolons as optional in many situations. </p>
<p>But, as a general rule, use them at the end of any statement. Why? Because if you ever want to compress the script, it will save you from countless hours of frustration.</p>
<p>Automatic semicolon insertion is performed by the interpreter, so you <em>can</em> leave them out if you so choose. In the comments, someone claimed that </p>
<blockquote>
<p>Semicolons are not optional with statements like break/continue/throw</p>
</blockquote>
<p>but this is incorrect. They are optional; what is really happening is that line terminators affect the automatic semicolon insertion; it is a subtle difference. </p>
<p>Here is the rest of the standard on semicolon insertion:</p>
<blockquote>
<p>For convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations.</p>
</blockquote>
|
<p>This is not valid (see clarification below) JavaScript code, since the assignment is just a regular statement, no different from</p>
<pre><code>var foo = "bar";
</code></pre>
<p>The semicolon can be left out since JavaScript interpreters attempt to add a semicolon to fix syntax errors, but this is an extra and unnecessary step. I don't know of any strict mode, but I do know that automated parsers or compressors / obfuscators need that semicolon.</p>
<p>If you want to be writing correct JavaScript code, write the semicolon :-)</p>
<p>According to the ECMAscript spec, <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="nofollow noreferrer">http://www.ecma-international.org/publications/standards/Ecma-262.htm</a>, the semicolons are automatically inserted if missing. This makes them not required for the script author, but it implies they are required for the interpreter. This means the answer to the original question is 'No', they are not required when writing a script, but, as is pointed out by others, it is recommended for various reasons.</p>
| 6,368
|
<p>In Ultimaker Cura, is there a setting to slow down just the first layer (or two layers) covering over the infill? </p>
<p>I'm not talking about the top layers, since you may have infill covered over during a lower section of the print. And I'm not talking about bridging, since this isn't a true bridge, and quick testing shows the bridge settings don't seem to control this. I'm also not talking about the whole layer, since you may have just a section of a layer involved with covering the infill.</p>
<p>What I want, is, whenever a print transitions from infill back to shell, that first section of shell above the infill (and maybe also the next layer going the opposite direction) should be slower. </p>
<p>What I've observed is this layer prints at the same speed as other shell sections, which can be too fast at this point for complete coverage, leaving a stringy section. This won't be visible later, but it does matter for strength and potentially quality; if expected filament isn't deposited it has to end up somewhere. Slowing down should help get a cleaner layer. </p>
<p>Can Ultimaker Cura do this? I don't care which version. For completeness, what about other slicers? Even if I normally use Cura, I might be tempted to use a different slicer that can do this if I have a part where it really matters.</p>
|
<p>Cura can do this. It's a bit convoluted though. Here's what you need to do:</p>
<ul>
<li>Load your model / scene in the build plate.</li>
<li>Load an additional cube and make it as big as the entire build plate so that it overlaps with everything (in the preferences you may need to disable "Ensure that models are kept apart).</li>
<li>Select the cube and go to the per-object settings tool.</li>
<li>Change the cube's mesh type to "modify settings for infill".</li>
<li>For the cube, set Wall Line Count to 0, Top/Bottom Thickness to 0 and Top Layers to 1. This effectively makes the cube add one additional layer on the top side of all infill volumes.</li>
<li>For the cube, set the Top/Bottom Speed to your desired speed for the one slower layer.</li>
<li>(Optional) In the normal settings panel on the right, set the number of top layers to be one less, so that you get the same number of top layers again.</li>
</ul>
|
<p>As far as I know, Cura has no option to do this. Conceptually Cura treats the model as a solid, so that the material over infill is not "overhang". However, you may be able to hack it by using the "magic mesh surface mode" feature under "special modes", to treat the model as a surface rather than a solid, then enable support and use the same model as a mask for where support material should be printed, and print support as infill-only. Alternatively you might just print a second copy of the model as infill-only (0 walls and 0 layers of top/bottom skin) in the same location.</p>
| 1,355
|
<p>Does anyone know how to achieve the cover-flow effect using JavaScript to scroll through a bunch of images. I'm not talking about the 3D rotating <em>itunes</em> cover-art, but the effect that happens when you hit the space bar in a folder of documents, allowing you to preview them in a <em>lightbox</em> fashion.</p>
|
<p><a href="http://www.jacksasylum.eu/ContentFlow/" rel="noreferrer">http://www.jacksasylum.eu/ContentFlow/</a></p>
<ul>
<li>is the best I ever found.
a true 'CoverFlow', highly configurable, cross-browser, very smooth action, has relections and supports scroll wheel + keyboard control. - has to be what your looking for! </li>
</ul>
|
<p>This one looks really promising, and closer to the actual Apple coverflow effect than the other examples:</p>
<p><a href="http://www.blarnee.com/projects/cflow/" rel="nofollow noreferrer">blarnee.com/projects/cflow</a></p>
| 9,279
|
<p>I am completely new to 3D Printing. I got my first printer a Creality Ender 5 Pro yesterday.</p>
<h3>My problem</h3>
<p>I did shutdown the printer without the axis being in home position (<strong>X: 0, Y: 0, Z: 320</strong> instead of <strong>X: 0, Y: 0, Z: 0</strong>). I thought this should be no problem but after turning the printer on again the info screen showed the axis as 0, 0, 0 again...</p>
<p>So I can't move the Z axis up again because the printer thinks its already at 0.</p>
<p>NOTE: On the Ender 5 the bed is lowering for the value of the Z so 320 is the lowest and 0 the highest. The motor works because it tries to go down further if i increase Z position but I am scared of damaging the motor because it can't move further but it tries to (judging by that weird sound).</p>
<h3>My question</h3>
<p>Is this a normal behavior that the printer axis cant remember its position? Because I think as I built the printer the axis were also not at the 0, 0, 0 position and on the first start they moved back without any problems.</p>
<p>Has someone any ideas how to solve this? Or is this a broken printer?</p>
<p>PS: I could replicate this behavior on X and Y as well (moving them with prepare->move axis and then shutdown the printer) but here for I can easily disable the motors and move them manually back to 0, 0 which isn't the case for the Z Axis.</p>
<p>I hope I could explain that understandably.</p>
|
<p>Once you pull the plug or disable power to the stepper motors, the printer forgets its location. That is perfectly normal and exactly how it is supposed to work.</p>
<p>The printer knows where the printer volume is once you have "homed" the printer. Homing is done prior to printing with G-code <a href="https://reprap.org/wiki/G-code#G28:_Move_to_Origin_.28Home.29" rel="nofollow noreferrer"><code>G28</code></a> which should be present in your start G-code script of your slicer. Once homed, the offsets from the endstops determine where the origin of the printer is and the maximum dimensions determine the build volume.</p>
<p>After you switched on the printer, the printer doesn't know where the origin is and movement is limited. E.g. when the following constant is defined: <code>#define NO_MOTION_BEFORE_HOMING</code> no movement at all is possible before the printer is homed, this can help prevent destroying the printer.</p>
|
<p>Slightly unscrew the motor. Manually rig the Z-axis above its lowest point. Rescrew the motor back into place tightly. Then auto home it.</p>
| 1,700
|
<p>SVN in Eclipse is spread into two camps. The SVN people have developed a plugin called <a href="http://subclipse.tigris.org/" rel="noreferrer">Subclipse</a>. The Eclipse people have a plugin called <a href="http://www.eclipse.org/subversive/" rel="noreferrer">Subversive</a>. Broadly speaking they both do the same things. What are the advantages and disadvantages of each?</p>
|
<p>Both are very similar but Subversive is the "eclipse svn provider". I primarily use Subversive because of a few convenient features:</p>
<p><strong>Grouping of history</strong></p>
<p>When I'm browsing the history of a branch instead of just seeing a bunch of rows for every commit it can group commits by today, week, etc.</p>
<p><strong>Mapping of trunk, branches, and tags</strong></p>
<p>Subversive assumes the default svn layout: trunk, branches, tags (which you can change), so whenever you want to tag or branch it is one click and you provide the name of the tag or branch.</p>
<p>Like I said these are minor differences that I just find convenient. Both work great with mylyn, but overall there really isn't a whole lot of differences with these two extensions.</p>
<p>Merging with Subversive is a pain though (haven't tried Subclipse), I've never been able to successfully merge. The preview of the merge is great but it would never complete the merge or it will take way to long. Most of the time I complete merging through the command line without any issues.</p>
|
<p>If you are using Zend Studio 9, Zend's implementation of Eclipse, I recommend using Subclipse instead of Subversive which comes shipped with Zend Studio be default.</p>
<p>I have posted a problem with Subversive and Zend Studio 9 and <a href="http://forums.zend.com/viewtopic.php?f=59&t=42373&p=98993#p98733" rel="nofollow noreferrer">my solution of using Subclipse instead on the Zend forums</a>.</p>
| 8,648
|
<p>We have an application with a good amount of jQuery JSON calls to server side code. Because of this, we have a large amount of binding code to parse responses and bind the appropriate values to the form. This is a two part question.</p>
<ol>
<li><p>What is the reccomended approach for dealing with a large number of forms that all have different data. Right now were are trying to take a structured approach in setting up a js "class" for each page, with an init, wireClickEvents etc.. to try to have everything conformed.</p></li>
<li><p>Is there any "best practices" with creating repetitive jQuery code or any type of reccomended structure other than just throwing a bunch of functions in a js file?</p></li>
</ol>
|
<p>Not 100% sure example what you are asking, but personally, and I use MochiKit, I create JavaScript "classes" (or widgets, if you prefer) for every significant client-side UI structure. These know, of course, how to populate themselves with data.</p>
<p>I don't know what more there is to say - writing UI code for the browser in JavaScript is no different than writing UI code for other types of apps, as far as I am concerned. Build classes and instantiate them as needed, populate them with data, have them throw events, etc. etc.</p>
<p>Am I up in the night on this? :)</p>
<hr>
<p>EDIT: In other words, yes - do what you are doing, for the most part. I see too many novice JavaScript hackers write a bunch of poorly-cohesive functions that don't appear to be a part of anything specific other than they are all in a single file. Hope that makes sense. </p>
|
<p>I think there are multiple challanges for you. The first question is how to structure javascript code, i.e. how to build namespaces so that you don't fight name clashes or have to name your functions like </p>
<pre><code>form1validate
form1aftersubmit
form2validate
form2aftersubmit
</code></pre>
<p>One of the proven patterns for modules in javascript is to use an anonymous function to build a new naming scope. The basic idea is shon in the following code</p>
<pre><code>(function() {
var foo = 1;
})();
(function() {
if(foo == 1) alert("namespace separation failed!")
})();
</code></pre>
<p>I think this <a href="http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth" rel="nofollow">blog entry</a> is a good introduction.</p>
<p>The second question you face is how to avoid all the repetition in javascript code.
You have a couple of weapons against this.</p>
<ol>
<li>functions - this seams obvious but it's often forgotten to refactor common code into functions where it can be done. In you case this will be functions to copy values from the json response into the forms and like that</li>
<li>higher order function - or functions as data - or callback, as they are often called in javascript. These are the mightiest weapon in javascript. In case for form and ajax handling you can use callback to avoid repetition in the control flow of your forms. </li>
</ol>
<p>Let me construct an example out of my head (using jquery for convinence)</p>
<pre><code>// this is a validator for one form
var form1validator = function() {
if($("input[name=name]",this).attr("value").length < 1 &&
$("input[name=organisation]",this).attr("value").length < 1)
return "Either name or organisation required"
}
// and this for a second form
var form2validator = function() {
if($("input[name=age]",this).attr("value").length < 21
return "Age of 21 required"
}
// and a function to display a validation result
var displayResult = function(r) {
$(this).prepend("<span></span>").text(r);
}
// we use them as higher order functions like that
$("#form1").onSubmit(validator(form1validator, displayResult, function() {
//on submit
...send some xhr request or like that
});
$("#form2").onSubmit(validator(form2validator, displayResult, function() {
this.submit() // simply submit form
});
$("#form1b").onSubmit(validator(form1validator, function(r) {
alert("There was an validation error " + r);
}, function() {
//on submit
...send some xhr request or like that
});
// the validator function itself would be defined as
function validator(formValidator, displayResult, onSubmit) {
var r = formValidator.apply(this)
if(typeof(r) === 'undefined')
onSubmit(this)
else
displayResult(r)
}
</code></pre>
| 5,503
|
<p>In a macro for Visual Studio 6, I wanted to run an external program, so I typed:</p>
<pre><code>shell("p4 open " + ActiveDocument.FullName)
</code></pre>
<p>Which gave me a type mismatch runtime error. What I ended up having to type was this:</p>
<pre><code>Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
strResult = wshShell.Run("p4 open " + ActiveDocument.FullName)
</code></pre>
<p>What is going on here? Is that nonsense really necessary or have I missed something?</p>
|
<p>As <a href="https://stackoverflow.com/questions/20272/why-doesnt-shell-work-in-vbscript-in-vs6#20304">lassevk</a> pointed out, VBScript is not Visual Basic.</p>
<p>I believe the only built in object in VBScript is the WScript object.</p>
<pre><code>WScript.Echo "Hello, World!"
</code></pre>
<p>From the docs</p>
<blockquote>
<p>The WScript object is the root object of the Windows Script Host
object model hierarchy. It never needs to be instantiated before invoking its
properties and methods, and it is always available from any script file.</p>
</blockquote>
<p>Everything else must be created via the CreateObject call. Some of those objects are <a href="http://msdn.microsoft.com/en-us/library/f51wc7hz(VS.85).aspx" rel="nofollow noreferrer">listed here</a>.</p>
<p>The Shell object is one of the <em>other</em> objects that you need to create if you want to call methods on it.</p>
<p>One caveat, is that RegExp is <em>sort of</em> built in, in that you can instantiate a RegExp object like so in VBScript:</p>
<pre><code>Dim r as New RegExp
</code></pre>
|
<p>VB6 uses & to concatenate strings rather than +, and you'll want to make sure the file name is encased in quotes in case of spaces. Try it like this: </p>
<pre><code>Shell "p4 open """ & ActiveDocument.FullName & """"
</code></pre>
| 4,064
|
<p>We have a toy with some broken parts, an Executivity Gear Master. I don't think it's made anymore. Some tiny parts were easy to break and we'd like to 3d print some replacement parts. We don't have CAD or any other 3D drawings file, just a few of the unbroken parts. What's the best way to get some of these printed? Do I have to turn this into a 3D file first? (Is there a quick way to do that from the part itself?) Or is there a way to do it where I just need the part, rather like getting a spare key cut from a pre-existing key being used as the template?</p>
<p>Here's a photo of the part I need to print. Placed next to a quarter for size comparison:</p>
<p><a href="https://i.stack.imgur.com/xZ6VN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/xZ6VN.jpg" alt="enter image description here"></a> </p>
|
<p>I had the same problem with ABS, but printing different test objects I found out that the distance between the wavy structures depends on the cross sectional area of the object. Printing the testcube in 70.1% (1/sqrt(2) times of the original size) takes half the time per layer and the distance between two grooves doubles. I was printing ABS with 0.1 mm layer height and the simple bang-bang heat bed controller. The temperature is clearly wandering for 4° with a period of aproximately 2.5 minutes, which corresponds to the groove distances. After changing to a PID controller for the heated bed the temperature stayed within 0.1°C and the problem was gone. Several hundredths of a millimeter thermal expansion of the heated bed can have substantial impact at 0.1 mm layer height!</p>
<p>You can enable the PID controller for the heated bed in Marlin or Skynet firmware by enabling (removing the <code>//</code>) here:</p>
<blockquote>
<p><code>//#define PIDTEMPBED</code></p>
</blockquote>
<p>and disabling (putting <code>//</code> at the beginning of the line) here:</p>
<blockquote>
<p><code>#define BED_LIMIT_SWITCHING</code></p>
</blockquote>
<p>in Configuration.h. Calibration of the PID controller can then be done with the GCODE Command: </p>
<blockquote>
<p>M303 E-1 S90 C8</p>
</blockquote>
<p>for 90°C. I had to preheat the heated bed before, otherwise the calibration would run into a timeout. The command will return parameters for the PID algorithm. The values can then be applied by the </p>
<blockquote>
<p>M304 P579.01 I100.87 D586.0</p>
</blockquote>
<p>GCODE command (here for example values). Everything can then be saved to the EEPROM with </p>
<blockquote>
<p>M500</p>
</blockquote>
<p>Bang-Bang controller:
<img src="https://i.stack.imgur.com/rQbWH.jpg" alt="Bang-Bang controller"></p>
<p>PID controller:
<img src="https://i.stack.imgur.com/Ka0AA.jpg" alt="PID controller"></p>
|
<p>Looks like something is catching on the z axis. A bent peice would likely cause much smaller deformations unless it was very obviously bent. Something could be loose, allowing the vertical play, perhaps the motor mounts.</p>
<p>More likely I think is a level-difference between the z-axis worm gears, possibly caused by an obstruction, lack of lubrication, or possibly even the wrong lubrication. That's where I would look. Further, since it's a very consistent pattern, my guess would be your issue can be isolated to the tops and bottoms of the z axis worm gears. Even if it's not the issues I think, the issue most likely located at the top or bottom.</p>
| 515
|
<p>I'm using the Infragistics grid and I'm having a difficult time using a drop-down list as the value selector for one of my columns.</p>
<p>I tried reading the documentation but Infragistics' documentation is not so good. I've also taken a look at this <a href="http://news.infragistics.com/forums/p/9063/45792.aspx" rel="nofollow noreferrer">discussion</a> with no luck.</p>
<p>What I'm doing so far:</p>
<pre><code>col.Type = ColumnType.DropDownList;
col.DataType = "System.String";
col.ValueList = myValueList;
</code></pre>
<p>where <code>myValueList</code> is:</p>
<pre><code>ValueList myValueList = new ValueList();
myValueList.Prompt = "My text prompt";
myValueList.DisplayStyle = ValueListDisplayStyle.DisplayText;
foreach(MyObjectType item in MyObjectTypeCollection)
{
myValueList.ValueItems.Add(item.ID, item.Text); // Note that the ID is a string (not my design)
}
</code></pre>
<p>When I look at the page, I expect to see a drop-down list in the cells for this column, but my columns are empty.</p>
|
<p>Here's an example from one of my pages:</p>
<pre><code>UltraWebGrid uwgMyGrid = new UltraWebGrid();
uwgMyGrid.Columns.Add("colTest", "Test Dropdown");
uwgMyGrid.Columns.FromKey("colTest").Type = ColumnType.DropDownList;
uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(0, "ONE", "Choice 1");
uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(1, "TWO", "Choice 2");
</code></pre>
|
<pre><code> public void MakeCellValueListDropDownList(UltraWebGrid grid, string columnName, string valueListName, string[] listArray)
{
//Set the column to be a dropdownlist
UltraGridColumn Col = grid.Columns.FromKey(columnName);
Col.Type = ColumnType.DropDownList;
Col.DataType = "System.String";
try
{
ValueList ValList = grid.DisplayLayout.Bands[0].Columns.FromKey(columnName).ValueList;
ValList.DataSource = listArray;
foreach (string item in listArray)
{
ValList.ValueListItems.Add(item);
}
ValList.DataBind();
}
catch (ArgumentException)
{
}
}
</code></pre>
| 3,602
|
<p>I'm developing a website which will be used in the corporate intranet which uses JCIFS and NTLM to automatically authenticate the users without asking them to log on. Everything seems to be working in IE 6, but some users are being prompted for their passwords in IE 7. </p>
<p>We've had some success by getting the users to change their Logon option to "Automatic logon using current username and password" (Tools > Internet Options > Securty Tab > Select Local Intranet > Custom Level > All the way at the bottom User Authentication > Logon), but we are still having a few users who are getting username/password prompts.</p>
<p>Also, we've had some users report they can just click cancel when the prompt comes up and the page will come up correctly.</p>
<p>If anyone has any other suggestions, I'd greatly appreciate them.</p>
|
<p>If you access an intranet Web site by using an IP address or a fully qualified domain name , or a url with a dot in it the Web site may be identified as in the Internet zone instead of in the Local intranet zone.</p>
<p><a href="http://support.microsoft.com/kb/303650" rel="nofollow noreferrer">http://support.microsoft.com/kb/303650</a></p>
|
<p>If you access an intranet Web site by using an IP address or a fully qualified domain name , or a url with a dot in it the Web site may be identified as in the Internet zone instead of in the Local intranet zone.</p>
<p><a href="http://support.microsoft.com/kb/303650" rel="nofollow noreferrer">http://support.microsoft.com/kb/303650</a></p>
| 4,229
|
<p>What issues / pitfalls must be considered when overriding <code>equals</code> and <code>hashCode</code>?</p>
|
<h3>The theory (for the language lawyers and the mathematically inclined):</h3>
<p><code>equals()</code> (<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)" rel="noreferrer">javadoc</a>) must define an equivalence relation (it must be <em>reflexive</em>, <em>symmetric</em>, and <em>transitive</em>). In addition, it must be <em>consistent</em> (if the objects are not modified, then it must keep returning the same value). Furthermore, <code>o.equals(null)</code> must always return false.</p>
<p><code>hashCode()</code> (<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()" rel="noreferrer">javadoc</a>) must also be <em>consistent</em> (if the object is not modified in terms of <code>equals()</code>, it must keep returning the same value).</p>
<p>The <strong>relation</strong> between the two methods is:</p>
<blockquote>
<p><em>Whenever <code>a.equals(b)</code>, then <code>a.hashCode()</code> must be same as <code>b.hashCode()</code>.</em></p>
</blockquote>
<h3>In practice:</h3>
<p>If you override one, then you should override the other.</p>
<p>Use the same set of fields that you use to compute <code>equals()</code> to compute <code>hashCode()</code>.</p>
<p>Use the excellent helper classes <a href="http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/EqualsBuilder.html" rel="noreferrer">EqualsBuilder</a> and <a href="http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/HashCodeBuilder.html" rel="noreferrer">HashCodeBuilder</a> from the <a href="http://commons.apache.org/lang/" rel="noreferrer">Apache Commons Lang</a> library. An example:</p>
<pre><code>public class Person {
private String name;
private int age;
// ...
@Override
public int hashCode() {
return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers
// if deriving: appendSuper(super.hashCode()).
append(name).
append(age).
toHashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Person))
return false;
if (obj == this)
return true;
Person rhs = (Person) obj;
return new EqualsBuilder().
// if deriving: appendSuper(super.equals(obj)).
append(name, rhs.name).
append(age, rhs.age).
isEquals();
}
}
</code></pre>
<h3>Also remember:</h3>
<p>When using a hash-based <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/Collection.html" rel="noreferrer">Collection</a> or <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html" rel="noreferrer">Map</a> such as <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashSet.html" rel="noreferrer">HashSet</a>, <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/LinkedHashSet.html" rel="noreferrer">LinkedHashSet</a>, <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html" rel="noreferrer">HashMap</a>, <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/Hashtable.html" rel="noreferrer">Hashtable</a>, or <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/WeakHashMap.html" rel="noreferrer">WeakHashMap</a>, make sure that the hashCode() of the key objects that you put into the collection never changes while the object is in the collection. The bulletproof way to ensure this is to make your keys immutable, <a href="http://www.javapractices.com/topic/TopicAction.do?Id=29" rel="noreferrer">which has also other benefits</a>.</p>
|
<p>One gotcha I have found is where two objects contain references to each other (one example being a parent/child relationship with a convenience method on the parent to get all children).<br>
These sorts of things are fairly common when doing Hibernate mappings for example.</p>
<p>If you include both ends of the relationship in your hashCode or equals tests it's possible to get into a recursive loop which ends in a StackOverflowException.<br>
The simplest solution is to not include the getChildren collection in the methods.</p>
| 4,721
|
<p>I am using a Flash Forge Creator, and when I print big parts (only in this case) I have about 25% of the bottom of the printed object sticking very hard to its support layer. And I spend a lot of time removing it with a cutter.</p>
<p>Is there any clue or good practice to avoid that?</p>
<p>I use ReplicatorG for my printing settings.</p>
|
<p>I finally found out two causes:</p>
<ol>
<li><p>The 3D printer has default settings for ABS, and since there is no printer bed settings in ReplicatorG, the bed temperature was set to 110 °C instead of 60°C. I fixed the setting directly on the printer itself.</p></li>
<li><p>It seems that one side of the printer bed was little closer to the nozzle than other sides (relatively to the extruder) and this added a pressure on the support layer. I found this by observing the structure of the support layer that was little more compressed in one side. That was easy to fix by iteratively tightening/loosening the screw of that side and observing the support layer (and canceling the print if it is not homogeneous).</p></li>
</ol>
<p>I installed Ultimaker Cura and Slic3r to try them and I found that Ultimaker Cura was not adapted to my printer (I did not found a complying model), Slic3r seems to be okay but I was not able to fit my big part inside of it.
I am trying to use the maximum available space for my part, perhaps I need to change some settings for Slic3r and anyway it is already working on ReplicatorG.</p>
|
<p>According to the manufacturer:</p>
<blockquote>
<p>... you are able to choose your favorite software such as
FlashPrint, Simplify3D, Cura and more.</p>
</blockquote>
<p>Not being familiar with ReplicatorG, I know that other slicer software can set the distance between supports and print (in terms of the amount of layers). You could look for such a setting in ReplicatorG, or use a different slicer such as Ultimaker Cura or Slic3r; which are free and able to make such adjustments.</p>
| 1,234
|
<p>I am trying to improve the performance of a web application. I have metrics that I can use to optimize the time taken to return the main HTML page, but I'm concerned about the external CSS and JavaScript files that are included from these HTML pages. These are served statically, with HTTP Expires headers, but are shared between all the pages of the application.</p>
<p>I'm concerned that the browser has to parse these CSS and JavaScript files for each page that is displayed and so having all the CSS and JavaScript for the site shared into common files will negatively affect performance. Should I be trying to split out these files so I link from each page to only the CSS and JavaScript needed for that page, or would I get little return for my efforts?</p>
<p>Are there any tools that could help me generate metrics for this?
</p>
|
<p><strong>Context:</strong> While it's true that HTTP overhead is more significant than parsing JS and CSS, ignoring the impact of parsing on browser performance (even if you have less than a meg of JS) is a good way to get yourself in trouble.</p>
<p>YSlow, Fiddler, and Firebug are not the best tools to monitor parsing speed. Unless they've been updated very recently, they don't separate the amount of time required to fetch JS over HTTP or load from cache versus the amount of time spent parsing the actual JS payload.</p>
<p>Parse speed is slightly difficult to measure, but we've chased this metric a number of times on projects I've worked on and the impact on pageloads were significant even with ~500k of JS. Obviously the older browsers suffer the most...hopefully Chrome, TraceMonkey and the like help resolve this situation.</p>
<p><strong>Suggestion:</strong> Depending on the type of traffic you have at your site, it may be well worth your while to split up your JS payload so some large chunks of JS that will never be used on a the most popular pages are never sent down to the client. Of course, this means that when a new client hits a page where this JS is needed, you'll have to send it over the wire.</p>
<p>However, it may well be the case that, say, 50% of your JS is never needed by 80% of your users due to your traffic patterns. If this is so, you should definitely user smaller, packaged JS payloads only on pages where the JS is necessary. Otherwise 80% of your users will suffer unnecessary JS parsing penalties on <em>every single pageload</em>.</p>
<p><strong>Bottom Line:</strong> It's difficult to find the proper balance of JS caching and smaller, packaged payloads, but depending on your traffic pattern it's definitely well worth considering a technique other than smashing all of your JS into every single pageload.</p>
|
<p>I believe <a href="http://developer.yahoo.com/yslow/" rel="nofollow noreferrer">YSlow</a> does, but be aware that unless all requests are over a loopback connection you shouldn't worry. The HTTP overhead of split-up files will impact performance <em>far</em> more than parsing, unless your CSS/JS files exceed several megabytes.</p>
| 6,916
|
<p>When I purchased my China made Anet A8 printer, it came with the ball bearing style linear bearings for the 8mm guide rods. While pulling parts out of the box and putting them together, I noticed several of the small ball bearings fell out of their respective holders. At the time, I really didn't know what to think of it (ie: were these just <em>extra</em> ball bearings falling out; were they actually needed). I put the printer together anyway and it seems to work okay.</p>
<p>I have noticed while I've been printing, there's a lot of noise during travel of the pieces. I'm not exactly sure where the noise is coming from, but realize it has to be coming from one or more of the bearings. To hopefully fix the issue, I've purchased some Igus Drylin polymer bushings to replace the linear bearings:</p>
<p><a href="https://i.stack.imgur.com/dA0pj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dA0pj.jpg" alt="enter image description here"></a></p>
<p>My questions are:</p>
<ul>
<li>When installing these bushings, should they be completely dry?</li>
<li>Should I at least clean the rods?</li>
<li>Are they completely maintenance free?</li>
<li>Anything else I'm not thinking of to worry about?</li>
</ul>
|
<p>According to <a href="https://www.igus.eu/wpck/19864/drylin_plasticvsmetal" rel="noreferrer">igus commercial documentation</a>, these bushings:</p>
<ul>
<li>do not need any kind of lubrication,</li>
<li>are not susceptible to humidity (but your steel rods might) </li>
<li>work seamlessly in presence of dust (it gets expelled from the bushing with movements)</li>
</ul>
<p>I've replaced all of my bearings with these, and in my experience, the above claims have been true so far. I must say that I am really pleased with them. Movement is smoother, and the noise is considerably lower.</p>
<p>I did clean the rods to remove any trace of lubrication prior to installing them. I did not dry them.</p>
<p>I believe that igus is also selling rods in a material designed to even further improve the qualities of these bushings, but it starts to become quite an investment.</p>
|
<p>In addition to <a href="https://3dprinting.stackexchange.com/a/6741/5740">this answer</a> and addressing <code>Anything else I'm not thinking of to worry about?</code> I would like to add that you should take care in installing the plastic bearings in suitable housings. It is best to lower the mass of the carriages by replacing the blocks and the bearings, there are a lot of printable bearing housings to find on the internet (e.g. Thingiverse). When installing plastic bearings, it is quite easy to get problems with bearings that bind, so take care when you install them and make sure the bearings do not bind (before you re-install the belt).</p>
| 1,013
|
<p>In a <a href="https://stackoverflow.com/questions/21848/switch-branch-names-in-git">previous Git question</a>, Daniel Benamy was talking about a workflow in Git:</p>
<blockquote>
<p>I was working on master and committed some stuff and then decided I wanted to put that work on hold. I backed up a few commits and then branched from before I started my crap work.</p>
</blockquote>
<p>He wanted to restore his working state to a previous point in time without losing his current changes. All of the answers revolved around, in various ways, something like</p>
<pre><code>git branch -m master crap_work
git branch -m previous_master master
</code></pre>
<p>How does this compare to <code>git stash</code>? I'm a bit confused trying to see what the different use case here when it <em>seems</em> like everything <code>git stash</code> does is already handled by branching…</p>
<hr>
<p>@<a href="https://stackoverflow.com/questions/39651/git-stash-vs-git-branch#39862">Jordi Bunster</a>: Thanks, that clears things up. I guess I'd kind of consider "stashing" to be like a lightweight, nameless, branch. So anything stash can do, branch can as well but with more words. Nice!</p>
|
<p>'stash' takes the uncommitted, "<em>dirty</em>" stuff on your working copy, and stashes it away, leaving you with a clean working copy.</p>
<p>It doesn't really branch at all. You can then apply the stash on top of any other branch. Or, as of Git 1.6, you can do:</p>
<pre><code>git stash branch <branchname> [<stash>]
</code></pre>
<p>to apply the stash on top of a new branch, all in one command.</p>
<p>So, stash works great if you have not committed to the "<em>wrong</em>" branch yet.</p>
<p>If you've already committed, then the workflow you describe in your question is a better alternative. And by the way, you're right: Git is very flexible, and with that flexibility comes overlapping functionality.</p>
|
<p>If you look for a workflow that may be more fitting than git stash, you may want to look at <a href="https://github.com/da-x/git-bottle" rel="nofollow" title="git-bottle">git-bottle</a>. It's a utility for the purpose of saving and restoring the various git working states as normal git commits, effectively snapshotting the current and pertinent state of your working tree and <strong>all</strong> various file states shown under git status.</p>
<p>Key differences from <code>git stash</code>:</p>
<ul>
<li><code>git stash</code> saves the dirty git state narrowly (modified files, and added files in the index), whereas <code>git-bottle</code> is designed to save <em>everything</em> that is different from <code>HEAD</code>, and it differentiates in a preserving way between modified, modified and not added, not added, unmerged paths, and the complete rebase/merge states (only paths under <code>.gitignore</code> are not saved).</li>
<li><code>git stash</code> saves to stash objects that you need to keep track separately. If I stashed something 2 weeks ago I might not remember it, whereas <code>git-bottle</code> saves as <strong>tentative commits to the current branch</strong>. The reverse action is <code>git-unbottle</code> which is the equivalent of the <code>git stash</code> pop. It is possible to push and share these commits among repositories. This can be useful for remote builds, where you have another repository in a remote server just for building, or for collaborating with other people on conflict resolution.</li>
</ul>
| 6,075
|
<p>Is there an automatic way in SQL Server 2005 to create a database from several tables in another database? I need to work on a project and I only need a few tables to run it locally, and I don't want to make a backup of a 50 gig DB.</p>
<p><strong>UPDATE</strong></p>
<p>I tried the Tasks -> Export Data in Management studio, and while it created a new sub database with the tables I wanted, it did not copy over any table metadata, ie...no PK/FK constraints and no Identity data (Even with Preserve Identity checked).</p>
<p>I obviously need these for it to work, so I'm open to other suggestions. I'll try that database publishing tool.</p>
<p>I don't have Integration Services available, and the two SQL Servers cannot directly connect to each other, so those are out.</p>
<p><strong>Update of the Update</strong></p>
<p>The Database Publishing Tool worked, the SQL it generated was slightly buggy, so a little hand editing was needed (Tried to reference nonexistent triggers), but once I did that I was good to go.</p>
|
<p>You can use the <a href="http://www.codeplex.com/sqlhost/wiki/view.aspx?title=database%20publishing%20wizard" rel="nofollow noreferrer">Database Publishing Wizard</a> for this. It will let you select a set of tables with or without the data and export it into a .sql script file that you can then run against your other db to recreate the tables and/or the data.</p>
|
<ol>
<li>Create new database</li>
<li>Right click on it,</li>
<li>Tasks -> Import Data</li>
<li>Follow instructions</li>
</ol>
| 4,415
|
<p>I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model. Is there a way to access a model from inside another mode, or a better way to handle authentication inside CodeIgniter?</p>
|
<p>In general, you don't want to create objects inside an object. That's a bad habit, instead, write a clear API and inject a model into your model.</p>
<pre><code><?php
// in your controller
$model1 = new Model1();
$model2 = new Model2();
$model2->setWhatever($model1);
?>
</code></pre>
|
<p>Don't handle authentication in your model. Only use models to interface with your database, or ldap or whatever.</p>
<p>I created an Auth library that I use to manage authentication and authorization. You can access a library like this from your controllers.</p>
| 6,842
|
<p>All of my Visio experience is with LAN/WAN documentation. I recently had a desire to visualize the relationship between <a href="http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html" rel="nofollow noreferrer">objects</a> in the <a href="http://www.nagios.org/" rel="nofollow noreferrer">Nagios</a> configuration and I realized I didn't know how to do it properly and moved on to something more important. I was reading the responses to <a href="https://stackoverflow.com/questions/15446/documenting-program-archetecture">this thread</a> and realized this is something software developers must do a lot.</p>
<p>So this is probably a soft-pitch question, but what is the proper method for documenting object relationships in Visio? Is there a better template to use? What stencil collection is the proper stencil in?</p>
<p>In my probably naive view I imagine an object being a large box with a single "reception" connector and containing multiple smaller boxes, each of which represents an object member and having its own connector. So, each object member field would connect out to the "reception" connector on the object of the member's type. In and of itself those objects are fairly easy to build. The problem I ran into is that the connector lines didn't respect the objects and ran over the top of them, making an awful, unusable mess.</p>
<p>Thanks for any pointers.</p>
|
<p>I just built a quad core - 8 GB of RAM and run Server 2008 with Hyper-V on it. I have VMs for my build server, dev platform, and deployment options (XP, Vista, Server 2003/2008) with snapshots at the various service pack levels. What's nice is you can spin up a VM whenever you need it, and re-allocate the resources when you don't.. So if I want to have 4 or 5 GB of ram and four processors available for my dev platform, no problem.. when I need to test some installs, I can save my status and spin up my test machines.. (and it only ran about $800 US).</p>
|
<p>People are probably going to yell at me...but I've found that Vista 64 is mostly worth it. The main reason for me though is that I'm always maxing out my memory and having a 64bit OS allows me to go past the <4GB limit of 32bit.</p>
<p>But even if you don't get 64bit, just buy 2 2GB RAM cards anyways....you will be able to use most of it (my system shows 3.5GB on 32bit) and then you've got it for if you upgrade later and (if your system has 4 slots) you'll have room to expand to 8GB later on....</p>
| 3,636
|
<p>I haven't been able to find an understandable explanation of how to actually use Python's <code>itertools.groupby()</code> function. What I'm trying to do is this:</p>
<ul>
<li>Take a list - in this case, the children of an objectified <code>lxml</code> element</li>
<li>Divide it into groups based on some criteria</li>
<li>Then later iterate over each of these groups separately.</li>
</ul>
<p>I've reviewed <a href="https://docs.python.org/3/library/itertools.html#itertools.groupby" rel="noreferrer">the documentation</a>, but I've had trouble trying to apply them beyond a simple list of numbers.</p>
<p>So, how do I use of <code>itertools.groupby()</code>? Is there another technique I should be using? Pointers to good "prerequisite" reading would also be appreciated.</p>
|
<p><strong>IMPORTANT NOTE:</strong> You have to <strong>sort your data</strong> first.</p>
<hr />
<p>The part I didn't get is that in the example construction</p>
<pre><code>groups = []
uniquekeys = []
for k, g in groupby(data, keyfunc):
groups.append(list(g)) # Store group iterator as a list
uniquekeys.append(k)
</code></pre>
<p><code>k</code> is the current grouping key, and <code>g</code> is an iterator that you can use to iterate over the group defined by that grouping key. In other words, the <code>groupby</code> iterator itself returns iterators.</p>
<p>Here's an example of that, using clearer variable names:</p>
<pre><code>from itertools import groupby
things = [("animal", "bear"), ("animal", "duck"), ("plant", "cactus"), ("vehicle", "speed boat"), ("vehicle", "school bus")]
for key, group in groupby(things, lambda x: x[0]):
for thing in group:
print("A %s is a %s." % (thing[1], key))
print("")
</code></pre>
<p>This will give you the output:</p>
<blockquote>
<p>A bear is a animal.<br />
A duck is a animal.</p>
<p>A cactus is a plant.</p>
<p>A speed boat is a vehicle.<br />
A school bus is a vehicle.</p>
</blockquote>
<p>In this example, <code>things</code> is a list of tuples where the first item in each tuple is the group the second item belongs to.</p>
<p>The <code>groupby()</code> function takes two arguments: (1) the data to group and (2) the function to group it with.</p>
<p>Here, <code>lambda x: x[0]</code> tells <code>groupby()</code> to use the first item in each tuple as the grouping key.</p>
<p>In the above <code>for</code> statement, <code>groupby</code> returns three (key, group iterator) pairs - once for each unique key. You can use the returned iterator to iterate over each individual item in that group.</p>
<p>Here's a slightly different example with the same data, using a list comprehension:</p>
<pre><code>for key, group in groupby(things, lambda x: x[0]):
listOfThings = " and ".join([thing[1] for thing in group])
print(key + "s: " + listOfThings + ".")
</code></pre>
<p>This will give you the output:</p>
<blockquote>
<p>animals: bear and duck.<br />
plants: cactus.<br />
vehicles: speed boat and school bus.</p>
</blockquote>
|
<p>One useful example that I came across may be helpful:</p>
<pre><code>from itertools import groupby
#user input
myinput = input()
#creating empty list to store output
myoutput = []
for k,g in groupby(myinput):
myoutput.append((len(list(g)),int(k)))
print(*myoutput)
</code></pre>
<p>Sample input: 14445221</p>
<p>Sample output: (1,1) (3,4) (1,5) (2,2) (1,1)</p>
| 2,321
|
<p>I was asked this question in a job interview. The interviewer and I disagreed on what the correct answer was. I'm wondering if anyone has any data on this.</p>
<p>Update: I should have mentioned that the use of shuffle() was strictly forbidden... sorry.</p>
|
<p>You could use the <a href="http://en.wikipedia.org/wiki/Knuth_shuffle" rel="nofollow noreferrer">Fisher-Yates shuffle</a>.</p>
|
<p>The "correct" way is pretty vague. The best (fastest / easiest / most elegant) to sort an array would be to just use the built-in shuffle() function.</p>
| 9,161
|
<p>What kind of programming problems are state machines most suited for?</p>
<p>I have read about parsers being implemented using state machines, but would like to find out about problems that scream out to be implemented as a state machine.</p>
|
<p>The easiest answer is probably that they are suited for practically any problem. Don't forget that a computer itself is also a state machine.</p>
<p>Regardless of that, state machines are typically used for problems where there is some stream of input and the activity that needs to be done at a given moment depends the last elements seen in that stream at that point.</p>
<p>Examples of this stream of input: some text file in the case of parsing, a string for regular expressions, events such as <code>player entered room</code> for game AI, etc.</p>
<p>Examples of activities: be ready to read a number (after another number followed by a <code>+</code> have appear in the input in a parser for a calculator), turn around (after player approached and then sneezed), perform jumping kick (after player pressed left, left, right, up, up).</p>
|
<p>Things that comes to mind are:</p>
<blockquote>
<ul>
<li>Robot/Machine manipulation... those robot arms in factories</li>
<li>Simulation Games, (SimCity, Racing Game etc..)</li>
</ul>
</blockquote>
<p>Generalizing: When you have a string of inputs that when interacting with anyone of them, requires the knowledge of the previous inputs or in other words, when processing of any single input requires the knowledge of previous inputs. (that is, it needs to have "states")</p>
<p>Not much that I know of that isn't reducible to a parsing problem though.</p>
| 6,182
|
<p>Suppose I have <code>fileA.h</code> which declares a class <code>classA</code> with template function <code>SomeFunc<T>()</code>. This function is implemented directly in the header file (as is usual for template functions). Now I add a specialized implementation of <code>SomeFunc()</code> (like for <code>SomeFunc<int>()</code>) in <code>fileA.C</code> (ie. not in the header file).</p>
<p>If I now call <code>SomeFunc<int>()</code> from some other code (maybe also from another library), would it call the generic version, or the specialization?</p>
<p>I have this problem right now, where the class and function live in a library which is used by two applications. And one application correctly uses the specialization, while another app uses the generic form (which causes runtime problems later on). Why the difference? Could this be related to linker options etc? This is on Linux, with g++ 4.1.2.</p>
|
<p>It is <strong>an error</strong> to have a specialization for a template which is not visible at the point of call. Unfortunately, compilers are not required to diagnose this error, and can then do what they like with your code (in standardese it is "ill formed, no diagnostic required").</p>
<p>Technically, you need to define the specialization in the header file, but just about every compiler will handle this as you might expect: this is fixed in C++11 with the new "extern template" facility:</p>
<pre><code>extern template<> SomeFunc<int>();
</code></pre>
<p>This explicitly declares that the particular specialization is defined elsewhere. Many compilers support this already, some with and some without the <code>extern</code>.</p>
|
<p>Unless the specialized template function is also listed in the header file, the other application will have no knowledge of the specialized version. The solution is the add <code>SomeFunc<int>()</code> to the header as well.</p>
| 8,391
|
<p><a href="http://www.5axismaker.com/5axis/" rel="nofollow noreferrer">5AxisMaker</a> has a 5 axis CNC/3D printer combo machine. I understand what the benefits of 5 axis are for CNC machines, but are there any benefits for 3D printing. In this <a href="https://youtu.be/w8Fl8L4yk8M" rel="nofollow noreferrer">video</a> they show the printer printing on an angle, but this could have been done with just linear layers.</p>
<p>Would there be any cases where a 5 axis printer would preform better than a 3 axis printer?</p>
|
<p>One aspect of having this level of control with 3d printing of a model is the removal of the need for supports and the attendant post-processing. In the case of the model shown in the video, some effects are created by printing the continents in a conformal manner that would otherwise be impossible with conventional 3d printing. Cosmetically, the results of the "5d" printer are superior in this example.</p>
<p>There would also be some structural benefit for models with high organic content, that is curves and bulges, as opposed to orthogonal designs. Even with orthogonal designs, one can achieve stronger parts with cross-layered plastic in all directions, rather than being limited by x and y filament layers.</p>
<p>I see on the web site that one can exchange tool heads as well. One could print a 3d model, layering the filament on all the surfaces, then use a tool head change to a milling bit and smooth the surface under CAD control. Alternatively, one could use foam or wood and mill a model shape to be covered with a 3d printed material.</p>
<p>Considering the relative novelty of this product, it's likely that many aspects of the creative utility have yet to be discovered!</p>
|
<p>Slicing prints for printing in 5 Axis is not going to be simple with the current software. If you look at the web site for the 5AxisMaker you can see they are using Algorithmic modeling software (Grasshopper). You would probably need to buy this as well and then spend a decent amount of time learning how to use this software as well if you were going to try and take advantage of the 5th Axis for 3D printing. </p>
<p>I have only seen Grasshopper used for 3D printing and 5 Axis used in research papers. </p>
| 428
|
<p>I am using git on a project, that generates lots of data-files (simulation-results).
I am "forced" to version and track all those results in the same repository. (This is a hard requirement and can not be changed)</p>
<p>However I don't need them. We have about 50 MB for the project and 5 GB results in the repository.</p>
<p>Is it feasible for me to create a branch, delete all the results, check this branch out and only work on that branch?</p>
<p>How hard would it be (what would I have to do), to push my local changes back into the fat branch?</p>
<p>Is there a better solution to get rid of those 5 GB for my work?</p>
|
<p>If you were to make a branch and delete the result files from the branch, then merging your branch back into master would also try to delete the results from master. A file delete is a change just like any other.</p>
<p>Perhaps you could use the git submodule support to manage your code changes as a submodule of the fat repository. In this way, the fat repository would appear to contain everything, but you could work on just the small code bits independently. This may take some fiddling around to work smoothly.</p>
|
<p>Besides git cherry-pick, another alternative is to run git-revert on the file delete change just before merging.</p>
| 9,680
|
<p>Is there a way to use sql-server like analytic functions in Hibernate?</p>
<p>Something like </p>
<pre><code>select foo from Foo foo where f.x = max(f.x) over (partition by f.y)
</code></pre>
|
<p>You are after a native SQL query.</p>
<p>If you are using JPA the syntax is:</p>
<pre><code>Query q = em.createNativeQuery("select foo.* from Foo foo " +
"where f.x = max(f.x) over " +
"(partition by f.y)", Foo.class);
</code></pre>
<p>If you need to return multiple types, take a look at the <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/SqlResultSetMapping.html" rel="noreferrer">SQLResultSetMapping</a> annotation.</p>
<p>If you're using the the Hibernate API directly:</p>
<pre><code>Query q = session.createSQLQuery("select {foo.*} from Foo foo " +
"where f.x = max(f.x) over "+
"(partition by f.y)");
q.addEntity("foo", Foo.class);
</code></pre>
<p>See <a href="http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#objectstate-querying-nativesql" rel="noreferrer">10.4.4. Queries in native SQL</a> in the Hibernate documentation for more details.</p>
<p>In both APIs you can pass in parameters as normal using setParameter. </p>
|
<p>Another approach would be to use the mapping. Please see this article: <a href="https://forums.hibernate.org/viewtopic.php?f=1&t=998482" rel="nofollow noreferrer">https://forums.hibernate.org/viewtopic.php?f=1&t=998482</a></p>
<p>I am against the usage of native SQL queries in Hibernate... you lose the benefits of having a mapping:-)</p>
| 9,976
|
<p>I'm sure you have all been there, you take on a project where there is a creaky old code base which is barely fit for purpose and you have to make the decision to either re-write it from scratch or repair what already exists. </p>
<p>Conventional wisdom tends to suggest that you should never attempt a re-write from scratch as the risk of failure is very high. So what did you do when faced with this problem, how did you make the decision and how did it turn out?</p>
|
<p>It really depends on how bad it is.</p>
<p>If it's a small system, and you fully understand it, then a rewrite is not crazy.</p>
<p>On the other hand, if it's a giant legacy monster with ten million lines of undocumented mystery code, then you're really going to have a hard time with a full rewrite.</p>
<p>Points to consider:</p>
<ul>
<li>If it looks good to the user, they
won't care what kind of spaghetti
mess it is for you. On the other
hand, if it's bad for them too, then
it's easier to get agreement (and
patience).</li>
<li>If you do rewrite, try to do it one
part at a time. A messy,
disorganized codebase may make this
difficult (i.e, replacing just one
part requires a rewrite of large
icebergs of dependency code), but if
possible, this makes it a lot easier
to gradually do the rewrite and get
feedback from users along the way.</li>
</ul>
<p>I would really hesitate to take on a giant rewrite project for a large system without being able to release the new edition one part at a time.</p>
|
<p>It's not so black and white... it really depends on a lot of factors (the more important being "what does the person paying you want you to do")</p>
<p>Where I work we re-wrote a development framework, and on the other hand, we keep modifying some old systems that cannot be migrated (because of the client's technology and time restrictions). In this case, we try to mantain the coding style and sometimes you have to implement a lot of workarounds because of the way it was built</p>
| 5,568
|
<p>My G29 command reports</p>
<pre><code>+0.178 +0.281 +0.830
-0.614 -0.012 +0.371
-1.208 -0.849 -0.351
</code></pre>
<p>So should I tighten up the screw of the bed, close to 0,0 position or loosen it?</p>
<p>I have a feeling that when I loosen it, it gets away from zero and I expect the opposite to happen.</p>
<p>For bed leveling i use a capacitive probe and after playing around with the screws here is the result</p>
<pre><code>+0.406 +0.127 +0.411
-0.161 -0.007 -0.041
-0.572 -0.652 -0.668
</code></pre>
<p>Finally the leveling process was found <a href="https://www.youtube.com/watch?v=y_1Kg45APko" rel="nofollow noreferrer">here</a>
But the question remains. The value <code>-0.572</code> corresponds close to <code>0,0</code> ?</p>
|
<p>Using Repetier Host V2.1.2 and slicing with Slic3r (or with CuraEngine), there is an "edit Gcode" button under the Print Preview tab. It is located at the top right of the screen. With that button you can access, examine and change the Gcode of the project you are working on.</p>
|
<p>After you use the Slice Now button (and the slicing progress bar shows completed), select the preview tab. To the right of the window you will see a pair of vertical sliders. Each slider changes the start and finish locations for the filament layers.</p>
<p>You can slide the left one to the bottom, which will "empty" the virtual print bed. Each movement upward will display a succeeding layer, showing the placement of the filament. This ostensibly will present to you alignment information as well as unexpected holes or other failure points.</p>
<p>I don't know of any slicer that lacks a preview. That doesn't mean one does not exist, but why would such a useful feature be omitted?</p>
| 944
|
<p>I know there is a 3d printing technique, where sheet of papers are cut and glued. Like the ones <a href="http://www.gizmag.com/staples-mcor-easy-3d-printing/25284/" rel="nofollow">Staples</a> has in their stores. But this sort of paper isnt recyclable, because of the heavy use of glue.</p>
<p>Is anywhere filament available, which is made of cellulose or other recyclable and bio-degradable material? Or do you know if research is going on in this area?</p>
<p>edit: added bio-degradable</p>
|
<p>Filament made of Polylactic acid (<a href="http://reprap.org/wiki/PLA" rel="nofollow">PLA</a>) is usually made of biological materials (such as corn), and can therefore be considered bio-degradable in most cases.</p>
<p>Whether the filament is 100% bio-degradable (and non-toxic for the surroundings) will depend on the specific formula used by each individual filament manufacturer. (Many manufacturers include various additives to achieve particular effects, such as <a href="http://3dprintingforbeginners.com/glow-in-the-dark-filament-review/" rel="nofollow">glow-in-the-dark</a>, <a href="http://colorfabb.com/bronzefill" rel="nofollow">metallic</a> finish or extra strengh.)</p>
<p><a href="http://colorfabb.com/woodfill-fine" rel="nofollow">Woodfill PLA</a>-like filament might be of extra interest to you, not only because it typically is bio-degradable, but also because it will give you the <em>look and feel</em> of being bio-degradable. </p>
<p>Hope that helps!</p>
<p><em>PS: there are multiple other filament types that are either recyclable, bio-degradable, or both, although PLA might be the most commonly available of them all.</em></p>
|
<p>Check Green-TEC by <a href="http://extrudr.eu/collections/bdp" rel="nofollow">extrudr.eu</a> is made from lignin (wood)
or perhaps Algix Dura. They are both bio degradeable.
Green-TEC ist my favorite because of less warping and <a href="https://www.youtube.com/watch?v=Oqx170kPmg4" rel="nofollow">fast printing</a>.</p>
| 284
|
<p>What is the difference, what is the official terms, are any terms obsolete in ASP.NET 3.5?</p>
|
<p><strong>UserControl</strong>: A custom control, ending in .ascx, that is composed of other web controls. Its almost like a small version of an aspx webpage. It consists of a UI (the ascx) and codebehind. Cannot be reused in other projects by referencing a DLL.</p>
<p><strong>WebControl</strong>: A control hosted on a webpage or in a UserControl. It consists of one or more classes, working in tandem, and is hosted on an aspx page or in a UserControl. WebControls don't have a UI "page" and must render their content directly. They can be reused in other applications by referencing their DLLs.</p>
<p><strong>RenderedControl</strong>: Does not exist. May be synonymous to WebControl. Might indicate the control is written directly to the HttpResponse rather than rendered to an aspx page.</p>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/aa479016.aspx" rel="noreferrer">CompositeControl</a></strong>: Inbetween UserControls and WebControls. They code like UserControls, as they are composed of other controls. There is not any graphical UI for control compositing, and support for UI editing of CompositeControls must be coded by the control designer. Compositing is done in the codebehind. CompositeControls can be reused in other projects like WebControls. </p>
|
<p>Since I don't have enough reputation yet to comment, I'll add this as an answer, but it refers to Will's answer above.</p>
<p>From the <a href="http://msdn.microsoft.com/en-us/library/aa479016.aspx" rel="nofollow noreferrer">link</a> you included:</p>
<blockquote>
<p>Composite controls are the right tool to architect complex components in which multiple child controls are aggregated and interact among themselves and with the outside world. Rendered controls are just right for read-only aggregation of controls in which the output doesn't include interactive elements such as drop-down or text boxes.</p>
</blockquote>
<p>I believe the documentation is refering to UserControls that have been created by overriding the Render method as Rendered Controls. Thus, it is not a separate type as the question implies, but a way of implementing a UserControl; a pattern.</p>
| 9,653
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.