instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I'm looking at a new computer which will probably have vista on it. But there are so many editions of vista; are there any weird restrictions on what you can run on the various editions? For instance you couldn't run IIS on Windows ME. Can you still run IIS on the home editions of vista? </p>
|
<p>There's a very nice and efficient algorithm for this using a method called <strong>reservoir sampling</strong>.</p>
<p>Let me start by giving you its <strong>history</strong>:</p>
<p><strong>Knuth</strong> calls this Algorithm R on p. 144 of his 1997 edition of Seminumerical Algorithms (volume 2 of The Art of Computer Programming), and provides some code for it there. Knuth attributes the algorithm to Alan G. Waterman. Despite a lengthy search, I haven't been able to find Waterman's original document, if it exists, which may be why you'll most often see Knuth quoted as the source of this algorithm.</p>
<p><strong>McLeod and Bellhouse, 1983</strong> (1) provide a more thorough discussion than Knuth as well as the first published proof (that I'm aware of) that the algorithm works.</p>
<p><strong>Vitter 1985</strong> (2) reviews Algorithm R and then presents an additional three algorithms which provide the same output, but with a twist. Rather than making a choice to include or skip each incoming element, his algorithm predetermines the number of incoming elements to be skipped. In his tests (which, admittedly, are out of date now) this decreased execution time dramatically by avoiding random number generation and comparisons on each in-coming number.</p>
<p>In <strong>pseudocode</strong> the algorithm is:</p>
<pre><code>Let R be the result array of size s
Let I be an input queue
> Fill the reservoir array
for j in the range [1,s]:
R[j]=I.pop()
elements_seen=s
while I is not empty:
elements_seen+=1
j=random(1,elements_seen) > This is inclusive
if j<=s:
R[j]=I.pop()
else:
I.pop()
</code></pre>
<p>Note that I've specifically written the code to avoid specifying the size of the input. That's one of the cool properties of this algorithm: you can run it without needing to know the size of the input beforehand and it <em>still</em> assures you that each element you encounter has an equal probability of ending up in <code>R</code> (that is, there is no bias). Furthermore, <code>R</code> contains a fair and representative sample of the elements the algorithm has considered at all times. This means you can use this as an <a href="https://en.wikipedia.org/wiki/Online_algorithm" rel="noreferrer">online algorithm</a>.</p>
<p><strong>Why does this work?</strong></p>
<p>McLeod and Bellhouse (1983) provide a proof using the mathematics of combinations. It's pretty, but it would be a bit difficult to reconstruct it here. Therefore, I've generated an alternative proof which is easier to explain.</p>
<p>We proceed via proof by induction.</p>
<p>Say we want to generate a set of <code>s</code> elements and that we have already seen <code>n>s</code> elements.</p>
<p>Let's assume that our current <code>s</code> elements have already each been chosen with probability <code>s/n</code>.</p>
<p>By the definition of the algorithm, we choose element <code>n+1</code> with probability <code>s/(n+1)</code>.</p>
<p>Each element already part of our result set has a probability <code>1/s</code> of being replaced.</p>
<p>The probability that an element from the <code>n</code>-seen result set is replaced in the <code>n+1</code>-seen result set is therefore <code>(1/s)*s/(n+1)=1/(n+1)</code>. Conversely, the probability that an element is not replaced is <code>1-1/(n+1)=n/(n+1)</code>.</p>
<p>Thus, the <code>n+1</code>-seen result set contains an element either if it was part of the <code>n</code>-seen result set and was not replaced---this probability is <code>(s/n)*n/(n+1)=s/(n+1)</code>---or if the element was chosen---with probability <code>s/(n+1)</code>.</p>
<p>The definition of the algorithm tells us that the first <code>s</code> elements are automatically included as the first <code>n=s</code> members of the result set. Therefore, the <code>n-seen</code> result set includes each element with <code>s/n</code> (=1) probability giving us the necessary base case for the induction.</p>
<p><strong>References</strong></p>
<ol>
<li><p>McLeod, A. Ian, and David R. Bellhouse. "A convenient algorithm for drawing a simple random sample." Journal of the Royal Statistical Society. Series C (Applied Statistics) 32.2 (1983): 182-184. (<a href="http://www.jstor.org/stable/10.2307/2347297" rel="noreferrer">Link</a>)</p></li>
<li><p>Vitter, Jeffrey S. "Random sampling with a reservoir." ACM Transactions on Mathematical Software (TOMS) 11.1 (1985): 37-57. (<a href="http://www.mathcs.emory.edu/~cheung/Courses/584-StreamDB/Syllabus/papers/RandomSampling/1985-Vitter-Random-sampling-with-reservior.pdf" rel="noreferrer">Link</a>)</p></li>
</ol>
|
<p>Well, you do need to know what N is at runtime at least, even if this involves doing an extra pass over the list to count them. The simplest algorithm to do this is to just pick a random number in N and remove that item, repeated k times. Or, if it is permissible to return repeat numbers, don't remove the item.</p>
<p>Unless you have a VERY large N, and very stringent performance requirements, this algorithm runs with <code>O(N*k)</code> complexity, which should be acceptable.</p>
<p>Edit: Nevermind, Tom Hawtin's method is way better. Select the random numbers first, then traverse the list once. Same theoretical complexity, I think, but much better expected runtime.</p>
| 7,768
|
<p>How can I programatically cause a control's tooltip to show in a Winforms app without needing the mouse to hover over the control? (P/Invoke is ok if necessary). </p>
|
<p>If you are using the <code>Tooltip</code> control on the form, you can do it like this:</p>
<p><code>ToolTip1.Show("Text to display", Control)</code></p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.show.aspx" rel="noreferrer">MSDN documentation for the ToolTip control's "Show" method</a> has all the different variations on this and how to use them.</p>
|
<p>This is the code I use:</p>
<pre><code>static HWND hwndToolTip = NULL;
void CreateToolTip( HWND hWndControl, TCHAR *tipText )
{
BOOL success;
if( hwndToolTip == NULL )
{
hwndToolTip = CreateWindow( TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
hInstResource,
NULL );
}
if( hwndToolTip )
{
TOOLINFO ti;
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_TRANSPARENT | TTF_SUBCLASS;
ti.hwnd = hWndControl;
ti.uId = 0;
ti.hinst = NULL;
ti.lpszText = tipText;
GetClientRect( hWndControl, &ti.rect );
success = SendMessage( hwndToolTip, TTM_ADDTOOL, 0, (LPARAM) &ti );
}
}
</code></pre>
<p>Call CreateToolTip function to create a tool tip for a certain control.</p>
| 8,891
|
<p>Linq To SQL or Entity framework both integrate nicely with SQL Server 2005.</p>
<p>The SQL Server 2008 spec sheet promises even better integration - but I can't see it.</p>
<p>What are some examples of what you can do Linq-wise when talking to a 2008 server that you can't when talking to SQL Server 2005?</p>
|
<p>There is a problem of paging over a joined set that SQL 2005 mis-interprets.</p>
<pre><code>var orders = (
from c in Customers
from o in c.Orders
select new {c, o}
).Skip(10).Take(10).ToList();
</code></pre>
<p>LINQ generates a ROW_Number against the joined set. SQL2005 generates a bad plan from that code. Here's a link to the <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3091519&SiteID=1" rel="nofollow noreferrer">discussion</a>.</p>
<p>Edit#2: I'd like to clarify that I don't know that SQL2008 solves this problem. I'm just hopeful.</p>
|
<p>it has full support for the new data types. lol. beyond that you got me, other than possibilities of optimised queries (like the merge command, etc).</p>
| 3,621
|
<p>I run Flex Builder 3 on a mac and as my project grows - the compile time gets longer and longer and longer. I am using some SWC's and there is a fair amount of code but it shouldn't take minutes to build and crash daily should it?</p>
|
<p>In addition to the suggestions already mentioned, close any projects that you have open that you are not using.</p>
<p>Rich click on the Project in the Navigator view and select "Close Unrelated Projects".</p>
<p>Depending on how many projects you have open, this can lead to a significant improvements in compile time, as well as all around performance.</p>
<p>mike chambers</p>
<p>mesh@adobe.com</p>
|
<p>Usually the first build takes the longest, and then it's pretty quick after that. That's using Vista x64 w/ core 2 duo. </p>
<p>Otherwise, I am nearly certain a Intel Core i7 Extreme Edition 965 3.2GHz upgrade processor would speed your Flex building up nicely .. :) :) :)</p>
| 5,386
|
<p>I just got my first 3D printer (Creality Ender 3) on Friday, 2 days ago. It works great, but for some reason I'm getting a lot of stringing on my prints, especially the ones where the extruder head has to move a long distance between columns/posts, etc.</p>
<p>I'm using Hatchbox "True White" PLA, which has a recommended temperature range of 180-210 °C. I've tried printing at 200, 190, and 185 °C and didn't see much improvement. I've also made sure I've enabled the 'retract' setting in the slicer (4.5 mm) and verified the printer is retracting when it should.</p>
<p>I'm not sure what else I can try... any suggestions?</p>
|
<p>4.5 mm is a low retraction distance. Cura's default is 6.5 mm, and the Ender 3 profile provided with Cura sets it to 6 mm. The first thing you should try is increasing the retraction amount up to at least 6 mm. Also, make sure you actually enabled retraction. I saw one question here where a Cura user had enabled "Retract at layer change", which <strong>does not</strong> enable retraction (but of course it shows the options like retraction amount since you need to be able to select it for this too).</p>
<p>Your low nozzle temperature of 185 °C is also a problem. You'll have very low flow at that temperature, resulting in under-extrusion and pressure building up in the nozzle instead of extruding the material. That in turn will make it so, even after retracting, there's still material (and pressure) at the nozzle and it will keep oozing, unless you set a <strong>really</strong> high retraction amount (and even then problems will build up over time during the print, but you might get lucky and not see them). The only way to print PLA at 185 °C is really, <strong>really</strong> slowly.</p>
<p>In general, some people would also recommend trying a different filament, based on reports that some vendors' PLA oozes and strings badly, but I don't think that's an issue for you. I use Hatchbox filament on my Ender 3 all the time and never have a problem with stringing from it. And even if the filament is prone to stringing, you can almost surely avoid it with proper settings. Even very soft flex filaments can be printed on this printer without stringing as long as your retraction, temperature, and speed are tuned to avoid having pressure at the nozzle during travel moves.</p>
|
<p>decrease retraction speed to 25-30mm/sec</p>
| 1,434
|
<p>Is there a way to track which window currently has keyboard focus. I could handle WM_SETFOCUS for every window but I'm wondering if there's an alternative, simpler method (i.e. a single message handler somewhere).</p>
<p>I could use OnIdle() in MFC and call GetFocus() but that seems a little hacky.</p>
|
<p>So from the way you worded the question I'm inferring that you want to have an event handler which is invoked whenever focus switches between windows. You want to be notified, rather than having to poll.</p>
<p>I actually don't think calling GetFocus from OnIdle is that much of a hack - sure it's polling, but it's low-overhead polling without side effects - but if you really want to track this, <a href="http://msdn.microsoft.com/en-us/library/ms997537.aspx" rel="noreferrer">Windows Hooks</a> are probably your best choice. Specifically you can install a CBT hook (WH_CBT) and listen for the HCBT_SETFOCUS notification.</p>
<blockquote>
<p>Windows calls the WH_CBT hook with this hook code when Windows is about to set the focus to any window. In the case of thread-specific hooks, the window must belong to the thread. If the filter function returns TRUE, the focus does not change.</p>
</blockquote>
<p>You could also do with with a WH_CALLWNDPROC hook and listen for the WM_SETFOCUS message.</p>
<p>Depending on whether you make it a global hook, or app-local, you can track focus across all windows on the system, or only the windows owned by your process.</p>
|
<p>You could monitor messages for the <a href="http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_activate.asp?frame=true" rel="nofollow noreferrer">WM_ACTIVATE</a> event.</p>
<p><a href="http://blogs.msdn.com/jfoscoding/archive/2006/08/02/686141.aspx" rel="nofollow noreferrer">ref</a></p>
| 6,595
|
<p>I recently bought a Titan Aero hot end which came with a 24 V 30 W heater cartridge from E3D. I'd like to use this but the cable length is only 1 meter long and I need it to be 2 meters. The ends terminate with prong connections and there is no polarity to the prongs. How can I safely extend the leads one meter and then connect to my Duet 3 Mainboard 6HC?</p>
<p>Should the cable terminate with a JST connector instead of the prongs to connect to the Duet board?</p>
<p><a href="https://i.stack.imgur.com/OVTbP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OVTbP.jpg" alt="heater cartridge" /></a>
<a href="https://i.stack.imgur.com/bucyV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bucyV.jpg" alt="duet" /></a></p>
|
<h1>Heater polarity doesn't matter</h1>
<p>The heater cartridges are just large resistors and so polarity is irrelevant. Either can be positive or negative.</p>
<p>You can extend the leads by cutting and splicing in ~20 gauge wires* to a two pin JST connector line you suggest.</p>
<hr />
<p>*<sup>At 24 volts and 30 watts, you need <a href="https://www.platt.com/CutSheets/Multiple/AWG%20Conductors.pdf" rel="nofollow noreferrer">wire that is rated to carry at least 1.25 amps</a>. The US National Electric Code dictates that this should be 20 gauge wire, but their standard is very conservative. Since you don't need to adhere to NEC codes, you could get away with something thinner (ie higher gauge number).</sup></p>
|
<p>1 meter puts you far enough away from the heater than you don't need high temperature wiring to extend it. The larger the guage(e.g. 20 guage) the less resistance you will add to the heater circuit. This doesn't matter as long as you can still achieve your maximum temperature (if you can still achieve the same current without maxing out your voltage on the heater).</p>
<p>Your sensor is where added series resistance is critical. Series resistance to the thermistor will give a negative error in the temperature.</p>
| 1,918
|
<p>What are the JVM implementations available on Windows Mobile?</p>
<p><a href="http://www.esmertec.com/40.html" rel="noreferrer">Esmertec JBed</a> is the one on my WinMo phone.</p>
<p>Wondering how many other JVM vendors are in this zone. Are there any comparison or benchmarking data available?</p>
|
<p>JVM Choices for Windows CE in general (including Pocket PC and Windows Mobile):</p>
<ul>
<li>CrE-ME</li>
<li><a href="http://www2s.biglobe.ne.jp/~dat/java/project/jvm/index_en.html" rel="noreferrer">Mysaifu</a></li>
<li><a href="http://www.skelmir.com/solutions/handheld.html" rel="noreferrer">Skelmir CEEJ</a></li>
</ul>
<p>If you're looking to have a common code base between WinMo and Symbina, you might also look at <a href="http://www.redfivelabs.com/" rel="noreferrer">Red Five Labs</a>. They have a Symbian runtime that allows you to run COmpact Framework apps, so you could have a CF codebase that works on both. I evaluated the early betas of Red Five's offering, but haven't used it since, so I can't attest to the quality or coverage.</p>
|
<p>This is not really an answer, but wouldn't it make more sense to target your software at the .NET framework compact edition if you're developing for WinMo?</p>
| 7,904
|
<p>Since I have lots of PETG, I ran tuning to 230 °C (average temp for my filaments).
What is it good for, in terms of temperature ranges?</p>
<p>For the same printer configuration, and just different filaments, will I need to run it again and again?
Let's assume that I'll be printing between 200 °C and 240 °C.</p>
<p><a href="https://i.stack.imgur.com/SOVjm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SOVjm.png" alt="marlin pid via octoprint" /></a></p>
|
<p>PID tuning can be performed multiple times and the results saved for future use, since the question is about "what are the usable ranges for PID tuning", based on my experience</p>
<ol>
<li>a slightly suboptimal tuning will not make the temperature oscillate more than 2-3 degrees, which is more than enough for most traditional filaments</li>
<li>if you have a 30-40 °C temperature range you can likely keep a tuning in the middle and be done with it</li>
<li>an accurate tuning is needed if you run the hot end at its maximum rated temperature: mine was rated 250 °C and without a good PID tuning the temperature was overshooting by 2-3 degrees, which was enough to trigger a over-temperature safety shutdown. Using the printer at 245 °C would have resulted in no issues even with sub-optimal PID tuning.</li>
</ol>
<p>Of course, people with high temperature hot ends (up to 270-300 °C or more) will need a tuning for the usual range (200-240 °C) and one for the higher temperature range to obtain better prints.</p>
|
<p>It's not a straight answer, but you don't have to run PID tuning every time you decide to print with different temperature. (Until you change something in a hardware near or related to the hotend.)</p>
<p>You can tune PID for different temperatures and grab necessary values, for example:</p>
<pre><code>M303 C16 D1 E0 S190
22:14:31.872 > PID Autotune finished! Put the last Kp, Ki and Kd constants from below into Configuration.h
22:14:31.886 > #define DEFAULT_Kp 30.87
22:14:31.886 > #define DEFAULT_Ki 3.06
22:14:31.886 > #define DEFAULT_Kd 77.75
</code></pre>
<p>and then store respective G-code commands (like <code>M301 P30.87 I3.06 D77.75</code>) as few different "PID profiles" as new entries in <em><a href="/q/7676/">custom menu for Marlin</a></em> or <em>menu.cfg for Klipper</em> for quick switching.</p>
| 1,857
|
<p>In Ruby 1.8, there are subtle differences between proc/lambda on the one hand, and <code>Proc.new</code> on the other. </p>
<ul>
<li>What are those differences?</li>
<li>Can you give guidelines on how to decide which one to choose?</li>
<li>In Ruby 1.9, proc and lambda are different. What's the deal?</li>
</ul>
|
<p>Another important but subtle difference between procs created with <code>lambda</code> and procs created with <code>Proc.new</code> is how they handle the <code>return</code> statement:</p>
<ul>
<li>In a <code>lambda</code>-created proc, the <code>return</code> statement returns only from the proc itself</li>
<li>In a <code>Proc.new</code>-created proc, the <code>return</code> statement is a little more surprising: it returns control not just from the proc, <strong>but also from the method enclosing the proc!</strong></li>
</ul>
<p>Here's <code>lambda</code>-created proc's <code>return</code> in action. It behaves in a way that you probably expect:</p>
<pre><code>def whowouldwin
mylambda = lambda {return "Freddy"}
mylambda.call
# mylambda gets called and returns "Freddy", and execution
# continues on the next line
return "Jason"
end
whowouldwin
#=> "Jason"
</code></pre>
<p>Now here's a <code>Proc.new</code>-created proc's <code>return</code> doing the same thing. You're about to see one of those cases where Ruby breaks the much-vaunted Principle of Least Surprise:</p>
<pre><code>def whowouldwin2
myproc = Proc.new {return "Freddy"}
myproc.call
# myproc gets called and returns "Freddy",
# but also returns control from whowhouldwin2!
# The line below *never* gets executed.
return "Jason"
end
whowouldwin2
#=> "Freddy"
</code></pre>
<p>Thanks to this surprising behavior (as well as less typing), I tend to favor using <code>lambda</code> over <code>Proc.new</code> when making procs.</p>
|
<p>The difference in behaviour with <code>return</code> is IMHO the most important difference between the 2. I also prefer lambda because it's less typing than Proc.new :-)</p>
| 2,305
|
<p>I have a control that, upon postback, saves form results back to the database. It populates the values to be saved by iterating through the querystring. So, for the following SQL statement (vastly simplified for the sake of discussion)...</p>
<pre><code>UPDATE MyTable
SET MyVal1 = @val1,
MyVal2 = @val2
WHERE @id = @id
</code></pre>
<p>...it would cycle through the querystring keys thusly:</p>
<pre><code>For Each Key As String In Request.QueryString.Keys
Command.Parameters.AddWithValue("@" & Key, Request.QueryString(Key))
Next
</code></pre>
<p>HOWEVER, I'm now running into a situation where, under certain circumstances, some of these variables may not be present in the querystring. If I don't pass along val2 in the querystring, I get an error: <code>System.Data.SqlClient.SqlException: Must declare the scalar value "@val2"</code>.</p>
<p>Attempts to detect the missing value in the SQL statement...</p>
<pre><code>IF @val2 IS NOT NULL
UPDATE MyTable
SET MyVal1 = @val1,
MyVal2 = @val2
WHERE @id = @id
</code></pre>
<p>... have failed.</p>
<p>What's the best way to attack this? Must I parse the SQL block with RegEx, scanning for variable names not present in the querystring? Or, is there a more elegant way to approach?</p>
<p>UPDATE: Detecting null values in the VB codebehind defeats the purpose of decoupling the code from its context. I'd rather not litter my function with conditions for every conceivable variable that might be passed, or not passed.</p>
|
<p>First of all, I would suggest against adding all entries on the querystring as parameter names, I'm not sure this is unsafe, but I wouldn't take that chance.</p>
<p>The problem is you're calling</p>
<pre><code>Command.Parameters.AddWithValue("@val2", null)
</code></pre>
<p>Instead of this you should be calling:</p>
<pre><code>If MyValue Is Nothing Then
Command.Parameters.AddWithValue("@val2", DBNull.Value)
Else
Command.Parameters.AddWithValue("@val2", MyValue)
End If
</code></pre>
|
<p>Update: The solution I gave is based on the assumption that it is a stored proc.
<em>Will giving a default value of Null to the SQL Stored proc parameters work?</em></p>
<p>If it is dynamic sql, always pass the correct number of params, whether it is null or the actual value or specify default values.</p>
| 9,130
|
<p>So, I've read that it is not a good idea to install VS2008 on my test server machine as it changes the run time environment too much. I've never attempted remote debugging with Visual Studio before, so what is the "best" way to get line by line remote debugging of server side web app code. I'd like to be able to set a breakpoint, attach, and start stepping line by line to verify code flow and, you know, debug and stuff :).</p>
<p>I'm sure most of the answers will pertain to ASP.NET code, and I'm interested in that, but my current code base is actually Classic ASP and ISAPI Extensions, so I care about that a little more.</p>
<p>Also, my test server is running in VMWare, I've noticed in the latest VMWare install it mentioning something about debugging support, but I'm unfamiliar with what that means...anyone using it, what does it do for you?</p>
|
<p>First, this is MUCH easier if both the server and your workstation are on the same domain (the server needs access to connect to your machine). In your C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86 (or x64, or ia64) directory are the files you need to copy to your server. There are different versions between Visual Studio versions, so make sure they match on the client and server side. On the server, fire up msvsmon. It will say something like "Msvsmon started a new server named xxx@yyyy". This is the name you'll use in Visual Studio to connect to this server. You can go into Tools > Options to set the server name and to set the authentication mode (hopefully Windows Authentication) - BTW No Authentication doesn't work for managed code. </p>
<p>On the client side, open up Visual Studio and load the solution you're going to debug. Then go to Debug > Attach to Process. In the "Qualifier" field enter the name of the server as you saw it appear earlier. Click on the Select button and select the type of code you want to debug, then hit OK. Hopefully you'll see a list of the processes on the server that you can attach to (you should also see on the server that the debugging monitor just said you connected). Find the process to attach to (start up the app if necessary). If it's an ASP.NET website, you'd select w3wp.exe, then hit Attach. Set your breakpoints and hopefully you're now remotely debugging the code.</p>
<p>AFAIK - the VMWare option lets you start up code inside of a VM but debug it from your workstation. </p>
|
<p>Visual Studio comes with a <a href="http://msdn.microsoft.com/en-us/library/bt727f1t(VS.71).aspx" rel="nofollow noreferrer">remote debugger</a> that you can run as an exe on your server. It works best if you can run it as the same domain user as your copy of visual studio. You can then do an attach to process from the debugger on your machine to the IIS process on the server and debug as if it was running on your machine. You get more options for .Net debugging, but there's support for older platforms too.</p>
| 6,087
|
<p>I am developing an online strategy game using .Net v2. Although the game is primarily strategic, it does have some tactical elements that require reasonable network performance. I plan to use TCP packets for strategic data and UDP packets for tactical data. </p>
<p>{EDIT} I forgot to mention that I am leaning away from WCF and .NET 3+ for a couple of reasons. First, because I want to keep my download small and most of my customers already have .NET 2.0. Second, because I would like to have the option of porting to Mac and Linux and am unsure of WCF availability in Mono. {/EDIT}</p>
<p>I am looking for network library recommendations. I have found a few options, such as GarageGames' Torque Network Library (C++), RakNet (C++), and the lidgren network library (C#):</p>
<p><a href="http://www.opentnl.org/" rel="nofollow noreferrer">http://www.opentnl.org/</a>
<a href="http://www.jenkinssoftware.com/" rel="nofollow noreferrer">http://www.jenkinssoftware.com/</a>
<a href="http://code.google.com/p/lidgren-network/" rel="nofollow noreferrer">http://code.google.com/p/lidgren-network/</a></p>
<p>Does anyone have real-world experience with these or other libraries?</p>
<hr>
<p>I just stumbled on RakNetDotNet:</p>
<p><a href="http://code.google.com/p/raknetdotnet/" rel="nofollow noreferrer">http://code.google.com/p/raknetdotnet/</a></p>
<p>This <em>might</em> be what I'm looking for...</p>
|
<p>Microsoft's own .NET based <a href="http://creators.xna.com/" rel="noreferrer">XNA</a> allows you to create networked games on Windows and XBox 360.</p>
|
<p>If you're new to game development, I'd recommend XNA- it's easy to program with. The advantage of Torque, however, is it has asset creation tools, which can also be invaluable. For a higher end game or FPS, the Source engine is great.</p>
| 6,901
|
<p>Has anybody used C# to write a sample screen scraper for IBM as400?</p>
|
<p><a href="http://www.codeproject.com/KB/cs/all_ehllapi.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/all_ehllapi.aspx</a></p>
<p>I've modified this example and it works just fine.</p>
|
<p>I wrote one in C many years ago for a project at Frigidaire. The internal card would cause all sorts of fun with memory leaks but I eventually found a solution by allocating arrays at the boundary of the communication card. This was over 8 years ago, I'm sure today's cards are much better and/or using native comm to read the AS400 screens.</p>
| 9,050
|
<p>I found <a href="https://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference">What are mvp and mvc and what is the difference</a> but it didn't really answer this question.</p>
<p>I've recently started using MVC because it's part of the framework that myself and my work-partner are going to use. We chose it because it looked easy and separated process from display, are there advantages besides this that we don't know about and could be missing out on?</p>
<p><strong>Pros</strong></p>
<ol>
<li>Display and Processing are seperated</li>
</ol>
<p><br />
<strong>Cons</strong></p>
<ol>
<li>None so far</li>
</ol>
|
<p>MVC is the separation of <b>m</b>odel, <b>v</b>iew and <b>c</b>ontroller — nothing more, nothing less. It's simply a paradigm; an ideal that you should have in the back of your mind when designing classes. Avoid mixing code from the three categories into one class.</p>
<p>For example, while a table grid <em>view</em> should obviously present data once shown, it should not have code on where to retrieve the data from, or what its native structure (the <em>model</em>) is like. Likewise, while it may have a function to sum up a column, the actual summing is supposed to happen in the <em>controller</em>.</p>
<p>A 'save file' dialog (<em>view</em>) ultimately passes the path, once picked by the user, on to the <em>controller</em>, which then asks the <em>model</em> for the data, and does the actual saving.</p>
<p>This separation of responsibilities allows flexibility down the road. For example, because the view doesn't care about the underlying model, supporting multiple file formats is easier: just add a model subclass for each.</p>
|
<p>Main advantage of MVC architecture is differentiating the layers of a project in Model,View and Controller for the Re-usability of code, easy to maintain code and maintenance. The best thing is the developer feels good to add some code in between the project maintenance. </p>
<p>Here you can see the some more points on <a href="http://javabynataraj.blogspot.in/2009/05/14-advantages-of-mvc-arch.html" rel="nofollow">Main Advantages of MVC Architecture</a>.</p>
| 4,622
|
<p>Is there an easy way to discover a File's creation time with Java? The File class only has a method to get the "last modified" time. According to some resources I found on Google, the File class doesn't provide a getCreationTime() method because not all file systems support the idea of a creation time.</p>
<p>The only working solution I found involes shelling out the the command line and executing the "dir" command, which looks like it outputs the file's creation time. I guess this works, I only need to support Windows, but it seems very error prone to me.</p>
<p>Are there any third party libraries that provide the info I need?</p>
<p><strong>Update:</strong> In the end, I don't think it's worth it for me to buy the third party library, but their API does seem pretty good so it's probably a good choice for anyone else that has this problem. </p>
|
<p>With the release of Java 7 there is a built-in way to do this:</p>
<pre><code>Path path = Paths.get("path/to/file");
BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
FileTime creationTime = attributes.creationTime();
</code></pre>
<p>It is important to note that not all operating systems provide this information. I believe in those instances this returns the mtime which is the last modified time.</p>
<p>Windows does provide creation time.</p>
|
<p>This is a basic example in <code>Java</code>, using <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/BasicFileAttributes.html" rel="nofollow"><strong><code>BasicFileAttributes</code></strong></a> class:</p>
<pre><code> Path path = Paths.get("C:\\Users\\jorgesys\\workspaceJava\\myfile.txt");
BasicFileAttributes attr;
try {
attr = Files.readAttributes(path, BasicFileAttributes.class);
System.out.println("File creation time: " + attr.creationTime());
} catch (IOException e) {
System.out.println("oops un error! " + e.getMessage());
}
</code></pre>
| 5,253
|
<p>I was listening to a <a href="http://www.hanselminutes.com/default.aspx?showID=143" rel="noreferrer">recent episode of Hanselminutes</a> where Scott Hanselman was discussing accessibility in web applications and it got me thinking about accessibility in my own applications.</p>
<p>We all understand the importance of semantic markup in our web applications as it relates to accessibility but what about other simple enhancements that can be made to improve the user experience for disabled users?</p>
<p>In the episode, there were a number of times where I slapped my forehead and said "Of course! Why haven't I done that?" In particular, Scott talked about a website that placed a hidden link at the top of a web page that said "skip to main content". The link will only be visible to people using screen readers and it allows their screen reader to jump past menus and other secondary content. It's such an obvious improvement yet it's easy not to think of it.</p>
<p>There is more to accessibility and the overall user experience than simply creating valid XHTML and calling it a day.</p>
<p>What are some of your simple tricks for improving the user experience for the vision impaired?</p>
|
<p>Check out <a href="http://www.standards-schmandards.com/index.php?show/fangs" rel="nofollow noreferrer">Fangs</a></p>
<p><a href="http://www.standards-schmandards.com/index.php?show/fangs" rel="nofollow noreferrer">Fangs</a> is an in-browser tool for Firefox that emulates what a screen reader “sees” when visiting a Web page. Its function is simple: to output a transcript of what a screen reader will read out to a user when a Web page is visited. It’s a helpful tool for quickly analyzing if you’ve structured your content effectively so that it’s understandable and usable by vision-impaired individuals, without forcing you to learn to use (and purchase) a screen-reader application such as JAWS or Windows Eyes.</p>
|
<p>Biggest problem with screen readers is usually tables to position things on your page. Screenreaders can't really handle those. Put stuff in div's in your html and put them in a sensible order. Then position the div's on your page with css. Use tables to display content that should be in a table.</p>
| 8,659
|
<p>We got <a href="https://3dprinting.meta.stackexchange.com/questions/314/can-we-get-mathjax-enabled">MathJax enabled</a>. Today I learned that there is even more! We could have <a href="https://worldbuilding.meta.stackexchange.com/questions/9710/can-we-extend-mhchem-support-in-mathjax-to-include-physical-units?cb=1"><strong>support for Physical units</strong> enabled as part of the mhchem package</a>! We use physical units <strong>a lot</strong> and demand the SI formatting. Let me quote from Worldbuilding:</p>
<blockquote>
<p>Chemistry Stack Exchange is obviously the main consumer of this feature and has a <a href="https://worldbuilding.meta.stackexchange.com/questions/9710/can-we-extend-mhchem-support-in-mathjax-to-include-physical-units?cb=1">nice FAQ on its use</a>. The chemists get two things that we don't:</p>
<ul>
<li><code>\require{mhchem}</code> is implicit... you get support automatically without having to require it explicitly.</li>
<li>They get physical unit formatting via <code>$\pu{273.15 K}$</code>, which currently renders as a grumpy error on WB.SE and WB meta that looks [with only mhchem enabled] like this <a href="https://i.stack.imgur.com/NyXoU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NyXoU.png" alt="mathjax markup error" /></a></li>
</ul>
</blockquote>
<p><strong>Can we have that too? Pretty please?</strong> I am tired of having to type <code>$273.15\ \text{K}$</code> and such, especially if it is complex things in the unit!</p>
|
<p>The deed is done. Behold! In all its glory:</p>
<p><span class="math-container">$$\pu{273.15 K}$$</span></p>
|
<p>I do not support this request to support physical units.</p>
<p><em>(vote up this answer if you are not in favor)</em></p>
| 81
|
<p>After seeing a question about FDM printing of temperature-resistant parts, high-temperature 2-part epoxy came to mind. Are there any (experimental or production) FDM extruders for laying viscous, fast-curing epoxy, mixing it at the last moment before extrusion? Or likewise other cured/resin materials, either 2-part or UV-cured (with whole print volume flooded with UV)?</p>
|
<p>Apparently now the answer is yes. A company called MASSIVit has a system they call GDP - gel dispensing printing - that's essentially what I asked about, on an extremely large scale. 3D Printing Nerd has <a href="https://www.youtube.com/watch?v=SSE2q_ejjKc" rel="nofollow noreferrer">a video</a> from their booth at Formnext 2021 in Frankfurt, Germany.</p>
|
<p>Is this what you're looking for?</p>
<p>(<a href="https://the3dprinterbee.com/how-does-a-resin-3d-printer-work-sla-dlp-lcd-explained/" rel="nofollow noreferrer">https://the3dprinterbee.com/how-does-a-resin-3d-printer-work-sla-dlp-lcd-explained/</a>)</p>
<p>Material Beam</p>
<p>Material blasting is a unique 3D resin printing technology that can be compared to an office inkjet printer. It is also considered one of the fastest and most accurate 3D printing technologies available for resin printing today.</p>
<p>Material Beam 3D printers are similar to inkjet 3D printers in that they also have a print head from which thousands of tiny resin droplets are applied to the building platform and then cured with UV light. Once a layer has been completed, the building platform automatically lowers to the height of a layer and the process is repeated until the object is completed.</p>
<p>The technology of material blasting enables high dimensional accuracy, but speed is also a convincing point. The process in which the resin droplets are ejected from several print heads, which in turn move back and forth over the building platform, is known as line-by-line cutting. This ensures that multiple parts can be produced without affecting the build speed. As a user, you also have the choice between matte and shiny surfaces on your 3D printed object. However, the individual components for material beam technology are very cost-intensive. Other disadvantages are the waste of material when you choose to print matt surfaces and the low strength of the 3D printed parts.</p>
| 1,847
|
<p>In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to put logic.</p>
<p>Please answer in the affirmative - With <em>Do put this here</em>, rather than <em>Don't put that there</em>.</p>
|
<p>MVC</p>
<p><strong>Controller</strong>: Put code here that has to do with working out what a user wants, and deciding what to give them, working out whether they are logged in, whether they should see certain data, etc. In the end, the controller looks at requests and works out what data (Models) to show and what Views to render. If you are in doubt about whether code should go in the controller, then it probably shouldn't. Keep your controllers <a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model" rel="noreferrer">skinny</a>.</p>
<p><strong>View</strong>: The view should only contain the minimum code to display your data (Model), it shouldn't do lots of processing or calculating, it should be displaying data calculated (or summarized) by the Model, or generated from the Controller. If your View really needs to do processing that can't be done by the Model or Controller, put the code in a Helper. Lots of Ruby code in a View makes the pages markup hard to read.</p>
<p><strong>Model</strong>: Your model should be where <strong>all</strong> your code that relates to your data (the entities that make up your site e.g. Users, Post, Accounts, Friends etc.) lives. If code needs to save, update or summarise data related to your entities, put it here. It will be re-usable across your Views and Controllers.</p>
|
<p>Testing, Testing ...
Put as much logic as possible in the model and then you will be able to test it properly. Unit tests test the data and the way it is formed by testing the model, and functional tests test the way it is routed or controlled by testing the controllers, so it follows that you can't test the integrity of the data unless it is in the model.</p>
<p>j</p>
| 8,562
|
<p>I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git.</p>
<p>Has anyone made a side-by-side comparison between git and hg? I'm interested to know what differs hg and git without having to jump into a fanboy discussion.</p>
|
<p>These articles may help:</p>
<ul>
<li><a href="http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/" rel="noreferrer">Git vs. Mercurial: Please Relax</a> (Git is MacGyver and Mercurial is James Bond)</li>
<li><a href="http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/" rel="noreferrer">The Differences Between Mercurial and Git</a></li>
</ul>
<p><strong>Edit</strong>: Comparing Git and Mercurial to celebrities seems to be a trend. Here's one more:</p>
<ul>
<li><a href="http://www.ericsink.com/entries/hg_denzel.html" rel="noreferrer">Git is Wesley Snipes, Mercurial is Denzel Washington</a></li>
</ul>
|
<p>This link may help you to understand the difference
<a href="http://www.techtatva.com/2010/09/git-mercurial-and-bazaar-a-comparison/" rel="nofollow">http://www.techtatva.com/2010/09/git-mercurial-and-bazaar-a-comparison/</a></p>
| 5,641
|
<p>The primary class in the <code>subprocess</code> module is name <code>Popen</code>, and represents a subprocess. <code>Popen</code> sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it was chosen over something simple like, say, <code>Subprocess</code>?</p>
|
<p>Now, I'm not saying that this is the greatest name in the world, but here was the idea as I understand it.</p>
<p>Originally, the popen family was in the os module and was an implementation of the venerable posix popen. The movement to the subprocess module would have been an opportune time to rename them, but I guess that keeping Popen makes it easier to find in the docs for those who have a long history with python or even to the venerable posix functions.</p>
<p>From its earliest posix incarnation, <code>Popen</code> has always been meant to open a Process and allow you to read and write from its stdio like a file. Thus the mnemonic for <code>Popen</code> is that it is short for <code>ProcessOpen</code> in an attempt to kind of, sorta, look like open.</p>
|
<p>I suppose the name was chosen because the functionality <code>subprocess</code> is replacing was formerly in the <code>os</code> module as the <code>os.popen</code> function. There could be even ways to automate migration between the two.</p>
| 5,911
|
<p>What is the difference between</p>
<pre><code>char str1[32] = "\0";
</code></pre>
<p>and </p>
<pre><code>char str2[32] = "";
</code></pre>
|
<p>Since you already declared the sizes, the two declarations are exactly equal. However, if you do not specify the sizes, you can see that the first declaration makes a larger string:</p>
<pre><code>char a[] = "a\0";
char b[] = "a";
printf("%i %i\n", sizeof(a), sizeof(b));
</code></pre>
<p>prints</p>
<pre><code>3 2
</code></pre>
<p>This is because a ends with two nulls (the explicit one and the implicit one) while b ends only with the implicit one.</p>
|
<p>Unless I'm mistaken, the first will initialize 2 chars to 0 (the '\0' and the terminator that's always there, and leave the rest untouched, and the last will initialize only 1 char (the terminator).</p>
| 7,221
|
<p>I am using forms authentication. My users are redirected to a page (written in web.config) when they login, but some of them may not have the privilages to access this default page. In this case, I want them to redirect to another page but RedirectFromLoginPage method always redirects to the default page in web.config. How do I make the users login, and then redirect to a page which depends on some criteria?</p>
|
<p>The <code>SetAuthCookie</code> allows you to issue the auth cookie but retain control over the navigation. After that method is called you can run your logic to do a typical ASP.NET redirect to wherever you want.</p>
|
<pre><code>if(mc.GetfaalUsers(mm.UserName.ToString())=="True")
{
this.Page.ClientScript.
RegisterClientScriptBlock(this.GetType(), "key",
"alert('این نام کاربری فعال نشده است');", false);
FormsAuthentication.SignOut();
Response.Redirect("default.aspx");
}
</code></pre>
| 5,746
|
<p>Say I have this given XML file:</p>
<pre><code><root>
<node>x</node>
<node>y</node>
<node>a</node>
</root>
</code></pre>
<p>And I want the following to be displayed:</p>
<pre><code>ayx
</code></pre>
<p>Using something similar to:</p>
<pre><code><xsl:template match="/">
<xsl:apply-templates select="root/node"/>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
</code></pre>
|
<p>Easy!</p>
<pre><code><xsl:template match="/">
<xsl:apply-templates select="root/node">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
</code></pre>
|
<pre><code><xsl:template match="/">
<xsl:apply-templates select="root/node[3]"/>
<xsl:apply-templates select="root/node[2]"/>
<xsl:apply-templates select="root/node[1]"/>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
</code></pre>
| 7,246
|
<p>What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like :</p>
<pre><code><class1 prop1="foo" prop2="bar"/>
</code></pre>
<p>and turning that into :</p>
<pre><code>blah = new class1();
blah.prop1="foo";
blah.prop2="bar";
</code></pre>
<p>In a very generic way. The thing I don't know how to do is take the string <code>prop1</code> in the config file and turn that into the actual property accessor in the code. Are there any meta-programming facilities in C# to allow that?</p>
|
<p>It may be easier to serialise the classes to/from xml, you can then simply pass the XmlReader (which is reading your config file) to the deserializer and it will do the rest for you..</p>
<p><a href="http://www.diranieh.com/NETSerialization/XMLSerialization.htm" rel="noreferrer">This is a pretty good article on serialization</a></p>
<h2>Edit</h2>
<p>One thing I would like to add, even though reflection is powerful, it requires you to know some stuff about the type, such as parameters etc.</p>
<p>Serializing to XML doesnt need any of that, and you can still have type safety by ensuring you write the fully qualified type name to the XML file, so the same type is automatically loaded.</p>
|
<p>Reflection is what you want. Reflection + TypeConverter. Don't have much more time to explain, but just google those, and you should be well on your way. Or you could just use the xml serializer, but then you have to adhere to a format, but works great.</p>
| 5,114
|
<p>Printf got added to Java with the 1.5 release but I can't seem to find how to send the output to a string rather than a file (which is what sprintf does in C). Does anyone know how to do this? </p>
|
<pre><code>// Store the formatted string in 'result'
String result = String.format("%4d", i * j);
// Write the result to standard output
System.out.println( result );
</code></pre>
<p>See <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)" rel="noreferrer">format</a> and its <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax" rel="noreferrer">syntax</a></p>
|
<p>You can do a printf with a PrintStream to anything that is an OutputStream.
Somehow like this, printing into a string stream:</p>
<pre><code>PrintStream ps = new PrintStream(baos);
ps.printf("there is a %s from %d %s", "hello", 3, "friends");
System.out.println(baos.toString());
</code></pre>
<p>This outputs following text <strong>there is a hello from 3 friends</strong>
The string stream can be created like this ByteArrayOutputStream:</p>
<pre><code>ByteArrayOutputStream baos = new ByteArrayOutputStream();
</code></pre>
<p>You can accumulate many formats:</p>
<pre><code>PrintStream ps = new PrintStream(baos);
ps.printf("there is a %s from %d %s ", "hello", 3, "friends");
ps.printf("there are %d % from a %", 2, "kisses", "girl");
System.out.println(baos.toString());
</code></pre>
<p>This outputs <strong>there is a hello from 3 friends there are 2 kisses from a girl</strong><br />
Call reset on ByteArrayOutputStream to generate a clean new string</p>
<pre><code>ps.printf("there is a %s from %d %s", "flip", 5, "haters");
baos.reset(); //need reset to write new string
ps.printf("there are %d % from a %", 2, "kisses", "girl");
System.out.println(baos.toString());
</code></pre>
<p>The output will be <strong>there are 2 kisses from a girl</strong></p>
| 6,923
|
<p>I'm trying to implement a data compression idea I've had, and since I'm imagining running it against a large corpus of test data, I had thought to code it in C (I mostly have experience in scripting languages like Ruby and Tcl.) </p>
<p>Looking through the O'Reilly 'cow' books on C, I realize that I can't simply index the bits of a simple 'char' or 'int' type variable as I'd like to to do bitwise comparisons and operators. </p>
<p>Am I correct in this perception? Is it reasonable for me to use an enumerated type for representing a bit (and make an array of these, and writing functions to convert to and from char)? If so, is such a type and functions defined in a standard library already somewhere? Are there other (better?) approaches? Is there some example code somewhere that someone could point me to?</p>
<p>Thanks - </p>
|
<p>Following on from what Kyle has said, you can use a macro to do the hard work for you.</p>
<blockquote>
<p>It is possible.</p>
<p>To set the nth bit, use OR:</p>
<p>x |= (1 << 5); // sets the 6th-from
right</p>
<p>To clear a bit, use AND:</p>
<p>x &= ~(1 << 5); // clears
6th-from-right</p>
<p>To flip a bit, use XOR:</p>
<p>x ^= (1 << 5); // flips 6th-from-right</p>
</blockquote>
<p><strong>Or...</strong></p>
<pre><code>#define GetBit(var, bit) ((var & (1 << bit)) != 0) // Returns true / false if bit is set
#define SetBit(var, bit) (var |= (1 << bit))
#define FlipBit(var, bit) (var ^= (1 << bit))
</code></pre>
<p>Then you can use it in code like:</p>
<pre><code>int myVar = 0;
SetBit(myVar, 5);
if (GetBit(myVar, 5))
{
// Do something
}
</code></pre>
|
<p>IF you want to index a bit you could:</p>
<pre><code>bit = (char & 0xF0) >> 7;
</code></pre>
<p>gets the msb of a char. You could even leave out the right shift and do a test on 0.</p>
<pre><code>bit = char & 0xF0;
</code></pre>
<p>if the bit is set the result will be > 0;</p>
<p>obviousuly, you need to change the mask to get different bits (NB: the 0xF is the bit mask if it is unclear). It is possible to define numerous masks e.g.</p>
<pre><code>#define BIT_0 0x1 // or 1 << 0
#define BIT_1 0x2 // or 1 << 1
#define BIT_2 0x4 // or 1 << 2
#define BIT_3 0x8 // or 1 << 3
</code></pre>
<p>etc...</p>
<p>This gives you:</p>
<pre><code>bit = char & BIT_1;
</code></pre>
<p>You can use these definitions in the above code to sucessfully index a bit within either a macro or a function.</p>
<p>To set a bit:</p>
<pre><code>char |= BIT_2;
</code></pre>
<p>To clear a bit:</p>
<pre><code>char &= ~BIT_3
</code></pre>
<p>To toggle a bit</p>
<pre><code>char ^= BIT_4
</code></pre>
<p>This help?</p>
| 8,819
|
<p>I'm a long time hobbyist programmer interested in getting into web application development. I have a fair amount of personal experience with various non-web languages, but have never really branched over to web applications.</p>
<p>I don't usually have any issues learning new languages or technologies, so I'm not worried about which is the "best" language or web stack to work with. Instead, I'd like to know of any recommended resources (books, articles, web sites, maybe even college courses) that discuss web application design: managing and optimizing server interaction, security concerns, scalability, and other topics that fall under design rather than implementation.</p>
<p>What would you recommend for a Standalone Application Developer wanting to branch out into Web Development?</p>
|
<p>There is a wide variety of web application languages you could get into. The ones I have most experience with (and therefore will be talking about here) are PHP, eRuby and Ruby on Rails. All of these have good tutorials available on the internet - I'll link to some of them below.</p>
<p>Which to choose depends on exactly what you're looking to do. Using PHP and eRuby you have to do most things yourself - whereas Ruby on Rails will do lots of stuff for you (useful, but can also be dangerous if you don't know what you're doing). Ruby on Rails is good for doing database related things - for example the standard CRUD (Create, Read, Update, Delete) application. The standard kind of app Ruby on Rails (often abbreviated to RoR) tutorials teach you is a blog application (Create entries, Read entries, Update entries, Delete entries) or an Address Book Application. It is possible to do many of these sort of applications almost in one line of code - using RoR's 'scaffold' function.</p>
<p>PHP and eRuby make you do more of the work yourself - but this can be better in some situations. PHP is more well known and used than eRuby, but I like the Ruby language so I tend to like using eRuby. These are both good for doing simple applications (like contact forms on websites) or more complex applications (phpBB - a piece of forum software is written in php).</p>
<p>As for which one to choose - I'd have a play with them and see what you think. Try running through the first few bits of a tutorial with each and see how whether you like it or not.</p>
<p>Here come the links to various tutorials:</p>
<p><strong>PHP</strong></p>
<ul>
<li><a href="http://devzone.zend.com/node/view/id/627" rel="nofollow noreferrer">PHP 101</a></li>
<li><a href="http://www.w3schools.com/php/php_intro.asp" rel="nofollow noreferrer">PHP Intro from W3Schools</a></li>
</ul>
<p><strong>eRuby</strong></p>
<ul>
<li><a href="http://www.osix.net/modules/article/?id=384" rel="nofollow noreferrer">Beginning eRuby</a> - not great, but shows you how you can embed it in HTML</li>
<li><a href="http://tryruby.hobix.com/" rel="nofollow noreferrer">Try Ruby in your Browser</a> - helps you learn Ruby which you need to know for eRuby</li>
</ul>
<p><strong>Ruby on Rails</strong></p>
<ul>
<li><a href="http://www.onlamp.com/pub/a/onlamp/2006/12/14/revisiting-ruby-on-rails-revisited.html" rel="nofollow noreferrer">Rolling with Ruby on Rails</a> - the latest 'revisited' version for the latest version of RoR</li>
<li><a href="http://www.onlamp.com/pub/a/onlamp/2007/01/05/revisiting-ruby-on-rails-revisited-2.html" rel="nofollow noreferrer">Rolling with Ruby on Rails part 2</a></li>
</ul>
<p>There are a few tutorials to get you started. Some of these take you through installing the necessary software (webserver and anything else needed - eg. php or ruby) and some don't. A good way to get Apache (webserver), MySQL (db) and PHP installed on windows is to use <a href="http://www.apachefriends.org/en/xampp.html" rel="nofollow noreferrer">XAMPP</a>. If you're on linux then apache, mysql and php will be in your package repositories and there may be distro specific guides to setting them up.</p>
|
<p><a href="http://eloquentjavascript.net/" rel="nofollow noreferrer">Eloquent JavaScript</a> and <a href="http://appjet.com/learn-to-program/lessons/intro" rel="nofollow noreferrer">AppJet</a> offer great tutorials that allow you to follow along while you learn.</p>
<p>Once you cover all the basics, <a href="http://ajaxian.com/" rel="nofollow noreferrer">Ajaxian</a> should answer many of the questions you have about application design, etc. Not only do they post many excellent articles on these topics, but you should explore many of the sites they link to, as these sites usually also provide a wealth of info.</p>
<p>When it comes to server interactions, know your options. Ajax isn't all there is. Research technologies like <a href="http://cometdaily.com/" rel="nofollow noreferrer">Comet</a> and <a href="http://en.wikipedia.org/wiki/JSON-RPC" rel="nofollow noreferrer">JSON-RPC</a>, as well as looking at various server-side frameworks that provide easy access to JavaScript such as <a href="http://directwebremoting.org/" rel="nofollow noreferrer">DWR</a>, <a href="http://jayrock.berlios.de/" rel="nofollow noreferrer">Jayrock</a>, or any tool that exposes your functions to JavaScript using whatever language you choose to use on the server.</p>
| 3,888
|
<p>I recently bought a 3D printer called Dreamer NX from FlashForge. The dealer told me to use FlashPrint software that belongs to the FlashForge printer manufacturer. But, many people advise me to use Ultimaker Cura. Are there many differences between these two software packages?</p>
|
<p>The commonality of the 2 slicers is that both are developed and maintained by a printer manufacturer. The largest difference is that FlashPrint is <a href="https://en.wikipedia.org/wiki/Proprietary_software" rel="nofollow noreferrer">closed/proprietary software</a>, while Ultimaker Cura is released in source (<a href="https://en.wikipedia.org/wiki/Cura_(software)" rel="nofollow noreferrer">so-called open source project</a>) to the public; this is valid for both the <a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">frontend (Cura)</a> (Graphical User Interface) as for the <a href="https://github.com/Ultimaker/CuraEngine" rel="nofollow noreferrer">slicing core (CuraEngine)</a>. Basically this implies that there is a larger community developing and bug fixing the software. Also, FlashPrint is exclusively available for the FlashForge printers while Ultimaker Cura can be used for different brands as well.</p>
<p>Statement from <a href="https://www.3dprms.com/products/flashprint-slicer-for-3d-printing" rel="nofollow noreferrer">www.3dprms.com</a>:</p>
<blockquote>
<p>The Flashpoint software is an in-house software program developed by FlashForge for use exclusively with the FlashForge 3D Printers</p>
</blockquote>
<p>Statement from the <a href="https://en.wikipedia.org/wiki/Cura_(software)" rel="nofollow noreferrer">Cura wikipedia</a>:</p>
<blockquote>
<p>Cura is an open source 3D printer slicing application. It was created by David Braam who was later employed by Ultimaker, a 3D printer manufacturing company, to maintain the software.</p>
</blockquote>
<p>As FlashPrint is proprietary, it has no shared source repository and can therefore not be based on existing forks of software that are released under e.g. some version of the <a href="https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License" rel="nofollow noreferrer">LGPL</a> license as this implies that you need to share the amendments you made to the software, otherwise you would be in violation:</p>
<blockquote>
<p>...any developer who modifies an LGPL-covered component is required to make their modified version available under the same LGPL license..</p>
</blockquote>
<hr>
<p><sub><em>Note that discussing the exact differences in features between the 2 software packages (e.g. implementation differences of model support structures) would be more fit in a forum style discussion board rather than on a Stack Exchange site.</em></sub></p>
|
<p>Perhaps this is veering out a little bit from being an answer to the specific differences between software functionality, but one important difference that shouldn't be overlooked is that whatever you learn with Cura is applicable to <em>all FDM 3D printers</em>.</p>
<p>Surely some setting tweaks you do might be specific to the properties of your particular printer, but a large amount of them, like choices of infill patterns, shells, adaptive layer heights, using secondary models as custom support and infill masks, breaking up models into multiple pieces for printing, etc. are completely printer-agnostic. If you learn to do these with software that's only usable (or at least only meant to be used) with your particular brand of printers, you'll have to translate/relearn if you later want to use a different printer, or help someone else who has a different brand of printer. If you learn with software that works with any printer, everything you learn is immediately applicable to different printers.</p>
| 1,450
|
<p>Googling 'HDPLA' has so far availed me very little. </p>
<p><a href="http://3dinsider.com/what-is-pla/" rel="nofollow noreferrer">http://3dinsider.com/what-is-pla/</a> indicates that /all/ modern PLA is 'high density' compared to 'the early days'. But a fellow at the local makerspace indicated that he was specifically using 'HDPLA', with [he claimed] markedly better properties than regular PLA in the final product.</p>
<p>A company named Florion claims to have some secret sauce they add to their PLA, and Maker Filament touts a high temp PLA; but neither seems to use the 'HD' prefix.</p>
<p>I haven't yet been able to track down the fellow to get any more specifics from him. There's no reel of the stuff sitting around so I can't look at its labeling for clues. He claimed to be fabbing lab fittings but I don't know the intended operating situation/requirements. </p>
<p>It's possible he meant something else, like HDPE, which would be quite inert and thus a good choice for lab fittings--but I'd like to think that if it was lab equipment he was making he'd get the name of the polymer right.</p>
<p>Comments, including any regarding the Florion or Maker Filament or any other 'high performance' PLAs, would be most welcome.</p>
|
<p>So, low-teck, old-style investigative work from my side.... I contacted <a href="http://www.filright.com" rel="nofollow noreferrer">a company</a> selling HDPLA and they got back to me with the following reply.</p>
<blockquote>
<p>We created HDPLA as an industrial PLA with special additives. As a result, our so called HDPLA has the advantages of ABS, but prints as easy as regular PLA. HDPLA has high impact, high strength and high heat deflection temperature (hdt). You can also print at high speed (max 140mm/s inhouse tests). HDPLA has is own high strength, but is even more strong after annealing. A heated bed is not necessary (50-60˚C recommended), and you can print with HDPLA with a 3D printer with open structure.</p>
</blockquote>
<p>This is strikingly similar to the <a href="https://www.3dprima.com/filaments/primaselect-pla-pro-1-75mm-750-g-black/a-22432/" rel="nofollow noreferrer">description of what 3Dprima calls "Prima SELECT PRO"</a>:</p>
<blockquote>
<p>PrimaSelect™ PLA PRO ist the next generation of high performance PLA for demanding industrial applications. Designed to be able to print fast >120mm/s so you can save on production time. Very high heat resistance (95°C+) after annealing. Excellent mechanical properties combined with a matte surface finish that helps concealing the printed layers for optimum appearance.</p>
</blockquote>
<p>While writing this answer I also found <a href="http://fiberlogy.com/en/fiberlogy-filaments/filament-hd-pla/" rel="nofollow noreferrer">a page</a> that escaped my googling until now, sating an additional property of "their" HDPLA: food safety.</p>
<blockquote>
<p>With our HD PLA you have many more options. You can use this material in two ways. Choose the one you like best. You can use it as a normal PLA and get prints characterized by a very good adhesion between the layers and high precision. You can also make your prints acquire similar properties to that of ABS – better impact resistance and high temperature resistance. All you need is an oven. Yes, an oven! By annealing our HD PLA in an oven, in accordance with the manual, you will avoid all the inconveniences of printing with ABS, such as unpleasant odour or hazardous fumes. But these are not all the advantages of HD PLA. For the production of this material we have chosen raw materials that are approved for food contact in compliance with the EU directive and FDA regulations. HD PLA is also certified by RoHS.</p>
</blockquote>
<p>So, it looks like HDPLA is not the shorthand of a polymer molecule, but rather <strong>a trade word indicating that the base PLA has been mixed with additives</strong>. Furthermore, the answer I got via mail seems to indicate that <strong>"HD" refers to the high <em>Heat Deflection</em> temperature</strong> of the filament (the <a href="https://en.wikipedia.org/wiki/Heat_deflection_temperature" rel="nofollow noreferrer">heat deflection temperature</a> is the temperature at which a polymer or plastic sample deforms under a specified load).</p>
|
<p>I doubt that it means very much at all. Filament manufacturers are very tight-lipped about the co-polymers that they add to their base stock in order to improve handling and performance characteristics, so it is impossible to say. The only common attribute that I can see is an advertised diameter tolerance of ±0.02mm. Maybe HD stands for <em>high-definition</em>, rather than <em>high-density</em>?</p>
| 790
|
<p>I have to load a PDF within a page.</p>
<p>Ideally I would like to have a loading animated gif which is replaced once the PDF has loaded.</p>
|
<p>Have you tried:</p>
<pre><code>$("#iFrameId").on("load", function () {
// do something once the iframe is loaded
});
</code></pre>
|
<p>Here is what I do for any action and it works in Firefox, IE, Opera, and Safari.</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
doMethod();
});
function actionIframe(iframe)
{
... do what ever ...
}
function doMethod()
{
var iFrames = document.getElementsByTagName('iframe');
// what ever action you want.
function iAction()
{
// Iterate through all iframes in the page.
for (var i = 0, j = iFrames.length; i < j; i++)
{
actionIframe(iFrames[i]);
}
}
// Check if browser is Safari or Opera.
if ($.browser.safari || $.browser.opera)
{
// Start timer when loaded.
$('iframe').load(function()
{
setTimeout(iAction, 0);
}
);
// Safari and Opera need something to force a load.
for (var i = 0, j = iFrames.length; i < j; i++)
{
var iSource = iFrames[i].src;
iFrames[i].src = '';
iFrames[i].src = iSource;
}
}
else
{
// For other good browsers.
$('iframe').load(function()
{
actionIframe(this);
}
);
}
}
</script>
</code></pre>
| 4,985
|
<p><strong>Problem</strong></p>
<p>I need to redirect some short convenience URLs to longer actual URLs. The site in question uses a set of subdomains to identify a set of development or live versions.</p>
<p>I would like the URL to which certain requests are redirected to include the HTTP_HOST such that I don't have to create a custom .htaccess file for each host.</p>
<p><strong>Host-specific Example (snipped from .htaccess file)</strong></p>
<pre><code>Redirect /terms http://support.dev01.example.com/articles/terms/
</code></pre>
<p>This example works fine for the development version running at dev01.example.com. If I use the same line in the main .htaccess file for the development version running under dev02.example.com I'd end up being redirected to the wrong place.</p>
<p><strong>Ideal rule (not sure of the correct syntax)</strong></p>
<pre><code>Redirect /terms http://support.{HTTP_HOST}/articles/terms/
</code></pre>
<p>This rule does not work and merely serves as an example of what I'd like to achieve. I could then use the exact same rule under many different hosts and get the correct result.</p>
<p><strong>Answers?</strong></p>
<ul>
<li>Can this be done with mod_alias or does it require the more complex mod_rewrite?</li>
<li>How can this be achieved using mod_alias or mod_rewrite? I'd prefer a mod_alias solution if possible.</li>
</ul>
<p><strong>Clarifications</strong></p>
<p>I'm not staying on the same server. I'd like:</p>
<ul>
<li>http://<strong>example.com</strong>/terms/ -> <a href="http://support" rel="nofollow noreferrer">http://support</a>.<strong>example.com</strong>/articles/terms/</li>
<li><a href="https://secure" rel="nofollow noreferrer">https://secure</a>.<strong>example.com</strong>/terms/ -> <a href="http://support" rel="nofollow noreferrer">http://support</a>.<strong>example.com</strong>/articles/terms/</li>
<li>http://<strong>dev.example.com</strong>/terms/ -> <a href="http://support" rel="nofollow noreferrer">http://support</a>.<strong>dev.example.com</strong>/articles/terms/</li>
<li><a href="https://secure" rel="nofollow noreferrer">https://secure</a>.<strong>dev.example.com</strong>/terms/ -> <a href="http://support" rel="nofollow noreferrer">http://support</a>.<strong>dev.example.com</strong>/articles/terms/</li>
</ul>
<p>I'd like to be able to use the same rule in the .htaccess file on both example.com and dev.example.com. In this situation I'd need to be able to refer to the HTTP_HOST as a variable rather than specifying it literally in the URL to which requests are redirected.</p>
<p>I'll investigate the HTTP_HOST parameter as suggested but was hoping for a working example.</p>
|
<p>It's strange that nobody has done the actual <strong>working</strong> answer (lol):</p>
<pre><code>RewriteCond %{HTTP_HOST} support\.(([^\.]+))\.example\.com
RewriteRule ^/terms http://support.%1/article/terms [NC,QSA,R]
</code></pre>
<hr>
<p>To help you doing the job faster, my favorite tool to check for regexp:</p>
<p><a href="http://www.quanetic.com/Regex" rel="nofollow">http://www.quanetic.com/Regex</a> (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)</p>
<p>You use this tool when you want to check the URL and see if they're valid or not.</p>
|
<p>According to this cheatsheet ( <a href="http://www.addedbytes.com/download/mod_rewrite-cheat-sheet-v2/png/" rel="nofollow noreferrer">http://www.addedbytes.com/download/mod_rewrite-cheat-sheet-v2/png/</a> ) this should work</p>
<pre><code>RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1
</code></pre>
<p>Note that i don't have a way to test this so this should be taken as a pointer in the right direction as opposed to an explicit answer.</p>
| 9,806
|
<p>What is the best unobtrusive CAPTCHA for web forms? One that does not involve a UI, rather a non-UI Turing test. I have seen a simple example of a non UI CAPTCHA like the <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/NoBot/NoBot.aspx" rel="noreferrer">Nobot</a> control from Microsoft. I am looking for a CAPTCHA that does not ask the user any question in any form. No riddles, no what's in this image.</p>
|
<p>I think you might be alluding to an "invisible" captcha. Check out the Subkismet project for an invisible captcha implementation.</p>
<p><a href="http://www.codeplex.com/subkismet" rel="noreferrer">http://www.codeplex.com/subkismet</a></p>
|
<p><a href="http://meyerweb.com" rel="nofollow noreferrer">Eric Meyer</a> implemented a very similar thing as a WordPress plugin called <a href="http://meyerweb.com/eric/tools/wordpress/wp-gatekeeper.html" rel="nofollow noreferrer">WP-GateKeeper</a> that asks human-readable questions like "What colour is an orange?". He did have some issues around asking questions that a non-native English speaker would be able to answer simply, though. </p>
<p>There are a few posts on <a href="http://meyerweb.com" rel="nofollow noreferrer">his blog</a> about it.</p>
| 2,516
|
<p>There has been some talk of Website performance monitoring tools and services on stackoverflow, however, they seem fairly expensive for what they actually do. Are there any good opensource libraries for automating checking/monitoring the availability of a website?</p>
|
<p>If you just want to know if your server is serving out content or not, take a look at <a href="http://www.montastic.com/" rel="nofollow noreferrer">Montastic</a>. I use it, and am pleased. Plus its free!</p>
<p>It will ping your site periodically, and if it doesn't get a 200 status, it lets you know.</p>
|
<p>I have always used <a href="http://www.zabbix.com/" rel="nofollow noreferrer">Zabbix</a> especially for critical web sites. It uses MySql for the database and it has a PHP frontend. Of course it is open source and it is very flexible. It uses servers to stick data in the database and agents collect the data and send it to the servers. It is very scalable with this respect. I cannot recommend this software enough. I have all kinds of monitoring going on, not just web servers.</p>
| 7,839
|
<p>I want to add the selected item from the <code>TreeView</code> to the <code>ListBox</code> control using <code>DataBinding</code> (If it can work with <code>DataBinding</code>). </p>
<pre><code><TreeView HorizontalAlignment="Left"
Margin="30,32,0,83"
Name="treeView1"
Width="133" >
</TreeView>
<ListBox VerticalAlignment="Top"
Margin="208,36,93,0"
Name="listBox1"
Height="196" >
</ListBox>
</code></pre>
<p><code>TreeView</code> is populated from the code behind page with some dummy data. </p>
|
<p>You can bind to an element using ElementName, so if you wanted to bind the selected tree item to the ItemsSource of a ListBox:</p>
<pre><code>ItemsSource="{Binding SelectedItem, ElementName=treeView1}"
</code></pre>
|
<p>I'm pretty sure it is possible, since WPF is really flexible with data binding, but I haven't done that specific scenario yet.</p>
<p>I've been following a <a href="http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx" rel="nofollow noreferrer">WPF Databinding FAQ</a> from the MSDN blogs as of late and it provides a lot of insights that might help.</p>
| 7,806
|
<p>I downloaded a couple of webapps and placed them in my /webapps folder.
Some of them I could open by going to <code>http://localhost:8080/app1</code> and it would open.
However, some others I would do the exact same thing and go to <code>http://localhost:8080/app2</code> and it will display "HTTP Status 404 - /app2/", even though I am sure it is there. I've checked that it contains a WEB-INF folder just like app1, and I've even restarted Tomcat to be sure.</p>
<p>My question is: is there anything (perhaps in the web.xml file) that specifies what the URL has to be to start the webapp? Or is it simply just <code>http://localhost:8080/<folder name></code> ?</p>
<p>P.S. If you want to know exactly what app1 and app2 I am refering to:
app1 (works) = <a href="http://assets.devx.com/sourcecode/11237.zip" rel="nofollow noreferrer">http://assets.devx.com/sourcecode/11237.zip</a>
app2 (doesn't work) = <a href="http://www.laliluna.de/download/eclipse-spring-jdbc-tutorial.zip" rel="nofollow noreferrer">http://www.laliluna.de/download/eclipse-spring-jdbc-tutorial.zip</a></p>
<p>I've tried a few others as well, some work, some don't. I'm just wondering if I'm missing something.</p>
|
<p>I usually debug this by going the the manager page and making sure that all of the contexts are deployed (<a href="http://localhost:8080/manager/html" rel="noreferrer">http://localhost:8080/manager/html</a>). </p>
<p>It sounds like app2 has not been deployed properly or is not starting up because of some other error.</p>
<p>I would look at the logs. There may be a bunch of information in there but usually it explains what is broken.</p>
|
<p>If "/" is not accessible it means that there is no "index.html", "index.jsp" or whatever is defined in the welcome-files list of the web.xml
Also no Servlet-Mapping for the context ROOT directory is present.
Check the web.xml for Servlet-Mappings or try to figure out the name of the jsp/html /... file being in the context root</p>
| 7,681
|
<p>I'm writing a structural modeling tool for a civil enginering application. I have one huge model class representing the entire building, which include collections of nodes, line elements, loads, etc. which are also custom classes. </p>
<p>I have already coded an undo engine which saves a deep-copy after each modification to the model. Now I started thinking if I could have coded differently. Instead of saving the deep-copies, I could perhaps save a list of each modifier action with a corresponding reverse modifier. So that I could apply the reverse modifiers to the current model to undo, or the modifiers to redo. </p>
<p>I can imagine how you would carry out simple commands that change object properties, etc. But how about complex commands? Like inserting new node objects to the model and adding some line objects which keep references to the new nodes.</p>
<p>How would one go about implementing that?</p>
|
<p>Most examples I've seen use a variant of the <a href="http://en.wikipedia.org/wiki/Command_pattern" rel="noreferrer">Command-Pattern</a> for this. Every user-action that's undoable gets its own command instance with all the information to execute the action and roll it back. You can then maintain a list of all the commands that have been executed and you can roll them back one by one.</p>
|
<p>I don't know if this is going to be of any use to you, but when I had to do something similar on one of my projects, I ended up downloading UndoEngine from <a href="http://www.undomadeeasy.com" rel="nofollow">http://www.undomadeeasy.com</a> - a wonderful engine and I really didn't care too much about what was under the bonnet - it just worked. </p>
| 7,237
|
<p>I'm trying to set up an inheritance hierarchy similar to the following:</p>
<pre><code>abstract class Vehicle
{
public string Name;
public List<Axle> Axles;
}
class Motorcycle : Vehicle
{
}
class Car : Vehicle
{
}
abstract class Axle
{
public int Length;
public void Turn(int numTurns) { ... }
}
class MotorcycleAxle : Axle
{
public bool WheelAttached;
}
class CarAxle : Axle
{
public bool LeftWheelAttached;
public bool RightWheelAttached;
}
</code></pre>
<p>I would like to only store MotorcycleAxle objects in a Motorcycle object's Axles array, and CarAxle objects in a Car object's Axles array. The problem is there is no way to override the array in the subclass to force one or the other. Ideally something like the following would be valid for the Motorcycle class:</p>
<pre><code>class Motorcycle : Vehicle
{
public override List<MotorcycleAxle> Axles;
}
</code></pre>
<p>but the types have to match when overriding. How can I support this architecture? Will I just have to do a lot of run-time type checking and casting wherever the Axles member is accessed? I don't like adding run-time type checks because you start to lose the benefits of strong typing and polymorphism. There have to be at least some run-time checks in this scenario since the WheelAttached and Left/RightWheelAttached properties depend on the type, but I would like to minimize them.</p>
|
<p>Use more generics</p>
<pre><code>abstract class Vehicle<T> where T : Axle
{
public string Name;
public List<T> Axles;
}
class Motorcycle : Vehicle<MotorcycleAxle>
{
}
class Car : Vehicle<CarAxle>
{
}
abstract class Axle
{
public int Length;
public void Turn(int numTurns) { ... }
}
class MotorcycleAxle : Axle
{
public bool WheelAttached;
}
class CarAxle : Axle
{
public bool LeftWheelAttached;
public bool RightWheelAttached;
}
</code></pre>
|
<p>2 options spring to mind. 1 is using generics:</p>
<pre><code>abstract class Vehicle<TAxle> where TAxle : Axle {
public List<TAxle> Axles;
}
</code></pre>
<p>The second uses shadowing - and this assumes you have properties:</p>
<pre><code>abstract class Vehicle {
public IList<Axle> Axles { get; set; }
}
class Motorcyle : Vehicle {
public new IList<MotorcycleAxle> Axles { get; set; }
}
class Car : Vehicle {
public new IList<CarAxle> Axles { get; set; }
}
void Main() {
Vehicle v = new Car();
// v.Axles is IList<Axle>
Car c = (Car) v;
// c.Axles is IList<CarAxle>
// ((Vehicle)c).Axles is IList<Axle>
</code></pre>
<p>The problem with shadowing is that you have a generic List. Unfortunately, you can't constrain the list to only contain CarAxle. Also, you can't cast a List<Axle> into List<CarAxle> - even though there's an inheritance chain there. You have to cast each object into a new List (though that becomes much easier with LINQ).</p>
<p>I'd go for generics myself.</p>
| 5,097
|
<p>In C++ Windows app, I launch several long running child processes (currently I use CreateProcess(...) to do this. </p>
<p>I want the child processes to be automatically closed <strong>if my main processes crashes</strong> or is closed.</p>
<p>Because of the requirement that this needs to work for a crash of the "parent", I believe this would need to be done using some API/feature of the operating system. So that all the "child" processes are cleaned up.</p>
<p>How do I do this?</p>
|
<p>The Windows API supports objects called "Job Objects". The following code will create a "job" that is configured to shut down all processes when the main application ends (when its handles are cleaned up). This code should only be run once.:</p>
<pre class="lang-cpp prettyprint-override"><code>HANDLE ghJob = CreateJobObject( NULL, NULL); // GLOBAL
if( ghJob == NULL)
{
::MessageBox( 0, "Could not create job object", "TEST", MB_OK);
}
else
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
// Configure all child processes associated with the job to terminate when the
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
{
::MessageBox( 0, "Could not SetInformationJobObject", "TEST", MB_OK);
}
}
</code></pre>
<p>Then when each child process is created, execute the following code to launch each child each process and add it to the job object:</p>
<pre class="lang-cpp prettyprint-override"><code>STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
// Launch child process - example is notepad.exe
if (::CreateProcess( NULL, "notepad.exe", NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
::MessageBox( 0, "CreateProcess succeeded.", "TEST", MB_OK);
if(ghJob)
{
if(0 == AssignProcessToJobObject( ghJob, processInfo.hProcess))
{
::MessageBox( 0, "Could not AssignProcessToObject", "TEST", MB_OK);
}
}
// Can we free handles now? Not sure about this.
//CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
</code></pre>
<p>VISTA NOTE: See <a href="http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/71c9599e-a3d5-4b79-bfc1-1800565c5b8a" rel="noreferrer">AssignProcessToJobObject always return "access denied" on Vista</a> if you encounter access-denied issues with AssignProcessToObject() on vista.</p>
|
<p>You'd probably have to keep a list of the processes you start, and kill them off one by one when you exit your program. I'm not sure of the specifics of doing this in C++ but it shouldn't be hard. The difficult part would probably be ensuring that child processes are shutdown in the case of an application crash. .Net has the ability to add a function that get's called when an unhandled exception occurs. I'm not sure if C++ offers the same capabilities.</p>
| 7,664
|
<ul>
<li>Any personal experience in overcoming web application performance hurdles? </li>
<li>Any recommended strategies for improving the performance of a data-driven web application? </li>
</ul>
<p>My development team works on a web application (JSP reports, HTML, JavaScript) that uses an Oracle database (PL/SQL). The key functionality the application delivers is in reporting, where a user can get PDFs of reports at a high level and drill down to lower levels of supporting details. </p>
<p>As the number of supporting detail records has grown into the millions, the performance of the system has significantly degraded. Based on our current analysis of the metrics, the bottleneck seems to be in the logic hitting the DB and the DB performance. Changing the DB model and re-doing some of the server side logic is currently being explored. </p>
<p>Partioning, indexing, explain plans, and running statistics are things that have been done on the DB side to try to help improve performance. While they've helped, they haven't solved the issue satisfactorily. The toughest part in analyzing performance data is that the database and web servers are remotely administered by a different part of the IT organization, so the developers don't have regular, full access to see what's going on (especially in the production environment, which is not mirrored exactly in any other development/testing environment). </p>
|
<p>While my answer may not contain any concrete steps to help this is always where I start.</p>
<p>First thing I would do is try to throw away all of your assumptions about what the trouble is and take steps to install metrics everywhere you can. Let the metrics guide you rather than your intuition. I've chased many, many, many white rabbits going on a hunch...the let me down more times than they've been right.</p>
|
<p>As Webjedi says, metrics are your friend.</p>
<p>Also look at your stack and see where there are opportunities for caching - then employ mercilessly wherever possible!</p>
| 4,274
|
<p>So WPF doesn't support standard sorting or filtering behavior for views of CompositeCollections, so what would be a best practice for solving this problem. </p>
<p>There are two or more object collections of different types. You want to combine them into a single sortable and filterable collection (withing having to manually implement sort or filter).</p>
<p>One of the approaches I've considered is to create a new object collection with only a few core properties, including the ones that I would want the collection sorted on, and an object instance of each type. </p>
<pre><code>class MyCompositeObject
{
enum ObjectType;
DateTime CreatedDate;
string SomeAttribute;
myObjectType1 Obj1;
myObjectType2 Obj2;
{
class MyCompositeObjects : List<MyCompositeObject> { }
</code></pre>
<p>And then loop through my two object collections to build the new composite collection. Obviously this is a bit of a brute force method, but it would work. I'd get all the default view sorting and filtering behavior on my new composite object collection, and I'd be able to put a data template on it to display my list items properly depending on which type is actually stored in that composite item.</p>
<p>What suggestions are there for doing this in a more elegant way?</p>
|
<p>Change the code for the About box to </p>
<pre><code>Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString)
</code></pre>
<p>Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish version".</p>
|
<p>I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*?
This should increase the revision number (at least it does in the AssemblyInfo.cs in C#).</p>
| 3,243
|
<p>I need to create a 2D int array of size 800x800. But doing so creates a stack overflow (ha ha).</p>
<p>I'm new to C++, so should I do something like a vector of vectors? And just encapsulate the 2d array into a class?</p>
<p>Specifically, this array is my zbuffer in a graphics program. I need to store a z value for every pixel on the screen (hence the large size of 800x800).</p>
<p>Thanks!</p>
|
<p>You need about 2.5 megs, so just using the heap should be fine. You don't need a vector unless you need to resize it. See <a href="https://isocpp.org/wiki/faq/freestore-mgmt#multidim-arrays" rel="nofollow noreferrer">C++ FAQ Lite</a> for an example of using a "2D" heap array.</p>
<pre><code>int *array = new int[800*800];
</code></pre>
<p>(Don't forget to <code>delete[]</code> it when you're done.)</p>
|
<p>Well, building on what Niall Ryan started, if performance is an issue, you can take this one step further by optimizing the math and encapsulating this into a class.</p>
<p>So we'll start with a bit of math. Recall that 800 can be written in powers of 2 as:</p>
<pre><code>800 = 512 + 256 + 32 = 2^5 + 2^8 + 2^9
</code></pre>
<p>So we can write our addressing function as:</p>
<pre><code>int index = y << 9 + y << 8 + y << 5 + x;
</code></pre>
<p>So if we encapsulate everything into a nice class we get:</p>
<pre><code>class ZBuffer
{
public:
const int width = 800;
const int height = 800;
ZBuffer()
{
for(unsigned int i = 0, *pBuff = zbuff; i < width * height; i++, pBuff++)
*pBuff = 0;
}
inline unsigned int getZAt(unsigned int x, unsigned int y)
{
return *(zbuff + y << 9 + y << 8 + y << 5 + x);
}
inline unsigned int setZAt(unsigned int x, unsigned int y, unsigned int z)
{
*(zbuff + y << 9 + y << 8 + y << 5 + x) = z;
}
private:
unsigned int zbuff[width * height];
};
</code></pre>
| 8,692
|
<p>Sometimes my meshes turn out with artifacts Which can be seen in the bottom image. What is the cause? The first image shows my mesh which its generated from.
I've tried multiple slicers. This tends to occur sometimes.
Any help appreciated. Is there something going over my head???</p>
<p><a href="https://i.stack.imgur.com/neQxc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/neQxc.png" alt="mesh wireframe"></a></p>
<p><a href="https://i.stack.imgur.com/W19Y7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W19Y7.png" alt="Artifacts in 3d model"></a></p>
|
<p>Hardboard is called <em>Masonite</em> here in the States because that is the trade name of the product. If you look up the <a href="http://www.gunnersens.co.nz/images/stories/products/Masonite%20Standard/specs/Australian_Hardboards_Masonite_MSDS.pdf" rel="noreferrer">Material Safety Data Sheet</a> you will see Masonite it states the following (Section 5):</p>
<blockquote>
<p>Auto-ignition Temperature (°C): >200 degrees Celsius</p>
</blockquote>
<p>In Section 7, it states:</p>
<blockquote>
<p>These boards are flammable but difficult to ignite.</p>
</blockquote>
<p>Furthermore in Section 10, it states:</p>
<blockquote>
<p><strong>Conditions to avoid:</strong> Avoid sources of radiant heat and flame; and avoid sparks and sources of ignition in all electrical equipment, including dust extraction equipment.
Avoid excessive build up of dust from boards.</p>
</blockquote>
<p>The hot end works of printers are neither radiant heat, nor flames, nor sparks. Yes, you'll have a buildup of heat within the working confines of an enclosure, but if you are only using it for a base there should be absolutely no issues. If you were to build an entire enclosure from hardboard, you could put a thermal probe inside with the printer to ensure it doesn't get too hot, but realistically, it will never get hot enough within the enclosure to light the hardboard on fire.</p>
|
<p>Masonite or hardboard is a high-density board without a resin. It is <a href="https://www.chromaluxe.com/wp-content/uploads/SDS-Hardboard-Universal-Woods.pdf" rel="nofollow noreferrer">listed</a> at around 200 to 275 °C for its autoignition temperature. Just for comparison, let's look at similar products.</p>
<p>Medium-density fiberboard (MDF) is similar to hardboard but bonded with a resin, offering a smoother surface and is <a href="https://www.westfraser.com/sites/default/files/products/MDF/WP-GoldPlus%202013.pdf" rel="nofollow noreferrer">listed</a> at 200 to 275 °C, so pretty close.</p>
<p>The heavier High-density fiberboard variant is <a href="http://www.clarionindustries.com/assets/files/Clarion-msds-hdf.pdf" rel="nofollow noreferrer">listed</a> with about the same temperatures of about 200 to 275 °C.</p>
<p>Oriented Strand Board (OSB) is <a href="http://www.langboard.com/osb/data/osb_msds.pdf" rel="nofollow noreferrer">listed</a> at 200 to 260 °C.</p>
<h2>Conclusion</h2>
<p>All the materials have very similar autoignition temperatures, so none of them particularly shines over the other. Using a proper fire safety procedure is highly encouraged, even though the ambient temperature in the enclosure should not reach even close to the 200 °C unless the printer has a freak accident and catches fire itself.</p>
<ul>
<li>A smoke detector is a must.</li>
<li>Some kind of cooling method that keeps the inside at a temperature down is highly encouraged. A simple temperature activated fan might help in this.</li>
<li>Lining the inside of the box with a thicker aluminium or copper tape can help to even out the temperature over the surfaces faster, preventing the formation of hotspots that might otherwise reach dangerous temperatures. <a href="https://uk.rs-online.com/web/c/adhesives-sealants-tapes/tapes/copper-tapes/" rel="nofollow noreferrer">Copper tapes</a> are more expensive than <a href="https://uk.rs-online.com/web/c/adhesives-sealants-tapes/tapes/aluminium-tapes/" rel="nofollow noreferrer">Aluminium tapes</a> but have a better heat transfer coefficient.<sup>1</sup></li>
<li>Including an automatic fire suppression system could be an option.</li>
</ul>
<p><sup>1 - The RS Catalogue was just chosen for ease of navigation. <a href="https://www.mcmaster.com/" rel="nofollow noreferrer">McMaster Carr</a> does list special <a href="https://www.mcmaster.com/catalog/125/3591" rel="nofollow noreferrer">heat shielding tape</a> in both thin and aluminium as well as <a href="https://www.mcmaster.com/catalog/125/3587" rel="nofollow noreferrer">copper and aluminium foil</a> tapes. I am not affiliated to either.</sup></p>
| 1,240
|
<p>Saw a post about hidden features in C# but not a lot of people have written linq/lambdas example so... I wonder...</p>
<blockquote>
<p>What's the coolest (as in the most elegant) use of the C# LINQ and/or Lambdas/anonymous delegates you have ever saw/written?</p>
</blockquote>
<p>Bonus if it has went into production too!</p>
|
<p>The <a href="http://blogs.msdn.com/lukeh/archive/2007/10/01/taking-linq-to-objects-to-extremes-a-fully-linqified-raytracer.aspx" rel="noreferrer">LINQ Raytracer</a> certainly tops my list =)</p>
<p>I'm not quite sure if qualifies as elegant but it is most certainly the coolest linq-expression I've ever seen!</p>
<p>Oh, and just to be extremely clear; I did <em>not</em> write it (<a href="http://blogs.msdn.com/lukeh/" rel="noreferrer">Luke Hoban</a> did)</p>
|
<p>Working with attributes:</p>
<pre><code>private void WriteMemberDescriptions(Type type)
{
var descriptions =
from member in type.GetMembers()
let attributes = member.GetAttributes<DescriptionAttribute>(true)
let attribute = attributes.FirstOrDefault()
where attribute != null
select new
{
Member = member.Name,
Text = attribute.Description
};
foreach(var description in descriptions)
{
Console.WriteLine("{0}: {1}", description.Member, description.Text);
}
}
</code></pre>
<p>The <code>GetAttributes</code> extension method:</p>
<pre><code>public static class AttributeSelection
{
public static IEnumerable<T> GetAttributes<T>(this ICustomAttributeProvider provider, bool inherit) where T : Attribute
{
if(provider == null)
{
throw new ArgumentNullException("provider");
}
return provider.GetCustomAttributes(typeof(T), inherit).Cast<T>();
}
}
</code></pre>
<p><code>AttributeSelection</code> is production code and also defines <code>GetAttribute</code> and <code>HasAttribute</code>. I chose to use the <code>let</code> and <code>where</code> clauses in this example.</p>
| 4,850
|
<p>Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring to the table is </p>
<ul>
<li>Support for Callbacks (Validation, Change, etc) </li>
<li>Property inheritance</li>
<li>Attached properties </li>
</ul>
<p>among others.</p>
<p>But my question here is why do they need to be declared as static in the containing class? The recommmended way is to then add instance 'wrapper' property for them. Why ?</p>
<p>edit:
@Matt, but doesn't that also mandate that the property value is also shared across instances - unless of course it is a derived value ?</p>
|
<p>I see 2 reasons behind that requirement:</p>
<ol>
<li>You can't register same DP twice. To comply with this constraint you should use static variable, it will be initialized only one time thus you will register DP one time only.</li>
<li>DP should be registered before any class (which uses that DB) instance created</li>
</ol>
|
<p>I see 2 reasons behind that requirement:</p>
<ol>
<li>You can't register same DP twice. To comply with this constraint you should use static variable, it will be initialized only one time thus you will register DP one time only.</li>
<li>DP should be registered before any class (which uses that DB) instance created</li>
</ol>
| 5,728
|
<p>I'm starting to learn ruby. I'm also a day-to-day C++ dev.
For C++ projects I usually go with following dir structure</p>
<pre><code>/
-/bin <- built binaries
-/build <- build time temporary object (eg. .obj, cmake intermediates)
-/doc <- manuals and/or Doxygen docs
-/src
--/module-1
--/module-2
-- non module specific sources, like main.cpp
- IDE project files (.sln), etc.
</code></pre>
<p>What dir layout for Ruby (non-Rails, non-Merb) would you suggest to keep it clean, simple and maintainable?</p>
|
<p>Bundler includes the necessary infrastructure to generate a gem:</p>
<pre><code>$ bundle gem --coc --mit --test=minitest --exe spider
Creating gem 'spider'...
MIT License enabled in config
Code of conduct enabled in config
create spider/Gemfile
create spider/lib/spider.rb
create spider/lib/spider/version.rb
create spider/spider.gemspec
create spider/Rakefile
create spider/README.md
create spider/bin/console
create spider/bin/setup
create spider/.gitignore
create spider/.travis.yml
create spider/test/test_helper.rb
create spider/test/spider_test.rb
create spider/LICENSE.txt
create spider/CODE_OF_CONDUCT.md
create spider/exe/spider
Initializing git repo in /Users/francois/Projects/spider
Gem 'spider' was successfully created. For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html
</code></pre>
<p>Then, in lib/, you create modules as needed:</p>
<pre><code>lib/
spider/
base.rb
crawler/
base.rb
spider.rb
require "spider/base"
require "crawler/base"
</code></pre>
<p>Read the manual page for <a href="https://bundler.io/man/bundle-gem.1.html" rel="nofollow noreferrer">bundle gem</a> for details on the <code>--coc</code>, <code>--exe</code> and <code>--mit</code> options.</p>
|
<p>I would stick to something similar to what you are familiar with: there's no point being a stranger in your own project directory. :-)</p>
<p>Typical things I always have are lib|src, bin, test.</p>
<p>(I dislike these monster generators: the first thing I want to do with a new project is get some code down, not write a README, docs, etc.!)</p>
| 8,028
|
<p><code>mime_content_type()</code> is deprecated.</p>
<p>How can I find the <code>MIME type</code> of a local file using <code>PHP5</code> but without using this deprecated method or the <code>PECL fileinfo</code> extension?</p>
<p>Edit: That's what I was afraid of. It's unfortunate that they deprecated a built-in function in favour of one that requires an extension that isn't always available.</p>
|
<p>If you can't use the fileinfo extension, and you don't want to use mime_content_type, your options are limited.</p>
<p>Most likely you'll need to do a lookup based on the file extension. mime_content_type did something a bit more intelligent and actually looked for special data in the file to determine the mime type.</p>
|
<p>The <a href="http://getid3.sourceforge.met" rel="nofollow noreferrer" title="getId3">getID3()</a> library is a quick and easy works-most-of-the-time option. Originally named for a project to obtain MP3 ID3 data, the library does two hecks of a lot more than that and is quite convenient for all sorts of common or odd file meta data tasks.</p>
<p>I've used it to get the MIME types of files for online image and video tools. In all the testing I've done I've not seen getID3 get the MIME type wrong.</p>
<p>I've also used it to check if QuickTime videos have streaming hints. I mention this as an example of versatility.</p>
<p>A second more time consuming option is to roll your own MIME type checker as already suggested. If you have a MIME magic file you can go a little further than a lookup on the file extension by comparing the first n bytes of file data against a first-n-bytes to MIME type lookup table derived from your MIME magic file.</p>
<p>A typical MIME magic file will contain in excess of 500 sets of MIME types which might result in slow comparisons (lots of checks to make). Hard-coding the 10 most common MIME type checks in your home rolled solution will help there.</p>
| 7,401
|
<p>What is the best way to implement mutliple Default Buttons on a ASP.NET Webform?</p>
<p>I have what I think is a pretty standard page. There is a login area with user/pass field and a login button. Then elsewhere on the same page there is a single search field with a search button.</p>
|
<p><code>asp:Panel</code> has a property named <code>DefaultButton</code>. You just need to encapsulate your markup portions with appropriate panels and set the default buttons for each.</p>
|
<p>Capture the enter key press for each area of the screen and then fire the corresponding button's click even. </p>
| 9,761
|
<p>Just one quick question about the filament. </p>
<p>Can I leave the filament in the extruder for a prolonged period of time while the printer is off?</p>
|
<p>Most filaments you can leave in the extruder indefinitely without any ill effects.</p>
<p>There are some filaments that need to be stored away from moisture, particularly Nylon, because they absorb moisture from the air and don't print well if they contain a lot of absorbed moisture. However, this isn't an inherent issue with having the filaments in the extruder (if you had some setup that protected the filament from moisture while in the extruder, that would be fine as well - but in most cases it is more practical to store such filament in an airtight box). </p>
<p>Most commodity filaments (ABS/PLA/PETG) don't suffer from this as much (PLA supposedly also absorbs moisture but I haven't noticed this to be a problem, perhaps it depends on the conditions of the room in which your printer is kept) so they're fine to leave in the extruder.</p>
|
<p>If you "planing" to leave the filament there for months, then it would be a good idea to store it away, but for most filaments it is not a big deal to be stay loaded... provided that the humidity is not high (e.g. a shower or kitchen next to it would be not so good). </p>
<p>My experiences with "moistured" filament is that they get brittle, but only breaks when I don't print something. And it is a pain in the a** to get out the last part of the filament that broke right at the entrance... so store it away is always a good idea, if you are not too lazy ;) </p>
| 928
|
<p>How do you give a C# auto-property an initial value?</p>
<p>I either use the constructor, or revert to the old syntax. </p>
<p><strong> Using the Constructor:</strong></p>
<pre><code>class Person
{
public Person()
{
Name = "Initial Name";
}
public string Name { get; set; }
}
</code></pre>
<p><strong>Using normal property syntax</strong> (with an initial value)</p>
<pre><code>private string name = "Initial Name";
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
</code></pre>
<p>Is there a better way?</p>
|
<p>In C# 5 and earlier, to give auto implemented properties an initial value, you have to do it in a constructor.</p>
<p>Since <a href="https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-60" rel="noreferrer">C# 6.0</a>, you can specify initial value in-line. The syntax is:</p>
<pre><code>public int X { get; set; } = x; // C# 6 or higher
</code></pre>
<p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.defaultvalueattribute?view=netframework-4.8" rel="noreferrer"><code>DefaultValueAttribute</code></a> is intended to be used by the VS designer (or any other consumer) to specify a default value, not an initial value. (Even if in designed object, initial value is the default value).</p>
<p>At compile time <code>DefaultValueAttribute</code> will not impact the generated IL and it will not be read to initialize the property to that value (see <a href="https://stackoverflow.com/questions/1980520/defaultvalue-attribute-is-not-working-with-my-auto-property">DefaultValue attribute is not working with my Auto Property</a>).</p>
<p>Example of attributes that impact the IL are <a href="https://learn.microsoft.com/en-us/dotnet/api/system.threadstaticattribute?view=netframework-4.8" rel="noreferrer"><code>ThreadStaticAttribute</code></a>, <a href="https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callermembernameattribute?view=netframework-4.8" rel="noreferrer"><code>CallerMemberNameAttribute</code></a>, ...</p>
|
<p>I think this would do it for ya givng SomeFlag a default of false.</p>
<pre><code>private bool _SomeFlagSet = false;
public bool SomeFlag
{
get
{
if (!_SomeFlagSet)
SomeFlag = false;
return SomeFlag;
}
set
{
if (!_SomeFlagSet)
_SomeFlagSet = true;
SomeFlag = value;
}
}
</code></pre>
| 6,199
|
<p>I'm at a loss for where to get the best information about the meaning, likely causes, and possible solutions to resolve COM errors when all you have is the HRESULT.</p>
<p>Searching Google for terms like '80004027' is just about useless as it sends you to random discussion groups where 90% of the time, the question 'What does 80004027 mean?' is not answered.</p>
<p>What is a good resource for this? Why isn't MSDN the top Google result?</p>
|
<p>I always use WinError.h. That has the vast majority of Windows error codes of all sorts.</p>
<p>A key indicator to look out for is the Facility part of the code: the second most-significant byte. That is, 0x80nnmmmm, where nn is the Facility. That tells you which component generated the code. Anything with a facility of 7 is a Windows error code repackaged as an HRESULT, and you should convert the low word to decimal and look it up in WinError.h. There are also error ranges that appear in their own headers (e.g. anything from 12000 - 12999 is a WinInet error code and you should look it up in WinInet.h).</p>
<p>Looking up the error code will give you the symbolic name, which might be found in more documentation than the code itself or the wording of the error message.</p>
<p>FACILITY_ITF (which has the value 4, so these HRESULTs start 0x8004) indicates that the error is defined by the interface you're using; you'll have to check with that interface to find out what it means.</p>
<p>Finally, COM also offers the interface IErrorInfo to retrieve extended error information: call GetErrorInfo to retrieve the error object. You'll have to query for ISupportErrorInfo and call that interface's InterfaceSupportsErrorInfo method to determine whether the interface you called actually set the error object (and of course, if it was template code, it could be lying).</p>
|
<p><H2><a href="http://msdn.microsoft.com/en-us/library/ms690088.aspx" rel="nofollow noreferrer">Structure of COM Error Code</a></H2></p>
<p>Second in Google results for COM Error Code.</p>
| 7,527
|
<p>I just received my E3D v6 hotend and I am installing it on the open source design of a Prusa i3. How do I clean my hotend after each print and after using different filaments?</p>
|
<p>Usually there is no need to clean the hotend, as filament sticks well to itself rather than to the inside of the hotend. If there are remains - the simplest way to clean it up is to extrude 5-10 cm of new filament, which will gather all remainings clean the hotend.</p>
<p>The above concerns changing filament in the same group of plastic. So if you print PLA you can switch colors/manufacturers and so on without issues. The same goes for ABS.</p>
<p>There is also usually no problem when switching from PLA to ABS.</p>
<p>The worst scenario is to switch from ABS to PLA. This is because the extruding temperature of these two materials is different. Unfortunately ABS can have such a high melting temperature that the PLA will burn. So having a dirty hotend with ABS remainings, there is no way to extrude PLA to clean the hotend because the PLA temperature will not result in melting ABS. It can eventually lead to total plug of HE.</p>
<p>So what can you do when you are in such a situation (ABS -> PLA)?</p>
<p>You can clean the hotend first with ABS. Extrude some, wait until it is cold, ease the springs and pull or tear out the filament from the hotend.</p>
<p>If you are stuck you can use special drills to clean the nozzle.</p>
<p>But to totally omit the issue you can have two hotends :) One for ABS and one for PLA ;) But I think you can manage cleaning if you apply what I've written above.</p>
|
<p>Or you can use atomic nozle clianning!It woks fine for me :)
<a href="https://www.youtube.com/watch?v=04T8zdgyh3E" rel="nofollow">https://www.youtube.com/watch?v=04T8zdgyh3E</a></p>
| 292
|
<p>What is actually the difference between these two casts?</p>
<pre><code>SomeClass sc = (SomeClass)SomeObject;
SomeClass sc2 = SomeObject as SomeClass;
</code></pre>
<p>Normally, shouldn't they both be explicit casts to the specified type?</p>
|
<p>The former will throw an exception if the source type can't be cast to the target type. The latter will result in sc2 being a null reference, but no exception.</p>
<p>[Edit]</p>
<p>My original answer is certainly the most pronounced difference, but as Eric Lippert <a href="http://blogs.msdn.com/ericlippert/archive/2009/10/08/what-s-the-difference-between-as-and-cast-operators.aspx" rel="noreferrer">points out</a>, it's not the only one. Other differences include:</p>
<ul>
<li>You can't use the 'as' operator to cast to a type that doesn't accept 'null' as a value</li>
<li>You can't use 'as' to <em>convert</em> things, like numbers to a different representation (float to int, for example).</li>
</ul>
<p>And finally, using 'as' vs. the cast operator, you're also saying "I'm not sure if this will succeed." </p>
|
<p>The parenthetical cast throws an exception if the cast attempt fails. The "as" cast returns null if the cast attempt fails.</p>
| 2,458
|
<p>I'll take away the obvious one here: mic and webcam support. Other than that, if you ran the Silverlight team, what would your highest priority be for Silverlight v.Next?</p>
<p>Disclaimer: If we get some good responses, I'll pass them along to folks I know on the Silverlight team.</p>
<p><strong>UPDATE</strong>: The best place to report Silverlight feature requests now is the UserVoice site: <a href="http://silverlight.uservoice.com/pages/4325-feature-suggestions" rel="nofollow noreferrer">http://silverlight.uservoice.com/</a></p>
|
<p>Full cross-platform support for Windows, Mac and Linux with complete feature parity for each OS. ;)</p>
|
<p>What about some way to be able to wrap Silverlight around AIR and be able to run it as a client in a multi platform way... I guess this is more of a request to the Adobe team rather than the Microsoft one, yet I should be cool!</p>
<p>Cheers!</p>
| 3,788
|
<p>I am trying to make stencils of Japanese Kanji characters with my 3D Printer.</p>
<p>I am very new to Autodesk Fusion360 so I am running into some barriers: </p>
<ol>
<li><p>I am having trouble sketching a rectangle and then a text character and extruding them separately. If I extrude one they both disappear. Therefore I have to sketch one, then extrude, then create the next sketch object.
How can I create both sketches and select different ones to extrude? </p></li>
<li><p>I am having this basic problem where my stencil has parts that are disconnected (see example below). I've tried sketching lines and thin rectangles to connect the pieces but they both didn't work. I once again can't extrude after it's created. </p></li>
</ol>
<p>How can I connect the pieces after extruding? How can I connect them inside a text object? </p>
<p><a href="https://i.stack.imgur.com/hLaBH.png" rel="nofollow noreferrer" title="Example Kanji Stencil"><img src="https://i.stack.imgur.com/hLaBH.png" alt="Example Kanji Stencil" title="Example Kanji Stencil"></a></p>
|
<p>As I see it, for a stencil you want the brown part with the white part(s) cut out.</p>
<p>This is easily doable. You can do this one sketch at a time, extrude it, and cut it out of the brown part.</p>
<p>To connect the inner brown parts to the rest of the brown, you'll need to cut a thin rectangle in the white character so that the inner brown pieces are connected to the outer brown pieces.</p>
|
<p>May I suggest an alternative? Create your characters in a document editor (such as Word or OpenOffice), using a very large font size. Save the characters to an image file. Go to one of many converter sites, such as <a href="http://www.embossify.com/" rel="nofollow noreferrer">embossify</a> or <a href="https://www.sculpteo.com/en/workshops/create/text/?uuid=QTy21E63tHOjsSDR8WDdZd" rel="nofollow noreferrer">sculpteo</a>, and let them make a 3-D model of your character.</p>
| 879
|
<p>Is there anything similar on Windows what would achieve the same as the InputManager on OS X?</p>
|
<ol>
<li>Require SSL on the application</li>
<li>In a custom error page for the 403 redirect the browser to the incoming URL, changing http to https along the way.</li>
</ol>
<p>Note: Keep port 80 open for this - or there won't be a server to listen for requests to redirect.</p>
|
<p>Is just not accepting any connections on port 80 an option? I'm a complete web server noob so I don't know if the server can operate without an unsecured listen port but if the server can operate only listen on port 443 that would seem to be simplest option.</p>
<p>Another option would be a redirect from the unsecure port to the secure one</p>
| 5,083
|
<p>How to take screenshot programmically of desktop area in Mac OS X ?</p>
|
<p>Two interesting options I have seen, but yet to use professionally, are the screencapture utility and a MacFuse demo.</p>
<p>The screencapture utility has been around since 10.2, according to the man page, and could be linked to a Cocoa application by use of NSTask.</p>
<p>The MacFuse demo worked by creating a new screenshot each time a folder was opened, or something like that. The idea being you could write a quick script to access the image when you needed it, without having to have the script actually run on that machine.</p>
<p>But seriously, Apple has some other sample code called "Son of Grab" which uses the new CGWindow API which is pretty awesome. </p>
<p><a href="http://developer.apple.com/samplecode/SonOfGrab/" rel="noreferrer">http://developer.apple.com/samplecode/SonOfGrab/</a></p>
|
<p>If you consider REALbasic, this is extremely easy to do with RB and the MBS Plugins. I've just written an application that does timed screenshots using RB and the MBS Plugins. You can read about it here: <a href="http://tektalkin.blogspot.com/2008/08/screenaudit-for-mac-osx.html" rel="nofollow noreferrer">http://tektalkin.blogspot.com/2008/08/screenaudit-for-mac-osx.html</a></p>
| 5,993
|
<p>I would like to make a child class that has a method of the parent class where the method is a 'classmethod' in the child class but <strong>not</strong> in the parent class.</p>
<p>Essentially, I am trying to accomplish the following:</p>
<pre><code>class foo(Object):
def meth1(self, val):
self.value = val
class bar(foo):
meth1 = classmethod(foo.meth1)
</code></pre>
|
<p>I'm also not entirely sure what the exact behaviour you want is, but assuming its that you want bar.meth1(42) to be equivalent to foo.meth1 being a classmethod of bar (with "self" being the class), then you can acheive this with:</p>
<pre><code>def convert_to_classmethod(method):
return classmethod(method.im_func)
class bar(foo):
meth1 = convert_to_classmethod(foo.meth1)
</code></pre>
<p>The problem with classmethod(foo.meth1) is that foo.meth1 has already been converted to a method, with a special meaning for the first parameter. You need to undo this and look at the underlying function object, reinterpreting what "self" means.</p>
<p>I'd also caution that this is a pretty odd thing to do, and thus liable to cause confusion to anyone reading your code. You are probably better off thinking through a different solution to your problem.</p>
|
<p>The question, as posed, seems quite odd to me: I can't see why anyone would want to do that. It is possible that you are misunderstanding just what a "classmethod" is in Python (it's a bit different from, say, a static method in Java).</p>
<p>A normal method is more-or-less just a function which takes as its first argument (usually called "self"), an instance of the class, and which is invoked as ".".</p>
<p>A classmethod is more-or-less just a function which takes as its first argument (often called "cls"), a class, and which can be invoked as "." OR as ".".</p>
<p>With this in mind, and your code shown above, what would you expect to have happen if someone creates an instance of bar and calls meth1 on it?</p>
<pre><code>bar1 = bar()
bar1.meth1("xyz")
</code></pre>
<p>When the code to meth1 is called, it is passed two arguments 'self' and 'val'. I guess that you expect "xyz" to be passed for 'val', but what are you thinking gets passed for 'self'? Should it be the bar1 instance (in this case, no override was needed)? Or should it be the class bar (what then would this code DO)?</p>
| 9,214
|
<p>Has anyone implemented Lightbox style background dimming on a modal dialog box in a MFC/non .net app.<br>
I think the procedure would have to be something like:</p>
<p>steps:</p>
<ol>
<li><p>Get dialog parent HWND or CWnd* </p></li>
<li><p>Get the rect of the parent window and draw an overlay with a translucency over that window </p></li>
<li>allow the dialog to do it's modal draw routine, e.g DoModal()</li>
</ol>
<p>Are there any existing libraries/frameworks to do this, or what's the best way to drop a translucent overlay in MFC?<br>
<strong>edit</strong> Here's a mockup of what i'm trying to achieve if you don't know what 'lightbox style' means<br>
<strong>Some App</strong>:<br>
<img src="https://farm4.static.flickr.com/3065/2843243996_8a4536f516_o.png" alt="alt text"> </p>
<p>with a lightbox dialog box<br>
<img src="https://farm4.static.flickr.com/3280/2842409249_4a1c7f5810_o.png" alt="alt text"></p>
|
<p>Here's what I did* based on Brian's links<br>
First create a dialog resource with the properties:</p>
<ul>
<li>border <strong>FALSE</strong></li>
<li>3D look <strong>FALSE</strong></li>
<li>client edge <strong>FALSE</strong></li>
<li>Popup style</li>
<li>static edge <strong>FALSE</strong></li>
<li>Transparent <strong>TRUE</strong></li>
<li>Title bar <strong>FALSE</strong> </li>
</ul>
<p>and you should end up with a dialog window with no frame or anything, just a grey box.
override the Create function to look like this: </p>
<pre><code>BOOL LightBoxDlg::Create(UINT nIDTemplate, CWnd* pParentWnd)
{
if(!CDialog::Create(nIDTemplate, pParentWnd))
return false;
RECT rect;
RECT size;
GetParent()->GetWindowRect(&rect);
size.top = 0;
size.left = 0;
size.right = rect.right - rect.left;
size.bottom = rect.bottom - rect.top;
SetWindowPos(m_pParentWnd,rect.left,rect.top,size.right,size.bottom,NULL);
HWND hWnd=m_hWnd;
SetWindowLong (hWnd , GWL_EXSTYLE ,GetWindowLong (hWnd , GWL_EXSTYLE ) | WS_EX_LAYERED ) ;
typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD);
PSLWA pSetLayeredWindowAttributes;
HMODULE hDLL = LoadLibrary (_T("user32"));
pSetLayeredWindowAttributes =
(PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes");
if (pSetLayeredWindowAttributes != NULL)
{
/*
* Second parameter RGB(255,255,255) sets the colorkey
* to white LWA_COLORKEY flag indicates that color key
* is valid LWA_ALPHA indicates that ALphablend parameter
* is valid - here 100 is used
*/
pSetLayeredWindowAttributes (hWnd,
RGB(255,255,255), 100, LWA_COLORKEY|LWA_ALPHA);
}
return true;
}
</code></pre>
<p>then create a small black bitmap in an image editor (say 48x48) and import it as a bitmap resource (in this example IDB_BITMAP1)<br>
override the WM_ERASEBKGND message with:</p>
<pre><code>BOOL LightBoxDlg::OnEraseBkgnd(CDC* pDC)
{
BOOL bRet = CDialog::OnEraseBkgnd(pDC);
RECT rect;
RECT size;
m_pParentWnd->GetWindowRect(&rect);
size.top = 0;
size.left = 0;
size.right = rect.right - rect.left;
size.bottom = rect.bottom - rect.top;
CBitmap cbmp;
cbmp.LoadBitmapW(IDB_BITMAP1);
BITMAP bmp;
cbmp.GetBitmap(&bmp);
CDC memDc;
memDc.CreateCompatibleDC(pDC);
memDc.SelectObject(&cbmp);
pDC->StretchBlt(0,0,size.right,size.bottom,&memDc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
return bRet;
}
</code></pre>
<p>Instantiate it in the DoModal of the desired dialog, Create it like a Modal Dialog i.e. on the stack(or heap if desired), call it's Create manually, show it then create your actual modal dialog over the top of it: </p>
<pre><code>INT_PTR CAboutDlg::DoModal()
{
LightBoxDlg Dlg(m_pParentWnd);//make sure to pass in the parent of the new dialog
Dlg.Create(LightBoxDlg::IDD);
Dlg.ShowWindow(SW_SHOW);
BOOL ret = CDialog::DoModal();
Dlg.ShowWindow(SW_HIDE);
return ret;
}
</code></pre>
<p>and this results in something <strong>exactly</strong> like my mock up above </p>
<p>*there are still places for improvment, like doing it without making a dialog box to begin with and some other general tidyups.</p>
|
<p>I think you just need to create a window and set the transparency. There is an MFC <a href="http://www.codeproject.com/KB/dialog/CGlassDialog.aspx" rel="nofollow noreferrer">CGlassDialog sample on CodeProject</a> that might help you. There is also an <a href="http://www.codeproject.com/KB/winsdk/quaker1.aspx" rel="nofollow noreferrer">article</a> on how to do this with the Win32 APIs.</p>
| 7,490
|
<p>I'm compiling a simple .c in visual c++ with Compile as C Code (/TC)
and i get this compiler error </p>
<blockquote>
<p>error C2143: syntax error : missing ';' before 'type'</p>
</blockquote>
<p>on a line that calls for a simple struct </p>
<pre><code> struct foo test;
</code></pre>
<p>same goes for using the typedef of the struct.</p>
<blockquote>
<p>error C2275: 'FOO' : illegal use of this type as an expression</p>
</blockquote>
|
<p>I forgot that in C you have to declare all your variables before any code.</p>
|
<p>How is your structure type defined? There are two ways to do it:</p>
<pre><code>// This will define a typedef for S1, in both C and in C++
typedef struct {
int data;
int text;
} S1;
// This will define a typedef for S2 ONLY in C++, will create error in C.
struct S2 {
int data;
int text;
};
</code></pre>
| 5,579
|
<p>What tools would you recommend for setting up CI for build and deployment of multiple websites built on DotNetNuke using SVN for source control? </p>
<p>We are currently looking at configuring Cruise Control to work with NAnt, NUnit, NCover and Trac as a test case. What other combinations would worth investigating?</p>
<p>We have full control of our development environment so using some form of CI is certain here but I would also like to convince our production services team that they can reliably deploy to the system test, uat and even production environments using these tools.</p>
|
<p>We use CruiseControl with NUnit, NCover, FxCop, SVN and some custom tools we wrote ourselves to produce the reports. In my opinion it has proven (over the last few years) to be an excellent combination.</p>
<p>It's frustrating that MS restricts <em>all</em> of its integration tools to VSTS. Its test framework is as good as NUnit, but you can't use its code coverage tools or anything else.</p>
<p>I'd check out XNuit - it's looking pretty promising (but currently lacking UI).</p>
<p>We automate nightly builds, and you could automate UAT and manual test builds, but I'm not sure that we'd ever want to automate the release to our production servers. Even if it were any change would be important enough that someone would have to watch over it anyway.</p>
|
<p>Microsoft loosened it's constraint on the Testing Platform by including it in Visual Studio 2008 Professional and allowing for the tests to be run from the command line with Framework 3.5 installed. We did a crossover for a client recently and so far they have been able to run all the tests without the need for NUnit.</p>
| 2,879
|
<p>Does anybody know any good resources for learning how to program CIL with in-depth descriptions of commands, etc.? I have looked around but not found anything particularly good.</p>
|
<p>The only CIL book on my shelf is <a href="https://rads.stackoverflow.com/amzn/click/com/1590596463" rel="nofollow noreferrer" rel="nofollow noreferrer">Expert .NET 2.0 IL Assembler</a> by Serge Lidin. In terms of what the individual opcodes do or mean, the Microsoft documentation on System.Reflection.Emit has some pretty good information. And it's always useful to look at existing IL with <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a>.</p>
<p><strong>Edit:</strong> CIL (and indeed the CLR in general) has not changed at all between .NET 2.0 and .NET 3.5 -- the underlying runtime is basically the same, modulo fixes and performance improvements. So there's nothing newer available on a CIL level than what would be in a book on 2.0</p>
|
<p><a href="https://rads.stackoverflow.com/amzn/click/com/1590596463" rel="nofollow noreferrer" rel="nofollow noreferrer">Expert .NET 2.0 IL Assembler by Serge Lidin</a></p>
<p>There was a 1.1 version of the same book, but I haven't seen anything for the latest .NET release. It's an excellent book. I used it to write an OCR component in MSIL, as a learning project.</p>
<p>[Edit] @Curt is right, 3.0 and 3.5 are just extensions to 2.0, I hadn't plugged that in to my head yet. Now I've thought of a fun geek project... compare the disassembly of standard 2.0 code to the new LINQ/Lambda way of performing common tasks like filtering lists. For some reason I assumed that the magic was happening in new IL features, not just the compiler.</p>
| 6,672
|
<p>I'm looking for a tool which can generate a <a href="https://en.wikipedia.org/wiki/Make_(software)#Makefile" rel="nofollow noreferrer">Makefile</a> for a C/C++ project for different compilers (<a href="https://en.wikipedia.org/wiki/GNU_Compiler_Collection" rel="nofollow noreferrer">GCC</a>, <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B" rel="nofollow noreferrer">Microsoft Visual C++</a>, <a href="https://en.wikipedia.org/wiki/C%2B%2BBuilder" rel="nofollow noreferrer">C++Builder</a>, etc.) and different platforms (Windows, Linux, and Mac).</p>
|
<p>Other suggestions you may want to consider:</p>
<ul>
<li><p><a href="http://www.scons.org/" rel="nofollow noreferrer">Scons</a> is a cross-platform, cross-compiler build library, uses Python scripting for the build systems. Used in a variety of large projects, and performs very well.</p>
</li>
<li><p>If you're using <a href="https://en.wikipedia.org/wiki/Qt_%28software%29" rel="nofollow noreferrer">Qt</a>, <a href="https://doc.qt.io/qt-5/qmake-manual.html" rel="nofollow noreferrer">QMake</a> is a nice build system too.</p>
</li>
<li><p><a href="https://cmake.org/" rel="nofollow noreferrer">CMake</a> is also pretty sweet.</p>
</li>
<li><p>Finally, <a href="http://www.google.co.uk/search?q=cross+platform+build+system" rel="nofollow noreferrer">if all else fails...</a></p>
</li>
</ul>
|
<p>One issue to consider is do you want a "makefile" creator or a replacement build system? The problem with replacement build systems is that you typically don't get good IDE integration for platforms whose users expect this (Visual C++).
If you do want a makefile creator instead of a replacement build system, take a look at <a href="http://ociweb.com/products/mpc" rel="nofollow noreferrer">MPC</a>. It's free and open source.</p>
| 3,095
|
<p>I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars.</p>
<ol>
<li>? => causes the variable not to be found in the params object</li>
<li>(pound) => causes an invalid authenticity error</li>
<li>% => stops the div from being updated</li>
<li>& => every thing after the & is no longer passed into the variable on the server. </li>
</ol>
<p>Is there a way to solve this?</p>
<p>--- code sample ---</p>
<p>this is the view. ( 'postbody' is a text area)</p>
<pre><code><%= observe_field 'postbody',
:update => 'preview',
:url => {:controller => 'blog', :action => 'textile_to_html'},
:frequency => 0.5,
:with => 'postbody' -%>
</code></pre>
<p>this is the controller that is called</p>
<pre><code>def textile_to_html
text = params['postbody']
if text == nil then
@textile_to_html = '<br/>never set'
else
r = RedCloth.new text
@textile_to_html = r.to_html
end
render :layout => false
end
</code></pre>
<p>and this is the javascript that is created:</p>
<pre><code>new Form.Element.Observer('postbody', 0.5, function(element, value) {new Ajax.Updater('preview', '/blog/textile_to_html', {asynchronous:true, evalScripts:true, parameters:'postbody=' + value + '&authenticity_token=' + encodeURIComponent('22f7ee12eac9efd418caa0fe76ae9e862025ef97')})})
</code></pre>
|
<p>This is an escaping issue (as stated by others).</p>
<p>You'll want to change your observe_field :with statement to something like:</p>
<pre><code> :with => "'postbody=' + encodeURIComponent(value)"
</code></pre>
<p>Then in your controller:</p>
<pre><code>def textile_to_html
text = URI.unescape(params['postbody'])
...
</code></pre>
|
<p>Can you provide a code sample?</p>
<p>More likely than not you'll just need to escape your HTML entities using <a href="http://www.w3schools.com/jsref/jsref_encodeURI.asp" rel="nofollow noreferrer">encodeuri</a> or something like that.</p>
| 5,124
|
<p>I want to programatically create an NSTextView. How can I determine the correct frame height so that the view displays one line of text in the current default font?</p>
|
<p>The NSFont class has a method that can give you the size of a rectangle that would enclose a specific attributed string. Get the font used by your text view, create a string that serves as a reasonable example of what will be in the text view, and use that to inform your frame height. (The frame height will need to be some number of points larger than the actual rectangle the string would be displayed in.)</p>
<p>Alternately, you can get the various metrics from the font and attempt to calculate a reasonable frame from that. That might or might not work; for example, a font like Apple Chancery has a huge amount of variation depending on the glyphs that are being rendered, where they are in a word, and so on; I don't know that you can calculate what the needed size would be in advance without knowing exactly what you were going to render.</p>
|
<p>It would be more normal to be using an NSTextField than an NSTextView for a single line of text.</p>
<p>With NSTextField, just do the following:</p>
<pre><code>[textField setFont:myFont];
[textField sizeToFit];
</code></pre>
<p>Oh, and there is no built-in 'current default font'. If an application has such a concept, it needs to track it itself. The font panel doesn't read or write to anything global, it's used to operate on specific text objects.</p>
| 4,525
|
<p>Does anyone have any good starting points for me when looking at making web pages/sites/applications specifically for viewing on the iPhone?</p>
<p>I've looked at templates like the one <a href="http://blog.wired.com/monkeybites/2007/07/meet-joe-hewitt.html" rel="noreferrer">Joe Hewitt</a> has made, and also seen some templates I can purchase, which I haven't done yet.</p>
<p>I figured someone else had already started on this track and decided that I could probably leech on their newfound knowledge :)</p>
<p>So, does anyone have any pointers? I'm well aware of the problem that the more such a template/framework makes a web app look like a native iPhone app, the more likely I'm going to get into trouble because it just isn't, but for now I want a framework I can start building on, and then in the process figure out how to make it distinctive enough to be perceived as a web app as well as looking like a native iPhone application.</p>
<p>Specifically I'm looking for features like:</p>
<ul>
<li>stylesheets set up, or pointers to how to do them for iPhone</li>
<li>page flipping animation, ie. pick an item in a list, list scrolls out of view to the left and information for item scrolls in from the right</li>
<li>the animation part would have to work with dynamic pages, ie. not just one big page that has divs set up for each sub-item, which at least one such framework had as a sort of quick fix, I would need to have list item picking load the <em>page</em> for that item, and then when loaded, scroll to it</li>
</ul>
<hr>
<p><strong>Edit</strong>: To avoid people reading only the question and answering, before reading my other reply, I'll add my clarification for GPL licensing and similar issues here.</p>
<p>The framework I need to use can not be distributed under a license which would require me to license my own project out under a similar license. The GPL family of licenses allows for exceptions regarding library usage, but this won't apply to this since by necessity, the kind of framework I would need to use would be all source code.</p>
<p>The project can easily accomodate commercial libraries.</p>
<p>Also, I don't need a <em>library</em> or a <em>framework</em> as such, example files that look good and aren't overly obfuscated would be welcome as well.</p>
|
<p>I found <a href="http://code.google.com/p/iphone-universal/" rel="nofollow noreferrer">iphone-universal</a> on Google Code the other day. Haven't had a chance to try it out but it looks promising.</p>
|
<p>This <em>looks</em> good, but unfortunately it's being licensed under GPLv3, so I'm actually a bit afraid to start looking at that code. The framework I either need to find, or develop if needs be, must be able to be used as part of a commercial program, without having to license the entire program different. Commercial libraries are fine, I just haven't found any I can demo yet, presumably because I could just then steal all the code if I wanted to.</p>
<p>Guess I'll look further, thanks for the link though.</p>
<p><strong>Edit</strong>: Clarification. I'd be fine with the requirement to share the source to the web framework part for the iPhone, if someone wanted it, but since this framework is all source, I'm afraid that incorporating bits of it into an existing web application (to make a <em>skin</em> for iPhone), I'd be making the whole web application liable for GPL license, which is totally out of the question. Even sharing all the files related to the iPhone pages is out of the question, since they will contain proprietary code.</p>
| 3,025
|
<p>I know very little about the history of 3D printing, except that SLA came first (in the 1980's?), and FDM development was probably held back by patents.</p>
<p>By 2016, very low price kit machines were available to hobbyists, in the <€300 price range, as price-reduced clones of designs which had already seen several iterations.</p>
<p>Was this the start of the break-out of cheap FDM machines (as opposed to the >€2000 semi-professional lab budget prototyping class), or were the earlier iterations of these kit machines also suitable/adopted by hobbyists?</p>
<p>I realise that early popularity would grow exponentially, but I'm thinking particularly at what point people could build a printer without needing to compile their own firmware, solder any boards, etc.</p>
|
<blockquote>
<p>By 2016, very low price kit machines were available to hobbyists [..]</p>
<p>Was this the start of the break-out of cheap FDM machines</p>
</blockquote>
<p>No, not by any means. The <a href="https://en.wikipedia.org/wiki/RepRap_project" rel="noreferrer">RepRap project</a> started in 2005, and by 2008-2010 there were several open-source printer designs out there that were somewhat workable for hobbyists. These designs were still quite expensive, you needed to source all the components yourself and do a very significant amount of troubleshooting.</p>
<p>However, as early as mid-2009 you could buy a <a href="https://gizmodo.com/5286457/makerbot-cupcake-cnc-delivers-diy-3d-printing-for-just-750/" rel="noreferrer">Makerbot Cupcake CNC</a> for \$750 as a kit (which might have involved some soldering) or \$2500 fully assembled (presumably without soldering, but it's conceivable it was plug-and-play). Makerbot went on to become quite a successful company, piggybacking off the RepRap project and could be viewed as the "break-out" you ask about.</p>
<p>I purchased my first printer kit (no soldering or firmware involved) for \$500 (plus around \$150 in shipping and taxes) in February 2014; cheap hobbyist machines were commonplace well before that. </p>
|
<p>The Makerbot Replicator was released in 2012 and was the first 3D consumer-level printer that was sold only as a complete unit, not a kit. They were also well funded and had a famous Maker-Person as a founder. This seemed to coincide with wide-scale coverage of 3D printing in the media, and a big boom in the DIY side of the movement which is continuing to this day.</p>
<p>The unit was still expensive by many standards (US$2500), but it did solve the bootstrap problem... you could just buy one at a store, instead of having to have a specific knowledge set in order to build one.</p>
| 984
|
<p>Using the same <strong>sort</strong> command with the same input produces different results on different machines. How do I fix that?</p>
|
<p>The <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/sort.1.html" rel="nofollow noreferrer">man-page</a> on OS X says:</p>
<blockquote>
<p>******* WARNING ******* The locale specified by the environment affects sort order. Set LC_ALL=C to get
the traditional sort order that uses native byte values.</p>
</blockquote>
<p>which might explain things.</p>
<p>If some of your systems have no locale support, they would default to that locale (C), so you wouldn't have to set it on those. If you have some that supports locales and want the same behavior, set <code>LC_ALL=C</code> on those systems. That would be the way to have as many systems as I know do it the same way.</p>
<p>If you don't have any locale-less systems, just making sure they share locale would probably be enough.</p>
<p>For more canonical information, see The Single UNIX ® Specification, Version 2 description of <a href="http://opengroup.org/onlinepubs/007908799/xbd/locale.html" rel="nofollow noreferrer">locale</a>, <a href="http://opengroup.org/onlinepubs/007908799/xbd/envvar.html" rel="nofollow noreferrer">environment variables</a>, <a href="http://opengroup.org/onlinepubs/007908799/xsh/setlocale.html" rel="nofollow noreferrer">setlocale()</a> and the description of the <a href="http://opengroup.org/onlinepubs/007908799/xcu/sort.html" rel="nofollow noreferrer">sort(1)</a> utility.</p>
|
<p>This is probably due to different settings of the <a href="http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.nls/doc/nlsgdrf/locale_env.htm" rel="nofollow noreferrer">locale environment variables</a>. <code>sort</code> will use these settings to determine how to compare strings. By setting these environment variables the way you want before calling <code>sort</code>, you should be able to force it to behave in one specific way.</p>
| 4,853
|
<p>Can you please point to alternative data storage tools and give good reasons to use them instead of good-old relational databases? In my opinion, most applications rarely use the full power of SQL--it would be interesting to see how to build an SQL-free application.</p>
|
<p>Plain text files in a filesystem</p>
<ul>
<li>Very simple to create and edit</li>
<li>Easy for users to manipulate with simple tools (i.e. text editors, grep etc)</li>
<li>Efficient storage of binary documents</li>
</ul>
<hr>
<p>XML or JSON files on disk</p>
<ul>
<li>As above, but with a bit more ability to validate the structure.</li>
</ul>
<hr>
<p>Spreadsheet / CSV file</p>
<ul>
<li>Very easy model for business users to understand</li>
</ul>
<hr>
<p>Subversion (or similar disk based version control system)</p>
<ul>
<li>Very good support for versioning of data</li>
</ul>
<hr>
<p><a href="http://www.oracle.com/technology/products/berkeley-db/index.html" rel="noreferrer">Berkeley DB</a> (Basically, a disk based hashtable)</p>
<ul>
<li>Very simple conceptually (just un-typed key/value)</li>
<li>Quite fast</li>
<li>No administration overhead</li>
<li>Supports transactions I believe</li>
</ul>
<hr>
<p><a href="http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b/ref=sc_fe_l_2?ie=UTF8&node=342335011&no=3435361&me=A36L942TSJ2AJA" rel="noreferrer">Amazon's Simple DB</a></p>
<ul>
<li>Much like Berkeley DB I believe, but hosted</li>
</ul>
<hr>
<p><a href="http://code.google.com/appengine/docs/datastore/" rel="noreferrer">Google's App Engine Datastore</a></p>
<ul>
<li>Hosted and highly scalable</li>
<li>Per document key-value storage (i.e. flexible data model)</li>
</ul>
<hr>
<p><a href="http://incubator.apache.org/couchdb/" rel="noreferrer">CouchDB</a></p>
<ul>
<li>Document focus</li>
<li>Simple storage of semi-structured / document based data</li>
</ul>
<hr>
<p>Native language collections (stored in memory or serialised on disk)</p>
<ul>
<li>Very tight language integration</li>
</ul>
<hr>
<p>Custom (hand-written) storage engine</p>
<ul>
<li>Potentially very high performance in required uses cases</li>
</ul>
<hr>
<p>I can't claim to know anything much about them, but you might also like to look into <a href="http://en.wikipedia.org/wiki/Object_database" rel="noreferrer">object database systems</a>.</p>
|
<p>One good reason not to use a relational database would be when you have a massive data set and want to do massively parallel and distributed processing on the data. The Google web index would be a perfect example of such a case. </p>
<p>Hadoop also has an implementation of the <a href="http://labs.google.com/papers/gfs.html" rel="nofollow noreferrer">Google File System</a> called the <a href="http://hadoop.apache.org/core/docs/current/hdfs_design.html" rel="nofollow noreferrer">Hadoop Distributed File System</a>.</p>
| 5,867
|
<p>Please note that this question is from 2008 and now is of only historic interest.</p>
<hr>
<p>What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?</p>
<p>Both programmatically and using the Interface Builder.</p>
|
<h1>Historic answer only. Spectacularly out of date.</h1>
<p>Please note that this answer is now hugely out of date/</p>
<p>This answer is <strong>only a historical curiosity</strong>.</p>
<hr />
<p>Exciting news! As discovered by Andrew below, this problem has been fixed by Apple in 4.0+.</p>
<p>It would appear it is NO longer necessary to force the size of the view on every view, and the specific serious problem of landscape "only working the first time" has been resolved.</p>
<p>As of April 2011, it is not possible to test or even build anything below 4.0, so the question is purely a historic curiosity. It's incredible how much trouble it caused developers for so long!</p>
<hr />
<p>Here is the original discussion and solution. This is utterly irrelevant now, as these systems are not even operable.</p>
<hr />
<p>It is EXTREMELY DIFFICULT to make this work fully -- there are at least three problems/bugs at play.</p>
<p>try this .. <a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/7366-interface-builder-landscape-design.html#post186977" rel="noreferrer">interface builder landscape design</a></p>
<p>Note in particular that where it says <em>"and you need to use shouldAutorotateToInterfaceOrientation properly everywhere"</em> it means everywhere, all your fullscreen views.</p>
<p>Hope it helps in this nightmare!</p>
<p>An important reminder of the ADDITIONAL well-known problem at hand here: if you are trying to swap between <em><strong>MORE THAN ONE</strong></em> view (all landscape), <em><strong>IT SIMPLY DOES NOT WORK</strong></em>. It is essential to remember this or you will waste days on the problem. It is literally NOT POSSIBLE. It is the biggest open, known, bug on the iOS platform. There is literally no way to make the hardware make the second view you load, be landscape. The annoying but simple workaround, and what you must do, is have a trivial master UIViewController that does nothing but sit there and let you swap between your views.</p>
<p>In other words, in iOS because of a major know bug:</p>
<pre><code>[window addSubview:happyThing.view];
[window makeKeyAndVisible];
</code></pre>
<p><em><strong>You can do that only once</strong></em>. Later, if you try to remove happyThing.view, and instead put in there newThing.view, IT DOES NOT WORK - AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix, even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController that simply sits there and just holds your various views (happyThing, newThing, etc). Hope it helps!</p>
|
<p>See this answer: <a href="https://stackoverflow.com/questions/2647786/landscape-mode-only-for-iphone-or-ipad/2647807#2647807">Landscape Mode ONLY for iPhone or iPad</a></p>
<ol>
<li>add orientation to plist</li>
<li>shouldAutorotateToInterfaceOrientation = YES in all files</li>
</ol>
<p>Although if you're using mixed modes, you might be better off with </p>
<pre><code>[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
</code></pre>
| 2,288
|
<p>Got a bluescreen in windows while cloning a mercurial repository.</p>
<p>After reboot, I now get this message for almost all hg commands:</p>
<pre>
c:\src\>hg commit
waiting for lock on repository c:\src\McVrsServer held by '\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
interrupted!
</pre>
<p>Google is no help.</p>
<p>Any tips?</p>
|
<p>When "waiting for lock on repository", delete the repository file: <code>.hg/wlock</code> (or it may be in <code><code>.hg/store/lock</code></code>)</p>
<p>When deleting the lock file, you must make sure nothing else is accessing the repository. (If the lock is a string of zeros or blank, this is almost certainly true).</p>
|
<p>If it only happens on mapped drives it might be bug <a href="https://bitbucket.org/tortoisehg/thg/issue/889/cant-commit-file-over-network-share" rel="nofollow">https://bitbucket.org/tortoisehg/thg/issue/889/cant-commit-file-over-network-share</a>. Using UNC path instead of drive letter seems to sidestep the issue.</p>
| 3,393
|
<p>Printing supports, either complete, or partially from PVA have not always resulted in successful prints according to my experience with the filament (used in a dual extruder Ultimaker 3 extended). But, when it works well, the surface finish is perfect as there is no gap between the PVA and PLA.</p>
<p>From my experience with PVA, I conclude it is prone to clog, the filament is very hygroscopic, resulting in popping sounds when printing if too moist which most probably also impacts on clogging. The clogs lead to failed support structures as the extruder grinds through the filament and as such failed prints.</p>
<p>I was wondering if PETG can be used for supports or for the interface layer of supports for printing supports for PLA prints? For example:</p>
<p><a href="https://i.stack.imgur.com/1ysAhm.png" rel="nofollow noreferrer" title="Non scaffolding support structure"><img src="https://i.stack.imgur.com/1ysAhm.png" alt="Non scaffolding support structure" title="Non scaffolding support structure" /></a> <a href="https://i.stack.imgur.com/Zk35Cm.png" rel="nofollow noreferrer" title="Non scaffolding support structure in material color"><img src="https://i.stack.imgur.com/Zk35Cm.png" alt="Non scaffolding support structure in material color" title="Non scaffolding support structure in material color" /></a></p>
<p>This is a sliced view of a print in line color (left or top on small screens) and material color (right or bottom on small screens); black PLA and cream colored PETG. This print contains a larger gap that needs support. Can you make the support from PETG, either the support as a whole or just the top interface.</p>
<ul>
<li>How does PLA-PETG or PETG-PLA bond or stick considering the 2 different print temperatures?</li>
<li>What are the concerns using a single nozzle?</li>
</ul>
|
<p>PETG works as support material for PLA, see video</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/3lZlyzYJd-I?start=12"></iframe>
</div></div></p>
<p>In theory, PLA printed on top of PETG will be fine because PETG softens and gets sticky at higher temperatures.</p>
<p>Printing PETG support on top of PLA may cause remelting of PLA, but if PETG is kept quite cold (220 °C) the issue will likely be minor. As shown in the video, it works.</p>
<p>PLA/PETG may still be better than using PLA/PLA because of this difference in extrusion temperatures that, for example in bridges where PLA is printed on top of PETG support, should result in very easily removable supports.</p>
<p>The type of supports used should be tested: tree supports could minimize the contact surface between the two and thus minimize marring by the hotter PETG being deposited onto the PLA at the expense of more PETG and normal supports could be used on a limited surface, so they can be removed easily. If the two materials really don't adhere much to each other, you may even be able to fake dissolvable supports, which increase the contact surface but provide a far better finish for bridges and bottom surfaces.</p>
<p>Using a single nozzle may require experimentation. In my experience, I print PLA at 230 °C so it wouldn't be an issue, and 220 °C would also work, but if PLA is printed cold, below 215 °C, you may need to heat/cool the nozzle. In any case, switching filament (especially PETG -> PLA) requires quite some filament to be discarded, so there is time for the heating. It is however to be kept in mind that cleaning of the nozzle between PLA and PETG (or in fact after any material swap) is difficult: some residue can remain in small gaps or low flow areas of the hotend and will be blended into the stream for quite some time after the swap, resulting in hybrid materials of unknown properties.<sup>1</sup></p>
<p>As I said, experimentation is needed for this kind of task: my experience, with a 2012-era hot end, may not even be representative of the behaviour of modern hot ends.</p>
<hr />
<p><sup>1</sup> - this effect is easily noticeable even with similar materials if switching from dark to light color filament, especially if not doing a cold pull to remove most of the material from the melt zone.</p>
|
<p>While it is most certainly possible to use PETG as a support material, you might run into some trouble when the first layer of PETG goes down on top of the PLA. Since PETG prints so much hotter than PLA, the PETG may bond too aggressively to the PLA causing it to become very difficult to remove after the print has finished. I would say the hassle involved in using PETG to print supports outweighs any perceivable benefits as opposed to using PLA.</p>
| 1,693
|
<p>What are the best practices in setting up a new instance of TFS 2008 Workgroup edition? </p>
<p>Specifically, the constraints are as follows:</p>
<ul>
<li>Must install on an existing Windows Server 2008 64 bit</li>
<li>TFS application layer is 32 bit only</li>
</ul>
<p>Should I install SQL Server 2008, Sharepoint and the app layer in a virtual instance of Windows Server 2008 or 2003(I am already running Hyper-V) or split the layers with a database on the host OS and the app layer in a virtual machine?</p>
<p>Edit: Apparently, splitting the layers is <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3501572&SiteID=1" rel="nofollow noreferrer">not</a> recommended </p>
|
<p>This is my recipe for installing TFS 2008 SP1. </p>
<p>There is no domain controller in this scenario, we are only a couple of users. If I was to do it again, I would consider changing our environement to use a active directory domain.</p>
<ul>
<li>Host Server running Windows Server 2008 with 8GB RAM and quad processor</li>
<li>Fresh install of Windows Server 2008 32bit in a VM under Hyper-V</li>
<li>Install Application Server role with IIS</li>
<li>Install SQL Server 2008 Standard edition
<ul>
<li>Use a user account for Reporting Services and Analysis Services</li>
</ul></li>
<li><a href="http://www.woodwardweb.com/vsts/000444.html" rel="nofollow noreferrer">Create a slipstreamed image of TFS 2008 with SP1</a> and install TFS</li>
<li>Install VSTS 2008</li>
<li>Install Team System Explorer</li>
<li>Install VSTS 2008 SP1</li>
<li>Install TFS Web Access Power tool</li>
</ul>
<p>After installing everything, reports were not generated. Found <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=317697&SiteID=1" rel="nofollow noreferrer">this forum post </a> that helped resolve the problem.</p>
<ul>
<li>Open <a href="http://localhost:8080/Warehouse/v1.0/warehousecontroller.asmx" rel="nofollow noreferrer">p://localhost:8080/Warehouse/v1.0/warehousecontroller.asmx</a></li>
<li>Run the webservice (see above link for details), it will take a little while, the tfsWarehouse will be rebuilt</li>
</ul>
<p>It is very important to do things in order, download the installation guide and follow it to the letter. I forgot to install the Team System Explorer until after installing SP1 and ventured into all sorts of problems. Installing SP1 once more fixed that.</p>
|
<p>I just upgraded our team to TFS 2008, from TFS 2005. The hardest part was upgrading SharePoint 2.0 to 3.0, so I would make sure to do that first, if you have not already installed TFS 2008. We had a couple of other difficulties, but they were all either related to the SharePoint upgrade, or to the fact that we were using an aftermarket Policy package - Scrum for TeamSystem. We are on SQL Server 2005, so I cannot address SQL Server 2008. As for splitting the layers, we did not do this either, as we are running on Windows Server 2003 and everything ran under the host OS.</p>
| 5,254
|
<p>I need to find a bottleneck and need to accurately as possible measure time.</p>
<p>Is the following code snippet the best way to measure the performance?</p>
<pre><code>DateTime startTime = DateTime.Now;
// Some execution process
DateTime endTime = DateTime.Now;
TimeSpan totalTimeTaken = endTime.Subtract(startTime);
</code></pre>
|
<p>No, it's not. Use the <a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx" rel="noreferrer">Stopwatch</a> (in <code>System.Diagnostics</code>)</p>
<pre><code>Stopwatch sw = Stopwatch.StartNew();
PerformWork();
sw.Stop();
Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds);
</code></pre>
<p>Stopwatch automatically checks for the existence of high-precision timers.</p>
<p>It is worth mentioning that <code>DateTime.Now</code> often is quite a bit slower than <code>DateTime.UtcNow</code> due to the work that has to be done with timezones, <a href="http://en.wikipedia.org/wiki/Daylight_saving_time" rel="noreferrer">DST</a> and such.</p>
<p>DateTime.UtcNow typically has a resolution of 15 ms. See <a href="http://jaychapman.blogspot.com/2007/12/datetimenow-precision-issues-enter.html" rel="noreferrer">John Chapman's blog post</a> about <code>DateTime.Now</code> precision for a great summary.</p>
<p>Interesting trivia: The stopwatch falls back on <code>DateTime.UtcNow</code> if your hardware doesn't support a high frequency counter. You can check to see if Stopwatch uses hardware to achieve high precision by looking at the static field <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.ishighresolution.aspx" rel="noreferrer">Stopwatch.IsHighResolution</a>.</p>
|
<p>Since I do not care to much about precision I ended up comparing them. I am capturing lots of packets on the network and I want to place the time when I receive each packet. Here is the code that tests 5 million iterations</p>
<pre><code> int iterations = 5000000;
// Test using datetime.now
{
var date = DateTime.UtcNow.AddHours(DateTime.UtcNow.Second);
var now = DateTime.UtcNow;
for (int i = 0; i < iterations; i++)
{
if (date == DateTime.Now)
Console.WriteLine("it is!");
}
Console.WriteLine($"Done executing {iterations} iterations using datetime.now. It took {(DateTime.UtcNow - now).TotalSeconds} seconds");
}
// Test using datetime.utcnow
{
var date = DateTime.UtcNow.AddHours(DateTime.UtcNow.Second);
var now = DateTime.UtcNow;
for (int i = 0; i < iterations; i++)
{
if (date == DateTime.UtcNow)
Console.WriteLine("it is!");
}
Console.WriteLine($"Done executing {iterations} iterations using datetime.utcnow. It took {(DateTime.UtcNow - now).TotalSeconds} seconds");
}
// Test using stopwatch
{
Stopwatch sw = new Stopwatch();
sw.Start();
var now = DateTime.UtcNow;
for (int i = 0; i < iterations; i++)
{
if (sw.ElapsedTicks == DateTime.Now.Ticks)
Console.WriteLine("it is!");
}
Console.WriteLine($"Done executing {iterations} iterations using stopwatch. It took {(DateTime.UtcNow - now).TotalSeconds} seconds");
}
</code></pre>
<p>The output is:</p>
<pre><code>Done executing 5000000 iterations using datetime.now. It took 0.8685502 seconds
Done executing 5000000 iterations using datetime.utcnow. It took 0.1074324 seconds
Done executing 5000000 iterations using stopwatch. It took 0.9625021 seconds
</code></pre>
<p><strong>So in conclusion DateTime.UtcNow is the fastest if you do not care to much about precision</strong>. This also supports the answer <a href="https://stackoverflow.com/a/6986472/637142">https://stackoverflow.com/a/6986472/637142</a> from this question.</p>
| 4,824
|
<p>From a desktop application developer point of view, is there any difference between developing for Windows XP and developing for Windows Vista?</p>
|
<p><strong>User Interface</strong></p>
<p>Looking at the <a href="http://msdn.microsoft.com/en-us/library/aa511258.aspx" rel="nofollow noreferrer">Windows Vista User Experience Guidelines</a> you can see that they have changed many UI elements, which you should be aware of. Some major things to take note of:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa511280.aspx" rel="nofollow noreferrer">Larger icons</a></li>
<li>New <a href="http://msdn.microsoft.com/en-us/library/aa511295.aspx" rel="nofollow noreferrer">font</a> (Which affects some custom UI constistency)</li>
<li>New <a href="http://msdn.microsoft.com/en-us/library/aa511268.aspx" rel="nofollow noreferrer">dialog box features</a> (<a href="http://msdn.microsoft.com/en-us/library/bb787471%28VS.85%29.aspx" rel="nofollow noreferrer">task dialogs</a>)</li>
<li>Altered <a href="http://msdn.microsoft.com/en-us/library/aa511293.aspx" rel="nofollow noreferrer">common dialogs</a> (like File Open, Save As, etc.)</li>
<li>Dialog text <a href="http://msdn.microsoft.com/en-us/library/aa974175.aspx" rel="nofollow noreferrer">style and tone</a>, and <a href="http://msdn.microsoft.com/en-us/library/aa974176.aspx" rel="nofollow noreferrer">look and feel</a></li>
<li>New <a href="http://msdn.microsoft.com/en-us/library/aa511302.aspx" rel="nofollow noreferrer">Aero Wizards</a></li>
<li>Redesigned <a href="http://msdn.microsoft.com/en-us/library/aa511500.aspx" rel="nofollow noreferrer">toolbars</a></li>
<li>Better <a href="http://msdn.microsoft.com/en-us/library/aa511297.aspx" rel="nofollow noreferrer">notification UI</a></li>
<li>New recommended method of including a <a href="http://msdn.microsoft.com/en-us/library/aa511327.aspx#search" rel="nofollow noreferrer">search control</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa511327.aspx#frames" rel="nofollow noreferrer">Glass</a></li>
</ul>
<p><strong>64-bit</strong></p>
<p>Vista has a 64-bit edition, and although XP did too, your users are more likely to use Vista 64 than XP 64. Now you have to deal with:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa965884.aspx" rel="nofollow noreferrer">Registry virtualization</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa384232%28VS.85%29.aspx" rel="nofollow noreferrer">Registry redirection</a> (<a href="http://msdn.microsoft.com/en-us/library/ms724072%28VS.85%29.aspx" rel="nofollow noreferrer">Wow6432Node</a>)</li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa384235.aspx" rel="nofollow noreferrer">Registry reflection</a></li>
<li><a href="http://www.microsoft.com/whdc/winlogo/drvsign/kmsigning.mspx" rel="nofollow noreferrer">Digital signatures for kernel modules</a></li>
<li>MSI installers have <a href="http://blogs.msdn.com/heaths/archive/2005/10/24/windows-installer-on-64-bit-platforms.aspx" rel="nofollow noreferrer">new properties</a> to deal with</li>
</ul>
<p><strong>UAC</strong></p>
<p><a href="http://en.wikipedia.org/wiki/User_Account_Control" rel="nofollow noreferrer">User Account Control</a> vastly affects the default permissions that your application has when interacting with the OS.</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/bb756996.aspx" rel="nofollow noreferrer">How UAC works and affects your application</a> (also see the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=BA73B169-A648-49AF-BC5E-A2EEBB74C16B&displaylang=en" rel="nofollow noreferrer">requirements doc</a>)</li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa372468%28VS.85%29.aspx" rel="nofollow noreferrer">Installers have to deal with UAC</a></li>
</ul>
<p><strong>New APIs</strong></p>
<p>There are new APIs which are targeted at either new methods of application construction or allowing new functionality:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa376210%28VS.85%29.aspx" rel="nofollow noreferrer">Cryptography API: Next Generation</a> (CNG)</li>
<li><a href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language" rel="nofollow noreferrer">Extensible Application Markup Language</a> (XAML)</li>
<li><a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx" rel="nofollow noreferrer">Windows Communication Foundation</a> (WCF)</li>
<li><a href="http://msdn.microsoft.com/en-us/netframework/aa663328.aspx" rel="nofollow noreferrer">Windows Workflow Foundation</a> (WF)</li>
<li>And <a href="http://msdn.microsoft.com/en-us/library/aa383874.aspx" rel="nofollow noreferrer">many more smaller ones</a></li>
</ul>
<p><strong>Installers</strong></p>
<p>Because installations can only use common runtimes they install after a transaction has completed, <a href="http://blogs.msdn.com/astebner/archive/2007/05/20/2760317.aspx" rel="nofollow noreferrer">custom actions</a> <a href="http://blogs.msdn.com/astebner/archive/2007/01/09/problems-with-custom-actions-that-depend-on-the-visual-c-8-0-runtime-files-on-windows-vista.aspx" rel="nofollow noreferrer">will fail</a> if your custom action dll requires the Visual C++ runtimes above the VS 2005 CRT (non-SP1).</p>
|
<p>By far the most painful part of moving an application from XP to Vista (from my point of view) is dealing with the numerous services and IPv6 stuff that uses ports which were previously free, and dealing with the Wireless Provisioning -> Native WiFi transition.</p>
<p>The UAC stuff is basically a moot point; there is very little the application developer needs to do.</p>
| 4,268
|
<p>Do I risk losing sales by disabling SSL 2.0 and PCT 1.0 in IIS5?</p>
<p>Clarification: Sales would be lost by client not being able to connect via SSL to complete ecommerce transaction because SSL 2.0 or PCT 1.0 is disabled on the web server. </p>
<p>Microsoft kbase article: <a href="http://support.microsoft.com/kb/187498" rel="nofollow noreferrer">http://support.microsoft.com/kb/187498</a></p>
|
<p>Modern browsers either don't appear to support SSLv2 at all (Google Chrome, Opera 9.52, Firefox) or have it disabled by default (IE7, IE8).</p>
<p>That said, are you concerned about losing business from people using much-less-than-modern web browsers?</p>
<p>Possibly more importantly, are you concerned about your customers' security? Even if they can only connect using SSLv2, do you want them performing secure transactions with you using a protocol that is known to be insecure (see <a href="http://www.google.ca/search?q=sslv2+insecure" rel="nofollow noreferrer">Google</a>)?</p>
<p>As a computer professional, I would not hesitate to recommend to management that SSLv2 be disabled. I would leave it up to the bean counters to determine whether they think the additional income is worth the potential liability.</p>
|
<p>Presumably you use SSL to protect users from man-in-the-middle or other attacks, yes? SSLv2 is useless for this. Disable it -- the number of users who use a browser without SSLv3 or TLS support is vanishingly small, and it's easier to make them somebody else's problem than explain why somebody in Nigeria is using their credit card.</p>
| 9,020
|
<p>How can a .net class library project and resulting dll be protected so it cant be referenced by other applications (.net projects) except those projects in my own solution?</p>
|
<p>I think you can't forbid other applications to reference you library.<br>
You can make library's classes internal and provide access to them via <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="nofollow noreferrer">InternalVisibleTo</a> attribute but it won't save you from reflection.</p>
|
<p>Forgive my ignorance, but if they're all class libraries, what does the code do? Isn't the purpose of having a dll so that the code can be referenced.</p>
<p>In any case if you mark everything <a href="http://msdn.microsoft.com/en-us/library/7c5ka91b.aspx" rel="nofollow noreferrer"><code>internal</code></a> it won't be able to be accessed outside its own library</p>
| 6,022
|
<p>I've been trying to get something decent printed for days but nothing works! I have a Tarantula Tevo i3 <code>MKS Base V1.4</code> and have done a lot of trial & plenty of error. Still I am puzzled to get good prints.</p>
<ol>
<li>What is the stock firmware for a single extruder regular/large bed firmware & how to configure a large bed (if needed to be configured)?</li>
<li>Which is the auto bed leveling firmware?</li>
</ol>
<p>I need help sorting out what's out there. I did not manage to configure a large bed with a single extruder. But did manage to restore firmware with <a href="https://github.com/MarlinFirmware/Marlin/" rel="nofollow noreferrer">Marlin-2.0.x</a></p>
<ol>
<li>So the <a href="https://tevo3dprinterstore.com/pages/tevo-tarantula-firmware" rel="nofollow noreferrer">Tevo 3D Printing Store firmware link</a> directs to a <a href="https://www.dropbox.com/sh/ndykfl1wkw8enpj/AACTlV5qC9dpaJA1PYYLACeha?dl=0" rel="nofollow noreferrer">dropbox</a> - only dual extruders - both regular & large bed,</li>
<li>There is JimBrown's GitHub <a href="https://github.com/JimBrown/MarlinTarantula" rel="nofollow noreferrer">MarlinTarantula</a> - Optimized firmware for RepRap 3D printers based on the Arduino platform,</li>
<li>JoelLisenby's GitHub <a href="https://github.com/JoelLisenby/TEVO-Tarantula-I3-Marlin-Firmware" rel="nofollow noreferrer">TEVO-Tarantula-I3-Marlin-Firmware</a>.</li>
</ol>
<p>I followed this, <a href="https://www.youtube.com/watch?v=93p5ziFiGqs" rel="nofollow noreferrer">YouTube - Setting Up Auto Bed Leveling (Tevo Tarantula)</a>, for setting up the auto bed leveling sensor but it just got me messed-up even more, see <a href="https://3dprinting.stackexchange.com/questions/4624/tt-is-bed-auto-leveling">Tevo Tarantula incorrectly auto leveling of bed</a>. I'm just now in the process of trying to manually level the bed and I broke the hot end holder plastic plate...</p>
<hr>
<p><strong>EDIT</strong>:
The sensor I'm using is <a href="https://www.phidgets.com/?tier=3&catid=13&pcid=11&prodid=402" rel="nofollow noreferrer">SN04-N Inductive Proximity Sensor - 5mm</a></p>
|
<h2>Answer for <strong>"2)"</strong>:</h2>
<p>The default firmware seems to be Repetier. It also includes Bed leveling (see documentation):
<a href="https://www.repetier.com/documentation/repetier-firmware/z-probing/" rel="nofollow noreferrer">https://www.repetier.com/documentation/repetier-firmware/z-probing/</a></p>
<p>Marlin includes the Auto Bed Leveling feature too. You need to enable it by editing the Configuration.h file.</p>
<p>Bed size settings are there aswell.</p>
<p>"stylesuxx" made a video on how to get Marlin onto the Tevo:
<div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/-sQ8p00pG5E?start=0"></iframe>
</div></div>
or you can take a look at their website:
<a href="http://marlinfw.org/docs/configuration/configuration.html#configuration.h" rel="nofollow noreferrer">http://marlinfw.org/docs/configuration/configuration.html#configuration.h</a></p>
<p>Autoleveling can be enabeled as well in this file. There is a good video from Thomas Sanladerer on Mesh Bed Leveling:
<div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/EcGFLwj0pnA?start=0"></iframe>
</div></div></p>
<p>If you want some help with auto bed leveling it would be nice if you can include what kind of sensor you want to use (inductive, capacitive, microswitch...) and what your prefered type of bed leveling is (mesh 3x3, just z-leveling)...</p>
|
<p>Tevo Tarantula i3 owners on FaceBook is where I got marlin 2.0. Other things I tried didn't work, but this is working fine if you just want to add auto bed leveling using the standard SN04 sensor.</p>
| 686
|
<p>I've been playing around with the ASP.NET MVC Framework and the one thing that's really confusing me is how I'm meant to do server side validation of posted form data. I presume I don't post back to the same URL, but if I don't, how do I redisplay the form with the entered data and error messages? Also, where should the validation logic go? In the model or the controller? This seems to be one of the few areas where web forms are much stronger (I miss the validation controls).</p>
|
<p>Here's an overview of the flow in MVC:</p>
<ol>
<li>/new - render your "New" view containing a form for the user to fill out
<ul>
<li>User fills out form and it is posted to /create</li>
<li>The post is routed to the Create action on your controller</li>
<li>In your action method, update the model with the data that was posted.</li>
<li>Your Model should validate itself.</li>
<li>Your Controller should read if the model is valid.</li>
<li>If the Model is valid, save it to your db. Redirect to /show to render the show View for your object.</li>
<li>If the Model is invalid, save the form values and error messages in the TempData, and redirect to the New action again. Fill your form fields with the data from TempData and show the error message(s).</li>
</ul></li>
</ol>
<p>The validation frameworks will help you along in this process. Also, I think the ASP.NET MVC team is planning a validation framework for the next preview.</p>
|
<p>I'm just learning the MVC framework too so I'm not sure how off this is, but from what I understand you would have a form on a View such as Edit.aspx. This form would then post to the controller to another action method such as Update() passing in the contents of the form that you set in Edit.aspx as parameters.</p>
<pre><code>Update(int id, string name, string foo)
</code></pre>
<p>You could do the validation within that method. If all is ok, </p>
<pre><code>return View("Item", yourObject)
</code></pre>
| 3,150
|
<p>I have a number of application settings (in user scope) for my custom grid control. Most of them are color settings. I have a form where the user can customize these colors and I want to add a button for reverting to default color settings. How can I read the default settings?</p>
<p>For example:</p>
<ol>
<li>I have a user setting named <code>CellBackgroundColor</code> in <code>Properties.Settings</code>.</li>
<li>At design time I set the value of <code>CellBackgroundColor</code> to <code>Color.White</code> using the IDE.</li>
<li>User sets <code>CellBackgroundColor</code> to <code>Color.Black</code> in my program.</li>
<li>I save the settings with <code>Properties.Settings.Default.Save()</code>.</li>
<li>User clicks on the <code>Restore Default Colors</code> button.</li>
</ol>
<p>Now, <code>Properties.Settings.Default.CellBackgroundColor</code> returns <code>Color.Black</code>. How do I go back to <code>Color.White</code>?</p>
|
<p>@ozgur,</p>
<pre><code>Settings.Default.Properties["property"].DefaultValue // initial value from config file
</code></pre>
<p>Example:</p>
<pre><code>string foo = Settings.Default.Foo; // Foo = "Foo" by default
Settings.Default.Foo = "Boo";
Settings.Default.Save();
string modifiedValue = Settings.Default.Foo; // modifiedValue = "Boo"
string originalValue = Settings.Default.Properties["Foo"].DefaultValue as string; // originalValue = "Foo"
</code></pre>
|
<blockquote>
<p>How do I go back to Color.White?</p>
</blockquote>
<p>Two ways you can do:</p>
<ul>
<li>Save a copy of the settings before the user changes it.</li>
<li>Cache the user modified settings and save it to Properties.Settings before the application closes.</li>
</ul>
| 7,178
|
<p>Any suggestions? Using visual studio in C#.</p>
<p>Are there any specific tools to use or methods to approach this?</p>
<h3>Update:</h3>
<p>Sorry, I should have been a little more specific. I am using ASP.Net 2.0 and was looking more for a tool like jUnit for Java. I took a look at NUnit and NUnitAsp and that looks very promising. And I didn't even know that Visual Studio Pro has a testing suite, so I'll look at all of these options (I've just started using Visual Studio/Asp.net/C# this summer).</p>
|
<p>Boy, that's a pretty general question. I'll do my best, but be prepared to see me miss by a mile.</p>
<p>Assumptions</p>
<ol>
<li>You are using ASP.NET, not plain ASP</li>
<li>You don't really want to test your web pages, but the <strong>logic</strong> behind them. Unit testing the actual .ASPX pages is rather painful, but there are frameworks out there to do it. <a href="http://nunitasp.sourceforge.net/" rel="nofollow noreferrer">NUnitAsp</a> is one.</li>
</ol>
<p>The first thing to do is to organize (or plan) your code so that it can be tested. The two most popular design patterns for this at the time seem to be MVP and MVC. Both separate the <strong>logic</strong> of the application away from the <strong>view</strong> so that you can test the logic without the view (web pages) getting in your way.</p>
<p>Either MVP or MVC will be effective. MVC has the advantage of having a Microsoft framework <a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">almost ready to go</a>. </p>
<p>Once you've selected a framework pattern that encourages testability, you need to use a unit testing tool. <a href="http://www.nunit.org/" rel="nofollow noreferrer">NUnit</a> is a good starting point. Visual Studio Professional has a <a href="https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/bb385902(v=vs.90)" rel="nofollow noreferrer">testing suite built it</a>, but NUnit + <a href="http://www.testdriven.net/" rel="nofollow noreferrer">TestDrive.NET</a> also works in the IDE.</p>
<p>That's sort of a shotgun blast of information. I hope some if it hits. The Pragmatic Bookshelf has a <a href="https://rads.stackoverflow.com/amzn/click/com/0974514020" rel="nofollow noreferrer" rel="nofollow noreferrer">good book covering the topic</a>.</p>
|
<p>There was a screencast series a year or so ago on Polymorphic Podcast that did a pretty good intro walkthrough of an MVP implementation in ASP.NET. Implemented this way, unit tests fall into place much more naturally.</p>
<p><a href="http://polymorphicpodcast.com/shows/mv-patterns/" rel="noreferrer">http://polymorphicpodcast.com/shows/mv-patterns/</a></p>
| 2,637
|
<p>So I just got a Da-Vinci 3-in-1 Junior Pro 3D Printer, and was excited to start printing my first model.</p>
<p>When I open my .STL File in the XYZWare that comes with the printer, and click print, it says that the cartridge inserted into my printer in not genuine, and that it won't print until I order a genuine cartridge. What is interesting is that the cartridge loaded into this printer came with the printer itself, so it is genuine.</p>
<p>Is there something I am doing wrong? Here is a picture of the cartridge in my printer --></p>
<p><a href="https://i.stack.imgur.com/cMo0l.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/cMo0l.jpg" alt="This is how the cartridge is sitting inside the printer housing"></a></p>
<p>A Google search about this issue doesn't come up with any results that are of any use to me.</p>
|
<p>A <a href="https://www.google.nl/search?q=Da-Vinci+3-in-1+Junior+Pro+3D+does+not+recognise+genuine+cartridge&rlz=1C1GCEA_en&oq=Da-Vinci+3-in-1+Junior+Pro+3D+does+not+recognise+genuine+cartridge&aqs=chrome..69i57.13982j0j7&sourceid=chrome&ie=UTF-8" rel="noreferrer">quick search on the internet</a> showed that your experiences are shared by others.</p>
<p>Apparently, it has something to do with a faulty chip or the software.</p>
<p>From <a href="https://www.3dhubs.com/talk/t/xyzprinting-aio-filament-cartridge-not-being-detected/4340" rel="noreferrer">this thread</a>:</p>
<blockquote>
<p>I had the same thing, the cop on the underside of the cartridge wasn’t
programmed properly, if you have the latest firmware update and it
still doesn’t work contact the seller and they should send you a
replacement chip</p>
</blockquote>
<br>
<blockquote>
<p>I had this happen 2x. It ended up being that I had xyzware open.
Xyzware needs to restart in order to detect the new serial number of
the filament.</p>
</blockquote>
<p>You could ask for support from your supplier or restart the XYZ software.</p>
<p>You could also <a href="https://www.instructables.com/id/XYZ-Da-Vinci-Junior-jr-NFC-Tag-Filament-Reset-Hack/" rel="noreferrer">hack</a> the NFC chip that is inside the spool. (<strong>DISCLAIMER</strong>: <em>Do it at your own risk</em>!)</p>
|
<p>A <a href="https://www.google.nl/search?q=Da-Vinci+3-in-1+Junior+Pro+3D+does+not+recognise+genuine+cartridge&rlz=1C1GCEA_en&oq=Da-Vinci+3-in-1+Junior+Pro+3D+does+not+recognise+genuine+cartridge&aqs=chrome..69i57.13982j0j7&sourceid=chrome&ie=UTF-8" rel="noreferrer">quick search on the internet</a> showed that your experiences are shared by others.</p>
<p>Apparently, it has something to do with a faulty chip or the software.</p>
<p>From <a href="https://www.3dhubs.com/talk/t/xyzprinting-aio-filament-cartridge-not-being-detected/4340" rel="noreferrer">this thread</a>:</p>
<blockquote>
<p>I had the same thing, the cop on the underside of the cartridge wasn’t
programmed properly, if you have the latest firmware update and it
still doesn’t work contact the seller and they should send you a
replacement chip</p>
</blockquote>
<br>
<blockquote>
<p>I had this happen 2x. It ended up being that I had xyzware open.
Xyzware needs to restart in order to detect the new serial number of
the filament.</p>
</blockquote>
<p>You could ask for support from your supplier or restart the XYZ software.</p>
<p>You could also <a href="https://www.instructables.com/id/XYZ-Da-Vinci-Junior-jr-NFC-Tag-Filament-Reset-Hack/" rel="noreferrer">hack</a> the NFC chip that is inside the spool. (<strong>DISCLAIMER</strong>: <em>Do it at your own risk</em>!)</p>
| 1,107
|
<p>I am doing laboratory experiments and need to print some components.</p>
<p>I am working with different aqueous (water) solutions containing sulphuric acid (H<sub>2</sub>SO<sub>4</sub>), hydrochloric acid (HCl), and hydrogen peroxide (H<sub>2</sub>O<sub>2</sub>), separately and in combination. The pH of the solutions are in the range 0 to 7. Temperatures don't exceed 40° Celsius.</p>
<p>In another application we have aqueous solutions containing high concentrations of FeCl<sub>3</sub>, HCl and in some cases H<sub>2</sub>O<sub>2</sub> at temperatures of up to 180° Celsius.</p>
<p>Which 3D printing filament materials can you recommend for these applications?</p>
|
<p>There are two issues you have here, one is temperature stability and the other is chemical reactivity of plastics. I can't help you with the chemistry side, but I can help with the temperature.</p>
<h1>Application 1 (Temp < 40 °C)</h1>
<p>Any FDM plastic will perform reasonably well under these temperatures. I would suggest trying a Nylon, PETG or a PolyCarbonate filament as I know these are more resistant to acids than PLA or ABS. As far as strength of the parts, all FDM plastics will work well</p>
<h1>Application 2 (Temp > 180 °C)</h1>
<p>This temperature range is above the glass transition temperature of the PLA, ABS, PETG and Nylon are all well below 180 °C and therefore aren't worth considering. Your best option is PolyCarbonate, or PolyCarbonate-ABS which are both fairly high (roughly 140-150 °C). However, are both below your minimum temperature threshold.</p>
<p>My conclusion is to try a polycarbonate sample and see how it reacts to the chemicals you're working with, though it doesn't look hopeful.</p>
<p>For Chemical reactivity, I did some Google-fu and found a few links that look helpful for PolyCarbonate:</p>
<ul>
<li><p><a href="http://www.perspex.co.uk/Perspex/media/Media/Technical%20Library/Chemical%20Resistance/Polycarbonate-Rod-and-TubeChemical-Resistance.pdf" rel="nofollow noreferrer">Chemical resistance polycarbonate</a></p>
</li>
<li><p><a href="https://www.calpaclab.com/polycarbonate-chemical-compatibility-chart/" rel="nofollow noreferrer">Polycarbonate Chemical Compatibility Chart</a></p>
</li>
</ul>
|
<p>There are two issues you have here, one is temperature stability and the other is chemical reactivity of plastics. I can't help you with the chemistry side, but I can help with the temperature.</p>
<h1>Application 1 (Temp < 40 °C)</h1>
<p>Any FDM plastic will perform reasonably well under these temperatures. I would suggest trying a Nylon, PETG or a PolyCarbonate filament as I know these are more resistant to acids than PLA or ABS. As far as strength of the parts, all FDM plastics will work well</p>
<h1>Application 2 (Temp > 180 °C)</h1>
<p>This temperature range is above the glass transition temperature of the PLA, ABS, PETG and Nylon are all well below 180 °C and therefore aren't worth considering. Your best option is PolyCarbonate, or PolyCarbonate-ABS which are both fairly high (roughly 140-150 °C). However, are both below your minimum temperature threshold.</p>
<p>My conclusion is to try a polycarbonate sample and see how it reacts to the chemicals you're working with, though it doesn't look hopeful.</p>
<p>For Chemical reactivity, I did some Google-fu and found a few links that look helpful for PolyCarbonate:</p>
<ul>
<li><p><a href="http://www.perspex.co.uk/Perspex/media/Media/Technical%20Library/Chemical%20Resistance/Polycarbonate-Rod-and-TubeChemical-Resistance.pdf" rel="nofollow noreferrer">Chemical resistance polycarbonate</a></p>
</li>
<li><p><a href="https://www.calpaclab.com/polycarbonate-chemical-compatibility-chart/" rel="nofollow noreferrer">Polycarbonate Chemical Compatibility Chart</a></p>
</li>
</ul>
| 567
|
<p>For general protocol message exchange, which can tolerate some packet loss. How much more efficient is UDP over TCP?</p>
|
<p>UDP is faster than TCP, and the simple reason is because its non-existent acknowledge packet (ACK) that permits a continuous packet stream, instead of TCP that acknowledges a set of packets, calculated by using the TCP window size and round-trip time (RTT).</p>
<p>For more information, I recommend the simple, but very comprehensible <a href="http://www.skullbox.net/tcpudp.php" rel="noreferrer">Skullbox explanation (TCP vs. UDP)</a></p>
|
<p>The network setup is crucial for any measurements. It makes a huge difference, if you are communicating via sockets on your local machine or with the other end of the world. </p>
<p>Three things I want to add to the discussion:</p>
<ol>
<li>You can find <a href="http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/" rel="nofollow noreferrer">here</a> a very good article about TCP vs. UDP in the
context of game development. </li>
<li>Additionally, <a href="https://iperf.fr" rel="nofollow noreferrer">iperf</a> (<a href="http://iperf.sourceforge.net" rel="nofollow noreferrer">jperf</a> enhance iperf with a GUI) is a
very nice tool for answering your question yourself by measuring.</li>
<li>I implemented a benchmark in Python (see <a href="https://stackoverflow.com/questions/32654551/tcp-vs-udp-socket-latency-benchmark">this SO question</a>). In average of 10^6 iterations the difference for sending 8 bytes is about 1-2 microseconds for UDP.</li>
</ol>
| 7,024
|
<p>When I print parts in ABS, acetone vapour smoothing is a good technique to get a smooth finish. Is there an equivalent solvent or process for parts printed in ASA? Ideally I'm looking for something as easy to obtain as acetone, and not so awful a chemical that I wouldn't want to work with it, but I'd still be curious to learn about less friendly solvents.</p>
|
<p><a href="https://en.wikipedia.org/wiki/Acrylonitrile_styrene_acrylate" rel="nofollow noreferrer">ASA</a> is Acrylonitrile styrene acrylate. According to Wikipedia:</p>
<blockquote>
<p>ASA can be solvent-welded, using e.g. cyclohexane, 1,2-dichloroethane, methylene chloride, or 2-butanone. Such solvents can also join ASA with ABS and SAN. Solutions of ASA in these solvents can also be used as adhesives.</p>
<p><sup>Staff, PDL (1997). Handbook of Plastics Joining: A Practical Guide. Elsevier Science. p. 515.</sup></p>
</blockquote>
<p>Solvent-welding means that the material is at least somewhat easily soluble in these fluids (they dissolve the material at the interface and as they evaporate, the former interface layers bond as if molded or welded), and the fact that the material can become an adhesive means that it is somewhat good soluble in these.</p>
<p>The least dangerous (and thus most advised from my side) of these 4 is 2-butanone, the others are listed as carcinogenic, and in the case of 1,2-dichloroethane, also toxic.</p>
<p>If these solvents can be used as a smoother similar to acetone with ABS would need testing, but a short exposition to their vapors should suffice to test this.</p>
<h3>Addendum:</h3>
<p>These four solvents also are able to solve Acrylonitrile butadiene styrene (<a href="https://en.wikipedia.org/wiki/Acrylonitrile_butadiene_styrene" rel="nofollow noreferrer">ABS</a>), which is a quite similar plastic in regards to its contents (butadiene instead of acrylate).</p>
<blockquote>
<p>The acrylate rubber differs from the butadiene based rubber by absence of double bonds, which gives the material about ten times the weathering resistance and resistance to ultraviolet radiation of ABS, higher long-term heat resistance, and better chemical resistance. <sup>Wikipedia</sup></p>
</blockquote>
<p>Acetone might prove to be also a possible option, but results might differ from those on ABS.</p>
|
<p>From <a href="https://www.simplify3d.com/support/materials-guide/asa/" rel="nofollow noreferrer">Simplify3D - ASA</a>:</p>
<blockquote>
<p>ASA can be smoothed using controlled exposure to acetone vapors (a process called “vapor smoothing”).</p>
</blockquote>
| 1,392
|
<p>What is a recommended architecture for providing storage for a dynamic logical database schema?</p>
<p>To clarify: Where a system is required to provide storage for a model whose schema may be extended or altered by its users once in production, what are some good technologies, database models or storage engines that will allow this? </p>
<p>A few possibilities to illustrate:</p>
<ul>
<li>Creating/altering database objects via dynamically generated DML</li>
<li>Creating tables with large numbers of sparse physical columns and using only those required for the 'overlaid' logical schema</li>
<li>Creating a 'long, narrow' table that stores dynamic column values as rows that then need to be pivoted to create a 'short, wide' rowset containing all the values for a specific entity</li>
<li>Using a BigTable/SimpleDB PropertyBag type system</li>
</ul>
<p>Any answers based on real world experience would be greatly appreciated</p>
|
<p>What you are proposing is not new. Plenty of people have tried it... most have found that they chase "infinite" flexibility and instead end up with much, much less than that. It's the "roach motel" of database designs -- data goes in, but it's almost impossible to get it out. Try and conceptualize writing the code for ANY sort of constraint and you'll see what I mean.</p>
<p>The end result typically is a system that is MUCH more difficult to debug, maintain, and full of data consistency problems. This is not <em>always</em> the case, but more often than not, that is how it ends up. Mostly because the programmer(s) don't see this train wreck coming and fail to defensively code against it. Also, often ends up the case that the "infinite" flexibility really isn't that necessary; it's a very bad "smell" when the dev team gets a spec that says "Gosh I have no clue what sort of data they are going to put here, so let 'em put WHATEVER"... and the end users are just fine having pre-defined attribute types that they can use (code up a generic phone #, and let them create any # of them -- this is trivial in a nicely normalized system and maintains flexibility and integrity!)</p>
<p>If you have a very good development team and are <strong>intimately aware</strong> of the problems you'll have to overcome with this design, you can successfully code up a well designed, not terribly buggy system. Most of the time. </p>
<p>Why start out with the odds stacked so much against you, though?</p>
<p>Don't believe me? Google "One True Lookup Table" or "single table design". Some good results:
<a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:10678084117056" rel="noreferrer">http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:10678084117056</a></p>
<p><a href="http://thedailywtf.com/Comments/Tom_Kyte_on_The_Ultimate_Extensibility.aspx?pg=3" rel="noreferrer">http://thedailywtf.com/Comments/Tom_Kyte_on_The_Ultimate_Extensibility.aspx?pg=3</a></p>
<p><a href="http://www.dbazine.com/ofinterest/oi-articles/celko22" rel="noreferrer">http://www.dbazine.com/ofinterest/oi-articles/celko22</a></p>
<p><a href="http://thedailywtf.com/Comments/The_Inner-Platform_Effect.aspx?pg=2" rel="noreferrer">http://thedailywtf.com/Comments/The_Inner-Platform_Effect.aspx?pg=2</a></p>
|
<p>sql already provides a way to change your schema: the ALTER command.</p>
<p>simply have a table that lists the fields that users are not allowed to change, and write a nice interface for ALTER.</p>
| 9,190
|
<p>I have an Ender 3 Pro modded with the Hero Me Gen 6 air ducts, installed a Creality 4.2.7 mainboard, and updated Marlin firmware to the latest for now 2.1.1 version. I'm printing with PLA only.</p>
<p>It was printing well enough. The nozzle started to wear down so I replaced the nozzle (standard brass one) but also upgraded the heatbreak to a bi-metal one (not all-metal, there is still a plastic tube inside the heatbreak) and a heatblock (standard goldish Creality block). And since that moment, the printer fails to print with good quality starting the second layer</p>
<p>What I tried:</p>
<ul>
<li>recalibrated it with a gauge of 0.2 mm and the first layer is perfect (did not know that could be a thing :))</li>
<li>updated firmware</li>
<li>tried to tighten screws (as it is recommended <a href="https://3dprinting.stackexchange.com/questions/5503/has-anyone-encountered-this-type-of-strange-print-patterns">here</a>)</li>
<li>adjusted Z-axis steps/mm</li>
<li>another filament</li>
</ul>
<p>I can't figure out what causes that thing.</p>
<p><a href="https://i.stack.imgur.com/NpYMj.jpg" rel="nofollow noreferrer" title="Photo of the first two layers of a printed model; the second layer looking very different"><img src="https://i.stack.imgur.com/NpYMj.jpg" alt="Photo of the first two layers of a printed model; the second layer looking very different" title="Photo of the first two layers of a printed model; the second layer looking very different" /></a></p>
<p><a href="https://i.stack.imgur.com/NPZVO.jpg" rel="nofollow noreferrer" title="Upclose photo of the printed model showing the difference in the two layers"><img src="https://i.stack.imgur.com/NPZVO.jpg" alt="Upclose photo of the printed model showing the difference in the two layers" title="Upclose photo of the printed model showing the difference in the two layers" /></a></p>
<p><a href="https://i.stack.imgur.com/SKahg.jpg" rel="nofollow noreferrer" title="Zoomed in photo of the printed model showing the detailed differences in the two layers"><img src="https://i.stack.imgur.com/SKahg.jpg" alt="Zoomed in photo of the printed model showing the detailed differences in the two layers" title="Zoomed in photo of the printed model showing the detailed differences in the two layers" /></a></p>
<p>edited 2022-10-25 23:41</p>
<p>I think it is overextrusion. I tried reprinting object. The first layer was perfect, but second was poor again. There was no difference with cooling or without, no difference printing slower. But flow rate did matter:</p>
<ol>
<li>100% flow rate</li>
<li>changed to 85% flow rate</li>
<li>changed to 75% flow rate</li>
<li>changed to 100% flow rate</li>
<li>changed to 75% flow rate</li>
</ol>
<p>Maybe it is prusa slicer doing its thing. I will try Cura. The only thing that bothers me is that diagonal scratch - that is from the nozzle which makes me think it is too low for the second layer</p>
<p><a href="https://i.stack.imgur.com/j0wWW.jpg" rel="nofollow noreferrer" title="Difference of other flow rates"><img src="https://i.stack.imgur.com/j0wWW.jpg" alt="Difference of other flow rates" title="Difference of other flow rates" /></a></p>
<p>edited 2022-10-28 15:53</p>
<p>It's not a slicer thing. I sliced object with Cura and got pretty much the same result. I babystepped z-axis during the print to get nice result. So I think it is either z-axis motor not stepping enough or I need to lower extrusion multiplier in slicer. I will print calibration cube to check if z-axis motor steps up enough</p>
<p>edited 2022-10-28 18:34</p>
<p>Printed calibration cube. Turns out my z-axis steps were off. Model was 19.66mm instead of 20mm. I tuned steps to 407 from 400. That helped a bit (model is 20.02mm now) , but still the same ugly overextruded result. Tried to lower extrusion multiplier to 0.8 and still got the same bad result</p>
<p>edited 2022-10-30 22:11</p>
<p>It is neither nozzle nor heatbreak tube. I checked it using my old hardware. Maybe it is somehow connected to firmware... Or E-steps are off while printing</p>
|
<p>I would go back to the brass nozzle and try again for comparison.</p>
<p>We had a batch of 10 cheap steel nozzles all of which caused problems.</p>
|
<p>I think the answer is printing temperature. This shiny PLA I'm using is Eryone Silk PLA. Although the working temperature is stated as 190-220 °C, my 205 °C was too much for it. A temperature of 190-195 °C produces good results though not as shiny anymore. It is three layers printed on the sample below with no problems.</p>
<p><a href="https://i.stack.imgur.com/tJP8x.jpg" rel="nofollow noreferrer" title="3D printed sample printed with 195 degrees Celsius and showing no printing errors"><img src="https://i.stack.imgur.com/tJP8x.jpg" alt="3D printed sample printed with 195 degrees Celsius and showing no printing errors" title="3D printed sample printed with 195 degrees Celsius and showing no printing errors" /></a></p>
| 2,221
|
<p>Need to show a credits screen where I want to acknowledge the many contributors to my application. </p>
<p>Want it to be an automatically scrolling box, much like the credits roll at the end of the film.</p>
|
<p>A easy-to-use snippet would be to make a multiline textbox. With a timer you may insert line after line and scroll to the end after that:</p>
<pre><code>textbox1.SelectionStart = textbox1.Text.Length;
textbox1.ScrollToCaret();
textbox1.Refresh();
</code></pre>
<p>Not the best method but it's simple and working. There are also some free controls available for exactly this auto-scrolling.</p>
|
<p>A quick and dirty method would be to use a Panel with a long list of Label controls on it that list out the various people and contributions. Then you need to set the Panel to be AutoScroll so that it has a vertical scrollbar because the list of labels goes past the bottom of the displayed Panel. Then add a time that updates the AutoScrollOffset by 1 vertical pixel each timer tick. When you get to the bottom you reset the offset to 0 and carry on. The only downside is the vertical scrollbar showing.</p>
| 8,847
|
<p>I've included a mobile web form in my asp.net project, I thought that it could/should be seen just for my mobile users but I realize that it can also be seen from any browser, I don't see problem there cause I could diff the access using HttpBrowserCapabilities.IsMobileDevice=true and transferring to the appropiate aspx page, but it results that when I access to the web form from my mobile device it is identified as IsMobileDevice = false and sends me to another page.</p>
<p>How could it be possible that?</p>
<p>The mobile device runs Pocket PC 2003.</p>
|
<p>Some are not recognized, because the UserAgent has been messed with or a new browser is being used. Such as Opera Mobile 9.5. To fix this you need to create a Browser (*.browser) file specifically for defining this. I had to do it for the new Mozilla based UserAgent that is being sent from Google.</p>
|
<p>I think you should use other DDR better than Microsoft Browser Capabilities. I´m using http://wurfl.sourceforge.net>WURFL, it is open source and maybe it is more extended and updated. There is other commercial DDRs like <a href="http://deviceatlas.com/" rel="nofollow noreferrer">DeviceAtlas</a>.</p>
<p>There is many some .net libraries but i´m using <a href="http://wurfl.marg.si/" rel="nofollow noreferrer">Marg.Wurfl</a>. It allows to rendering web mobile page using wurfl capabilities.</p>
| 3,422
|
<p>I have never much cared about self intersecting meshes when slicing with Cura. Geometry like the one below are often practical. I for instance add lots of rivets that self intersect with the base geometry:</p>
<p><a href="https://i.stack.imgur.com/cRZqk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cRZqk.png" alt="self intersecting mesh"></a></p>
<p>Now I have switched printer, and am using Simplify3D instead. All of a sudden, I get lots of problems with these models. The intersection of the objects become hollow. Simplify3D has a setting to join the outer solid shell but it also fills holes (such as the center hole of a gear).</p>
<p>I make models to sell so this is a big deal for me.</p>
<p>EDIT: Also, they printed perfectly fine in formlabs "slicer".</p>
|
<p>Self intersecting meshes are considered dirty, yes. The reason you haven't had trouble before is probably that the software you were using was cleaning your mesh for you, behind the scenes.
Generally speaking, these meshes can be cleaned without too much trouble by software like netfabb (<a href="https://www.netfabb.com/">https://www.netfabb.com/</a>) which has a nice free version that I use for basic cleaning of some of my meshes. A quick google on "netfabb free fix mesh" should turn up a tutorial or two.</p>
<p>If you're interested in learning more about an operation you can use to make this a <em>single unified mesh</em>, it's called a Boolean Union, and the blender project has a nice (open source, I think?) implementation of such: (<a href="https://www.blender.org/manual/modeling/modifiers/generate/booleans.html">https://www.blender.org/manual/modeling/modifiers/generate/booleans.html</a>)</p>
|
<p>You can download MeshLab from <a href="https://sourceforge.net/projects/meshlab/" rel="nofollow noreferrer">https://sourceforge.net/projects/meshlab/</a> and use it to head stls.</p>
<p>This video has healing instructions: <a href="https://www.youtube.com/watch?v=eLGIRAgLz4w" rel="nofollow noreferrer">https://www.youtube.com/watch?v=eLGIRAgLz4w</a></p>
| 467
|
<p>What graphics toolkit is used for the Window's Google Talk application?</p>
|
<p>There isn't much information on this out there but it seems to be their own customized controls plus an IE component (and not Qt like Google Earth). <a href="http://www.customizetalk.com/forums/viewtopic.php?t=841&postdays=0&postorder=asc&start=0" rel="nofollow noreferrer">This forum thread</a> has a little bit of information.</p>
|
<p>I'm not positive but I believe it's QT. </p>
| 5,505
|
<p>I recently got a Dremel 3D20, and I understand it only takes PLA filament according to the Dremel site. However, I was wondering if anyone has successfully used TPU filament or knows it will work fine. I’m more than happy to use other software to change the temperature, I just don’t want to gunk up or otherwise ruin my printer.</p>
|
<p>TPU wants in general two things of your printer:</p>
<ul>
<li>A Printing Temperature of (over many makers) 195-230 °C</li>
<li>A Direct Drive (extruder on the printhead)</li>
</ul>
<blockquote>
<p>Bowden extruders are not ideal for printing flexible filaments such as NinjaFlex due to the excessive
distance between the stepper motor and the extruder head. However, some users have generated
successful prints using reduced speeds.<sup><a href="http://www.fennerdrives.com/FetchFile.ashx?id=a272e483-39da-48c2-b16a-b5d899189867" rel="nofollow noreferrer">ninjaflex handout</a></sup></p>
</blockquote>
<p>Check the temperature you can reach, and you are lucky, as some of the smaller Dremels use Bowden but the 3d20 is apparently direct drive.</p>
<p>If you want to try to run a Bowden with flexible filaments, dial down speed down really low (20-30 mm/s at most) and pray.</p>
|
<p>I've never used a Dremel printer, thus I cannot guarantee that my solution will work fine, but you might want to give a try to the <a href="https://ultimaker.com/en/products/ultimaker-cura-software" rel="nofollow noreferrer">Ultimaker Cura</a> slicer. </p>
<p>Ultimaker printers have Bowden tubes, like the Dremel, unless I am mistaken, and I've been able to successfully print TPU on my Ultimaker 3 Extended printer. I also know that many Ultimaker users have printed using Ninjaflex without much problems on their Ultimaker machines, both old and new.</p>
<p>Ultimaker Cura comes with pre-programmed settings for TPU95, which is the Ultimaker brand of TPU, then I guess you'll have to fiddle a bit with settings to find what works best with your Dremel. Take a look around <a href="https://community.ultimaker.com/" rel="nofollow noreferrer">Ultimaker's forums</a>, many users have other printers beyond their Ultimaker printers, you might be lucky and find some useful information. The 'search' feature of the forum works quite nicely.</p>
<p>Quick summary of the settings for TPU95A in Ultimaker Cura for a 2.85 mm Bowden setup:</p>
<ul>
<li>Layer Height: 0.2mm</li>
<li>Printing Temperature: 225°C</li>
<li>Print Speed: 25 mm/s</li>
<li>Cooling Fan Speed: 20%</li>
</ul>
<p>Depending on how the Dremel performs and the quality of your TPU, you might want to disable retractions, it's been known to help.</p>
| 1,156
|
<p>When using IE, you cannot put an absolutely positioned div over a select input element. That's because the select element is considered an ActiveX object and is on top of every HTML element in the page.</p>
<p>I already saw people hiding selects when opening a popup div, that leads to pretty bad user experience having controls disappearing.</p>
<p>FogBugz actually had a pretty smart solution (before v6) of turning every select into text boxes when a popup was displayed. This solved the bug and tricked the user eye but the behavior was not perfect.</p>
<p>Another solution is in FogBugz 6 where they no more use the select element and recoded it everywhere.</p>
<p>Last solution I currently use is messing up the IE rendering engine and force it to render the absolutely positioned <code><div></code> as an ActiveX element too, ensuring it can live over a select element. This is achieved by placing an invisible <code><iframe></code> inside the <code><div></code> and styling it with:</p>
<pre class="lang-css prettyprint-override"><code>#MyDiv iframe
{
position: absolute;
z-index: -1;
filter: mask();
border: 0;
margin: 0;
padding: 0;
top: 0;
left: 0;
width: 9999px;
height: 9999px;
overflow: hidden;
}
</code></pre>
<p>Does anyone have an even better solution than this one?</p>
<p>EDIT: The purpose of this question is as much informative as it is a real question. I find the <code><iframe></code> trick to be a good solution, but I am still looking for improvement like removing this <em>ugly useless tag</em> that degrades accessibility.</p>
|
<p>I don't know anything better than an Iframe</p>
<p>But it does occur to me that this could be added in JS by looking for a couple of variables </p>
<ol>
<li>IE 6</li>
<li>A high Z-Index (you tend to have to set a z-index if you are floating a div over)</li>
<li>A box element</li>
</ol>
<p>Then a script that looks for these items and just add an iframe layer would be a neat solution</p>
<p>Paul</p>
|
<p>I don't think there is. I've tried to solve this problem at my job. Hiding the select control was the best we could come up with (being a corporate shop with a captive audience, user experience doesn't usually factor into the PM's decisions). </p>
<p>From what I could gather online when looking for a solution, there's just no good solution to this. I like the FogBugz solution (the same thing done by a lot of high-profile sites, like Facebook), and this is actually what I use in my own projects.</p>
| 2,949
|
<p>I'm trying to set the group type for a new Active Directory Entry via VB.NET and DirectoryServices to create a distribution list.</p>
<p>How do I access the ADS_GROUP_TYPE enumerations?</p>
<p>Specifically I'm after ADS_GROUP_TYPE_GLOBAL_GROUP.</p>
|
<p>You're correct, you can't actually get access to the enumerations. </p>
<p>Just a wee nitpick, this constant doesn't need to be an object, you can make it an int32 -</p>
<p>Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2</p>
|
<p>I don't think I can access the enumerations via .NET so instead I created the specific constant I needed. For what it's worth here's my code:</p>
<blockquote>
<pre><code> Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2
adNewGroup.Properties("groupType").Value = ADS_GROUP_TYPE_GLOBAL_GROUP
</code></pre>
</blockquote>
<p>Refactoring welcome!</p>
| 3,098
|
<p>I have a Tevo Tornado that I've outfitted with an official BL-Touch auto level sensor. I can see the bed probing run, and I can see the Z axis slowly adjust during x/y moves, so it's doing <em>something</em>. However, you can see that there appears to be a systematic tilt:</p>
<p><a href="https://i.stack.imgur.com/sacY6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sacY6.jpg" alt="BL-Touch tilted bed plane"></a></p>
<p>Any ideas what could be causing this? The bed, gantry and print head is tight, no wobble. Here's my start code:</p>
<pre><code>G28 ; home all axes
G29
G1 Z5 F5000 ; lift nozzle
</code></pre>
<p>I have mesh leveling enabled with a 5x5 grid and correct probe offsets. The bed itself is on PETG printed standoffs instead of springs to eliminate any jitter.</p>
|
<p>The problem with the Tevo Tornado design is that the design is as such that the Z-axis is powered by a single stepper (under the assumption that you have not added a second Z stepper).</p>
<p>This means that the level relies on the rigidity of the X-axis assembly, more specific the play on the guide wheels. Apparently the BL-Touch level determination suffers (the up and down movement while probing) from this design as can be seen from the tilt around the Y-axis direction. This effect causing the tilted level plane is called <a href="https://en.wikipedia.org/wiki/Hysteresis" rel="nofollow noreferrer">hysteresis</a>. Now that the Z-axis moves up and down you experience much more problems than using a mechanical switch. The effect is more pronounced when the mass of the hot end carriage is furthest from the Z-axis lead screw.</p>
<p>Note that an extra stepper can also cause tilted level when the second stepper does not move in sync (e.g. missing steps). In such designs, a single stepper (geared) belt driven 2 lead screw has better performance in that respect.</p>
|
<p>I know this is incredibly old at this point, but in case anyone stumbles upon this post like I did, I wanted to point out that there is no semicolon behind your G29 code, so it's not being read properly</p>
| 1,316
|
<p>What is iPhone's browser tag and how iPhone optimized web site is different from a usual mobile web site?</p>
<p>Thanks!</p>
|
<p>Nettuts has a great introduction to web-developement for iPhone. You find it <a href="http://nettuts.com/misc/learn-how-to-develop-for-the-iphone/" rel="nofollow noreferrer">here</a></p>
<p>This is the specific code you asked for (taken from that article):</p>
<pre><code><!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"-->
<!--
place iPhone code in here
-->
<!--#else -->
<!--
place standard code to be used by non iphone browser.
-->
<!--#endif -->
</code></pre>
|
<p>Better Solution:</p>
<pre><code>*
(NSString *)flattenHTML:(NSString *)html {
NSScanner *theScanner; NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];
while ([theScanner isAtEnd] == NO) {
// find start of tag
[theScanner scanUpToString:@"<" intoString:NULL] ;
// find end of tag
[theScanner scanUpToString:@">" intoString:&text] ;
// replace the found tag with a space
//(you can filter multi-spaces out later if you wish)
html = [html stringByReplacingOccurrencesOfString:
[ NSString stringWithFormat:@"%@>", text]
withString:@" "];
} // while //
return html;
</code></pre>
<p>}</p>
| 7,579
|
<p>I need to diff two log files but ignore the time stamp part of each line (the first 12 characters to be exact). Is there a good tool, or a clever awk command, that could help me out?</p>
|
<p>Depending on the shell you are using, you can turn the approach <a href="https://stackoverflow.com/questions/44019/an-easy-way-to-diff-log-files-ignoring-the-time-stamps#44028">@Blair</a> suggested into a 1-liner</p>
<pre><code>diff <(cut -b13- file1) <(cut -b13- file2)
</code></pre>
<p>(+1 to <a href="https://stackoverflow.com/questions/44019/an-easy-way-to-diff-log-files-ignoring-the-time-stamps#44028">@Blair</a> for the original suggestion :-)</p>
|
<p>I want to propose a solution for Visual Studio Code:</p>
<ol>
<li>Install this extension - <a href="https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff" rel="nofollow noreferrer">https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff</a></li>
<li>Configure it like this - <a href="https://github.com/ryu1kn/vscode-partial-diff/issues/49#issuecomment-608299085" rel="nofollow noreferrer">https://github.com/ryu1kn/vscode-partial-diff/issues/49#issuecomment-608299085</a></li>
<li>Run extension command "Toggle Pre-Comparison Text Normalization Rules" and enable rule added on step #2</li>
<li>Use the extension (here is an explanation of it's UI quirk - <a href="https://github.com/ryu1kn/vscode-partial-diff/issues/11" rel="nofollow noreferrer">https://github.com/ryu1kn/vscode-partial-diff/issues/11</a>)</li>
</ol>
| 6,565
|
<p>What do you do if members of your team are not cooperative during scrum meetings?
They either provide a very high level definition of what they are currently working on, ("working on feature x"), or go into extremely irrelevant details, <strong>in spite of being well educated in SCRUM methodology</strong>.
This causes the scrum meeting to be ineffective and boring.</p>
<p>As a scrum master, what are your techniques to getting the best out of people during the meeting?</p>
<p>Edited to add:</p>
<p><strong>What technique do you use to stop someone who is talking too much, without being offensive?</strong></p>
<p><strong>What technique do you use to encourage someone to provide a more detailed answer?</strong></p>
<p><strong>How do you react when you find yourself being the only one who listens, while other team members just sit there and maybe even fall asleep?</strong></p>
|
<p>First of all... make sure folks are standing up... and not even leaning on the wall or a desk.</p>
<p>At a high level, I would say that, whenever you face issues on the team, the best response is to <em>ask the team</em> for solutions. However, here are some of the techniques I've used for the issues you're facing.</p>
<p><strong>Talks too much</strong> </p>
<ul>
<li>have him/her stand on one leg</li>
<li>have him/her hold the scrum "speaking" token in an outstretched hand while they speak.</li>
<li>Add a flip chart to the scrum to list tabled issues... when someone gets longwinded on a topic that is not scrum-meeting-worthy, interrupt and say "Hey - great point. I'm not sure everyone needs to discuss this, how 'bout if we park this for a follow-up discussion?" A key to making this successful is to actually follow-up afterwards and get the side conversation scheduled. Alternatively, the speaker may just say "Not necessary... I'll be working with Joe this afternoon on this" or something like that, which accomplishes the goal of reducing the windedness without the need to schedule the follow-up.</li>
</ul>
<p><strong>Need more detail</strong>. Is this for the scrum master's benefit or the team's? </p>
<ul>
<li>wait until afterwards to ask the individual more detailed questions. If you think the team also needs to know them, coach the team member by conveying (in your after-scrum questioning) that "this is the sort of thing that I think Joe Smith would be helped in hearing from you, what do you think?"</li>
</ul>
<p><strong>Team doesn't listen</strong>. </p>
<ul>
<li>Ask them on an individual basis. "Sally, I noticed that you don't seem to be getting much out of the Scrum. How can we adjust it to make it valuable for you?".</li>
<li>Post questions to others during the scrum. Like if Sally says "I integrated with Bob's code yesterday", ask Bob "how'd that go?" (I'd use this sparingly... to guard against scrums taking too long).</li>
<li>I've found that sometimes team members tend towards old habits by looking at the scrum master or project manager when they speak. When this happens alot, I alter my gaze to look away, which almost forces the speaker to gain eye contact with other members of the team, which may help the other members of the team to pay attention.</li>
</ul>
|
<p>Ask for the specific details you need. People won't be aware of stuff you are interested in.</p>
<p>Also try to put forth some guidelines for better and effective presentation before the meeting.</p>
| 9,647
|
<p>I've just come across this in a WHERE clause:</p>
<pre><code>AND NOT (t.id = @id)
</code></pre>
<p>How does this compare with:</p>
<pre><code>AND t.id != @id
</code></pre>
<p>Or with:</p>
<pre><code>AND t.id <> @id
</code></pre>
<p>I'd always write the latter myself, but clearly someone else thinks differently. Is one going to perform any better than the other? I know that using <code><></code> or <code>!=</code> is going to bust any hopes for using an index that I might have had, but <em>surely</em> the first approach above will suffer the same problem?</p>
|
<p>These 3 will get the same exact execution plan</p>
<pre><code>declare @id varchar(40)
select @id = '172-32-1176'
select * from authors
where au_id <> @id
select * from authors
where au_id != @id
select * from authors
where not (au_id = @id)
</code></pre>
<p>It will also depend on the selectivity of the index itself of course. I always use au_id <> @id myself</p>
|
<p>There will be no performance hit, both statements are perfectly equal.</p>
<p>HTH</p>
| 2,944
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.