instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes...</p>
<p>I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that URL.</p>
<p>I know that I could make a page and keep it on my local machine and just refer to it that way, but I was just wondering if you could bypass that step and actually have the "location" of the bookmark really just be javascript. I could have sworn that this was possible years ago, but I can't find anything that tells me either way now.</p>
|
<p>What you want is a <a href="http://en.wikipedia.org/wiki/Bookmarklet" rel="noreferrer">bookmarklet</a> they are easy to create and should work in most major browsers.</p>
<p>Edit: Stack overflow seems not to allow creating bookmarklets in the context of the site, basically you can create a new bookmark and type the following in the location field</p>
<pre>javascript:window.location='http://www.google.com/search?q='+Date()</pre>
<p>to get a bookmarklet that searches google for the current date.</p>
|
<p>Well, I just created a bookmark in FF3, went back and updated it and added the following test:</p>
<pre><code>javascript:alert('Wacky%20test%20yo');
</code></pre>
<p>Low and behold, after I saved and loaded, I was able to get my alert.</p>
<p>I'm sure you can work up something similar for your needs.</p>
| 3,057
|
<p>After reading <a href="https://stackoverflow.com/questions/63668/confessions-of-your-worst-wtf-moment-what-not-to-do#63730">this answer</a>, I wonder if there's a way to get a "testing" credit card number. One that you can experiment with but that doesn't actually charge anything.</p>
|
<pre><code>MasterCard: 5431111111111111
Amex: 341111111111111
Discover: 6011601160116611
American Express (15 digits) 378282246310005
American Express (15 digits) 371449635398431
American Express Corporate (15 digits) 378734493671000
Diners Club (14 digits) 30569309025904
Diners Club (14 digits) 38520000023237
Discover (16 digits) 6011111111111117
Discover (16 digits) 6011000990139424
JCB (16 digits) 3530111333300000
JCB (16 digits) 3566002020360505
MasterCard (16 digits) 5555555555554444
MasterCard (16 digits) 5105105105105100
Visa (16 digits) 4111111111111111
Visa (16 digits) 4012888888881881
Visa (13 digits) 4222222222222
</code></pre>
<p><strong>Credit Card Prefix Numbers:</strong> </p>
<pre><code>Visa: 13 or 16 numbers starting with 4
MasterCard: 16 numbers starting with 5
Discover: 16 numbers starting with 6011
AMEX: 15 numbers starting with 34 or 37
</code></pre>
|
<p>Most payment processors provide either a testing number (PayPal does this) or the ability to go into testing mode (in which no transactions actually get processed). Consult the documentation.</p>
| 9,242
|
<p>I am going to be using C/C++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one?</p>
|
<p><a href="http://tangentsoft.net/mysql++/" rel="nofollow noreferrer">MySQL++</a></p>
|
<p>That depends a bit on what you want to do.</p>
<p>First, check out libraries that provide connectivity to more than on DBMS platform. For example, Qt makes it very easy to connect to MySQL, MS SQL Server and a bunch of others, and change the database driver (connection type) at runtime - with just a few lines of code.</p>
<p>MySQL-specific libraries are fine, but bear in mind that you are locking yourself down to one DB implementation - if you ever need to change in the future it's gonna be a whole lot of work - even if you design your code such that the DB-specific stuff is behind a facade. Why not use a library that provides connectivity to multiple platforms, and save yourself the trouble?</p>
| 4,291
|
<p>I have a library I created,</p>
<h3>File <em>mylib.c:</em></h3>
<pre><code>#include <mylib.h>
int
testlib() {
printf("Hello, World!\n");
return (0);
}
</code></pre>
<h3>File <em>mylib.h:</em></h3>
<pre><code>#include <stdio.h>
extern int testlib();
</code></pre>
<p>In my program, I've attempted to call this library function:</p>
<h3>File <em>myprogram.c</em>:</h3>
<pre><code>#include <mylib.h>
int
main (int argc, char *argv[]) {
testlib();
return (0);
}
</code></pre>
<p>When I attempt to compile this program I get the following error:</p>
<pre>In file included from myprogram.c:1
mylib.h:2 warning: function declaration isn't a prototype</pre>
<p>I'm using: <code>gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)</code></p>
<p>What is the proper way to declare a function prototype?</p>
|
<p>In C <code>int foo()</code> and <code>int foo(void)</code> are different functions. <code>int foo()</code> accepts an arbitrary number of arguments, while <code>int foo(void)</code> accepts 0 arguments. In C++ they mean the same thing. I suggest that you use <code>void</code> consistently when you mean no arguments.</p>
<p>If you have a variable <code>a</code>, <code>extern int a;</code> is a way to tell the compiler that <code>a</code> is a symbol that might be present in a different translation unit (C compiler speak for source file), don't resolve it until link time. On the other hand, symbols which are function names are anyway resolved at link time. The meaning of a storage class specifier on a function (<code>extern</code>, <code>static</code>) only affects its visibility and <code>extern</code> is the default, so <code>extern</code> is actually unnecessary.</p>
<p>I suggest removing the <code>extern</code>, it is extraneous and is usually omitted. </p>
|
<p>Try:</p>
<pre><code>extern int testlib(void);
</code></pre>
| 6,351
|
<p>I'm using two different libraries in my project, and both of them supply a basic rectangle <code>struct</code>. The problem with this is that there seems to be no way to insert a conversion between the types, so I can't call a function in one library with the result from a function in the other. If I was the author of either of these, I could create conversions, from the outside, I can't.</p>
<p>library a:</p>
<pre><code>typedef struct rectangle { sint16 x; sint16 y; uint16 w; uint16 h; } rectangle;
</code></pre>
<p>library b:</p>
<pre><code>class Rect {
int x; int y; int width; int height;
/* ... */
};
</code></pre>
<p>Now, I can't make a converter <code>class</code>, because C++ will only look for a conversion in one step. This is probably a good thing, because there would be a lot of possibilities involving creating new objects of all kinds of types.</p>
<p>I can't make an operator that takes the <code>struct</code> from <code>a</code> and supplies an object of the <code>class</code> from <code>b</code>:</p>
<pre>foo.cpp:123 error: ‘operator b::Rect(const rectangle&)’ must be a nonstatic member function</pre>
<p>So, is there a sensible way around this?</p>
<h2>edit:</h2>
<p>I should perhaps also point out that I'd really like some solution that makes working with the result seamless, since I don't expect to be that coder. (Though I agree, old-school, explicit, conversion would have been a good choice. The other branch, <a href="http://en.cppreference.com/w/cpp/language/reinterpret_cast" rel="nofollow noreferrer"><code>reinterpret_cast</code></a> has the same problem..)</p>
<h2>edit2:</h2>
<p>Actually, none of the suggestions really answer my actual question, <a href="https://stackoverflow.com/users/1968/konrad-rudolph">Konrad Rudolph</a> seems to be correct. C++ actually can't do this. Sucks, but true. (If it makes any difference, I'm going to try subclassing as suggested by <a href="https://stackoverflow.com/users/90/codingthewheel">CodingTheWheel</a>.</p>
|
<p>If you can't modify the structures then you have no alternative to writing a manual conversion function because overloading conversion operators only works within the class body. There's no other way.</p>
|
<p>Maybe you could try it with operator overloading ? (Maybe a = operator which is not a method of your class) ?</p>
<p>Rect operator= (const Rect&,const rectangle&)</p>
<p>More about this in the C++ programming language by Bjarne Stroustrup or maybe on this page: <a href="http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html" rel="nofollow noreferrer">http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html</a></p>
| 4,786
|
<p>In C# documentation tags allow you to produce output similar to MSDN. What are a list of allowable tags for use inside the /// (triple slash) comment area above classes, methods, and properties?</p>
|
<p>Check out <a href="http://web.archive.org/web/20100118163744/http://thoughtpad.net/alan-dean/cs-xml-documentation.html" rel="noreferrer">Great documentation on the various C# XML documentation tags.</a> (Go to the bottom to see the tags)</p>
|
<p>Look inside the docs for <a href="http://blogs.msdn.com/sandcastle/" rel="nofollow noreferrer">Sandcastle</a>. This is the new documentation standard for .NET.</p>
| 9,160
|
<p>How do I tell Subversion (svn) to treat a file as a binary file?</p>
|
<p>It is possible to manually identify a file located within a repository as <em>binary</em> by using:</p>
<pre><code>svn propset svn:mime-type application/octet-stream <filename>
</code></pre>
<p>This is generally not necessary, as Subversion will attempt to determine whether a file is binary when the file is first added. If Subversion is incorrectly tagging a certain type as "text" when it should be treated as binary, it is possible to configure Subversion's <a href="http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.auto" rel="noreferrer">auto-props feature</a> to automatically tag that file with a non-text MIME type. Regardless of the properties configured on the file, Subversion still stores the file in a binary format within the repository.</p>
<p>If Subversion identifies the MIME type as a "text" type, it enables certain features which are not available on binary files, such as <em>svn diff</em> and <em>svn blame</em>. It also allows for automatic line ending conversion, which is configurable on a client-by-client basis.</p>
<p>For more information, see <a href="http://subversion.apache.org/faq.html#binary-files" rel="noreferrer">How does Subversion handle binary files?</a></p>
|
<p>It usually does this by default for you, but if it isn't you need to look into file properties and propset. </p>
| 9,950
|
<p>We've got a page with a ton of jQuery (approximately 2000 lines) that we want to trim down b/c it is a maintenance nightmare, and it might be easier to maintain on the server. We've thought about using UpdatePanel for this. However, we don't like the fact that the UpdatePanel is sending the whole page back to the server. </p>
|
<p>Don't move to UpdatePanels. After coming from jQuery, <a href="http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/" rel="noreferrer">the drop in performance</a> would be untenable. Especially on a page as complex as yours sounds.</p>
<p>If you have 2,000 lines of JavaScript code, the solution is to refactor that code. If you put 2,000 lines of C# code in one file, it would be difficult to maintain too. That would be difficult to manage effectively with <strong>any</strong> language or tool.</p>
<p>If you're using 3.5 SP1, you can use the ScriptManager's new script combining to separate your JavaScript into multiple files with no penalty. That way, you can logically partition your code just as you would with server side code.</p>
|
<p>Using UpdatePanel force you to use ScriptManager that added tons of scripts in your webpages.
UpdatePanel provides you partial postback and not real ajax.
If your will run only on a LAN and not internet that's ok, but if your target is internet try refractoring your codes and compress them with some tools before publish on the website</p>
| 4,249
|
<p>So basically I'm building an app for my company and it NEEDS to be built using MS Access and it needs to be built on SQL Server.</p>
<p>I've drawn up most of the plans but am having a hard time figuring out a way to handle the auditing system.</p>
<p>Since it is being used internally only and you won't even be able to touch the db from outside the building we are not using a login system as the program will only be used once a user has already logged in to our internal network via Active Directory. Knowing this, we're using <a href="https://stackoverflow.com/questions/9052/is-there-a-way-for-ms-access-to-grab-the-current-active-directory-user">a system to detect automatically the name of the Active Directory user</a> and with their permissions in one of the DB tables, deciding what they can or cannot do.</p>
<p>So the actual audit table will have 3 columns (this design may change but for this question it doesn't matter); who (Active Directory User), when (time of addition/deletion/edit), what (what was changed)</p>
<p>My question is how should I be handling this. Ideally I know I should be using a trigger so that it is impossible for the database to be updated without an audit being logged, however I don't know how I could grab the Active Directory User that way. An alternate would be to code it directly into the Access source so that whenever something changes I run an INSERT statement. Obviously that is flawed because if something happens to Access or the database is touched by something else then it will not log the audit.</p>
<p>Any advice, examples or articles that may help me would be greatly appreciated!</p>
|
<p>Does this work for you?</p>
<pre><code>
select user_name(),suser_sname()
</code></pre>
<hr>
<p>Doh! I forgot to escape my code.</p>
|
<p>How many users of the app will there be? Is there possibility of using windows integrated authentication for SQL authentication?</p>
<p><strong>Updated</strong>: If you can give each user a SQL login (windows integrated) then you can pickup the logged on user using the SYSTEM_USER function. </p>
| 3,371
|
<p>I have string like this</p>
<pre><code> /c SomeText\MoreText "Some Text\More Text\Lol" SomeText
</code></pre>
<p>I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design.</p>
<p>This is in C# btw.</p>
<p><strong>EDIT:</strong> My ugly version, while ugly, is O(N) and may actually be faster than using a RegEx.</p>
<pre><code>private string[] tokenize(string input)
{
string[] tokens = input.Split(' ');
List<String> output = new List<String>();
for (int i = 0; i < tokens.Length; i++)
{
if (tokens[i].StartsWith("\""))
{
string temp = tokens[i];
int k = 0;
for (k = i + 1; k < tokens.Length; k++)
{
if (tokens[k].EndsWith("\""))
{
temp += " " + tokens[k];
break;
}
else
{
temp += " " + tokens[k];
}
}
output.Add(temp);
i = k + 1;
}
else
{
output.Add(tokens[i]);
}
}
return output.ToArray();
}
</code></pre>
|
<p>The computer term for what you're doing is <a href="http://en.wikipedia.org/wiki/Lexical_analysis" rel="nofollow noreferrer">lexical analysis</a>; read that for a good summary of this common task.</p>
<p>Based on your example, I'm guessing that you want whitespace to separate your words, but stuff in quotation marks should be treated as a "word" without the quotes.</p>
<p>The simplest way to do this is to define a word as a regular expression:</p>
<pre><code>([^"^\s]+)\s*|"([^"]+)"\s*
</code></pre>
<p>This expression states that a "word" is either (1) non-quote, non-whitespace text surrounded by whitespace, or (2) non-quote text surrounded by quotes (followed by some whitespace). Note the use of capturing parentheses to highlight the desired text.</p>
<p>Armed with that regex, your algorithm is simple: search your text for the next "word" as defined by the capturing parentheses, and return it. Repeat that until you run out of "words".</p>
<p>Here's the simplest bit of working code I could come up with, in VB.NET. Note that we have to check <em>both</em> groups for data since there are two sets of capturing parentheses.</p>
<pre><code>Dim token As String
Dim r As Regex = New Regex("([^""^\s]+)\s*|""([^""]+)""\s*")
Dim m As Match = r.Match("this is a ""test string""")
While m.Success
token = m.Groups(1).ToString
If token.length = 0 And m.Groups.Count > 1 Then
token = m.Groups(2).ToString
End If
m = m.NextMatch
End While
</code></pre>
<p>Note 1: <a href="https://stackoverflow.com/users/1228/will">Will's</a> answer, above, is the same idea as this one. Hopefully this answer explains the details behind the scene a little better :)</p>
|
<p><a href="https://stackoverflow.com/questions/54866/best-way-to-parse-space-seperated-text#54880">Craig</a> is right — use regular expressions. <a href="http://msdn.microsoft.com/en-us/library/8yttk7sy.aspx" rel="nofollow noreferrer">Regex.Split</a> may be more concise for your needs.</p>
| 7,851
|
<p>I am writing some software to identify tracking numbers (in the same way that Google identifies FedEx or UPS numbers when you search for them). Most couriers use a system, such as a "weighted average mod system" which can be used to identify if a number is a valid tracking number. Does anyone know if TNT consignment numbers use such a system, and if so, what it is? I have asked TNT support, and the rep told me they do not... but I'd like to doublecheck.</p>
|
<p>OK, so it's three months since you asked but I stumbled across this as I'm writing a similar piece of software. As far as we know TNT uses the <a href="http://en.wikipedia.org/wiki/S10_(UPU_standard)" rel="nofollow noreferrer">S10</a> tracking number system. Which means that their numbers will be of the type AA#########AA. With the last two letters corresponding to a ISO/IATA country code. Having said that TNT uses WW which we believe must stand for worldwide. This is not quite an answer, at least it's not about checksums or algorithms, but it might be useful? Hope that helps</p>
<p>Willow</p>
|
<p>As far as I can tell, there isn't one. Sorry.</p>
<p>I take it you're trying to validate the tracking number entered to make sure it was entered properly?</p>
<p>-- Kevin Fairchild</p>
| 8,124
|
<p>What are some real world places that call for delegates? I'm curious what situations or patterns are present where this method is the best solution. No code required.</p>
|
<p>As stated in <a href="http://msdn.microsoft.com/en-us/library/orm-9780596521066-01-17.aspx" rel="noreferrer">"Learning C# 3.0: Master the fundamentals of C# 3.0"</a></p>
<blockquote>
<p><strong>General Scenario:</strong> When a head of state dies, the President of the United States typically does not have time to attend the funeral
personally. Instead, he dispatches a delegate. Often this delegate is
the Vice President, but sometimes the VP is unavailable and the
President must send someone else, such as the Secretary of State or
even the First Lady. He does not want to “hardwire” his delegated
authority to a single person; he might delegate this responsibility to
anyone who is able to execute the correct international protocol.</p>
<p>The President defines in advance what responsibility will be delegated
(attend the funeral), what parameters will be passed (condolences,
kind words), and what value he hopes to get back (good will). He then
assigns a particular person to that delegated responsibility at
“runtime” as the course of his presidency progresses.</p>
<p><strong>In programming Scenario:</strong> You are often faced with situations where you need to execute a particular action, but you don’t know in
advance which method, or even which object, you’ll want to call upon
to execute it.</p>
<p><strong>For Example:</strong> A button might not know which object or objects need to be notified. Rather than wiring the button to a particular
object, you will connect the button to a delegate and then resolve
that delegate to a particular method when the program executes.</p>
</blockquote>
|
<p>A quick google search came up with this <a href="http://en.wikipedia.org/wiki/Delegation_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Delegation_pattern</a> . Basically, anytime that you use an object that forwards it's calls to another object then you are delegating.</p>
| 5,145
|
<p>Is there a terminal program that shows the difference between input, standard output, error output, the prompt, and user-entered commands? It should also show when standard input is needed vs. running a command.</p>
<p>One way would be to highlight each differently. The cursor could change color depending on if it was waiting for a command, running a command, or waiting for standard input.</p>
<p>Another way would be to have 3 frames -- a large frame on the top for output (including prompt and commands running), a small frame near the bottom for standard input, and an one-line frame at the bottom for command line input. That would possibly even allow running another command to provide input while the previous command is still waiting for standard input.</p>
<p>From <a href="http://jamesjava.blogspot.com/2007/09/terminal-window-with-3-frames.html" rel="nofollow noreferrer">http://jamesjava.blogspot.com/2007/09/terminal-window-with-3-frames.html</a></p>
|
<p><a href="http://hotwire-shell.org/" rel="nofollow noreferrer">Hotwire</a> could be a good candidate, but it's not doing that out of the box, AFAIK</p>
|
<p>For now it appears that there is no such program.</p>
| 9,036
|
<p>After my web form is submitted, a regex will be applied to user input on the server side (via PHP). I'd like to have the identical regex running in real-time on the client side to show the user what the real input will be. This will be pretty much the same as the Preview section on the Ask Question pages on Stack Overflow except with PHP on the back-end instead of .NET.</p>
<p>What do I need to keep in mind in order to have my PHP and JavaScript regular expressions act exactly the same as each other?</p>
|
<p>Hehe this was sort of asked moments ago and Jeff pointed out:<br>
<a href="http://www.regular-expressions.info/refflavors.html" rel="noreferrer">http://www.regular-expressions.info/refflavors.html</a>.</p>
<p>There is a comparison of regular expression capabilities across tools and languages.</p>
|
<p>Both JavaScript's regex and PHP's preg_match are based on Perl, so there shouldn't be any porting problems. Do note, however, that Javascript only supports a subset of modifiers that Perl supports.</p>
<p>For more info for comparing the two:</p>
<ul>
<li><a href="http://www.regular-expressions.info/javascript.html" rel="nofollow noreferrer">Javascript Regular Expressions</a></li>
<li><a href="http://www.regular-expressions.info/php.html" rel="nofollow noreferrer">PHP Regular Expressions</a></li>
</ul>
<p>As for delivery method, I'd suggest you'd use <a href="http://json.org/" rel="nofollow noreferrer">JSON</a>, the slimmest data interchange format as of date (AFAIK) and directly translatable to a JavaScript object through eval(). Just put that bad boy through an <a href="http://en.wikipedia.org/wiki/Ajax_(programming)" rel="nofollow noreferrer">AJAX</a> session and you should be set to go.</p>
<p>I hope this helps :)</p>
| 4,999
|
<p>What algorithm taught you the most about programming or a specific language feature?</p>
<p>We have all had those moments where all of a sudden we know, just know, we have learned an important lesson for the future based on finally understanding an algorithm written by a programmer a couple of steps up the evolutionary ladder. Whose ideas and code had the magic touch on you?</p>
|
<p>"To iterate is human, to recurse divine" - quoted in 1989 at college. </p>
<p>P.S. Posted by Woodgnome while waiting for invite to join</p>
|
<p>For me, the simple swap in Kelly & Pohl's <em>A Book on C</em> to demonstrate call-by-reference flipped me out when I first saw it. I looked at that, and pointers snapped into place. Verbatim. . .</p>
<pre><code>void swap(int *p, int *q)
{
int temp;
temp = *p;
*p = *q;
*q = temp;
}
</code></pre>
| 4,587
|
<p>I've got an Anycubic Predator (aka Anycubic D). I followed the official instructions and leveled my printer. </p>
<p>The first annoying problem I ran into is that after the auto-leveling, the level test printing shows that the printer wasn't leveled at all. I tried about 4-5 times, and finally leveled the printer (I thought I just got lucky).</p>
<p>The second problem that isn't solved is that the prints I get are of poor quality. Shown in <em>figure 1</em> and <em>figure 2</em>. The cube should be 20x20x20 mm, but what I got here is 19.6(x) x 20.4(y) x 20.5(z) mm.</p>
<p><a href="https://i.stack.imgur.com/xeclv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xeclv.jpg" alt="fig1"></a>
<em>Figure 1 - X-Y (side) view of calibration square</em></p>
<p><a href="https://i.stack.imgur.com/4YkU0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YkU0.jpg" alt="fig2"></a>
<em>Figure 2 - Z (top) view of calibration square</em></p>
<p>Does anyone have any idea about how to improve the printer's printing quality? Thanks in advance.</p>
|
<p>A wide line works if there is something below it to squeeze the filament against, but if you don't have a full layer below it, it will stay thinner and it will droop. I would not use extreme ratios on overhangs. Still, do a parametric test: a overhang tower (a compact one) at different line widths and layer heights. If you test 3 layer heights and 3 line widths, it's only 9 short prints.</p>
<p>However, as you can see in filament reviews, different materials behave differently. I think there is no <em>a priori</em> optimal value.</p>
|
<p>In terms of Cura's model for showing overhangs, I'm nearly sure it's just the ratio - rise over run, or rather run over rise. And indeed that's what makes sense mathematically:</p>
<p>At least some portion of the wall extrusion in layer N+1 needs to sit on top of the corresponding wall extrusion in layer N. For a given 3D surface slope, the "run" - the distance the cross-section moves from one layer to the next, which needs to be bounded by some fraction of the line width - varies proportionally to the "rise" - the layer height.</p>
| 1,664
|
<p>By default each row of a Gridview maps to each row in a datatable or dataset attached to its datasource. But what if I want to display these rows in multiple columns. For example if it has 10 rows, 5 rows each should be displayed in 2 columns side by side. Also can I do this with the Infragistics grid. Is this possible?</p>
|
<p>You can use a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.aspx" rel="noreferrer"><code>DataList</code></a> control instead. It has a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.repeatcolumns.aspx" rel="noreferrer"><code>RepeatColumns</code></a> property that you can define the number of columns you want to display.</p>
<p>In .NET Framework 3.5, there is an even better solution, the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview" rel="noreferrer"><code>ListView</code></a> control. You can find further information about how to use the ListView control <a href="http://msdn.microsoft.com/en-us/library/bb398790.aspx" rel="noreferrer">here</a>.</p>
|
<p>Can't you just put two identical bound columns one after the other?</p>
| 4,019
|
<p>Syntax aside, what is the difference between</p>
<pre><code>try {
}
catch() {
}
finally {
x = 3;
}
</code></pre>
<p>and </p>
<pre><code>try {
}
catch() {
}
x = 3;
</code></pre>
<p>edit: in .NET 2.0?</p>
<hr>
<p>so</p>
<pre><code>try {
throw something maybe
x = 3
}
catch (...) {
x = 3
}
</code></pre>
<p>is behaviourally equivalent?</p>
|
<p>Depends on the language as there might be some slight semantic differences, but the idea is that it will execute (almost) always, even if the code in the try block threw an exception.</p>
<p>In the second example, if the code in the catch block returns or quits, the x = 3 will not be executed. In the first it will.</p>
<p>In the .NET platform, in some cases the execution of the finally block won't occur:
Security Exceptions, Thread suspensions, Computer shut down :), etc.</p>
|
<p>So you can clean up any open connections, etc. initialized in the try block. If you opened a connection and then an exception occurred, that exception would not be properly closed. This type of scenario is what the finally block is for.</p>
| 7,343
|
<p>I have ASP.NET web pages for which I want to build automated tests (using WatiN & MBUnit). How do I start the ASP.Net Development Server from my code? I do not want to use IIS.</p>
|
<p>From what I know, you can fire up the dev server from the command prompt with the following path/syntax:</p>
<pre><code>C:\Windows\Microsoft.NET\Framework\v2.0.50727\Webdev.WebServer.exe /port:[PORT NUMBER] /path: [PATH TO ROOT]
</code></pre>
<p>...so I could imagine you could easily use Process.Start() to launch the particulars you need through some code.</p>
<p>Naturally you'll want to adjust that version number to whatever is most recent/desired for you.</p>
|
<p>You can easily use <strong>Process Explorer</strong> to find complete command line options needed for manually start it.
Start Process Explorer while debugging your website. For VS2012, expand 'devenv.exe' node. Right-click on 'WebDev.WebServer20.exe' and from there you can see Path and Command Line values.</p>
| 8,129
|
<p>How do you capture the mouse events, move and click over top of a Shockwave Director Object (not flash) in Firefox, via JavaScript. The code works in IE but not in FF. </p>
<p>The script works on the document body of both IE and Moz, but mouse events do not fire when mouse is over a shockwave director object embed.</p>
<p>Update: </p>
<pre><code> function displaycoordIE(){
window.status=event.clientX+" : " + event.clientY;
}
function displaycoordNS(e){
window.status=e.clientX+" : " + e.clientY;
}
function displaycoordMoz(e)
{
window.alert(e.clientX+" : " + e.clientY);
}
document.onmousemove = displaycoordIE;
document.onmousemove = displaycoordNS;
document.onclick = displaycoordMoz;
</code></pre>
<hr>
<p>Just a side note, I have also tried using an addEventListener to "mousemove".</p>
|
<p>You could also catch the mouse event within Director (That never fails) and then call your JS functions from there, using gotoNetPage "javascript:function('" & argument & "')"</p>
<p>ej:</p>
<pre><code>on mouseDown me
gotoNetPage "javascript:function('" & argument & "')"
end
</code></pre>
<p>The mouse move detection is a little bit trickier, as there is no such an event in lingo, but you can use:</p>
<pre><code>property pMouseLock
on beginsprite
pMouseLock = _mouse.mouseLock
end
on exitFrame
if _mouse.mouseLock <> pMouseLock then
gotoNetPage "javascript:function('" & argument & "')"
pMouseLock = _mouse.mouseLock
end if
end
</code></pre>
<p>regards</p>
|
<p>Just an idea.</p>
<p>Try overlaying the shockwave object with a div with opacity 0, then you can capture events on the div itself.</p>
| 7,341
|
<p>The default shell in Mac OS X is <code>bash</code>, which I'm generally happy to be using. I just take it for granted. It would be really nice if it auto-completed <em>more stuff</em>, though, and I've heard good things about <code>zsh</code> in this regard. But I don't really have the inclination to spend hours fiddling with settings to improve my command line usage by a tiny amount, since my life on the command line isn't that bad. </p>
<p>(As I understand it, <code>bash</code> can also be configured to auto-complete more cleverly. It's the configuring I'm not all that keen on.)</p>
<p>Will switching to <code>zsh</code>, even in a small number cases, make my life easier? Or is it only a better shell if you put in the time to learn <em>why</em> it's better? (Examples would be nice, too <code>:)</code> )</p>
<hr>
<p>@<a href="https://stackoverflow.com/questions/43321/worth-switching-to-zsh-for-casual-use#43340">Rodney Amato</a>
&
@<a href="https://stackoverflow.com/questions/43321/worth-switching-to-zsh-for-casual-use#43338">Vulcan Eager</a>
give two good reasons to respectively stick to <code>bash</code> and switch to <code>zsh</code>. Looks like I'll have to investigate both! Oh well <code>:)</code></p>
<p>Is there anyone with an opinion from both sides of the argument?</p>
|
<p>For casual use you are probably better off sticking with bash and just installing bash completion. </p>
<p>Installing it is pretty easy, grab the bash-completion-20060301.tar.gz from <a href="http://www.caliban.org/bash/index.shtml#completion" rel="noreferrer">http://www.caliban.org/bash/index.shtml#completion</a> and extract it with </p>
<pre><code>tar -xzvf bash-completion-20060301.tar.gz
</code></pre>
<p>then copy the bash_completion/bash_completion file to /etc with </p>
<pre><code>sudo cp bash_completion/bash_completion /etc
</code></pre>
<p>which will prompt you for your password. You probably will want to make a /etc/bash_completion.d directory for any additional completion scripts (for instance I have the git completion script in there).</p>
<p>Once this is done the last step is to make sure the .bash_profile file in your home directory has </p>
<pre><code>if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
</code></pre>
<p>in it to load the completion file when you login. </p>
<p>To test it just open a new terminal, and try completing on cvs and it should show you the cvs options in the list of completions.</p>
|
<p>Staale is talking about a wizard like program (CUI) which autoruns the first time you run zsh. Just answer some questions, view/change the defaults and its configured for you.</p>
<p>IBM developerWorks has great resources on zsh.</p>
<p>I have not used very advanced features and so far I have not come across serious differences which should hamper someone coming from bash.</p>
<p>Some examples:</p>
<ul>
<li><p>!?pattern<Tab> will autocomplete to
the last command in history matching
pattern. Very useful.</p></li>
<li><p>You can configure a prompt on the
RHS. One use is to keep a fixed
width prompt on the left hand side
so all commands line up nicely while
displaying the pwd (or anything of
variable width) as the right hand
side prompt.</p></li>
<li><p>You can redirect input from multiple files (yet to try this): cat < file1 < file2 < file3 </p></li>
</ul>
| 6,493
|
<p>We have several wizard style form applications on our website where we capture information from the user on each page and then submit to a backend process using a web service.</p>
<p>Unfortunately we can't submit the information in chunks during each form submission so we have to store it the users session until the end of the process and submit it all at the same time.</p>
<p>Is the amount of server memory/sql server disk space the only constraint on how much I can store in users sessions or is there something else I need to consider?</p>
<p>Edit: The site is built on ASP.NET web forms.</p>
|
<p>Assuming the information is not sensitive then you could store the information in a cookie which would reduce the amount of information required to be stored server side. This would also allow you to access the information via JavaScript. </p>
<p>Alternatively you could use the viewstate to store the information although this can lead to large amounts of data being sent between the server and the client and not my preferred solution.</p>
<p>The amount of session information you should store varies wildly depending on the application, number of expected users, server specification etc. To give a more accurate answer would require more information :)</p>
<p>Finally, assuming that the information collected throughout the process is not required from page to page then you could store all the information in a database table and only store the records unique id in the session. As each page is submitted the db record is updated and then on the final page all the information is retrieved and submitted. This is not an idea solution if you need to retrieve previous information on each subsequent page due to the number of db reads required.</p>
|
<p>If you use a traditional HTTP model (i.e. don't use runat="server") you can post the data to another asp page and place the posted data into hidden form elements, you can do this for however many pages you need thus avoiding placing anything in a session variable. </p>
| 9,863
|
<p>I'm coming from the open source world, and interested in giving ASP.NET a spin. But I'm having a little trouble separating the tools from the platform itself in regards to the licensing. I've downloaded Visual Web Developer 2008 Express, but not sure how different this is from one of the full-featured Visual Studio licenses -- and whether or not my Express license will prevent me from using all the features of ASP.NET.</p>
<p>Is a Visual Studio license just an IDE, or does it include pieces of .NET not available to the Express license? What about the other tools like IIS and SQL Server?</p>
<p>Thanks.</p>
|
<p>All of .net is available in the .net SDK, so in theory you will not need Visual Studio at all.</p>
<p>Now, there are some things that Express will not do. For example, the Database Designer is not very comprehensive and adding different remote databases is not or only very hardly possible. Still, in code you can connect to everything.</p>
<p>There is also no Remote Debugger, no support for creating Setup Files (well, that does not apply to ASP.net anyway), no real Publish Web Site Feature (although that can be <a href="https://web.archive.org/web/20150930210630/http://blogs.msdn.com:80/b/jamesche/archive/2007/09/27/automating-aspnet-compiler-in-visual-web-developer.aspx" rel="nofollow noreferrer">added manually</a> as it's just a Frontend for a SDK tool), no integrated Unit testing (and Microsoft <a href="https://weblogs.asp.net/nunitaddin/microsoft-vs-testdriven-net-express" rel="nofollow noreferrer">loves to threaten people</a> who add it), etc.</p>
<p>For a full comparison, see here:</p>
<p><a href="https://web.archive.org/web/20090118182937/http://msdn.microsoft.com:80/en-us/vstudio/products/cc149003.aspx" rel="nofollow noreferrer">Visual Studio 2008 Editions</a></p>
<p>But as said: Functionality of .net is all in the SDK, Visual Studio is just making it a bit easier to work with.</p>
|
<p>Visual Studio is just the IDE. You could theoretically create every file in Notepad and compile manually with just the .net framework.</p>
<p>IIS is an operating system feature, and SQL Server has different flavors with different capabilites.</p>
| 7,572
|
<p>How do you iterate through every file/directory recursively in standard C++?</p>
|
<p>In standard C++, technically there is no way to do this since standard C++ has no conception of directories. If you want to expand your net a little bit, you might like to look at using <a href="http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/index.htm" rel="noreferrer">Boost.FileSystem</a>. This has been accepted for inclusion in TR2, so this gives you the best chance of keeping your implementation as close as possible to the standard.</p>
<p>An example, taken straight from the website:</p>
<pre><code>bool find_file( const path & dir_path, // in this directory,
const std::string & file_name, // search for this name,
path & path_found ) // placing path here if found
{
if ( !exists( dir_path ) ) return false;
directory_iterator end_itr; // default construction yields past-the-end
for ( directory_iterator itr( dir_path );
itr != end_itr;
++itr )
{
if ( is_directory(itr->status()) )
{
if ( find_file( itr->path(), file_name, path_found ) ) return true;
}
else if ( itr->leaf() == file_name ) // see below
{
path_found = itr->path();
return true;
}
}
return false;
}
</code></pre>
|
<p>File tree walk <code>ftw</code> is a recursive way to wall the whole directory tree in the path. More details are <a href="https://linux.die.net/man/3/ftw" rel="nofollow noreferrer">here</a>.</p>
<p>NOTE : You can also use <code>fts</code> that can skip hidden files like <code>.</code> or <code>..</code> or <code>.bashrc</code></p>
<pre><code>#include <ftw.h>
#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
int list(const char *name, const struct stat *status, int type)
{
if (type == FTW_NS)
{
return 0;
}
if (type == FTW_F)
{
printf("0%3o\t%s\n", status->st_mode&0777, name);
}
if (type == FTW_D && strcmp(".", name) != 0)
{
printf("0%3o\t%s/\n", status->st_mode&0777, name);
}
return 0;
}
int main(int argc, char *argv[])
{
if(argc == 1)
{
ftw(".", list, 1);
}
else
{
ftw(argv[1], list, 1);
}
return 0;
}
</code></pre>
<p>output looks like following:</p>
<pre><code>0755 ./Shivaji/
0644 ./Shivaji/20200516_204454.png
0644 ./Shivaji/20200527_160408.png
0644 ./Shivaji/20200527_160352.png
0644 ./Shivaji/20200520_174754.png
0644 ./Shivaji/20200520_180103.png
0755 ./Saif/
0644 ./Saif/Snapchat-1751229005.jpg
0644 ./Saif/Snapchat-1356123194.jpg
0644 ./Saif/Snapchat-613911286.jpg
0644 ./Saif/Snapchat-107742096.jpg
0755 ./Milind/
0644 ./Milind/IMG_1828.JPG
0644 ./Milind/IMG_1839.JPG
0644 ./Milind/IMG_1825.JPG
0644 ./Milind/IMG_1831.JPG
0644 ./Milind/IMG_1840.JPG
</code></pre>
<p>Let us say if you want to match a filename (example: searching for all the <code>*.jpg, *.jpeg, *.png</code> files.) for a specific needs, use <code>fnmatch</code>.</p>
<pre><code> #include <ftw.h>
#include <stdio.h>
#include <sys/stat.h>
#include <iostream>
#include <fnmatch.h>
static const char *filters[] = {
"*.jpg", "*.jpeg", "*.png"
};
int list(const char *name, const struct stat *status, int type)
{
if (type == FTW_NS)
{
return 0;
}
if (type == FTW_F)
{
int i;
for (i = 0; i < sizeof(filters) / sizeof(filters[0]); i++) {
/* if the filename matches the filter, */
if (fnmatch(filters[i], name, FNM_CASEFOLD) == 0) {
printf("0%3o\t%s\n", status->st_mode&0777, name);
break;
}
}
}
if (type == FTW_D && strcmp(".", name) != 0)
{
//printf("0%3o\t%s/\n", status->st_mode&0777, name);
}
return 0;
}
int main(int argc, char *argv[])
{
if(argc == 1)
{
ftw(".", list, 1);
}
else
{
ftw(argv[1], list, 1);
}
return 0;
}
</code></pre>
| 9,284
|
<p>Does anyone know if it is possible to restart a J2EE application (from the application)? If so, how?</p>
<p>I would like to be able to do it in an app-server-agnostic way, if it is possible.</p>
<p>The application will be run on many different app servers-- basically whatever the client prefers.</p>
<p>If it isn't possible to do this in an app-server-agnostic manner, then it probably isn't really worth doing for my purposes. I can always just display a message informing the user that they will need to restart the app manually.</p>
|
<p>I would suggest that you're unlikely to find an appserver agnostic way. And while I don't pretend to know your requirements, I might question a design that requires the application to restart itself, other than an installer that is deploying a new version. Finally, I would suggest that for any nontrivial purpose "any" appserver will not work. You should have a list of supported app servers and versions, documented in your release notes, so you can test on all of those and dont have to worry about supporting clients on a non-conforming server/version. From experience, there are always subtle differences between, for example, Apache Tomcat and BEA WebLogic, and these differences are often undocument and hard to determine until you run into them. </p>
|
<p>Most application servers provide a JMX interface, so you could invoke that.</p>
| 6,871
|
<p>I see a number of people writing "CURA", when I have always called it "Cura". So I started to wonder if CURA was a <em>capitalised</em> acronym, like LiDAR or NATO (but not like radar or laser).</p>
<p>I had a look and the Wikipedia entry, <a href="https://en.wikipedia.org/wiki/Cura_(software)" rel="nofollow noreferrer">Cura (software)</a> doesn't appear to suggest that.</p>
<p>So I wondered if it was a marketing thing.</p>
<hr>
<p>After all, over on SE.Arduino, <em>lots</em> of people write "Arduino UNO" - I myself did so to, for a long time, until Nick Gammon <a href="https://arduino.stackexchange.com/questions/13839/can-i-use-analogreadresolution-on-an-uno-or-leonardo#comment25114_13839">picked me up on it</a>:</p>
<blockquote>
<p><a href="https://i.stack.imgur.com/6piXl.png" rel="nofollow noreferrer" title="Uno not UNO"><img src="https://i.stack.imgur.com/6piXl.png" alt="Uno not UNO" title="Uno not UNO"></a></p>
</blockquote>
<p>I <em>think</em> that the reason that I did was that the Arduino pages write it in that way (arguably incorrectly) and it just seems to be a branding/marketing ploy.</p>
<p>So, is this the same sort of thing with CURA? I am just wondering where it started and came from?<sup>1</sup></p>
<hr>
<p><sup>1</sup> As one does on a boring rainy Sunday morning :-)</p>
|
<p>As of version 4 the splash screen has changed, also the branding/naming of the product throughout Ultimaker's website.</p>
<p><a href="https://i.stack.imgur.com/1eX3U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1eX3U.png" alt="enter image description here" /></a></p>
<p>Technically it is not <em>CURA</em> or <em>cura</em>, it is <em>Ultimaker Cura</em>.</p>
|
<p>Actually, it's neither:</p>
<p><a href="https://i.stack.imgur.com/H7bOQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H7bOQ.png" alt="enter image description here"></a></p>
<p>If you wanna believe this image, it's: Ultimaker <strong>cura</strong> ... all lower case.</p>
| 55
|
<p>I am trying to publish an Asp.net MVC web application locally using the NAnt and MSBuild. This is what I am using for my NAnt target;</p>
<pre><code><target name="publish-artifacts-to-build">
<msbuild project="my-solution.sln" target="Publish">
<property name="Configuration" value="debug" />
<property name="OutDir" value="builds\" />
<arg line="/m:2 /tv:3.5" />
</msbuild>
</target>
</code></pre>
<p>and all I get is this as a response;</p>
<pre><code>[msbuild] Skipping unpublishable project.
</code></pre>
<p>Is it possible to publish web applications via the command line in this way?</p>
|
<p>The "Publish" target you are trying to invoke is for "OneClick" deployment, not for publishing a website... This is why you are getting the seemingly bizarre message.
You would want to use the AspNetCompiler task, rather than the MSBuild task. See <a href="http://msdn2.microsoft.com/en-us/library/ms164291.aspx" rel="noreferrer">http://msdn2.microsoft.com/en-us/library/ms164291.aspx</a> for more info on this task. Your "PublishDir" would correspond to the TargetPath property of the task. </p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1032073&SiteID=1" rel="noreferrer">Source</a></p>
|
<p>I came up with such solution, works great for me:</p>
<pre><code>msbuild /t:ResolveReferences;_WPPCopyWebApplication /p:BuildingProject=true;OutDir=C:\Temp\buidl\ Test.csproj
</code></pre>
<p>Secret sauce is _WPPCopyWebApplication target.</p>
| 7,101
|
<p>One of the CAD programs I use is called <a href="http://www.tinkercad.com" rel="noreferrer">TinkerCAD</a>, which lets you export your design in either STL or OBJ form. What is the difference between these two file types? And which one is better to use?</p>
|
<p><strong>STL is the <em>de facto</em> standard in consumer-grade 3D printing</strong>. It is a bare-bone format that describes the shape of the object by defining the coordinates of all the vertices of all triangles that a surface may be subdivided into.</p>
<p>This means that in STL any curved surface is represented with an approximation of many very small faces.</p>
<p>OBJ is also somewhat common, but it was originally developed for computer graphics, not manufacturing, and as such is capaple to store information like the texture images to be applied to the surface, which are of no use in the 3D printing world.</p>
<p>In terms of geometry description, OBJ is more capable than STL, as it can describe "real" curves, without the need to approximate them to a series of polygons. The benefit of this feature is however more theoretic than practical, as:</p>
<ul>
<li>most entry-level CAD software don't make use of that feature and create a STL-equivalent OBJ file (so, still with polygons)</li>
<li>a typical STL model for 3D printing will have enough resolution to give the illusion of perfect curves (the same way a high-res screen gives the illusion of perfect curves, despite its pixels being arranged in a squared matrix),</li>
<li>the slicer/printer's firmware may themselves approximate an accurate curve to a series of segments</li>
</ul>
<p>Short said, <strong>I would suggest you use STL unless you have a specific reason not to</strong>.</p>
<p>If you would find yourself in need to accurately describe curves I would rather use the STEP file format, as that has been specifically created for manufacturing, rather than "borrowed" from computer graphics.</p>
|
<p>While the STL-format can only describe your object aproximatively by those well known triangles, OBJ-files can describe parts of your object parametrically by curves. This can lead to a higher precision and be a huge advance with regard to scalability.
Which data format to choose depends, as always, on the application and the processes it contains. E.g. if you want to print large objects, you might consider the OBJ-format if your slicer can translate it to usable g-code.</p>
<p>You might want to read this <a href="https://all3dp.com/3d-file-format-3d-files-3d-printer-3d-cad-vrml-stl-obj/" rel="nofollow noreferrer">article on All3DP</a> to get a brief overview.</p>
| 841
|
<p>The question is how to scale an existing mesh without changing the thickness of the walls? </p>
<p>I am using Blender to create STL files for 3D printing. Let's say I create a shell for a model railroad car. Since 1/87th is the most common scale I make the walls of the shell just thick enough to make it rigid in 1/87 scale. Now, if I want to print the same shell in a larger scale, say 1/48, the wall thickness will nearly double and it will waste material printing walls that are thicker than needed. If I want to print in 1/160 the printing may fail because the wall thickness falls below the minimum the printer will support. </p>
<p>Any ideas?</p>
|
<p>Your question falls into two different categories, here at 3D Printing SE and there, at <a href="https://blender.stackexchange.com/">Blender SE</a>. </p>
<p>I would consider that your objective would best be solved using some form of parametric modeling, an aspect that is rarely embraced by Blender. Even though the limitations of Blender make life interesting for you, there may be a couple of useful features within (and without) the program.</p>
<p>On <a href="https://blender.stackexchange.com/questions/53293/is-blender-actually-useable-for-engineering">Blender SE</a>, a question of similar format exists, with a somewhat open-ended answer. A quick search using The Google, with the terms "<a href="https://www.google.com/#q=parametric+modeling+with+blender" rel="nofollow noreferrer">Parametric Modeling with Blender</a>" results in a number of different approaches. According to a quick perusal of the search results, some of the solutions involve free plug-ins or add-ons for Blender. More complexity rather than less, perhaps.</p>
<p>I'm familiar enough with the very simple basics of Blender to know I would not be able to make use of those answers. I'm also well aware that Blender's power extends beyond my own limitations with features supporting scripting, animation and so many other tools. Seeing the workflow diagrams/charts that make up some of the advanced portion of the program leads me to believe that one can accomplish your objective, but one must be a certified wizard with the program. </p>
<p>As an alternative, one could engage any one of the many parametric modeling programs available. I'm a fan of OpenSCAD, although the text/scripting interface can be daunting for some. If you've become skilled in Blender, a non-GUI format isn't necessarily the best route, although the GUI options are no less confusing, in my opinion.</p>
|
<p>The minimum scale of your model
The modeling of your 3D file doesn’t necessarily require that you work with a given unit or scale. It’s particularly true with software like Blender in which you’re able to give proportion but no unit. This job will be done after the modeling phase when you send your model to a 3D printer. That’s why you need to pay extra attention to both the scale and the size of your model at that point. Creating a 3D print in millimeters instead of centimeters might very well result in a bad 3D print.</p>
<p>A powerful example of that can be found in architectural models. This is, in fact, one of the main issues we encountered while working with La Cité de L’Architecture on La Merveille’s reproduction. With architectural models, it can, for instance, be entirely possible to 3D print a scale 1/10 of something and just impossible to do the same at 1/250.</p>
<p>After a certain level of miniaturization, the details (present in the digital 3D file) are starting to vanish in the physical world because the 3D printer itself is no able to create them (or will create very fragile one). Quite often for architectural models, human intervention is necessary to decide which details will be kept and which won’t so that the 3D file doesn’t contain information that won’t be printable.</p>
| 528
|
<p>I've never built a 3D printer before, but I understand dynamical systems and control theory, and I imagine a lot of the distortion/inaccuracy that happens during the FDM process (especially at high speeds) is due to position inaccuracies because of inertia. For example, a heavy print head moving fast enough might overshoot its position target if the system expects it to stop instantly. Does any existing 3D printer controller software try to measure the mass of the print head/movement assembly and then use that to come up with better movement instructions?</p>
<p>To speculate a bit: This additional accuracy might not be useful with many normal stepper-driven printers because they lack resolution and/or control, but I think in some cases it would. I imagine with enough positional accuracy and acceleration control you could model the print head position with a dynamical system and get extremely precise movement right up to the mechanical limits of the system.</p>
<p>Am I wrong that inertia has a large effect? Would this be theoretically impossible for some reason I'm not thinking about?</p>
|
<p>Stepper motors "want" to keep their position as they are told to by the firmware, therefore they do whatever it's needed (accelerate and brake) to follow the orders they received.</p>
<p>The question is: is the firmware telling them to move/accelerate/brake faster/harder than they can? if yes, they won't keep up (because of inertia and much more) so you'll see artefacts. If not, they will follow the orders exactly (well, mostly, but it's not important now) and no distortions will be there.</p>
<p>Whether they keep up or not is up to you: you are setting their power (the motor current) and you are telling them how fast/hard to move/accelerate/brake. If you push them too much, the motors will try... and fail to keep up. That's why you have max acceleration, speed, jerk in the firmware and in the slicer.</p>
<p>Additional info: even if the motors keep the position as they are told to, the motors have no knowledge of anything past them: belts, leadscrews, and so on.</p>
<p>Imagine the X axis belt (which connects the motor to the printing head) is made of an elastic band: the motors will be where you order them to be, but the inertia of the printing head will stretch the elastic band and the printing head will NOT be where you expect it to be.</p>
<p>It is again up to you to reduce the max acceleration to a value below what the motors could be able to do, if needed. Motors are often not pushed to their limit also because other factors cause issues before the motors fail.</p>
<p>How to know how much to limit the acceleration and speed? the only way is trying.</p>
|
<h1>Inertia is not what you think it is</h1>
<p>Inertia is technically speaking something that in physics is not what you commonly understand under the term. There is no mysterious "Inertia Force" that slows your actions on a setup. Inertia is not what makes you overshoot a print's endpoint.</p>
<p>Inertia is just the principle <em>why</em> you need to <em>break</em> (negative acceleration) before you reach the endpoint of travel and how much you need to and <em>how fast you can step on the break</em> (jerk).</p>
<h2>Recap on Newtonian Motion Mechanics</h2>
<p>Inertia is the fact that an item that is under movement and does not get acted upon just does nothing, as Newton's first law prescribes. That your applied force only takes effect on a body over time (the <em>common</em> thing understood under inertia) follows directly from the description of the 2nd Law of Newtonian Mechanics:</p>
<blockquote>
<p>Mutationem motus proportionalem esse vi motrici impressae, et fieri secundum
lineam rectam qua vis illa imprimitur.</p>
</blockquote>
<blockquote>
<p>The alteration of motion is ever proportional to the motive force impressed; and is
made in the direction of the right line in which that force is impressed.</p>
</blockquote>
<p><span class="math-container">$$F=\frac{d}{dt} (m\times v)$$</span></p>
<p>The <strong>F</strong>orce onto a body is the change over time(<span class="math-container">$\frac{d}{dt}$</span>) of <strong>m</strong>ass and <strong>v</strong>elocity. In the classics physical case with constant mass, this becomes the much more well known formulation: <span class="math-container">$$F=m\times \frac{d}{dt} v=m\times\dot v=m\times a$$</span></p>
<p>Now, we have an item of known mass and a known initial velocity <span class="math-container">$v_0$</span>. The speed of the item at any moment is thus <span class="math-container">$$v(t)=v_0-(\frac F m\times t)=v_0-(a\times t)$$</span></p>
<h3>Momentum</h3>
<p>Another thing that is often mingled into the therm inertia is actually the momentum of an item. It follows directly from the newton text: the force is proportional to the change of momentum. <span class="math-container">$$F=\frac{d}{dt}p=\frac{d}{dt}(m\times v)$$</span><span class="math-container">$$p=m\times v$$</span> Momentum can be best understood as an amount of "energy" (it's not, energy is <span class="math-container">$E_\text{kin}=m\times v^2$</span>)</p>
<h1>The <em>principle of inertia</em> is looked at in the slicer</h1>
<p>Most slicers set a <em>maximum acceleration</em> for machines and <em>jerk</em> for machines. These values are decided based on the mass of the printhead: Maximum acceleration times the mass of the printhead is the maximum force. <a href="https://en.wikipedia.org/wiki/Jerk_(physics)" rel="nofollow noreferrer">Jerk is the derivate of acceleration over time</a>, so it flows into motion mechanics back as <span class="math-container">$F(t)=m\times j\times t$</span>. So choosing the Jerk and Max-acceleration does include information about the mass of the printhead, without expressly stating it.</p>
<p>One <em>could</em> write the code in reverse and decide on a maximum allowable <strong>Force</strong> and include the mass of the printhead, resulting in automatically calculated settings for the maximum allowable 2nd and 3rd derivate of the position, acceleration and jerk.</p>
<h1>Printer control boards just throttle</h1>
<p>Likewise, printer control boards just throttle acceleration and jerk to a value in their firmware. They don't need to know the mass of the printhead if they put maximum values on both, and those account for the behavior wanted.</p>
<p>There is no accuracy to be gained from doing the calculation the other way around in the firmware: Even knowing the mass and some allowable force would not get you any way closer but spend quite some code on a function that is called for a few static values.</p>
<p>What is more influential, the acceleration and jerk settings are very heavily influenced by how your printhead is mounted, not just the mass of the printhead: Do you have a feather mounted on linear rails and moved with a screw? Or do we have a kilo chunk of lead mounted on a cross of 2 mm aluminium rod rails, pulled with a super soft rubber twist?</p>
| 1,864
|
<p>Is there a free or open source library to read Excel files (.xls) directly from a C# program? </p>
<p>It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've been using Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I'd like to eliminate the manual step.</p>
|
<pre><code>var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirectory());
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName);
var adapter = new OleDbDataAdapter("SELECT * FROM [workSheetNameHere$]", connectionString);
var ds = new DataSet();
adapter.Fill(ds, "anyNameHere");
DataTable data = ds.Tables["anyNameHere"];
</code></pre>
<p>This is what I usually use. It is a little different because I usually stick a AsEnumerable() at the edit of the tables: </p>
<pre><code>var data = ds.Tables["anyNameHere"].AsEnumerable();
</code></pre>
<p>as this lets me use LINQ to search and build structs from the fields.</p>
<pre><code>var query = data.Where(x => x.Field<string>("phoneNumber") != string.Empty).Select(x =>
new MyContact
{
firstName= x.Field<string>("First Name"),
lastName = x.Field<string>("Last Name"),
phoneNumber =x.Field<string>("Phone Number"),
});
</code></pre>
|
<p>I just used <a href="http://code.google.com/p/excellibrary/" rel="nofollow noreferrer">ExcelLibrary</a> to load an .xls spreadsheet into a DataSet. Worked great for me.</p>
| 3,664
|
<p>What is a good, simple encryption scheme for protecting passwords in a database? I don't necessarily need anything that's hyper-secure nor do I need anything that's lightning fast, but those things would be nice. Primarily, I just want something that's easy to implement without being terribly slow or insecure.</p>
|
<p>As mk says, <s>SHA1 or MD5 are the standard ones, along with SHA2</s>.</p>
<hr />
<p>Update: As processors have gotten faster over the years, hashes have gotten more brute-forceable. It's now recommended you use <a href="https://en.wikipedia.org/wiki/Bcrypt" rel="nofollow noreferrer"><code>bcrypt</code></a>.</p>
<p>Another update: <code>bcrypt</code> is still probably good, but if I was writing a new system today I would use <a href="https://en.wikipedia.org/wiki/Scrypt" rel="nofollow noreferrer"><code>scrypt</code></a>.</p>
<hr />
<p>What you want is more generally called a cryptographic hash function. Cryptographic hashes are designed to be one-way (given the resulting hash, you shouldn't be able to derive the original input). Also, the likelihood of two arbitrary strings having the same hash (known as a hash collision) should be low (ideally 1/number of hash values).</p>
<p>Unfortunately, just because your passwords are hashed doesn't free you from having to try really hard to keep the hashed versions safe. Far too many people will use weak passwords that would be vulnerable to an off-line brute-force attack.</p>
<p>Edit - several people have also already pointed out the importance of using a salt. A salt is a constant value that you mix in with the input before using the hash function. Having a unique salt prevents off-line attackers from using pre-computed tables of common passwords (rainbow tables) to brute-force your passwords even faster.</p>
|
<p>If you're using SQL Server, there's the HashBytes function: </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms174415.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms174415.aspx</a></p>
| 5,079
|
<p>I am ready to start using SVN, but I have NO (as in the money required for free beer) experience with source control. I have installed subversion on my server (that was easy, 'apt-get install subversion') but now I don't know what to do, how to configure it, or how to use it.<br /><br />What suggestions do you have, and where can I find good resources to learn to start using it?<br /><br />
Update:<br />
O.K. So the feedback has been great and I have read through a bit of it but I want to clarify my question by saying that I am looking for more information on how to actually go about setting my up my repositories, clients, server, etc. I know that I could do a quick Google search and find dozens (or more) resources but I'm hoping that someone whom has experience with subversion and a client(I have installed tortoise) could suggest a good reference that will be reliable, and have quality content.</p>
|
<p>Eric Sink has an <a href="http://www.ericsink.com/scm/source_control.html" rel="noreferrer">excellent series</a> on source code control aimed at beginners. For Subversion specifics, including setting up and administering a server, the <a href="http://svnbook.red-bean.com/" rel="noreferrer">Subversion book</a> is a great resource, and includes a section with examples of a typical session with Subversion (checkout, commit, merging and updating basics).</p>
<p><strong>Update:</strong> I forgot to mention that for beginners, I'd also recommend messing around in a graphical client, which removes the command-line hassle from the learning experience. <a href="http://rapidsvn.tigris.org/" rel="noreferrer">RapidSVN</a> is a reasonable cross-platform client. You'll also find that common IDEs either come with Subversion support, or have plugins which can be installed, which allow most version control operations to be performed within that environment.</p>
<p><strong>@John Millikin:</strong> While setting up a Subversion server can be complicated, depending on one's general admin experience, don't forget that you don't need to do that just to mess about with a repository and get to grips with the basics - the client can interact with a repository in the local filesystem.</p>
|
<p>I recommend using SVN with apache on Linux, svn as a linux client, and TortioseSVN on windows (It does great MS Office diffs).</p>
<p>I have lots of stuff on my svn, and I would hate not using it.</p>
| 5,621
|
<p>Over the past year or so my production platform has been plagued by an odd TCP/IP issue. I've spent zillions of hours working with competent & knowledgeable sysadmins, scouring the net, reading source code, been jerked around by RH's pathetic support, and <strong>crying tears of blood</strong>! To no avail. (Google <a href="http://www.google.ch/search?source=ig&hl=en&rlz=&=&q=unkn-4&btnG=Google+Search&meta=" rel="nofollow noreferrer">'unkn-4'</a> and you'll see many posts with my name all over.) </p>
<p>Work-a-rounds are in place, so the issue is not a priority. But the geek in me really would like to understand and solve this problem. </p>
<p><strong><em>So, where can a moderately competent systems programmer go to ask detailed questions and receive detailed answers from The Lords of TCP/IP stacks?</em></strong> I assume that their world so close to the bare metal, their population so small, is different from my own. That, and they don't want to answer emails to "My modem doesn't work" so they hide in the shadows. </p>
<p>Any pointers would be greatly appreciated.</p>
|
<p>Dave Miller (person in charge of networking in the linux kernel) and their fellow henchmen all inhabit the lkml or <a href="http://lkml.org" rel="noreferrer">Linux Kernel Mailing List</a>. If you can provide a reasonably decent bug report they'll get you a reasonable answer. </p>
<p>On the other hand if you tell them it's a very old kernel, they'll tell you to try the newest... At the very least you can try searching its archives.</p>
|
<p>The linux-net mailing list might interest you. There should be more details <a href="http://vger.kernel.org/vger-lists.html" rel="nofollow noreferrer">here</a>.</p>
| 7,268
|
<p>I have an Anycubic Chiron printer and use Ultimaker Cura for slicing. Recently I printed a simple clip, had no problems whatsoever.</p>
<p>I have since upgraded Cura to the latest version, and now the PLA will not stick to the build plate. The printer will make 3 passes whilst printing the brim, then it all collects into a ball. I have checked the level, all is OK, I have increased the temperatures, with the EO now at 225 °C (was 200 °C) and the bed at 75 °C (was 60 °C)</p>
<p>Does anyone know how much or what was changed by Ultimaker in the latest upgrade?</p>
|
<p>I don't think it's because of Cura. You can try if it still works with the older version.</p>
<p>Otherwise, clean your print bed with isopropanol before printing to remove residues or level again. Without pictures of the condition of the print bed or the first layer, it is difficult to help.</p>
|
<p>Have tried all the possible answers and found the older version of Cura works better with the Chiron. The printer is 3 months old, bed is cleaned after each print.</p>
<p>I then tried the new Cura version again but with glue for adhesion, that works. It seems that it is changing the bed temperature, and using a lower default. Have tried changing the bed temperature in the software before slicing, but found I have to manually set the temperature on the printer, I have been using the generic settings for the PLA, as the ones I have (E-DA) are not in the selection or in the market place. TPU and PETG are printing fine.</p>
<p>Will have to determine the optimum set-up and create my own defaults.</p>
| 2,099
|
<p>I have a database in ISO-8859-2 format, but I need to create XML in UTF-8. This means that I must encode the database before prinitng in UTF-8. I know very little about ASP.Net, so I'm hoping someone can help.</p>
<p>In PHP I would do something like this:</p>
<pre><code>db_connect();
mysql_query("SET NAMES 'UTF8'");
mysql_query("SET character_set_client='UTF8'");
</code></pre>
<p>This is my ASP.Net code for database connection:</p>
<pre><code> 'CONNECTION TO DATABASE
dim dbconn,sql,dbcomm
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("../baze/test.mdb"))
dbconn.Open()
sql="SELECT * FROM nekretnine, tipovinekretnina WHERE nekretnine.idtipnekretnine = tipovinekretnina.idtipnekretnine ORDER BY nekretnine.idnekretnine"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
while dbread.Read()
</code></pre>
<p>Where and how do I encode to UTF-8?</p>
|
<p>Assuming you have a value string in <code>str</code>, this is the pure-.NET way of doing this.</p>
<pre><code>var encoding = System.Text.Encoding.GetEncoding("iso-8859-2");
var bytes = System.Text.Encoding.Convert(encoding, System.Text.Encoding.Default, encoding.GetBytes(str));
var newString = System.Text.Encoding.Default.GetString(bytes);
</code></pre>
|
<p>The .NET Framework's internal string type is UTF-16. All database access will convert to UTF-16 so that you can view the data appropriately: the database, or the OLE DB provider, will convert to UTF-16.</p>
<p>The XML writer classes (you <em>are</em> using XmlDocument or XmlWriter, right?) will then convert to UTF-8 on the output.</p>
<p>Basically, you shouldn't need to do anything extra.</p>
| 9,710
|
<p>PLA has a heat capacity of <a href="https://www.sd3d.com/wp-content/uploads/2017/06/MaterialTDS-PLA_01.pdf" rel="nofollow noreferrer">1.8-2.1 J/g-K</a>, while <a href="http://www.matweb.com/search/datasheet_print.aspx?matguid=4de1c85bb946406a86c52b688e3810d0" rel="nofollow noreferrer">PETG 1.1-1.3 J/g-K</a>. This means that each gram of PLA needs more energy to heat up. I assume no "melting latent energy", since we talk about plastics.</p>
<p>The density is about the same.</p>
<p>Still, printing speed for PETG is said to be kept at max at 60 mm/s, while PLA can easily go up to 100 mm/s.</p>
<p>Why is PETG supposed to be printed slower than PLA?</p>
<p>Edit: a link to a more recent question may be of interest: <a href="https://3dprinting.stackexchange.com/questions/10173/power-consumption-of-filament-extrusion/10175?noredirect=1#comment30444_10175">Power consumption of filament extrusion</a></p>
|
<p>I'm adding this answer to somewhat challenge the findings of my original answer, and the premise of the question: PETG does not need lower print speeds, and can even be printed at higher speeds than PLA under some conditions due to reduced need for cooling. You can see this from some of the "#speedboatrace" entries printed with PETG. So what was really going on with the original claim and my agreement with it?</p>
<p>I think my original answer is still somewhat true: it's likely that it takes more hotend power to melt PETG at a rate that can be successfully extruded <em>and bonded</em> than to do the same for PLA. But there are other factors at play in the perception that "PETG has to be printed slow".</p>
<p>FarO did not specify details of the printer(s) in question, but I found the big limiting factor for my Ender 3 printing PETG was the stock extruder, which presumably was skipping bad to begin with, and even worse with Linear Advance, trying to keep the filament under high pressure to compensate for its compressibility. Since replacing the extruder with a direct drive one, I've had no problem printing PETG at the same speed as PLA, and both can print much faster than I ever could with the stock bowden extruder.</p>
|
<p>The density of PLA is around 1.25 g/cm³ and the density of PETG is around 1.38 g/cm³. When you're talking about the amount of energy needed to melt a particular <em>volume</em> (which is what your extrusion units are) rather than mass, you need to scale the heat capacities (with units of <span class="math-container">$\frac{\mathrm J}{\mathrm g\cdot \mathrm K}$</span>) by the density to get <span class="math-container">$\frac{\mathrm J}{\mathrm{cm}^3\cdot \mathrm K}$</span>. This brings their volumetric heat capacities somewhat closer: 2.25-2.63 vs 1.52-1.79 (about 47 % higher for PLA rather than your figure of about 62 %), but with PLA still higher.</p>
<p>You also have to account for heat loss to the environment. PLA is typically printed around 200 °C or 210 °C at most; PETG in my experience requires 250 °C to reach low enough viscosity to be printable at any speed. Assuming an ambient 20 °C, the rate of heat loss should be something like 25 % higher for PETG. So the hotend has that much additional energy needed to begin with.</p>
<p>Beside that, PLA is printed at temperatures where it's still extrudable and able to bond even if the temperature drops significantly below the nominal nozzle temperature (down to 180 °C, maybe even slightly lower), whereas PETG has trouble with increased viscosity and poor bonding right away if temperature drops.</p>
<p>Going broader still, PETG seems to need to keep its heat longer after being extruded in order for layers to bond well. (As evidenced by the need to lower fan or turn it off completely.) A slow-moving nozzle both provides heat (from the proximity of the nozzle itself) to slow the cooling, and reduces air flow across the part (by not causing as much air flow itself just by moving).</p>
| 1,633
|
<p>I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.</p>
<p>How can I kill all the connections to the database so that I can rename it?</p>
|
<p>The reason that the approach that <a href="https://stackoverflow.com/questions/11620/how-do-you-kill-all-current-connections-to-a-sql-server-2005-database/11627#11627">Adam suggested</a> won't work is that during the time that you are looping over the active connections new one can be established, and you'll miss those. You could instead use the following approach which does not have this drawback:</p>
<pre><code>-- set your current connection to use master otherwise you might get an error
use master
ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
--do you stuff here
ALTER DATABASE YourDatabase SET MULTI_USER
</code></pre>
|
<p>You can Use SP_Who command and kill all process that use your database and then rename your database.</p>
| 3,271
|
<p>I printed parts for a Harry Potter wand with HatchBox Wood PLA, now I want to apply stain. I intended to try MinWax PolyShades wood stain, then noticed Varathane water-based wood stain is available at my local Rona hardware store. This seems a "healthier" option, maybe not as fussy to apply as PolyShades, anyone had experience with this product?</p>
|
<p>I ended up using Saman brand water-based wood stain, also from Rona hardware (a brand of Lowe's Canada). The selection of colours for Saman stains was greater than the Varathane stains. </p>
<p>I applied a single coat of colour #117 "Chamois" to the stem portion of the wand, and two coats of colour #120 "Dark Walnut" to the handle. I did not apply a varnish or sealer. The results seem acceptable, given that I Am Not A Carpenter, and this is my first go at printing and finishing wood PLA! Overall, I'm quite happy with the result. I left the PLA mostly unsanded to take advantage of the layers' wood-grain appearance.</p>
<p><a href="https://i.stack.imgur.com/j8OTj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j8OTj.jpg" alt="Close up of wand"></a><a href="https://i.stack.imgur.com/jSl8B.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jSl8B.jpg" alt="Another close up, showing the Dark Walnut stained handle at left, the Chamois stained stem at left, with a section of unstained wood PLA at the joint"></a></p>
|
<p>Wood stains (as opposed to dyes, paints, etc.) work by having large particles that become lodged in the grain of the wood, yielding a result that varies in intensity with the grain of the wood and thereby brings out its beauty. It's unlikely that they will do what you want, or anything reasonable, on PLA that has wood particles mixed into it. You might be able to find some types of dyes that will work. I've used wood dyes on woods that don't take stain well and have had good results, and if the PLA+wood material consists of a significant amount of wood, it seems plausible that wood dyes might work well on it.</p>
| 1,309
|
<p>I have a need to convert images from CMYK to RGB - not necessarily back again, but hey, if it can be done...</p>
<p>With the release of ColdFusion 8, we got the <a href="http://cfquickdocs.com/cf8/?getDoc=cfimage" rel="nofollow noreferrer">CFImage</a> tag, but it doesn't support this conversion; and nor does <a href="http://x.com" rel="nofollow noreferrer">Image.cfc</a>, or <a href="http://x.com" rel="nofollow noreferrer">Alagad's Image Component</a>.</p>
<p>However, it should be possible in Java; which we can leverage through CF. For example, here's how you might create a Java thread to sleep a process:</p>
<pre><code><cfset jthread = createObject("java", "java.lang.Thread")/>
<cfset jthread.sleep(5000)/>
</code></pre>
<p>I would guess a similar method could be used to leverage java to do this image conversion, but not being a Java developer, I don't have a clue where to start. Can anyone lend a hand here?</p>
|
<p>A very simple formula for converting from CMYK to RGB ignoring all color profiles is:</p>
<pre>
R = ( (255-C)*(255-K) ) / 255;
G = ( (255-M)*(255-K) ) / 255;
B = ( (255-Y)*(255-K) ) / 255;
</pre>
<p>This code requires CMYK values to be in rage of 0-255. If you have 0 to 100 or 0.0 to 1.0 you'll have to convert the values.</p>
<p>Hope this will get you started.</p>
<p>As for the java and ColdFusion interfacing, I'm sorry, but I have no idea how to do that.</p>
|
<p>I know that this question is old, but I still encounter problems with CMYK images & ColdFusion. However, I just read a CMYK JPEG image using ColdFusion 10 and resaved it. The saved image was able to to be read using ColdFusion 9 (which is only capable of reading RGB JPEGs.) I'm not sure if this conversion is intentional or not and I don't currently have any way of identifying whether the source image's color profile is CMYK or not as the saved color profile still appears to be the same.</p>
<pre><code><cfset imgData = ImageRead(expandPath("./CMYK_image.jpg"))>
<cfset ImageWrite(imgData, expandPath("./Saved_image.jpg"))>
</code></pre>
| 4,242
|
<p>Greetings, I'm trying to find a way to 'unbind' a socket from a particular IP/Port combination. My pseudocode looks like this:</p>
<pre><code>ClassA a = new ClassA(); //(class A instantiates socket and binds it to 127.0.0.1:4567)
//do something
//...much later, a has been garbage-collected away.
ClassA aa = new ClassA(); //crash here.
</code></pre>
<p>At this point, .Net informs me that I've already got a socket bound to 127.0.0.1:4567, which is technically true. But no matter what code I put in ClassA's destructor, or no matter what functions I call on the socket (I've tried .Close() and .Disconnect(true)), the socket remains proudly bound to 127.0.0.1:4567. What do I do to be able to 'un-bind' the socket?</p>
<hr>
<p>EDIT: I'm not relying solely on garbage collection (though I tried that approach as well). I tried calling a.Close() or a.Disconnect() and only then instantiating aa; this doesn't solve the problem.</p>
<hr>
<p>EDIT: I've also tried implementing IDisposable, but the code never got there without my calling the method (which was the equivalent of earlier attempts, as the method would simply try .Close and .Disconnect). Let me try calling .Dispose directly and get back to you.</p>
<hr>
<p>EDIT (lots of edits, apologies): Implementing IDisposable and calling a.Dispose() from where 'a' loses scope doesn't work - my Dispose implementation still has to call either .Close or .Disconnect(true) (or .Shutdown(Both)) but none of those unbind the socket.</p>
<p>Any help would be appreciated!</p>
|
<p>(this is what finally got everything to work for me)</p>
<p>Make sure EVERY socket that the socket in A connects to has </p>
<pre><code>socket.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.ReuseAddress, true);
</code></pre>
<p>set upon being initiated. </p>
|
<p>you can't rely on object being garbage collected in C# (i assume you're using c#, based on tagging) if it holds resources like being bound to the network resource like in your example, or holding some other kind of stream, a file stream would be a common example.</p>
<p>you have to assure to release the resources that the object is holding, so that it can be garbage collected. otherwise it won't be garbage collected, but remain living somewhere in the memory. your pseudocode example doesn't provide that you're doing the resources releasing, you just state that the object gets (should get) garbage collected.</p>
| 7,078
|
<p>To minimize retractions and travel when printing several objects, some slicers produce gcode for sequential deposition when each object is built in a traditional manner bottom up layer by layer before starting a new object. Of course, there are limitations caused by the hotend geometry <a href="https://i.stack.imgur.com/ZW17O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZW17O.png" alt="from simplify 3d website"></a> :</p>
<p>So bulky hotends don't allow for this trick to be used wen sequential pieces are closer than several centimeters. If there where hotends with minimal end effector geometry (needle like, much like drill bit on CNC) we might even do things like spiralizing contours of a single object.
This has also potential for other tricks like producing interlacing layers for better layer bonding etc. I wasn't able to find any ongoing work on minimal geometry hotends. Any links? And what might be the challenges in making one? heatblocks and heating cartridges are out of the question but nichrome wire and a fast PID heat controller might do the job.</p>
|
<p>The site is not well-suited to crowd-sourced invention, but the drawbacks to your suggestion are (I think) on topic.</p>
<p>The hotend has two main tasks. Accurate control of extrusion, and maintaining the desired volumetric melt rate. One factor which influences extrusion quality is the size of the melt-zone - generally, you want this to be as small as possible because rigid filament is easier to extrude/retract without ooze/stringing. Equally, the melt zone needs to be provided with a thermal mass (physical or virtual) to stabilize its temperature under extrusion.</p>
<p>Whilst it might be feasible to prototype your concept quite easily, it is likely to be expensive in volume - and there is no great direct advantage. So this is a concept which might enable an area of research but it doesn't look like a development objective with its own intrinsic value.</p>
|
<p>Yes, using a needle to extrude will result in a smaller diameter extrusion. All that is needed is to find a one with a suitable bore size. The problem however is in generating enough hydraulic pressure, needed to extrude hot plastic through a nozzle of that size. If you can form an extruder that can, then go for it. The second problem is that the thin wall of such a nozzle won't have the same "ironing" effect that current nozzles have. From the picture referenced below you can see the nozzle hole and then a ring of metal around it. That ring flattens the filament out into the desired layer which helps with layer adhesion. With out it, the filament might not even stick to the previous layer, or the bed.</p>
<p><a href="https://i.stack.imgur.com/HP4n0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HP4n0.jpg" alt="E3D V6, 0.4 mm DIAMONDIZED™ 3D Printer Nozzle from 3dpc.tech"></a></p>
| 1,375
|
<p>For instance, my query is like the following using SQL Server 2005:</p>
<pre><code>SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#')
</code></pre>
<p>I have a full text index defined to use the column SearchField which returns results when using:</p>
<pre><code>SELECT * FROM Table WHERE SearchField LIKE '%c#%'
</code></pre>
<p>I believe # is a special letter, so how do I allow FREETEXT to work correctly for the query above?</p>
|
<p>The # char is indexed as punctuation and therefore ignored, so it looks like we'll remove the letter C from our word indexing ignore lists.</p>
<p>Tested it locally after doing that and rebuilding the indexes and I get results!</p>
<p>Looking at using a different word breaker language on the indexed column, so that those special characters aren't ignored.</p>
<p>EDIT: I also found <a href="http://www.simple-talk.com/sql/learn-sql-server/sql-server-full-text-search-language-features/" rel="noreferrer">this information</a>:</p>
<blockquote>
<p>c# is indexed as c (if c is not in your noise word list, see more on noise word lists later), but C# is indexed as C# (in SQL 2005 and SQL 2000 running on Win2003 regardless if C or c is in your noise word list). It is not only C# that is stored as C#, but any capital letter followed by #. Conversely, c++ ( and any other lower-cased letter followed by a ++) is indexed as c (regardless of whether c is in your noise word list).</p>
</blockquote>
|
<p>Quoting a much-replicated help page about Indexing Service query language:</p>
<blockquote>
<p>To use specially treated characters such as &, |, ^, #, @, $, (, ), in a query, enclose your query in quotation marks (“).</p>
</blockquote>
<p>As far as I know, full text search in <code>MSSQL</code> is also done by the Indexing Service, so this might help.</p>
| 2,347
|
<p>My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio 2005 Express edition. From time to time I have sent release .exe files to other people with pleasing results. However recently I made the disturbing discovery that the pleasing results were based on more luck that I would like. Attempting to run one of these programs on an old (2001 vintage, not scrupulously updated) XP box gave me nothing but a nasty "System cannot run x.exe" (or similar) message.</p>
<p>Some googling revealed that with this toolset, even specifying static linking results in a simple hello-world.exe actually relying on extra .dll files (msvcm80.dll etc.). An incredibly elaborate version scheming system (manifest files anyone?) then will not let the .exe run without exactly the right .dll versions. I don't want or need this stuff, I just want an old fashioned self contained .exe that does nothing but lowest common denominator Win32 operations and runs on any old win32 OS.</p>
<p>Does anyone know if its possible to do what I want to do with my existing toolset ?</p>
<p>Thank you.</p>
|
<p>For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.</p>
<p>If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly.</p>
|
<p>In regards Jared's response, having Windows 2000 or better will not necessarily fix the issue at hand. Rob's response does work, however it is possible that this fix introduces security issues, as Windows updates will not be able to patch applications built as such.</p>
<p>In another post, Nick Guerrera suggests packaging the Visual C++ Runtime Redistributable with your applications, which installs quickly, and is independent of Visual Studio.</p>
| 5,809
|
<p>Whenever I run rspec tests for my Rails application it takes forever and a day of overhead before it actually starts running tests. Why is rspec so slow? Is there a way to speed up Rails' initial load or single out the part of my Rails app I need (e.g. ActiveRecord stuff only) so it doesn't load absolutely everything to run a few tests?</p>
|
<p>You should be able to to speed up your <code>script/spec</code> calls by running <code>script/spec_server</code> in a separate terminal window, then adding the additional <code>-X</code> parameter to your spec calls.</p>
|
<p>If you are on a Windows environment then there is probably little you can do as Rails seems to startup really slowly under Windows. I had the same experience on Windows and had to move my setup to a Linux VM to make it really zippy (I was also using autotest).</p>
| 9,231
|
<p>We are currently storing plain text passwords for a web app that we have. </p>
<p>I keep advocating moving to a password hash but another developer said that this would be less secure -- more passwords could match the hash and a dictionary/hash attack would be faster.</p>
<p>Is there any truth to this argument? </p>
|
<p>Absolutely none. But it doesn't matter. I've posted a similar response before:</p>
<p>It's unfortunate, but people, even programmers, are just too emotional to be easily be swayed by argument. Once he's invested in his position (and, if you're posting here, he is) you're not likely to convince him with facts alone. What you need to do is switch the burden of proof. You need to get him out looking for data that he hopes will convince you, and in so doing learn the truth. Unfortunately, he has the benefit of the status quo, so you've got a tough road there.</p>
|
<blockquote>
<p>more passwords could match the hash and a dictionary/hash attack would be faster.</p>
</blockquote>
<p>Yes and no. Use a modern hashing algorithm, like an SHA variant, and that argument gets very, very week. Do you really need to be worried if that brute force attack is going to take only 352 years instead of 467 years? (Anecdotal joke there.) The value to be gained (not having the password stored in plain text on the system) far outstrips your colleague's concern. </p>
| 8,349
|
<p>I have an extender (IExtenderProvider) which extends certain types of
controls with additional properties. For one of these properties, I have
written a UITypeEditor. So far, all works just fine.</p>
<p>The extender also has a couple of properties itself, which I am trying to
use as a sort of default for the UITypeEditor. What I want to do is to be
able to set a property on the extender itself (not the extended controls),
and when I open up the UITypeEditor for one of the additional properties on
an extended control, I want to set a value in the UITypeEditor to the value
of the property on the extender.</p>
<p>A simple example: The ExtenderProvider has a property DefaultExtendedValue. On the form I set the value of this property to "My Value". Extended controls have, through the provider, a property ExtendedValue with a UITypeEditor. When I open the editor for the property ExtendedValue the default (initial) value should be set to "My Value".</p>
<p>It seems to me that the best place to do this would be
UITypeEditor.EditValue, just before calling
IWindowsFormsEditorService.DropDownControl or .ShowDialog.</p>
<p>The only problem is that I can't (or I haven't discovered how to) get hold
of the extender provider itself in EditValue, to read the value of the property in question and set it in the UITypeEditor. Context gives me the extended
control, but that is of no use to me in this case.</p>
<p>Is there any way to achieve what I'm trying? Any help appreciated!</p>
<p>Thanks
Tom</p>
<hr>
<p>@samjudson: That's not a bad idea, but unfortunately it doesn't quite get me there. I'd really like to be able to set this default value individually for each instance of the extender provider. (I might have more than one on a single form with different values for different groups of extended controls.)</p>
|
<p>Could you read the attribute yourself?</p>
<pre><code>DefaultValueAttribute att = context.
PropertyDescriptor.Attributes.
OfType<DefaultValueAttribute>().
FirstOrDefault();
object myDefault = null;
if ( att != null )
myDefault = att.Value;
</code></pre>
<p>I've used Linq to simplify the code, but you could do something similar back in .Net 1</p>
|
<p>Have you considered adding the DefaultValue as a static property of the ExtenderProvider, then you can access it without requiring an instance of the provider?</p>
| 4,636
|
<p>When designing for 3d FDM printing, I'm wondering what is best practice for items with large overhangs which cannot have (or would be fairly impractical) support structures. Consider my following design:</p>
<p><a href="https://i.stack.imgur.com/Rfmyd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rfmyd.png" alt="enter image description here" /></a></p>
<p>This item is about 7" long, and you'll notice the narrow slot running through the middle of it. The slot is 0.100" wide.</p>
<p>I was about to print this when I suddenly realized printing it would be a problem. So I started messing around with painting on supports, but since something slides in this slot, I would have to do some extensive cleanup to make sure it's smooth.</p>
<p>What I ended up doing was splitting the body at the start of the overhang, and placing some alignment pins in the body (with corresponding holes in the upper portion of the body. e.g.</p>
<p><a href="https://i.stack.imgur.com/ypGmc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ypGmc.png" alt="enter image description here" /></a></p>
<p>I will print the top and bottom separately and glue them together.</p>
<p>My question is whether this is my only option or if I'm missing something in the design process which might work better? This design is in Fusion360, in case that matters when discussing some specific tools that are available which I'm unaware of.</p>
|
<p>When constructing a model intended to be 3D printed, your approach is sound. Overhangs and the required supports can be a severe problem and I believe your assessment is accurate.</p>
<p>The complexity of the upper portion would make printed supports an inappropriate path for the reasons you've provided, while your solution eliminates all the negative aspects of this model's construction/design.</p>
<p>The split as presented turns an excessively supported print into two completely unsupported, easily-printed sections. The alignment pins are the perfect approach as well.</p>
<p>You've not indicated an aversion to adhesive, another plus in the overall assessment. Printing the model(s) in the orientation displayed is going to provide the most strength from the plastic. In some models, one can change the orientation to eliminate or reduce supports, but too often the layer direction change results in a weaker object. Your split design removes that factor as well.</p>
|
<p>If your end product allows it, one possible solution would be to remodel your part so that instead of having a square channel in the center, the channel had sloping or curved sides so that the overhand was removed, and then to print out an infill piece that could be clotted into the channel to square it off.</p>
<p>In essence, you would turn the square channel into a triangular notch with shallow sides that didn't need supporting, and then you restore it to being square after it's printed.</p>
<p>This would also have the advantage of meaning that you could print the infill to a much higher standard than the rest of the print, so it was stronger.</p>
| 2,227
|
<p>I have a network C++ program in Windows that I'd like to test for network disconnects at various times. What are my options?</p>
<p>Currently I am:</p>
<ol>
<li>Actually disconnecting the network wire from the back of my computer</li>
<li>using ipconfig /release</li>
<li>Using the <a href="http://www.nirsoft.net/utils/cports.html" rel="nofollow noreferrer">cports</a> program to close out the socket completely</li>
</ol>
<p>None of these methods though are ideal for me, and I'd like to emulate network problems more easily. </p>
<p>I would like for sometimes connects to fail, sometimes socket reads to fail, and sometimes socket writes to fail. It would be great if there was some utility I could use to emulate these types of problems.</p>
<p>It would also be nice to be able to build some automated unit tests while this emulated bad network is up.</p>
|
<p>You might want to abstract the network layer, and then you can have unit tests that inject interesting failure events at appropriate points.</p>
|
<p>You can subclass whatever library class you are using to manage your sockets (presumably CAsyncSocket or CSocket if you are using MFC), override the methods whose failure you want to test, and insert appropriate test code in your overrides.</p>
| 8,677
|
<p>My goal is to 3D print a 5 liter miniature barrel with a side stand, similar to <a href="http://rads.stackoverflow.com/amzn/click/B009K5DSJG" rel="noreferrer">this wooden one on Amazon</a>. I want it to have a removable top so that a boxed wine bladder may be put inside, and there should be a hole on the top as well so that the spigot may stick out and be used. I have no experience with 3D modeling or printing, but I have access to a public 3D printer at my local library. I know you can print parts individually (ex. curved wood-colored sides with staves and holes to interlock and make up the body of the barrel, the metal-colored hoops to go around the barrel). I don't know what software to use, though. I was thinking of starting to learn Blender? Would that be effective for this project? </p>
|
<p>Your question begins in an inappropriate format for StackExchange, but you've ended it with one more appropriate by asking if Blender would work.</p>
<p>If you are willing to take the time to learn Blender, you are certain to discover that it will do as you require, and much much more. Your referenced model could be created using engineering-type design software such as Fusion 360 or SolidWorks or many of the free packages, but the free-form aspect is more suited to the flexibility of Blender.</p>
<blockquote>
<p>2020 UPDATE: Fusion 360 now supports a sculpt feature, which combines organic modeling with the engineering-type for which it is previously known.</p>
</blockquote>
<p>Even though Blender is not an engineering-type program, it has internal support for precise modeling. Should you learn to use those features, you get the best of both types of software.</p>
<p>If you construct your model in the software in segments/pieces as you suggest, your result will have greater flexibility at the printing stage, specifically with respect to color and filament choices. Instead of wood-colored sides, you can use wood-simulated PLA filament! Depending on the printer at the library, you could also use filamet, a filament containing 88 percent metal for the hoops.</p>
<p>I use Blender for some aspects of modeling, often importing the STL into Meshmixer to address things I've not yet learned in Blender.</p>
<p>I hope your reference to 5 liter is the original size and that your model will be a miniature of it. A 3d printer with 5 liter capacity would be a wonderful asset at the public library!</p>
|
<p>To the people saying 123design. I can only say I have been a blender user way before 3D printing was a thing and just cant get around learning 123design. It just feels so limited as it only have a few tools. Yes blender might have a hard learning curve but it does pay off in the future as you wont be limited to 3D printing models and its crucial to make more complex models </p>
| 366
|
<p>I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name?</p>
<p>I know how to change author after commit but how to change before? Installing apache/svnserver is not an option. </p>
|
<p>Yes, it's possible.</p>
<p><em>TortoiseSVN</em> and the <a href="http://subversion.tigris.org/" rel="noreferrer"><em>svn</em></a> command line client share the same settings location in your profile folder. So you may simply checkout one version using <em>svn.exe</em>:</p>
<pre><code>$ svn co --username different_user_name file:///C:/path/to/your/repo
</code></pre>
<p>... and Subversion will happily replace the associated username for that repository. New commits from TortoiseSVN will then always use that username, no matter with what program you make the new checkouts.</p>
<p>The procedure should work with TortoiseSVN 1.5.5. If it doesn't, try emptying svn's authentication cache (<code>%APPDATA%\Subversion\auth\svn.username</code>) first.</p>
|
<p>As far as I know, TortoiseSVN does not offer any way to do this.</p>
<p>Presumably it's not seen as a big issue, since file based access is not practical for multi-user scenarios, and for single-user the author-name is of lesser importance.</p>
<p>A possible workaround would be to create another Windows username with the author name you want and connect with this.</p>
| 6,758
|
<p>Let's say I have a web site for hosting community generated content that targets a very specific set of users. Now, let's say in the interest of fostering a better community I have an off-topic area where community members can post or talk about anything they want, regardless of the site's main theme.</p>
<p>Now, I <em>want</em> most of the content to get indexed by Google. The notable exception is the off-topic content. Each thread has it's own page, but all the threads are listed in the same folder so I can't just exclude search engines from a folder somewhere. It has to be per-page. A traditional robots.txt file would get huge, so how else could I accomplish this?</p>
|
<p>This will work for all well-behaving search engines, just add it to the <code><head></code>:</p>
<pre><code><meta name="robots" content="noindex, nofollow" />
</code></pre>
|
<p>You can disallow search engines to read or index your content by restricting robot meta tags. In this way, spider will consider your instructions and will index only such pages that you want.</p>
| 6,560
|
<p>Does Server Core 2008 support asp.net? I see references online saying that it isn't supported, but they are all old references from CTPs.</p>
|
<p>No.</p>
<p>Answer here:
<a href="http://www.microsoft.com/windowsserver2008/en/us/compare-core-installation.aspx" rel="nofollow noreferrer">http://www.microsoft.com/windowsserver2008/en/us/compare-core-installation.aspx</a></p>
<p>"ASP.NET is not available with Server Core installation option in any edition"</p>
|
<p><a href="http://www.microsoft.com/windowsserver2008/en/us/compare-core-installation.aspx" rel="nofollow noreferrer">No</a></p>
| 9,102
|
<p><strong>Question</strong></p>
<p>How would you go adding automated testing to a game?</p>
<p>I believe you can unit test a lot of the game engine's functionality (networking, object creation, memory management, etc), but is it possible to automate test the actual game itself?</p>
<p>I'm not talking about gameplay elements (like Protoss would beat Zerg in map X), but I'm talking about the interaction between the game and the engine.</p>
<p><strong>Introduction</strong></p>
<p>In game development, the engine is just a platform for the game. You could think of the game engine as an OS and the game as a software the OS would run. The game could be a collection of scripts or an actual subroutine inside the game engine.</p>
<p><strong>Possible Answers</strong></p>
<p>My idea is this: </p>
<p>You would need an engine that is deterministic. This means that given one set of input, the output would be exactly the same. This would inlude the random generator being seeded with the same input.</p>
<p>Then, create a bare-bone level which contains a couple of objects the avatar/user can interact with. Start small and then add objects into the level as more interactions are developed.</p>
<p>Create a script which follows a path (tests pathfinding) and interact with the different objects (store the result or expected behavior). This script would be your automated test. After a certain amount of time (say, one week), run the script along with your engine's unit tests.</p>
|
<p><a href="http://gamesfromwithin.com/?p=97" rel="noreferrer">This post</a> at <a href="http://gamesfromwithin.com" rel="noreferrer">Games From Within</a> might be relevant/interesting. </p>
|
<p>This doesn't really answer your question but I was listening to a podcast on <a href="http://research.microsoft.com/pex/" rel="nofollow noreferrer">Pex from microsoft</a> which does a similar thing to the solution you're proposing and when I was listening to it I remember thinking that it would be really interesting to see if it would be able to test games. I don't know if it would be able to help you specifically, but perhaps you could take a look at some of the ideas they use and apply it to your unit testing.</p>
| 3,493
|
<p>I have a line color property in my custom grid control. I want it to default to <code>Drawing.SystemColors.InactiveBorder</code>. I tried:</p>
<pre><code>[DefaultValue(typeof(System.Drawing.SystemColors), "InactiveBorder")]
public Color LineColor { get; set; }
</code></pre>
<p>But it doesn't seem to work. How do I do that with the default value attribute?</p>
|
<p>You need to change first argument from <code>SystemColors</code> to <code>Color</code>.<br>
It seems that there is no type converter for the <code>SystemColors</code> type, only for the <code>Color</code> type.</p>
<pre><code>[DefaultValue(typeof(Color),"InactiveBorder")]
</code></pre>
|
<p>According to the link Matt posted, the DefaultValue attribute doesn't set the default value of the property, it just lets the form designer know that the property <em>has</em> a default value. If you change a property from the default value it is shown as bold in the properties window.</p>
<p>You can't set a default value using automatic properties - you'll have to do it the old-fashioned way:</p>
<pre><code>class MyClass
{
Color lineColor = SystemColors.InactiveBorder;
[DefaultValue(true)]
public Color LineColor {
get {
return lineColor;
}
set {
lineColor = value;
}
}
}
</code></pre>
| 6,529
|
<p>My firm have a talented and smart operations staff who are working very hard. I'd like to give them a SQL-execution tool that helps them avoid common, easily-detected SQL mistakes that are easy to make when they are in a hurry. Can anyone suggest such a tool? Details follow.</p>
<p>Part of the operations team remit is writing very complex ad-hoc SQL queries. Not surprisingly, operators sometimes make mistakes in the queries they write because they are so busy. </p>
<p>Luckily, their queries are all SELECTs not data-changing SQL, and they are running on a copy of the database anyway. Still, we'd like to prevent errors in the SQL they run. For instance, sometimes the mistakes lead to long-running queries that slow down the duplicate system they're using and inconvenience others until we find the culprit query and kill it. Worse, occasionally the mistakes lead to apparently-correct answers that we don't catch until much later, with consequent embarrassment. </p>
<p>Our developers also make mistakes in complex code that they write, but they have Eclipse and various plugins (such as <a href="http://findbugs.sourceforge.net/" rel="nofollow noreferrer" title="FindBugs">FindBugs</a>) that catch errors as they type. I'd like to give operators something similar - ideally it would see</p>
<pre><code>SELECT U.NAME, C.NAME FROM USER U, COMPANY C WHERE U.NAME = 'ibell';
</code></pre>
<p>and before you executed, it would say "Hey, did you realise that's a Cartesian product? Are you sure you want to do that?" It doesn't have to be very smart - finding obviously missing join conditions and similar evident errors would be fine.</p>
<p>It looks like <a href="http://www.toadsoft.com/" rel="nofollow noreferrer" title="TOAD">TOAD</a> should do this but I can't seem to find anything about such a feature. Are there other tools like TOAD that can provide this kind of semi-intelligent error correction?</p>
<p>Update: I forgot to mention that we're using MySQL.</p>
|
<p>If your people are using the mysql(1) program to run queries, you can use the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-tips.html" rel="nofollow noreferrer">safe-updates</a> option (aka i-am-a-dummy) to get you part of what you need. Its name is somewhat misleading; it not only prevents UPDATE and DELETE without a WHERE (which you're not worried about), but also adds an implicit LIMIT 1000 to SELECT statements, and aborts SELECTs that have joins and are estimated to consider over 1,000,000 tuples --- perfect for discouraging Cartesian joins.</p>
|
<p>You might find <a href="http://www.red-gate.com/Products/SQL_Prompt/index.htm" rel="nofollow noreferrer">SQL Prompt</a> from redgate useful. I'm not sure what database engine you're using, as it's only for MSSQL Server</p>
| 3,623
|
<p>So as the title said my heated bed stopped heating mid print. </p>
<p>I'm pretty confident the bed itself is not the problem as I've ran continuity tests from the wires and a resistance check (which showed a total resistance of about 1.5 ohms, which is where it should be). I've done voltage checks across the input terminals which showed a successful output of 12 V. </p>
<p>Finally I did a voltage test across the output terminal at D8 where the heated bed should be outputted to. The result came up with nearly 0 V. I then noticed that the LED that usually lights up for D8 was turned off. The weird thing is, I unplugged the wires from D8 and this time the LED lit up like it was supposed to. Due to this, I believe the problem to be with the MOSFET attached to D8. </p>
<p>My proposed solution would be to move the heated bed terminal to D9 instead of D8. I wish to this because despite the firmware set up for a fan, I do not have a fan attached to D9. This leaves this terminal open and with a potentially unharmed MOSFET. Despite this I have found no information on how to go about accomplishing this. </p>
<p>What do you guys think? Is that even a good idea or should the component (or board be replaced)? Any help would be greatly appreciated.</p>
|
<p>First you should check if the bed still works when applying 12V directly. You can then also check the voltage over the 12V output terminals to measure the power supply unit while it is powering the bed. It is unclear whether you measured the voltage of the PSU while it was powering a large load.</p>
<p>It is also a good idea to get the external MOSFET board out of the equation (the less components you have, the less you need to troubleshoot).</p>
<p>From the post can be concluded that you are using the so-called RAMPS EFB setup, e.g. in <a href="https://github.com/MarlinFirmware/Marlin/" rel="nofollow noreferrer">Marlin firmware</a> defined by constant <code>IS_RAMPS_EFB</code> in your firmware printer setup (Extruder on pin 10, fan on pin 9 and bed on pin 8).</p>
<p>In the pin configuration file <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/pins_RAMPS.h" rel="nofollow noreferrer">pins_RAMPS.h</a> you can find the following lines:</p>
<pre><code>#define FAN_PIN RAMPS_D9_PIN
#define HEATER_BED_PIN RAMPS_D8_PIN
</code></pre>
<p>To change the pin layout, switch the values of the constants.</p>
|
<p>you can swap pins in Marlin firmware.
When you download it from GitHub, there is a file called <a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/pins.h" rel="nofollow noreferrer">pins.h</a> (please be aware that this file is an example), and you can play with your setup to skip the broken mosfet.</p>
<p><strong>Sometimes, it could be easier and faster to desolder and swap elements directly on the board - that depends on the skill set we have</strong></p>
| 930
|
<p>What do I need to add to my <code>.spec</code> file to create the desktop shortcut and assign an icon to the shortcut during install of my <code>.rpm</code>? If a script is required, an example would be very helpful.</p>
|
<p>You use a .desktop file for icons under linux. Where to put the icon depends on what distribution and what desktop environment you are using. Since I'm currently running Gnome on Fedora 9, I will answer it in those terms.</p>
<p>An example foo.desktop file would be:</p>
<pre><code>[Desktop Entry]
Encoding=UTF-8
GenericName=Generic Piece Of Software
Name=FooBar
Exec=/usr/bin/foo.sh
Icon=foo.png
Terminal=false
Type=Application
Categories=Qt;Gnome;Applications;
</code></pre>
<p>The .desktop file should under Fedora 9 Gnome be located in /usr/share/applications/ , you can run a locate on .desktop to figure out where you should put in on your distro. Gnome will generally look in the KDE icon directory to see if there are other icons there also....</p>
<blockquote>
<p>Encoding, Name and Exec should speak for themselves.</p>
<ul>
<li>Generic name == Brief Description of application.</li>
<li>Icon == The image to display for the icon</li>
<li>Terminal == Is this a terminal application, should I start it as one?</li>
<li>Type == Type of program this is, can be used in placing the icon in a menu.</li>
<li>Categories == This information is what is mainly used to place the icon in a given menu if an XML file to specify such is not present. The setup for menus is handled a little differently by everyone.</li>
</ul>
</blockquote>
<p>There are more attributes you can set, but they aren't strictly necessary.</p>
<p>The image file used sits somewhere in the bowels of the /usr/share/icons/ directory. You can parse through that to find all the wonders of how such things work, but the basics are that you pick the directory for the icon type (in my case gnome) and place the image within the appropriate directory (there is a scalable directory for .svg images, and specific sizes such as 48x48 for raster images. Under Gnome all images are generally .png).</p>
|
<p>To create a desktop icon to an application follow the two steps below.</p>
<ol>
<li><p>In an Editor create a new file.</p>
<pre><code>gedit ~/.local/share/applications/NameYouWantForApplication.desktop
</code></pre></li>
<li><p>Place this section within the file and save it.</p>
<pre><code>[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=JeremysPentaho
Comment=Whatever Comment You want
Exec=/home/yourname@yourdomain.com/Source/Pentaho/data-integration/spoon.sh
Icon=/home/yourname@yourdomain.com/Source/Pentaho/data-integration/NameOfmyIconFile.jpg
Terminal=false
</code></pre></li>
</ol>
| 9,964
|
<p>I am trying to create a query string of variable assignments separated by the <code>&</code> symbol (ex: <code>"var1=x&var2=y&..."</code>). I plan to pass this string into an embedded flash file.</p>
<p>I am having trouble getting an <code>&</code> symbol to show up in XSLT. If I just type <code>&</code> with no tags around it, there is a problem rendering the XSLT document. If I type <code>&amp;</code> with no tags around it, then the output of the document is <code>&amp;</code> with no change. If I type <code><xsl:value-of select="&" /></code> or <code><xsl:value-of select="&amp;" /></code> I also get an error. Is this possible? Note: I have also tried <code>&amp;amp;</code> with no success.</p>
|
<p>You can combine <code>disable-output-escaping</code> with a <code>CDATA</code> section. Try this:</p>
<pre><code><xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text>
</code></pre>
|
<p>try:
<xsl:value-of select="&amp;" disable-output-escaping="yes"/></p>
<p>Sorry if the formatting is messed up.</p>
| 9,341
|
<p>What is the <strong>complete</strong> and correct syntax for the SQL Case expression?</p>
|
<p>The <strong>complete</strong> syntax depends on the database engine you're working with:</p>
<p>For SQL Server:</p>
<pre><code>CASE case-expression
WHEN when-expression-1 THEN value-1
[ WHEN when-expression-n THEN value-n ... ]
[ ELSE else-value ]
END
</code></pre>
<p>or:</p>
<pre><code>CASE
WHEN boolean-when-expression-1 THEN value-1
[ WHEN boolean-when-expression-n THEN value-n ... ]
[ ELSE else-value ]
END
</code></pre>
<p>expressions, etc:</p>
<pre><code>case-expression - something that produces a value
when-expression-x - something that is compared against the case-expression
value-1 - the result of the CASE statement if:
the when-expression == case-expression
OR the boolean-when-expression == TRUE
boolean-when-exp.. - something that produces a TRUE/FALSE answer
</code></pre>
<p>Link: <a href="http://msdn.microsoft.com/en-us/library/ms181765.aspx" rel="noreferrer">CASE (Transact-SQL)</a></p>
<p>Also note that the ordering of the WHEN statements is important. You can easily write multiple WHEN clauses that overlap, and <strong>the first one that matches is used</strong>.</p>
<p><strong>Note</strong>: If no ELSE clause is specified, and no matching WHEN-condition is found, the value of the CASE expression will be <em>NULL</em>.</p>
|
<p>Case statement syntax in SQL SERVER:</p>
<pre><code>CASE column
WHEN value1 THEN 1
WHEN value3 THEN 2
WHEN value3 THEN 3
WHEN value1 THEN 4
ELSE ''
END
</code></pre>
<p>And we can use like below also:</p>
<pre><code>CASE
WHEN column=value1 THEN 1
WHEN column=value3 THEN 2
WHEN column=value3 THEN 3
WHEN column=value1 THEN 4
ELSE ''
END
</code></pre>
| 2,661
|
<p>I am doing profiling of a C code in Microsoft VS 2005 on a Intel Core-2Duo platform.
I measure the time(secs:millisecs) counsumed by my function. But i have some doubts about the accuracy of this measurement as the operating system will not continuously run my application, but instead schedule others apps/services in between the execution of my code.(Although i have no major applications running while i do the profile run, still windows will have lot of code of its own which it will run by preempting my app.). Because of all this i believe the profiling number(time taken by my app to run) is not accurate. </p>
<p>So my question is there any way to find out the Operating system overheads, scheduling overhead on a typical windows system(I run Windows XP)e.g. if my applications says it ran for 60 milliseconds, out of that 60 msec, how much time really was used by my app. and how much time it was sitting idle, due to being pre-empted by some other task scheduled by the OS?</p>
<p>or </p>
<p>Atleast is there any ball-park number to get such OS overhead, based on your experience you came across while doing something similar?</p>
|
<p>@Kogus: Even if i run outside debugger(standalone app. from a command prompt) it still could be preempted by OS and cause a incorrect measurement of the time consumed by my app.</p>
<p>Is'nt it?</p>
<p>-AD</p>
|
<p><strong>Suggestion</strong></p>
<p>Try run on multi CPU systems. </p>
| 7,511
|
<p>I'm implementing a tagging system for a website. There are multiple tags per object and multiple objects per tag. This is accomplished by maintaining a table with two values per record, one for the ids of the object and the tag.</p>
<p>I'm looking to write a query to find the objects that match a given set of tags. Suppose I had the following data (in [object] -> [tags]* format)</p>
<pre><code>apple -> fruit red food
banana -> fruit yellow food
cheese -> yellow food
firetruck -> vehicle red
</code></pre>
<p>If I want to match (red), I should get apple and firetruck. If I want to match (fruit, food) I should get (apple, banana).</p>
<p>How do I write a SQL query do do what I want?</p>
<p>@Jeremy Ruten,</p>
<p>Thanks for your answer. The notation used was used to give some sample data - my database does have a table with 1 object id and 1 tag per record.</p>
<p>Second, my problem is that I need to get all objects that match all tags. Substituting your OR for an AND like so:</p>
<pre><code>SELECT object WHERE tag = 'fruit' AND tag = 'food';
</code></pre>
<p>Yields no results when run.</p>
|
<p>Given:</p>
<ul>
<li>object table (primary key id)</li>
<li>objecttags table (foreign keys objectId, tagid)</li>
<li><p>tags table (primary key id)</p>
<pre><code>SELECT distinct o.*
from object o join objecttags ot on o.Id = ot.objectid
join tags t on ot.tagid = t.id
where t.Name = 'fruit' or t.name = 'food';
</code></pre></li>
</ul>
<p>This seems backwards, since you want and, but the issue is, 2 tags aren't on the same row, and therefore, an and yields nothing, since 1 single row cannot be both a fruit and a food.
This query will yield duplicates usually, because you will get 1 row of each object, per tag.</p>
<p>If you wish to really do an and in this case, you will need a <code>group by</code>, and a <code>having count = <number of ors></code> in your query for example.</p>
<pre><code> SELECT distinct o.name, count(*) as count
from object o join objecttags ot on o.Id = ot.objectid
join tags t on ot.tagid = t.id
where t.Name = 'fruit' or t.name = 'food'
group by o.name
having count = 2;
</code></pre>
|
<p>I'd suggest making your table have 1 tag per record, like this:</p>
<pre><code> apple -> fruit
apple -> red
apple -> food
banana -> fruit
banana -> yellow
banana -> food
</code></pre>
<p>Then you could just</p>
<pre><code> SELECT object WHERE tag = 'fruit' OR tag = 'food';
</code></pre>
<p>If you really want to do it your way though, you could do it like this:</p>
<pre><code> SELECT object WHERE tag LIKE 'red' OR tag LIKE '% red' OR tag LIKE 'red %' OR tag LIKE '% red %';
</code></pre>
| 4,436
|
<p>I'm displaying a set of images as an overlay using Google Maps. Displaying these images should be in an endless loop but most most browsers detect this, and display a warning. </p>
<p>Is there a way to make a endless loop in JavaScript so that it isn't stopped or warned against by the browser?</p>
|
<p>Try <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval" rel="nofollow noreferrer">setInterval</a> or <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/settimeout" rel="nofollow noreferrer">setTimeout</a>.</p>
<p>Here is an example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>(show = (o) => setTimeout(() => {
console.log(o)
show(++o)
}, 1000))(1);</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code></pre>
</div>
</div>
</p>
|
<p>Perhaps try using a timer which retrieves the next image each time it ticks, unfortunately i don't know any JavaScript so I can't provide a code sample</p>
| 8,855
|
<p>What do I need to look at to see whether I'm on Windows or Unix, etc?</p>
|
<pre><code>>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'
</code></pre>
<p>The output of <a href="https://docs.python.org/library/platform.html#platform.system" rel="noreferrer"><code>platform.system()</code></a> is as follows:</p>
<ul>
<li>Linux: <code>Linux</code></li>
<li>Mac: <code>Darwin</code></li>
<li>Windows: <code>Windows</code></li>
</ul>
<p>See: <a href="https://docs.python.org/library/platform.html" rel="noreferrer"><code>platform</code> — Access to underlying platform’s identifying data</a></p>
|
<p>How about a simple Enum implementation like the following? No need for external libs!</p>
<pre><code>import platform
from enum import Enum
class OS(Enum):
def checkPlatform(osName):
return osName.lower()== platform.system().lower()
MAC = checkPlatform("darwin")
LINUX = checkPlatform("linux")
WINDOWS = checkPlatform("windows") #I haven't test this one
</code></pre>
<p>Simply you can access with Enum value</p>
<pre><code>if OS.LINUX.value:
print("Cool it is Linux")
</code></pre>
<p>P.S It is python3</p>
| 2,412
|
<p>I have a relationship between two entities (e1 and e2) and e1 has a collection of e2, however I have a similar relationship set up between (e2 and e3), yet e2 does not contain a collection of e3's, any reason why this would happen? Anything I can post to make this easier to figure out?</p>
<p>Edit: I just noticed that the relationship between e1 and e2 is solid and between e2 and e3 is dotted, what causes that? Is it related?</p>
|
<p><strong>Using this setup, everything worked.</strong> </p>
<p><em>1) LINQ to SQL Query, 2) DB Tables, 3) LINQ to SQL Data Model in VS.NET 2008</em></p>
<p><strong>1 - LINQ to SQL Query</strong></p>
<pre><code>DataClasses1DataContext db = new DataClasses1DataContext();
var results = from threes in db.tableThrees
join twos in db.tableTwos on threes.fk_tableTwo equals twos.id
join ones in db.tableOnes on twos.fk_tableOne equals ones.id
select new { ones, twos, threes };
</code></pre>
<p><strong>2 - Database Scripts</strong></p>
<pre><code>--Table One
CREATE TABLE tableOne(
[id] [int] IDENTITY(1,1) NOT NULL,
[value] [nvarchar](50) NULL,
CONSTRAINT [PK_tableOne] PRIMARY KEY CLUSTERED
( [id] ASC ) WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
--Table Two
CREATE TABLE tableTwo(
[id] [int] IDENTITY(1,1) NOT NULL,
[value] [nvarchar](50) NULL,
[fk_tableOne] [int] NOT NULL,
CONSTRAINT [PK_tableTwo] PRIMARY KEY CLUSTERED
( [id] ASC ) WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
ALTER TABLE tableTwo WITH CHECK
ADD CONSTRAINT [FK_tableTwo_tableOne]
FOREIGN KEY([fk_tableOne])
REFERENCES tableOne ([id]);
ALTER TABLE tableTwo CHECK CONSTRAINT [FK_tableTwo_tableOne];
--Table Three
CREATE TABLE tableThree(
[id] [int] IDENTITY(1,1) NOT NULL,
[value] [nvarchar](50) NULL,
[fk_tableTwo] [int] NOT NULL,
CONSTRAINT [PK_tableThree] PRIMARY KEY CLUSTERED
([id] ASC ) WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
ALTER TABLE tableThree WITH CHECK
ADD CONSTRAINT [FK_tableThree_tableTwo]
FOREIGN KEY([fk_tableTwo])
REFERENCES tableTwo ([id]);
ALTER TABLE tableThree CHECK CONSTRAINT [FK_tableThree_tableTwo];
</code></pre>
<p><strong>3 - LINQ to SQL Data Model in Visual Studio</strong> </p>
<p><a href="http://i478.photobucket.com/albums/rr148/KyleLanser/ThreeLevelHierarchy.png" rel="nofollow noreferrer">alt text http://i478.photobucket.com/albums/rr148/KyleLanser/ThreeLevelHierarchy.png</a> </p>
|
<p>the FK_Contraints are set up like this:</p>
<p>ALTER TABLE [dbo].[e2] WITH CHECK ADD CONSTRAINT [FK_e2_e1] FOREIGN KEY([E1Id]) REFERENCES [dbo].[e1] ([Id])</p>
<p>ALTER TABLE [dbo].[e3] WITH CHECK ADD CONSTRAINT [FK_e3_e2] FOREIGN KEY([E2Id]) REFERENCES [dbo].[e2] ([Id])</p>
<p>is this what you were asking for?</p>
| 7,369
|
<p>In Firefox you can enter the following into the awesome bar and hit enter:</p>
<pre><code>javascript:self.resizeTo(1024,768);
</code></pre>
<p>How do you do the same thing in IE?</p>
|
<pre><code>javascript:resizeTo(1024,768);
vbscript:resizeto(1024,768)</code></pre>
<p>Will work in IE7, But consider using something like</p>
<pre><code>javascript:moveTo(0,0);resizeTo(1024,768);</code></pre>
<p>because IE7 doesn't allow the window to "resize" beyond the screen borders. If you work on a 1024,768 desktop, this is what happens...<ul><li>Firefox: 1024x768 Window, going behind the taskbar. If you drop the moveTo part, the top left corner of the window won't change position.(You still get a 1024x768 window)</li>
<li>IE7: As close as possible to the requested size without obscuring the taskbar or allowing any part of the window to lie beyond the screen borders.</li>
<li>safari: As close as possible to the requested size without obscuring the taskbar or allowing any part of the window to lie beyond the screen borders, but you can ommit the moveTo part. Safari will move the top left corner of the window for you.</li>
<li>Opera: Nothing happens.</li>
<li>Chrome: Nothing happens.</li></p>
<p></ul></p>
|
<p>It works in IE6, but I think IE7 added some security around this?</p>
| 8,480
|
<p>Our investigations have shown us that not all browsers respect the HTTP cache directives in a uniform manner.</p>
<p>For security reasons we do not want certain pages in our application to be cached, <strong>ever,</strong> by the web browser. This must work for at least the following browsers:</p>
<ul>
<li>Internet Explorer 6+</li>
<li>Firefox 1.5+</li>
<li>Safari 3+</li>
<li>Opera 9+</li>
<li>Chrome</li>
</ul>
<p>Our requirement came from a security test. After logging out from our website you could press the back button and view cached pages.</p>
|
<h1>Introduction</h1>
<p>The correct minimum set of headers that works across all mentioned clients (and proxies):</p>
<pre><code>Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
</code></pre>
<p>The <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9" rel="noreferrer"><code>Cache-Control</code></a> is per the HTTP 1.1 spec for clients and proxies (and implicitly required by some clients next to <code>Expires</code>). The <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32" rel="noreferrer"><code>Pragma</code></a> is per the HTTP 1.0 spec for prehistoric clients. The <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21" rel="noreferrer"><code>Expires</code></a> is per the HTTP 1.0 and 1.1 specs for clients and proxies. In HTTP 1.1, the <code>Cache-Control</code> takes precedence over <code>Expires</code>, so it's after all for HTTP 1.0 proxies only.</p>
<p>If you don't care about IE6 and its broken caching when serving pages over HTTPS with only <code>no-store</code>, then you could omit <code>Cache-Control: no-cache</code>.</p>
<pre><code>Cache-Control: no-store, must-revalidate
Pragma: no-cache
Expires: 0
</code></pre>
<p>If you don't care about IE6 nor HTTP 1.0 clients (HTTP 1.1 was introduced in 1997), then you could omit <code>Pragma</code>.</p>
<pre><code>Cache-Control: no-store, must-revalidate
Expires: 0
</code></pre>
<p>If you don't care about HTTP 1.0 proxies either, then you could omit <code>Expires</code>.</p>
<pre><code>Cache-Control: no-store, must-revalidate
</code></pre>
<p>On the other hand, if the server auto-includes a valid <code>Date</code> header, then you could theoretically omit <code>Cache-Control</code> too and rely on <code>Expires</code> only.</p>
<pre><code>Date: Wed, 24 Aug 2016 18:32:02 GMT
Expires: 0
</code></pre>
<p>But that may fail if e.g. the end-user manipulates the operating system date and the client software is relying on it.</p>
<p>Other <code>Cache-Control</code> parameters such as <code>max-age</code> are irrelevant if the abovementioned <code>Cache-Control</code> parameters are specified. The <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29" rel="noreferrer"><code>Last-Modified</code></a> header as included in most other answers here is <em>only</em> interesting if you <strong>actually want</strong> to cache the request, so you don't need to specify it at all.</p>
<h1>How to set it?</h1>
<p>Using PHP:</p>
<pre class="lang-php prettyprint-override"><code>header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
</code></pre>
<p>Using Java Servlet, or Node.js:</p>
<pre class="lang-java prettyprint-override"><code>response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
</code></pre>
<p>Using ASP.NET-MVC</p>
<pre class="lang-cs prettyprint-override"><code>Response.Cache.SetCacheability(HttpCacheability.NoCache); // HTTP 1.1.
Response.Cache.AppendCacheExtension("no-store, must-revalidate");
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.
</code></pre>
<p>Using ASP.NET Web API:</p>
<pre class="lang-cs prettyprint-override"><code>// `response` is an instance of System.Net.Http.HttpResponseMessage
response.Headers.CacheControl = new CacheControlHeaderValue
{
NoCache = true,
NoStore = true,
MustRevalidate = true
};
response.Headers.Pragma.ParseAdd("no-cache");
// We can't use `response.Content.Headers.Expires` directly
// since it allows only `DateTimeOffset?` values.
response.Content?.Headers.TryAddWithoutValidation("Expires", 0.ToString());
</code></pre>
<p>Using ASP.NET:</p>
<pre class="lang-cs prettyprint-override"><code>Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.
</code></pre>
<p>Using ASP.NET Core v3</p>
<pre class="lang-c# prettyprint-override"><code>// using Microsoft.Net.Http.Headers
Response.Headers[HeaderNames.CacheControl] = "no-cache, no-store, must-revalidate";
Response.Headers[HeaderNames.Expires] = "0";
Response.Headers[HeaderNames.Pragma] = "no-cache";
</code></pre>
<p>Using ASP:</p>
<pre class="lang-vb prettyprint-override"><code>Response.addHeader "Cache-Control", "no-cache, no-store, must-revalidate" ' HTTP 1.1.
Response.addHeader "Pragma", "no-cache" ' HTTP 1.0.
Response.addHeader "Expires", "0" ' Proxies.
</code></pre>
<p>Using Ruby on Rails:</p>
<pre class="lang-ruby prettyprint-override"><code>headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1.
headers["Pragma"] = "no-cache" # HTTP 1.0.
headers["Expires"] = "0" # Proxies.
</code></pre>
<p>Using Python/Flask:</p>
<pre class="lang-python prettyprint-override"><code>response = make_response(render_template(...))
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1.
response.headers["Pragma"] = "no-cache" # HTTP 1.0.
response.headers["Expires"] = "0" # Proxies.
</code></pre>
<p>Using Python/Django:</p>
<pre class="lang-python prettyprint-override"><code>response["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1.
response["Pragma"] = "no-cache" # HTTP 1.0.
response["Expires"] = "0" # Proxies.
</code></pre>
<p>Using Python/Pyramid:</p>
<pre class="lang-python prettyprint-override"><code>request.response.headerlist.extend(
(
('Cache-Control', 'no-cache, no-store, must-revalidate'),
('Pragma', 'no-cache'),
('Expires', '0')
)
)
</code></pre>
<p>Using Go:</p>
<pre class="lang-default prettyprint-override"><code>responseWriter.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1.
responseWriter.Header().Set("Pragma", "no-cache") // HTTP 1.0.
responseWriter.Header().Set("Expires", "0") // Proxies.
</code></pre>
<p>Using Clojure (require Ring utils):</p>
<pre class="lang-clj prettyprint-override"><code>(require '[ring.util.response :as r])
(-> response
(r/header "Cache-Control" "no-cache, no-store, must-revalidate")
(r/header "Pragma" "no-cache")
(r/header "Expires" 0))
</code></pre>
<p>Using Apache <code>.htaccess</code> file:</p>
<pre class="lang-xml prettyprint-override"><code><IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
</code></pre>
<p>Using HTML:</p>
<pre class="lang-html prettyprint-override"><code><meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
</code></pre>
<h1>HTML meta tags vs HTTP response headers</h1>
<p>Important to know is that when an HTML page is served over an HTTP connection, and a header is present in <strong>both</strong> the HTTP response headers and the HTML <code><meta http-equiv></code> tags, then the one specified in the HTTP response header will get precedence over the HTML meta tag. The HTML meta tag will only be used when the page is viewed from a local disk file system via a <code>file://</code> URL. See also <a href="http://www.w3.org/TR/html4/charset.html#h-5.2.2" rel="noreferrer">W3 HTML spec chapter 5.2.2</a>. Take care with this when you don't specify them programmatically because the webserver can namely include some default values.</p>
<p>Generally, you'd better just <strong>not</strong> specify the HTML meta tags to avoid confusion by starters and rely on hard HTTP response headers. Moreover, specifically those <code><meta http-equiv></code> tags are <a href="http://validator.w3.org" rel="noreferrer"><strong>invalid</strong></a> in HTML5. Only the <code>http-equiv</code> values listed in <a href="http://w3c.github.io/html/document-metadata.html#pragma-directives" rel="noreferrer">HTML5 specification</a> are allowed.</p>
<h1>Verifying the actual HTTP response headers</h1>
<p>To verify the one and the other, you can see/debug them in the HTTP traffic monitor of the web browser's developer toolset. You can get there by pressing F12 in Chrome/Firefox23+/IE9+, and then opening the "Network" or "Net" tab panel, and then clicking the HTTP request of interest to uncover all detail about the HTTP request and response. The <a href="https://i.stack.imgur.com/fSnXH.png" rel="noreferrer">below screenshot</a> is from Chrome:</p>
<p><img src="https://i.stack.imgur.com/fSnXH.png" alt="Chrome developer toolset HTTP traffic monitor showing HTTP response headers on stackoverflow.com" /></p>
<h1>I want to set those headers on file downloads too</h1>
<p>First of all, this question and answer are targeted on "web pages" (HTML pages), not "file downloads" (PDF, zip, Excel, etc). You'd better have them cached and make use of some file version identifier somewhere in the URI path or query string to force a redownload on a changed file. When applying those no-cache headers on file downloads anyway, then beware of the IE7/8 bug when serving a file download over HTTPS instead of HTTP. For detail, see <a href="https://stackoverflow.com/q/5034454">IE cannot download foo.jsf. IE was not able to open this internet site. The requested site is either unavailable or cannot be found</a>.</p>
|
<p>you can use location block for set individual file instead of whole app get caching in IIS </p>
<pre><code> <location path="index.html">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
</code></pre>
| 7,215
|
<p>Has anyone successfully talked <a href="http://www.profibus.com/" rel="noreferrer">profibus</a> from a .NET application?</p>
<p>If you did, what device/card did you use to accomplish this, what was the application, and did you use any kind of preexisting or available code?</p>
|
<p>We've not used Profibus, but have used <strong>DeviceNET</strong> (another CAN based protocol), <strong>Ethernet/IP</strong> and <strong>ControlNet</strong> which all have similar challenges.</p>
<p>We've been doing this since the late 1990's and therefore rely mainly on our own generated code using off-the-shelf hardware. The companies that have shown longevity during that period that I remember are:-</p>
<ul>
<li>AnyBus (HMS, <a href="http://www.anybus.com" rel="noreferrer">www.anybus.com</a>) we've recently started using their gateway products as we can place fieldbus interfaces close to the hardware and then communicate over normal Ethernet (usually using Ethernet/IP <a href="http://www.odva.org" rel="noreferrer">www.odva.org</a>). This has the advantage of separating hardware and PC using only a network cable. The Ethernet/IP .NET classes were written by ourselves as nothing much was on the market at the time. I'm sure a quick google search would find suitable class libraries</li>
<li>SST (<a href="http://www.mysst.com" rel="noreferrer">www.mysst.com</a>) have had fieldbus interfaces for more than a decade. The last SST card we used for DeviceNET still only had VB6 sample code. A good selection of fieldbus support and different form-factors e.g. PC104, PCI, PMCIA</li>
<li>Beckhoff/Wago (<a href="http://www.beckhoff.com" rel="noreferrer">www.beckhoff.com</a>, <a href="http://www.beckhoff.com" rel="noreferrer">www.wago.com</a>) we typically use Beckhoff for the I/O more than the interface cards but again a company that has been around a long time. They also have products that support exposing using OPC (another way for you to get I/O information without directly communicating with the hardware/devicedrivers)</li>
</ul>
<p>I suggest not using OPC interfaces to the hardware directly (it’s OK for communication using PC (.NET)->PLC->Profibus) as you need to ensure that the control system responds to loss of control from your .NET application. I’m assuming that you are needing a profibus Master here (not a slave), so as long as your control system is intrinsically fail safe, then loss of communication should mean the control system enters an "Idle" state and therefore most of the I/O will return to the fails safe state.</p>
<p>We also try to ensure that we do not put safety related code in .NET. Most of our .NET code is userinterface from a PLC, but in some places we do control the fieldbus directly but ensure hardware interlocks will prevent un-safe operation, either using safety switches/relays or a small PLC with the the task of interlocking only. <strong>And above all make the system fail-safe!</strong> Loss of comms from the .NET code should shutdown the automation to the fail-safe state.</p>
|
<p>Try this: <a href="http://libnodave.sourceforge.net" rel="nofollow noreferrer">http://libnodave.sourceforge.net</a></p>
| 9,220
|
<p>I believe the application has some parts that target .NET, and some that don't. I'm particularly interested in looking at the resource files, if there are any.</p>
|
<p>If you want to disassemble native x86/64 app use <a href="http://www.idapro.ru" rel="nofollow noreferrer">IDA</a>, .NET exe/dll can be disassembled using Reflector. There are <a href="http://www.google.ru/search?complete=1&hl=en&newwindow=1&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=v1M&q=extract+resource+from+exe+file&btnG=%D0%9F%D0%BE%D0%B8%D1%81%D0%BA&lr=&aq=f&oq=" rel="nofollow noreferrer">tons</a> of utilities to extract resources. Can you elaborate your question a bit?</p>
|
<p>Looking at the resource files isn't really "disassembling" (not really) and if that's all you want to do you can just open the .exe or .dll inside Visual Studio or a similar tool and it will give you a resources view.</p>
| 8,617
|
<p>In the ContainsIngredients method in the following code, is it possible to cache the <em>p.Ingredients</em> value instead of explicitly referencing it several times? This is a fairly trivial example that I just cooked up for illustrative purposes, but the code I'm working on references values deep inside <em>p</em> eg. <em>p.InnerObject.ExpensiveMethod().Value</em></p>
<p>edit:
I'm using the PredicateBuilder from <a href="http://www.albahari.com/nutshell/predicatebuilder.html" rel="nofollow noreferrer">http://www.albahari.com/nutshell/predicatebuilder.html</a></p>
<pre><code>public class IngredientBag
{
private readonly Dictionary<string, string> _ingredients = new Dictionary<string, string>();
public void Add(string type, string name)
{
_ingredients.Add(type, name);
}
public string Get(string type)
{
return _ingredients[type];
}
public bool Contains(string type)
{
return _ingredients.ContainsKey(type);
}
}
public class Potion
{
public IngredientBag Ingredients { get; private set;}
public string Name {get; private set;}
public Potion(string name) : this(name, null)
{
}
public Potion(string name, IngredientBag ingredients)
{
Name = name;
Ingredients = ingredients;
}
public static Expression<Func<Potion, bool>>
ContainsIngredients(string ingredientType, params string[] ingredients)
{
var predicate = PredicateBuilder.False<Potion>();
// Here, I'm accessing p.Ingredients several times in one
// expression. Is there any way to cache this value and
// reference the cached value in the expression?
foreach (var ingredient in ingredients)
{
var temp = ingredient;
predicate = predicate.Or (
p => p.Ingredients != null &&
p.Ingredients.Contains(ingredientType) &&
p.Ingredients.Get(ingredientType).Contains(temp));
}
return predicate;
}
}
[STAThread]
static void Main()
{
var potions = new List<Potion>
{
new Potion("Invisibility", new IngredientBag()),
new Potion("Bonus"),
new Potion("Speed", new IngredientBag()),
new Potion("Strength", new IngredientBag()),
new Potion("Dummy Potion")
};
potions[0].Ingredients.Add("solid", "Eye of Newt");
potions[0].Ingredients.Add("liquid", "Gall of Peacock");
potions[0].Ingredients.Add("gas", "Breath of Spider");
potions[2].Ingredients.Add("solid", "Hair of Toad");
potions[2].Ingredients.Add("gas", "Peacock's anguish");
potions[3].Ingredients.Add("liquid", "Peacock Sweat");
potions[3].Ingredients.Add("gas", "Newt's aura");
var predicate = Potion.ContainsIngredients("solid", "Newt", "Toad")
.Or(Potion.ContainsIngredients("gas", "Spider", "Scorpion"));
foreach (var result in
from p in potions
where(predicate).Compile()(p)
select p)
{
Console.WriteLine(result.Name);
}
}
</code></pre>
|
<p>Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.Ingredients as a parameter...</p>
<pre><code>private static bool IsIngredientPresent(IngredientBag i, string ingredientType, string ingredient)
{
return i != null && i.Contains(ingredientType) && i.Get(ingredientType).Contains(ingredient);
}
public static Expression<Func<Potion, bool>>
ContainsIngredients(string ingredientType, params string[] ingredients)
{
var predicate = PredicateBuilder.False<Potion>();
// Here, I'm accessing p.Ingredients several times in one
// expression. Is there any way to cache this value and
// reference the cached value in the expression?
foreach (var ingredient in ingredients)
{
var temp = ingredient;
predicate = predicate.Or(
p => IsIngredientPresent(p.Ingredients, ingredientType, temp));
}
return predicate;
}
</code></pre>
|
<p>I would say no in this case. I assume that the compiler can figure out that it uses the <code>p.Ingredients</code> variable 3 times and will keep the variable closeby on the stack or the registers or whatever it uses.</p>
| 9,189
|
<p>Currently my app uses just Direct3D9 for graphics, however in the future I' m planning to extend this to D3D10 and possibly OpenGL. The question is how can I do this in a tidy way?</p>
<p>At present there are various Render methods in my code</p>
<pre><code>void Render(boost::function<void()> &Call)
{
D3dDevice->BeginScene();
Call();
D3dDevice->EndScene();
D3dDevice->Present(0,0,0,0);
}
</code></pre>
<p>The function passed then depends on the exact state, eg MainMenu->Render, Loading->Render, etc. These will then oftern call the methods of other objects.</p>
<pre><code>void RenderGame()
{
for(entity::iterator it = entity::instances.begin();it != entity::instance.end(); ++it)
(*it)->Render();
UI->Render();
}
</code></pre>
<p>And a sample class derived from entity::Base</p>
<pre><code>class Sprite: public Base
{
IDirect3DTexture9 *Tex;
Point2 Pos;
Size2 Size;
public:
Sprite(IDirect3DTexture9 *Tex, const Point2 &Pos, const Size2 &Size);
virtual void Render();
};
</code></pre>
<p>Each method then takes care of how best to render given the more detailed settings (eg are pixel shaders supported or not).</p>
<p>The problem is I'm really not sure how to extend this to be able to use one of, what may be somewhat different (D3D v OpenGL) render modes...</p>
|
<p>Define an interface that is sufficient for your application's graphic output demands. Then implement this interface for every renderer you want to support.</p>
<pre><code>class IRenderer {
public:
virtual ~IRenderer() {}
virtual void RenderModel(CModel* model) = 0;
virtual void DrawScreenQuad(int x1, int y1, int x2, int y2) = 0;
// ...etc...
};
class COpenGLRenderer : public IRenderer {
public:
virtual void RenderModel(CModel* model) {
// render model using OpenGL
}
virtual void DrawScreenQuad(int x1, int y1, int x2, int y2) {
// draw screen aligned quad using OpenGL
}
};
class CDirect3DRenderer : public IRenderer {
// similar, but render using Direct3D
};
</code></pre>
<p>Properly designing and maintaining these interfaces can be very challenging though.</p>
<p>In case you also operate with render driver dependent objects like textures, you can use a factory pattern to have the separate renderers each create their own implementation of e.g. ITexture using a factory method in IRenderer:</p>
<pre><code>class IRenderer {
//...
virtual ITexture* CreateTexture(const char* filename) = 0;
//...
};
class COpenGLRenderer : public IRenderer {
//...
virtual ITexture* CreateTexture(const char* filename) {
// COpenGLTexture is the OpenGL specific ITexture implementation
return new COpenGLTexture(filename);
}
//...
};
</code></pre>
<p>Isn't it an idea to look at existing (3d) engines though? In my experience designing this kind of interfaces really distracts from what you actually want to make :)</p>
|
<p>I'd say if you want a really complete the answer, go look at the source code for <code>Ogre3D</code>. They have both <code>D3D</code> and <code>OpenGL</code> back ends. Look at : <a href="http://www.ogre3d.org" rel="nofollow noreferrer">http://www.ogre3d.org</a>
Basically their API kind of forces you into working in a D3D-ish way, creating buffer objects and stuffing them with data, then issuing draw calls on those buffers. That's the way the hardware likes it anyway, so it's not a bad way to go. </p>
<p>And then once you see how they do things, you might as well just just go ahead and use it and save yourself the trouble of having to re-implement all that it already provides. :-)</p>
| 8,573
|
<p>Using reflection, I need to load 2 different versions of the same assembly. Can I load the 2 versions in 2 different AppDomains in the same process? </p>
<p>I need to do some data migration from the old version of the app to the new version.
Please let me know if this is possible or should I use 2 separate processes.</p>
|
<p>If you are doing it at design time (which you indicate you are not) this should help you: </p>
<p><a href="http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx</a></p>
<p>If you are doing it dynamically through reflection (looks like the case here) this might help you:</p>
<p><a href="https://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html" rel="nofollow noreferrer">https://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html</a></p>
|
<p>If you are doing it at design time (which you indicate you are not) this should help you: </p>
<p><a href="http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx</a></p>
<p>If you are doing it dynamically through reflection (looks like the case here) this might help you:</p>
<p><a href="https://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html" rel="nofollow noreferrer">https://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html</a></p>
| 8,248
|
<p>I have a table with an XML column. This column is storing some values I keep for configuring my application. I created it to have a more flexible schema.
I can't find a way to update this column directly from the table view in SQL Management Studio. Other (INT or Varchar for example) columns are editable. I know I can write an UPDATE statement or create some code to update it. But I'm looking for something more flexible that will let power users edit the XML directly.</p>
<p>Any ideas?</p>
<blockquote>
<p>Reiterating again: Please don't answer
I can write an application. I know
that, And that is exactly what I'm
trying to avoid.</p>
</blockquote>
|
<p>This is an old question, but I needed to do this today. The best I can come up with is to write a query that generates SQL code that can be edited in the query editor - it's sort of lame but it saves you copy/pasting stuff.</p>
<p>Note: you may need to go into Tools > Options > Query Results > Results to Text and set the maximum number of characters displayed to a large enough number to fit your XML fields.</p>
<p>e.g.</p>
<pre><code>select 'update [table name] set [xml field name] = ''' +
convert(varchar(max), [xml field name]) +
''' where [primary key name] = ' +
convert(varchar(max), [primary key name]) from [table name]
</code></pre>
<p>which produces a lot of queries that look like this (with some sample table/field names):</p>
<pre><code>update thetable set thedata = '<root><name>Bob</name></root>' where thekey = 1
</code></pre>
<p>You then copy these queries from the results window back up to the query window, edit the xml strings, and then run the queries.</p>
<p>(Edit: changed 10 to max to avoid error)</p>
|
<p>I do not think you can use the Management Studio GUI to update XML-columns without writing the UPDATE-command yourself.</p>
<p>One way you could let users update xml-data is to write a simple .net based program (winforms or asp.net) and then select/update the data from there. This way you can also sanitize the data and easily validate it against any given schema before inserting/updating the information.</p>
| 7,640
|
<p><strong>Is there anything built into the core C# libraries that can give me an immutable Dictionary?</strong> </p>
<p>Something along the lines of <em>Java's</em>:</p>
<pre><code>Collections.unmodifiableMap(myMap);
</code></pre>
<p>And just to clarify, I am not looking to stop the keys / values themselves from being changed, just the structure of the Dictionary. I want something that fails fast and loud if any of IDictionary's mutator methods are called (<code>Add, Remove, Clear</code>).</p>
|
<p>No, but a wrapper is rather trivial:</p>
<pre><code>public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{
IDictionary<TKey, TValue> _dict;
public ReadOnlyDictionary(IDictionary<TKey, TValue> backingDict)
{
_dict = backingDict;
}
public void Add(TKey key, TValue value)
{
throw new InvalidOperationException();
}
public bool ContainsKey(TKey key)
{
return _dict.ContainsKey(key);
}
public ICollection<TKey> Keys
{
get { return _dict.Keys; }
}
public bool Remove(TKey key)
{
throw new InvalidOperationException();
}
public bool TryGetValue(TKey key, out TValue value)
{
return _dict.TryGetValue(key, out value);
}
public ICollection<TValue> Values
{
get { return _dict.Values; }
}
public TValue this[TKey key]
{
get { return _dict[key]; }
set { throw new InvalidOperationException(); }
}
public void Add(KeyValuePair<TKey, TValue> item)
{
throw new InvalidOperationException();
}
public void Clear()
{
throw new InvalidOperationException();
}
public bool Contains(KeyValuePair<TKey, TValue> item)
{
return _dict.Contains(item);
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
_dict.CopyTo(array, arrayIndex);
}
public int Count
{
get { return _dict.Count; }
}
public bool IsReadOnly
{
get { return true; }
}
public bool Remove(KeyValuePair<TKey, TValue> item)
{
throw new InvalidOperationException();
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return _dict.GetEnumerator();
}
System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
{
return ((System.Collections.IEnumerable)_dict).GetEnumerator();
}
}
</code></pre>
<p>Obviously, you can change the this[] setter above if you want to allow modifying values. </p>
|
<p>There's also another alternative as I have described at:</p>
<p><a href="http://www.softwarerockstar.com/2010/10/readonlydictionary-tkey-tvalue/" rel="nofollow">http://www.softwarerockstar.com/2010/10/readonlydictionary-tkey-tvalue/</a></p>
<p>Essentially it's a subclass of ReadOnlyCollection>, which gets the work done in a more elegant manner. Elegant in the sense that it has compile-time support for making the Dictionary read-only rather than throwing exceptions from methods that modify the items within it.</p>
| 5,542
|
<p>I print a lot of stuff, and I was thinking I could get several magnetic bed-plates and when 1 print is done simply have my wife pull the plate off and stick on clean plate and start the print again.
But a friend of mine says that won't work. Because even if the plates are made by the same manufacturer you can't guarantee the bed will be level. 〰</p>
<p>Has anyone ever tried this? </p>
|
<p>It is a question of quality:</p>
<p>You better make sure that your plates are the same thickness evenly, and level very similarly. If that can be assured, they can be swapped easily.</p>
<p>In case you have a bed leveling sensor of some sort, you might include a whole bed-leveling cycle in front of every print and exchange between numerous beds, even of slightly variant thicknesses and with dings.</p>
|
<p>Yes ,I was also facing the same problem couples of month ago and to solution I had buyed extra plates and <strong>It works perfectly</strong> . Go for the extra beds and buy only from the same manufacturer.</p>
<p>Hope your get your answer</p>
| 2,104
|
<p>I'm going to be starting a project soon that requires support for large-ish binary files. I'd like to use Ruby on Rails for the webapp, but I'm concerned with the BLOB support. In my experience with other languages, frameworks, and databases, BLOBs are often overlooked and thus have poor, difficult, and/or buggy functionality.</p>
<p>Does RoR spport BLOBs adequately? Are there any gotchas that creep up once you're already committed to Rails?</p>
<p>BTW: I want to be using PostgreSQL and/or MySQL as the backend database. Obviously, BLOB support in the underlying database is important. For the moment, I want to avoid focusing on the DB's BLOB capabilities; I'm more interested in how Rails itself reacts. Ideally, Rails should be hiding the details of the database from me, and so I should be able to switch from one to the other. If this is <em>not</em> the case (ie: there's some problem with using Rails with a particular DB) then please do mention it. </p>
<p>UPDATE: Also, I'm not just talking about ActiveRecord here. I'll need to handle binary files on the HTTP side (file upload effectively). That means getting access to the appropriate HTTP headers and streams via Rails. I've updated the question title and description to reflect this.</p>
|
<p>+1 for attachment_fu</p>
<p>I use attachment_fu in one of my apps and MUST store files in the DB (for annoying reasons which are outside the scope of this convo).</p>
<p>The (one?) tricky thing dealing w/BLOB's I've found is that you need a separate code path to send the data to the user -- you can't simply in-line a path on the filesystem like you would if it was a plain-Jane file.</p>
<p>e.g. if you're storing avatar information, you can't simply do:</p>
<pre><code><%= image_tag @youruser.avatar.path %>
</code></pre>
<p>you have to write some wrapper logic and use send_data, e.g. (below is JUST an example w/attachment_fu, in practice you'd need to DRY this up)</p>
<pre><code>send_data(@youruser.avatar.current_data, :type => @youruser.avatar.content_type, :filename => @youruser.avatar.filename, :disposition => 'inline' )
</code></pre>
<p>Unfortunately, as far as I know attachment_fu (I don't have the latest version) does not do clever wrapping for you -- you've gotta write it yourself.</p>
<p>P.S.
Seeing your question edit - Attachment_fu handles all that annoying stuff that you mention -- about needing to know file paths and all that crap -- EXCEPT the one little issue when storing in the DB. Give it a try; it's the standard for rails apps. IF you insist on re-inventing the wheel, the source code for attachment_fu should document most of the gotchas, too!</p>
|
<p>Look into the plugin, <a href="http://john.guen.in/rdoc/x_send_file/" rel="nofollow noreferrer">x_send_file</a> too. </p>
<p>"The XSendFile plugin provides a simple interface for sending files via the X-Sendfile HTTP header. This enables your web server to serve the file directly from disk, instead of streaming it through your Rails process. This is faster and saves a lot of memory if you‘re using Mongrel. Not every web server supports this header. YMMV."</p>
<p>I'm not sure if it's usable with Blobs, it may just be for files on the file system. But you probably need something that doesn't tie up the web server streaming large chunks of data.</p>
| 8,130
|
<p>How do I create a button control (with <code>CreateWindow</code> of a <code>BUTTON</code> window class) that has a standard system-wide size (especially height) that's consistent with the rest of Windows applications?
I should of course take DPI into account and probably other settings.</p>
<blockquote>
<p><strong>Remark:</strong> Using <code>USE_CW_DEFAULT</code> for width and height results in a 0, 0 size button, so that's not a solution.</p>
</blockquote>
|
<h2>In the perfect, hassle-free world...</h2>
<p>To create a standard size button we would have to do this:</p>
<pre><code>LONG units = GetDialogBaseUnits();
m_hButton = CreateWindow(TEXT("BUTTON"), TEXT("Close"),
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
0, 0, MulDiv(LOWORD(units), 50, 4), MulDiv(HIWORD(units), 14, 8),
hwnd, NULL, hInst, NULL);
</code></pre>
<p>where <strong>50</strong> and <strong>14</strong> are respective DLU dimensions, <strong>4</strong> and <strong>8</strong> are horizontal and vertical dialog template units respectively, based on <a href="http://msdn.microsoft.com/en-us/library/ms645475(VS.85).aspx" rel="noreferrer"><code>GetDialogBaseUnits()</code> function</a> documentation remarks.</p>
<hr>
<h2>Nothing's perfect</h2>
<p><strong>BUT</strong> as Anders pointed out, those metrics are based on the system font. If your window uses a shell dialog font or simply anything not making your eyes bleed, you're pretty much on your own.</p>
<p>To get your own "dialog" base units, you have to retrieve current text metrics with <code>GetTextMetrics()</code> and use character height and average width (<code>tmHeight</code> and <code>tmAveCharWidth</code> of the <code>TEXTMETRIC</code> struct respectively) and translate them with MulDiv by your own, <strong>unless</strong> you are in a dialog, then <code>MapDialogRect()</code> will do all the job for you.</p>
<p>Note that <code>tmAveCharWidth</code> only approximates the actual average character width so it's recommended to use a <a href="http://msdn.microsoft.com/en-us/library/dd144938.aspx" rel="noreferrer"><code>GetTextExtentPoint32()</code></a> function on an alphabetic character set instead.</p>
<p>See:</p>
<ul>
<li><a href="http://support.microsoft.com/kb/145994" rel="noreferrer">How to calculate dialog box units based on the current font in Visual C++</a></li>
<li><a href="http://support.microsoft.com/kb/125681" rel="noreferrer">How To Calculate Dialog Base Units with Non-System-Based Font</a></li>
</ul>
<hr>
<h2>Simpler alternative</h2>
<p>If buttons are the only control you want to resize automatically, you can also use <a href="http://msdn.microsoft.com/en-us/library/bb775961(VS.85).aspx" rel="noreferrer"><code>BCM_GETIDEALSIZE</code></a> message <a href="http://msdn.microsoft.com/en-us/library/bb761851(VS.85).aspx" rel="noreferrer"><code>Button_GetIdealSize()</code></a> macro (Windows XP and up only) to retrieve optimal width and height that fits anything the button contains, though it looks pretty ugly without any margins applied around the button's text.</p>
|
<p>@macbirdie: you should NOT use GetDialogBaseUnits(), it is based on the default system font (Ugly bitmap font). You should use MapDialogRect()</p>
| 8,301
|
<p>I would like to test a function with a tuple from a set of fringe cases and normal values. For example, while testing a function which returns <code>true</code> whenever given three lengths that form a valid triangle, I would have specific cases, negative / small / large numbers, values close-to being overflowed, etc.; what is more, main aim is to generate combinations of these values, <em>with</em> or <em>without</em> repetition, in order to get a set of test data.</p>
<pre><code>(inf,0,-1), (5,10,1000), (10,5,5), (0,-1,5), (1000,inf,inf),
...
</code></pre>
<blockquote>
<p><em>As a note: I actually know the answer to this, but it might be helpful for others, and a challenge for people here! --will post my answer later on.</em></p>
</blockquote>
|
<p>Absolutely, especially dealing with lots of these permutations/combinations I can definitely see that the first pass would be an issue.</p>
<p>Interesting implementation in python, though I wrote a nice one in C and Ocaml based on "Algorithm 515" (see below). He wrote his in Fortran as it was common back then for all the "Algorithm XX" papers, well, that assembly or c. I had to re-write it and make some small improvements to work with arrays not ranges of numbers. This one does random access, I'm still working on getting some nice implementations of the ones mentioned in Knuth 4th volume fascicle 2. I'll an explanation of how this works to the reader. Though if someone is curious, I wouldn't object to writing something up.</p>
<pre><code>/** [combination c n p x]
* get the [x]th lexicographically ordered set of [p] elements in [n]
* output is in [c], and should be sizeof(int)*[p] */
void combination(int* c,int n,int p, int x){
int i,r,k = 0;
for(i=0;i<p-1;i++){
c[i] = (i != 0) ? c[i-1] : 0;
do {
c[i]++;
r = choose(n-c[i],p-(i+1));
k = k + r;
} while(k < x);
k = k - r;
}
c[p-1] = c[p-2] + x - k;
}
</code></pre>
<p>~"Algorithm 515: Generation of a Vector from the Lexicographical Index"; Buckles, B. P., and Lybanon, M. ACM Transactions on Mathematical Software, Vol. 3, No. 2, June 1977.</p>
|
<p>While it's possible to create lots of test data and see what happens, it's more efficient to try to minimize the data being used.</p>
<p>From a typical QA perspective, you would want to identify different classifications of inputs. Produce a set of input values for each classification and determine the appropriate outputs. </p>
<p>Here's a sample of classes of input values</p>
<ul>
<li>valid triangles with small numbers such as (1 billion, 2, billion, 2 billion)</li>
<li>valid triangles with large numbers such as (0.000001, 0.00002, 0.00003)</li>
<li>valid obtuse triangles that are 'almost'flat such as (10, 10, 19.9999)</li>
<li>valid acute triangles that are 'almost' flat such as (10, 10, 0000001)</li>
<li>invalid triangles with at least one negative value</li>
<li>invalid triangles where the sum of two sides equals the third</li>
<li>invalid triangles where the sum of two sides is greater than the third</li>
<li>input values that are non-numeric</li>
</ul>
<p>...</p>
<p>Once you are satisfied with the list of input classifications for this function, then you can create the actual test data. Likely, it would be helpful to test all permutations of each item. (e.g. (2,3,4), (2,4,3), (3,2,4), (3,4,2), (4,2,3), (4,3,2)) Typically, you'll find there are some classifications you missed (such as the concept of inf as an input parameter).</p>
<p>Random data for some period of time may be helpful as well, that can find strange bugs in the code, but is generally not productive.</p>
<p>More likely, this function is being used in some specific context where additional rules are applied.(e.g. only integer values or values must be in 0.01 increments, etc.) These add to the list of classifications of input parameters.</p>
| 2,297
|
<p>When working with large and/or many Javascript and CSS files, what's the best way to reduce the file sizes?</p>
|
<p>In addition to using server side compression, using intelligent coding is the best way to keep bandwidth costs low. You can always use tools like <a href="http://dean.edwards.name/download/#packer" rel="nofollow noreferrer">Dean Edward's Javascript Packer</a>, but for CSS, take the time to learn <a href="http://www.webcredible.co.uk/user-friendly-resources/css/css-shorthand-properties.shtml" rel="nofollow noreferrer" title="CSS Shorthand Examples">CSS Shorthand</a>. E.g. use:</p>
<pre class="lang-css prettyprint-override"><code>background: #fff url(image.gif) no-repeat top left;
</code></pre>
<p>...instead of:</p>
<pre class="lang-css prettyprint-override"><code>background-color: #fff;
background-image: url(image.gif);
background-repeat: no-repeat;
background-position: top left;
</code></pre>
<p>Also, use the cascading nature of CSS. For example, if you know that your site will use one font-family, define that for all elements that are in the body tag like this:</p>
<pre class="lang-css prettyprint-override"><code>body{font-family:arial;}
</code></pre>
<p>One other thing that can help is including your CSS and JavaScript as files instead of inline or at the head of each page. That way your server only has to serve them once to the browser after that browser will go from cache.</p>
<h3>Including Javascript</h3>
<pre><code><script type="text/javascript" src="/scripts/loginChecker.js"></script>
</code></pre>
<h3>Including CSS</h3>
<pre><code><link rel="stylesheet" href="/css/myStyle.css" type="text/css" media="All" />
</code></pre>
|
<p>I'd give a test-drive to the new runtime optimizers in ASP.Net published on <a href="http://www.codeplex.com/NCOptimizer" rel="nofollow noreferrer">http://www.codeplex.com/NCOptimizer</a></p>
| 9,123
|
<p>I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command:</p>
<pre><code>SELECT HashBytes('MD5', 'HelloWorld')
</code></pre>
<p>However, this returns a VarBinary instead of a VarChar value. If I attempt to convert <code>0x68E109F0F40CA72A15E05CC22786F8E6</code> into a VarChar I get <code>há ðô§*à\Â'†øæ</code> instead of <code>68E109F0F40CA72A15E05CC22786F8E6</code>.</p>
<p>Is there any SQL-based solution?</p>
<p><strong><a href="https://stackoverflow.com/questions/2120/#2382">Yes</a></strong></p>
|
<p>I have found the solution else where:</p>
<pre><code>SELECT SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5', 'HelloWorld')), 3, 32)
</code></pre>
|
<p>Changing the datatype to varbinary seems to work the best for me.</p>
| 2,430
|
<p>I am looking for some JavaScript plugin (preferably jQuery) to be able to scroll through an image, in the same way that <a href="http://maps.google.com" rel="noreferrer">Google Maps</a> works.</p>
<p>I can make the image draggable but then I see the whole image while dragging even if the parent div is <code>overflow:hidden</code>.</p>
<p>Any help would be greatly appreciated!</p>
|
<p>I may be a little late to the party, but I was just looking for the same thing. What I stumbled upon is <a href="http://code.google.com/p/jquery-scrollview/" rel="nofollow noreferrer">scrollview</a> for jquery, it works perfect and does exactly this google maps-like drag-to-scroll for overflowed divs.</p>
|
<p>Google Maps uses images sliced into blocks which are dynamically loaded as the user pans in different directions. The <a href="http://www.casa.ucl.ac.uk/software/googlemapimagecutter.asp" rel="nofollow noreferrer">Google Maps Image Cutter</a> Paul Dixon mentions is the tool you want for this.</p>
<p>If you just want to pan one large image, rather than have the additional complexity of slicing the image up into blocks, then instead of using the CSS overflow property, you should use the <a href="http://www.w3.org/TR/CSS21/visufx.html#propdef-clip" rel="nofollow noreferrer">clip</a> property. This is supported on all browsers worth thinking about, down to IE4 if I remember correctly.</p>
<p>One point to note: the CSS2.1 spec shows examples with the rect values separated by commas. However this isn't supported by IE6 (perhaps not IE7, either). However all other browsers understand the version without commas. So instead of</p>
<pre><code>clip: rect(5px, 40px, 45px, 5px);
</code></pre>
<p>you should use</p>
<pre><code>clip: rect(5px 40px 45px 5px);
</code></pre>
<p>for compatibility.</p>
<p>You need a container <div> set to position:relative around the <img> element, which you then set to position: absolute. </p>
<p>So the basic technique is to update the top and left values as the user drags, use these together with the defined width and height of the view onto the image to create the appropriate rect() string, and update the top, left, and clip properties of the <img> element's style property.</p>
<p>Don't do what I did and leave out the "px" after the values in the rect() string. It took me ages to realise why it wasn't working :-)</p>
| 9,216
|
<p>Using SQL Server, how do I split a string so I can access item x?</p>
<p>Take a string "Hello John Smith". How can I split the string by space and access the item at index 1 which should return "John"?</p>
|
<p>You may find the solution in <em><a href="http://www.codeproject.com/KB/database/SQL_UDF_to_Parse_a_String.aspx" rel="noreferrer">SQL User Defined Function to Parse a Delimited String</a></em> helpful (from <a href="http://en.wikipedia.org/wiki/The_Code_Project" rel="noreferrer">The Code Project</a>).</p>
<p>You can use this simple logic:</p>
<pre><code>Declare @products varchar(200) = '1|20|3|343|44|6|8765'
Declare @individual varchar(20) = null
WHILE LEN(@products) > 0
BEGIN
IF PATINDEX('%|%', @products) > 0
BEGIN
SET @individual = SUBSTRING(@products,
0,
PATINDEX('%|%', @products))
SELECT @individual
SET @products = SUBSTRING(@products,
LEN(@individual + '|') + 1,
LEN(@products))
END
ELSE
BEGIN
SET @individual = @products
SET @products = NULL
SELECT @individual
END
END
</code></pre>
|
<p>Well, mine isn't all that simpler, but here is the code I use to split a comma-delimited input variable into individual values, and put it into a table variable. I'm sure you could modify this slightly to split based on a space and then to do a basic SELECT query against that table variable to get your results.</p>
<pre><code>-- Create temporary table to parse the list of accounting cycles.
DECLARE @tblAccountingCycles table
(
AccountingCycle varchar(10)
)
DECLARE @vchAccountingCycle varchar(10)
DECLARE @intPosition int
SET @vchAccountingCycleIDs = LTRIM(RTRIM(@vchAccountingCycleIDs)) + ','
SET @intPosition = CHARINDEX(',', @vchAccountingCycleIDs, 1)
IF REPLACE(@vchAccountingCycleIDs, ',', '') <> ''
BEGIN
WHILE @intPosition > 0
BEGIN
SET @vchAccountingCycle = LTRIM(RTRIM(LEFT(@vchAccountingCycleIDs, @intPosition - 1)))
IF @vchAccountingCycle <> ''
BEGIN
INSERT INTO @tblAccountingCycles (AccountingCycle) VALUES (@vchAccountingCycle)
END
SET @vchAccountingCycleIDs = RIGHT(@vchAccountingCycleIDs, LEN(@vchAccountingCycleIDs) - @intPosition)
SET @intPosition = CHARINDEX(',', @vchAccountingCycleIDs, 1)
END
END
</code></pre>
<p>The concept is pretty much the same. One other alternative is to leverage the .NET compatibility within SQL Server 2005 itself. You can essentially write yourself a simple method in .NET that would split the string and then expose that as a stored procedure/function.</p>
| 2,475
|
<p>In my simple OpenGL program I get the following error about exit redefinition:</p>
<pre><code>1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
1> c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\glut.h(146) : see declaration of 'exit'
</code></pre>
<p>I'm using Nate Robins' <a href="http://www.xmission.com/~nate/glut.html" rel="noreferrer">GLUT for Win32</a> and get this error with Visual Studio 2005 or Visual C++ 2005 (Express Edition). What is the cause of this error and how do I fix it?</p>
|
<p><strong>Cause:</strong></p>
<p>The <strong>stdlib.h</strong> which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the <strong>exit()</strong> function. It clashes with the definition in <strong>glut.h</strong>.</p>
<p><strong>Solution:</strong></p>
<p>Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code.</p>
<pre><code>#include <stdlib.h>
#include <GL/glut.h>
</code></pre>
|
<p>or this...
To fix the error, right click on the project name in the Solution Explorer tab and select Properties -> C/C++ -> Preprocessor -> Preprocessor definitions and append GLUT_BUILDING_LIB to the existing definitions, seperated by semicolons. </p>
| 3,521
|
<p>I use this tool called <a href="http://www.lazycplusplus.com/" rel="nofollow noreferrer">Lazy C++</a> which breaks a single C++ .lzz file into a .h and .cpp file. I want <a href="http://makepp.sourceforge.net/" rel="nofollow noreferrer">Makepp</a> to expect both of these files to exist after my rule for building .lzz files, but I'm not sure how to put two targets into a single build line.</p>
|
<p>I've never used Makepp personally, but since it's a drop-in replacement for GNU Make, you should be able to do something like:</p>
<pre><code>build: foo.h foo.cpp
g++ $(CFLAGS) foo.cpp -o $(LFLAGS) foo
foo.h foo.cpp: foo.lzz
lzz foo.lzz
</code></pre>
<p>Also not sure about the lzz invocation there, but that should help. You can read more about this at <a href="http://theory.uwinnipeg.ca/gnu/make/make_37.html" rel="nofollow noreferrer">http://theory.uwinnipeg.ca/gnu/make/make_37.html</a>.</p>
|
<p>Lzz is amazing! This is just what I was looking for <a href="http://groups.google.com/group/comp.lang.c++/browse_thread/thread/c50de73b70a6a957/f3f47fcdcfb6bc09" rel="nofollow noreferrer">http://groups.google.com/group/comp.lang.c++/browse_thread/thread/c50de73b70a6a957/f3f47fcdcfb6bc09</a></p>
<p>Actually all you need is to depend (typically) on foo.o in your link rule, and a pattern rule to call lzz:</p>
<pre><code>%.cpp %.h: %.lzz
lzz $(input)
</code></pre>
<p>The rest will fall into place automatically. When compiling any source that includes foo.h, or linking foo.o to a library or program, lzz will first get called automatically.</p>
<p>Makepp will also recognize if only the timestamp but not the content of the produced file changed, and ignore that. But it can't hurt to give it less to do, by using the lzz options to suppress recreating an identical file.</p>
<p>Regards -- Daniel</p>
| 5,608
|
<p>Is anyone using Elmah to send exceptions via email? I've got Elmah logging set up via SQL Server, and can view the errors page via the Elmah.axd page, but I am unable to get the email component working. The idea here is to get the email notification so we can react more quickly to exceptions. Here is my web.config (unnecessary sectionss omitted), with all the sensitive data replaced by * * *. Even though I am specifying a server to connect to, does the SMTP service need to be running on the local machine?</p>
<pre><code><?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"/>
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah"/>
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings>
<add name="elmah-sql" connectionString="Data Source=***;Initial Catalog=***;Persist Security Info=True;User ID=***;Password=***" />
</connectionStrings>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-sql" >
</errorLog>
<errorMail from="test@test.com"
to="test@test.com"
subject="Application Exception"
async="false"
smtpPort="25"
smtpServer="***"
userName="***"
password="***">
</errorMail>
</elmah>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="CustomError.aspx">
<error statusCode="403" redirect="NotAuthorized.aspx" />
<!--<error statusCode="404" redirect="FileNotFound.htm" />-->
</customErrors>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
</system.web>
</configuration>
</code></pre>
|
<p>You need the ErrorMail httpModule.</p>
<p>add this line inside the <httpModules> section</p>
<pre><code><add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</code></pre>
<p>If you're using a remote SMTP server (which it looks like you are) you don't need SMTP on the server.</p>
|
<p>I have used Elmah myself in this configuration and I had to setup the server with SMTP locally. It is a straight-forward install on you local IIS server. This should do the trick.</p>
<p>Good point above, you need the errorMail module BUT if you are not using a remote SMTP server you need SMTP locally, just to clarify.</p>
| 5,464
|
<p>This one has me kind of stumped. I want to make the first word of all the paragraphs in my #content div at 14pt instead of the default for the paragraphs (12pt). Is there a way to do this in straight CSS or am I left wrapping the first word in a span to accomplish this?</p>
|
<p>What you are looking for is a pseudo-element that doesn't exist. There is <code>:first-letter</code> and <code>:first-line</code>, but no <code>:first-word</code>.</p>
<p>You can of course do this with JavaScript. Here's some code I found that does this: <a href="http://www.dynamicsitesolutions.com/javascript/first-word-selector/" rel="noreferrer">http://www.dynamicsitesolutions.com/javascript/first-word-selector/</a></p>
|
<p>Insert Span Tag in your paragraph text. For Example-
<code><p><span>Hello</span>My Name Is Dot</p</code>
and then style the first letter.</p>
| 7,943
|
<p>What is a good setup for .hgignore file when working with Visual Studio 2008?</p>
<p>I mostly develop on my own, only occasionly I clone the repository for somebody else to work on it.</p>
<p>I'm thinking about obj folders, .suo, .sln, .user files etc.. Can they just be included or are there file I shouldn't include?</p>
<p>Thanks!</p>
<p>p.s.: at the moment I do the following : ignore all .pdb files and all obj folders.</p>
<pre><code># regexp syntax.
syntax: glob
*.pdb
syntax: regexp
/obj/
</code></pre>
|
<p>Here's my standard .hgignore file for use with VS2008 that was originally modified from a Git ignore file:</p>
<pre><code># Ignore file for Visual Studio 2008
# use glob syntax
syntax: glob
# Ignore Visual Studio 2008 files
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
</code></pre>
|
<p>some others I use:</p>
<pre><code>output
PrecompiledWeb
_UpgradeReport_Files
#Guidance Automation Toolkit
*.gpState
#patches
*.patch
</code></pre>
| 5,514
|
<p>Any hints or suggestions (filament type? suggested settings? model sources?) for 3D printing minis to use in Dungeons & Dragons?</p>
<p>I've done a couple where the support structures were difficult to break off without breaking off a hand or something.</p>
<p>I have a Lulzbot Mini (1), single-extruder if that makes any difference.</p>
|
<p>There are adequate demonstration videos on YouTube showing that it is possible to print very acceptable 28 mm scale miniatures with FDM printers, easily rivaling the quality of resin printers from only a few years ago.</p>
<p>There are a couple of key requirements to get optimum quality for small, highly detailed parts (like miniatures): the smallest practical nozzle (0.2 mm seems to be elected), the smallest practical layer height (for 0.2 mm nozzle, this seems to be 0.1 mm), and optimal temperature and cooling. Supports, if needed, can be optimized for layer skip, interface, and traditional or tree style. It may take several test prints to find the best combination, but once found this should remain fairly constant for a given printer and filament choice.</p>
<p>The final ingredient, of course, is patience -- small nozzle, fine layer height, possibly reduced print speed required for those, mean these prints will take longer than you'd think for the size of the final object -- but if you get the settings right, and are willing to wait, you can get good miniatures with FDM.</p>
<p>For filament choice, I'd suggest PLA, generally -- it's very tolerant stuff, except for temperature, and you aren't likely to leave your minis on the dash of your car in the sun anyway.</p>
|
<p>Buckle up, this is going to be rough:</p>
<p>FDM printers are not the best choice for printing figurines in the 25 to 40 mm scale that is typical for wargaming and D&D games. Resolution-wise, that's the area of <em>resin</em> printers.</p>
<p>But there are ways to get some partially decent prints made:</p>
<ul>
<li>you might want a small nozzle. 0.2 is about the smallest you can do without specialty extruders, so there is our lower limit.</li>
<li>You need to make sure to have a minimum layer time set, especially as the crosssections of figures are often rather slim.</li>
<li>Overhangs can be a pain</li>
</ul>
<p>You might be better-served printing "meeples" than actual figurines.</p>
| 1,931
|
<p>Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters that belong to a stored procedure on a SQL Server before I actually execute it?</p>
<p>I have an a "multi-environment" scenario where there are multiple versions of the same database schema. Examples of environments might be "Development", "Staging", & "Production". "Development" is going to have one version of the stored procedure and "Staging" is going to have another.</p>
<p>All I want to do is validate that a parameter is going to be there before passing it a value and calling the stored procedure. Avoiding that SqlException rather than having to catch it is a plus for me.</p>
<p>Joshua</p>
|
<p>You can use SqlCommandBuilder.DeriveParameters() (see <a href="https://web.archive.org/web/20110304121600/http://www.davidhayden.com/blog/dave/archive/2006/11/01/SqlCommandBuilderDeriveParameters.aspx" rel="nofollow noreferrer">SqlCommandBuilder.DeriveParameters - Get Parameter Information for a Stored Procedure - ADO.NET Tutorials</a>) or there's <a href="http://www.codeproject.com/KB/database/enumeratesps.aspx" rel="nofollow noreferrer">this way</a> which isn't as elegant.</p>
|
<p>All of these ADO.NET solutions are are asking the code library to query the database's metadata on your behalf. If you are going to take that performance hit anyhow, maybe you should just write some helper functions that call </p>
<pre><code>Select count(*) from information_schema.parameters
where ...(proc name =.. param name=...) (pseudo-code)
</code></pre>
<p>Or maybe even generate your parameters based on the param list you get back. This technique will work with multiple versions of MS SQL and sometimes other ANSI SQL databases.</p>
| 5,385
|
<p>Does anybody know if it's possible, and how, to programmatically send a <strong>SMS</strong> from the <code>iPhone</code>, with the official SDK / Cocoa Touch?</p>
|
<h3>Restrictions</h3>
<p>If you could send an SMS within a program on the iPhone, you'll be able to write games that spam people in the background. I'm sure you really want to have spams from your friends, "Try out this new game! It roxxers my boxxers, and yours will be too! roxxersboxxers.com!!!! If you sign up now you'll get 3,200 RB points!!"</p>
<p>Apple has restrictions for automated (or even partially automated) SMS and dialing operations. (Imagine if the game instead dialed 911 at a particular time of day)</p>
<p>Your best bet is to set up an intermediate server on the internet that uses an online SMS sending service and send the SMS via that route if you need complete automation. (ie, your program on the iPhone sends a UDP packet to your server, which sends the real SMS)</p>
<h3>iOS 4 Update</h3>
<p>iOS 4, however, now provides a <code>viewController</code> you can import into your application. You prepopulate the SMS fields, then the user can initiate the SMS send within the controller. Unlike using the "SMS:..." url format, this allows your application to stay open, and allows you to populate both the <em>to</em> and the <em>body</em> fields. You can even specify multiple recipients.</p>
<p>This prevents applications from sending automated SMS without the user explicitly aware of it. You still cannot send fully automated SMS from the iPhone itself, it requires some user interaction. But this at least allows you to populate everything, and avoids closing the application.</p>
<p>The <a href="https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontroller" rel="noreferrer">MFMessageComposeViewController</a> class is well documented, and <a href="http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/" rel="noreferrer">tutorials</a> show how easy it is to implement.</p>
<h3>iOS 5 Update</h3>
<p>iOS 5 includes messaging for iPod touch and iPad devices, so while I've not yet tested this myself, it may be that all iOS devices will be able to send SMS via MFMessageComposeViewController. If this is the case, then Apple is running an SMS server that sends messages on behalf of devices that don't have a cellular modem.</p>
<h3>iOS 6 Update</h3>
<p>No changes to this class.</p>
<h3>iOS 7 Update</h3>
<p>You can now check to see if the message medium you are using will accept a subject or attachments, and what kind of attachments it will accept. You can edit the subject and add attachments to the message, where the medium allows it.</p>
<h3>iOS 8 Update</h3>
<p>No changes to this class.</p>
<h3>iOS 9 Update</h3>
<p>No changes to this class.</p>
<h3>iOS 10 Update</h3>
<p>No changes to this class.</p>
<h3>iOS 11 Update</h3>
<p><a href="https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontroller?changes=latest_major" rel="noreferrer">No significant changes to this class</a></p>
<h3>Limitations to this class</h3>
<p>Keep in mind that this won't work on phones without iOS 4, and it won't work on the iPod touch or the iPad, except, perhaps, under iOS 5. You must either detect the device and iOS limitations prior to using this controller, or risk restricting your app to recently upgraded 3G, 3GS, and 4 iPhones.</p>
<p>However, an intermediate server that sends SMS will allow any and all of these iOS devices to send SMS as long as they have internet access, so it may still be a better solution for many applications. Alternately, use both, and only fall back to an online SMS service when the device doesn't support it.</p>
|
<p>You need to use the <strong>MFMessageComposeViewController</strong> if you want to show creating and sending the message in your own app.</p>
<p>Otherwise, you can use the <strong>sharedApplication</strong> method.</p>
| 3,201
|
<p>I have something that is driving me absolutely crazy...</p>
<pre><code> Public Function GetAccountGroups() As IList(Of AccountGroup)
Dim raw_account_groups As IList(Of AccountGroup)
raw_account_groups = _repository.GetAccountGroups().ToList()
Dim parents = (From ag In raw_account_groups _
Where ag.parent_id = 0 _
Select ag).ToList()
parents(0).sub_account_groups = (From sag In raw_account_groups _
Where sag.parent_id = 0 _
Select sag).ToList()
Dim sql_func As Func(Of AccountGroup, List(Of AccountGroup)) = Function(p) _
(From sag In raw_account_groups _
Where sag.parent_id = p.id _
Select sag).ToList()
parents.ForEach(Function(p) p.sub_account_groups = sql_func(p))
Return parents
End Function
</code></pre>
<p>The line <code>parents.ForEach(Function(p) p.sub_account_groups = sql_func(p))</code> has this error...</p>
<blockquote>
<p>Operator '=' is not defined for types 'System.Collections.Generic.IList(Of st.data.AccountGroup)' and 'System.Collections.Generic.List(Of st.data.AccountGroup)'. </p>
</blockquote>
<p>but I really can't see how it is any different from this code from Rob Connery</p>
<pre><code>public IList<Category> GetCategories() {
IList<Category> rawCategories = _repository.GetCategories().ToList();
var parents = (from c in rawCategories
where c.ParentID == 0
select c).ToList();
parents.ForEach(p =>
{
p.SubCategories = (from subs in rawCategories
where subs.ParentID == p.ID
select subs).ToList();
});
return parents;
}
</code></pre>
<p>which compiles perfectly... what am I doing incorrectly?</p>
|
<p>Lambda's in VB.Net have to return a value, so your equal sign ('=') is being intepreted as a comparison (so that the lambda returns a boolean), rather than an assignment.</p>
|
<p>I haven't used VB.NET since moving to C# 3.0, but it seems like it could be a type inference issue. The error is a bit odd since List implements IList, so the assignment should work. You can say "p.ID = 123" for the lambda and things seem to work. </p>
<p>For anyone else interested in looking into it, here is code that you can paste into a new VB.NET console project to demonstrate this issue:</p>
<pre><code>Module Module1
Sub Main()
End Sub
End Module
Class AccountGroup
Public parent_id As Integer
Public id As Integer
Public sub_account_groups As List(Of AccountGroup)
End Class
Class AccountRepository
Private _repository As AccountRepository
Public Function GetAccountGroups() As IList(Of AccountGroup)
Dim raw_account_groups As IList(Of AccountGroup)
raw_account_groups = _repository.GetAccountGroups().ToList()
Dim parents = (From ag In raw_account_groups _
Where ag.parent_id = 0 _
Select ag).ToList()
parents(0).sub_account_groups = (From sag In raw_account_groups _
Where sag.parent_id = 0 _
Select sag).ToList()
Dim sql_func As Func(Of AccountGroup, List(Of AccountGroup)) = Function(p) _
(From sag In raw_account_groups _
Where sag.parent_id = p.id _
Select sag).ToList()
parents.ForEach(Function(p) p.sub_account_groups = sql_func(p))
Return parents
End Function
End Class
</code></pre>
| 9,346
|
<p>I'm trying to build a C# console application to automate grabbing certain files from our website, mostly to save myself clicks and - frankly - just to have done it. But I've hit a snag that for which I've been unable to find a working solution.</p>
<p>The website I'm trying to which I'm trying to connect uses ASP.Net forms authorization, and I cannot figure out how to authenticate myself with it. This application is a complete hack so I can hard code my username and password or any other needed auth info, and the solution itself doesn't need to be something that is viable enough to release to general users. In other words, if the only possible solution is a hack, I'm fine with that.</p>
<p>Basically, I'm trying to use HttpWebRequest to pull the site that has the list of files, iterating through that list and then downloading what I need. So the actual work on the site is fairly trivial once I can get the website to consider me authorized.</p>
|
<pre><code><?php
/*
Resizes an image and converts it to PNG returning the PNG data as a string
*/
function imageToPng($srcFile, $maxSize = 100) {
list($width_orig, $height_orig, $type) = getimagesize($srcFile);
// Get the aspect ratio
$ratio_orig = $width_orig / $height_orig;
$width = $maxSize;
$height = $maxSize;
// resize to height (orig is portrait)
if ($ratio_orig < 1) {
$width = $height * $ratio_orig;
}
// resize to width (orig is landscape)
else {
$height = $width / $ratio_orig;
}
// Temporarily increase the memory limit to allow for larger images
ini_set('memory_limit', '32M');
switch ($type)
{
case IMAGETYPE_GIF:
$image = imagecreatefromgif($srcFile);
break;
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($srcFile);
break;
case IMAGETYPE_PNG:
$image = imagecreatefrompng($srcFile);
break;
default:
throw new Exception('Unrecognized image type ' . $type);
}
// create a new blank image
$newImage = imagecreatetruecolor($width, $height);
// Copy the old image to the new image
imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output to a temp file
$destFile = tempnam();
imagepng($newImage, $destFile);
// Free memory
imagedestroy($newImage);
if ( is_file($destFile) ) {
$f = fopen($destFile, 'rb');
$data = fread($f);
fclose($f);
// Remove the tempfile
unlink($destFile);
return $data;
}
throw new Exception('Image conversion failed.');
}
</code></pre>
|
<p><a href="http://www.phpit.net/article/image-manipulation-php-gd-part2/" rel="nofollow noreferrer">This article</a> seems like it would fit what you want. You'll need to change the saving imagejpeg() function to imagepng() and have it save the file to a string rather than output it to the page, but other than that it should be easy copy/paste into your existing code.</p>
| 4,225
|
<p>I'm using <kbd>Ctrl</kbd>+<kbd>Left</kbd> / <kbd>Ctrl</kbd>+<kbd>Right</kbd> in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if it's an editable area, but it always returns "undefined".</p>
|
<p>document.activeElement works for me in FF3 but the following also works</p>
<pre><code>(function() {
var myActiveElement;
document.onkeypress = function(event) {
if ((myActiveElement || document.activeElement || {}).tagName != 'INPUT')
// do your magic
};
if (!document.activeElement) {
var elements = document.getElementsByTagName('input');
for(var i=0; i<elements.length; i++) {
elements[i].addEventListener('focus',function() {
myActiveElement = this;
},false);
elements[i].addEventListener('blur',function() {
myActiveElement = null;
},false);
}
}
})();
</code></pre>
|
<p>element.activeElement is part of HTML5 spec but is not supported by most browsers. It was first introduced by IE.</p>
| 6,434
|
<p>I bricked my Tevo Tarantula's controller board, and I've decided to just replace it rather than unbrick it because they are relatively cheap. I recently bought a new MKS GEN L v1.0 board, but I've been unable to flash new firmware onto it. Every time I go to upload the firmware, I get an error just as it begins to upload, saying:</p>
<pre><code>"failed to send command to serial port does not exist or is not connected"
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.
</code></pre>
<p>avrdude: stk500v2_ReceiveMessage(): timeout</p>
<pre><code>avrdude: stk500v2_getsync(): timeout communicating with programmer
</code></pre>
<p>Any ideas of what the issue could be? I've tried both the USB ports on my computer and using a USB 2.0 hub (I believe my computer ports are both USB 3.0). I've also made sure that I had the correct port selected in Marlin (1.1.8.13).</p>
<p>I also think that its worth mentioning that my bricked board and new board seem to appear differently in the device manager</p>
<p>Bricked:</p>
<p><a href="https://i.stack.imgur.com/Ex7ZK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ex7ZK.png" alt="enter image description here" /></a></p>
<p>While my new board appears as this:</p>
<p><a href="https://i.stack.imgur.com/TWYoP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TWYoP.png" alt="enter image description here" /></a></p>
<p>The new board also seems to "cut-out" when I first connect it to my computer as well. In the device manager, my computer will indicate that an unknown device is connected, then it will quickly disconnect and disappear, only to reconnect and reappear as pictured above.</p>
<p>Do you guys think there is a hardware issue with the motherboard? Thanks for your help, this is giving me quite the headache!</p>
|
<p>Your motherboard is not an MKS GEN L v1.0, it's a <a href="https://github.com/makerbase-mks/Datasheet/blob/master/English%20datasheet/MKS%20SGen%20Datasheet.pdf" rel="nofollow noreferrer">MKS SGEN L</a> - unfortunately, a very very naming scheme.</p>
<p>Your board is actually a <strong>32-bit board</strong>, and must therefore be flashed with Marlin 2.0, built for the 32-bit board.
The firmware is then updated by placing it on the SD card and restarting the board, as explained in the <a href="https://marlinfw.org/docs/basics/install_platformio_vscode.html" rel="nofollow noreferrer">documentation for Marlin here</a></p>
|
<p>Your new board may have a counterfeit FT232R USB-to-serial interface chip, and the Windows update channel has installed hobbled FTDI drivers that won't work with counterfeit chips. The use of counterfeit FT232R chips is very common with budget 3D printer controllers, and FTDI are trying to discourage their use. Because of this, a lot of manufacturers have switched to using the CH340 chip, which does not suffer from this problem, and it looks like your old board used a CH340 chip. Try deleting the device and its drivers, and then installing the Windows setup executable from the following website:</p>
<p><a href="https://www.ftdichip.com/Drivers/VCP.htm" rel="nofollow noreferrer">https://www.ftdichip.com/Drivers/VCP.htm</a></p>
<p>The 2.12.28 drivers will work with counterfeit chips.</p>
| 1,775
|
<p>The following SQL:</p>
<pre><code>SELECT notes + 'SomeText'
FROM NotesTable a
</code></pre>
<p>Give the error:</p>
<blockquote>
<p>The data types nvarchar and text are incompatible in the add operator.</p>
</blockquote>
|
<p>The only way would be to convert your text field into an nvarchar field.</p>
<pre><code>Select Cast(notes as nvarchar(4000)) + 'SomeText'
From NotesTable a
</code></pre>
<p>Otherwise, I suggest doing the concatenation in your application.</p>
|
<p>If you are using SQL Server 2005 (or greater) you might want to consider switching to NVARCHAR(MAX) in your table definition; TEXT, NTEXT, and IMAGE data types of SQL Server 2000 will be deprecated in future versions of SQL Server. SQL Server 2005 provides backward compatibility to data types, but you should probably be using VARCHAR(MAX), NVARCHAR(MAX), and VARBINARY(MAX) instead.</p>
| 7,795
|
<p>Usually it will either will rip the tape, or break the print somehow. Currently using ABS on a taped glass bed with a layer of hairspray for adhesion.</p>
|
<p>I moved to a plain glass heated bed with a brush applied acetone and ABS mixture. Using an old emptied nail polish bottle with brush, I added some acetone and then threw in ABS pieces until it reached a brush-able consistency. I then brush it on the glass build plate where I believe the print will occur, and it works very well. On removal of the part the coating comes with it.</p>
<p>I just found previously that ABS would adhere to my kapton taped heated bed too strongly to use, and so while this involves a little work before each print, it's overall better than kapton for me.</p>
<p>I did experiment with sheet metal beds coated with kapton, but they curl during printing due to the ABS thermal stress, allowing my parts to be concave on the bottom side. Easy to remove from the plate, though, since it flexed. There may be a good middle ground material but I didn't experiment further.</p>
|
<p>I have had best results with ABS on a heated printbed
(untaped) with a thin coat of UHU Stic. It can be a little tricky to remove but minimizes damage.</p>
| 142
|
<p>I have some Ruby code which takes dates on the command line in the format:</p>
<pre><code>-d 20080101,20080201..20080229,20080301
</code></pre>
<p>I want to run for all dates between <code>20080201</code> and <code>20080229</code> inclusive and the other dates present in the list.</p>
<p>I can get the string <code>20080201..20080229</code>, so is the best way to convert this to a Range instance? Currently, I am using <code>eval</code>, but it feels like there should be a better way.</p>
<hr>
<p>@Purfideas I was kind of looking for a more general answer for converting any string of type <code>int..int</code> to a Range I guess.</p>
|
<p>But then just do </p>
<pre><code>ends = '20080201..20080229'.split('..').map{|d| Integer(d)}
ends[0]..ends[1]
</code></pre>
<p>anyway I don't recommend eval, for security reasons</p>
|
<p>Combining @Purfideas answer with another answer somewhere on StackOverflow, I solved this by also surrounding the code with an input check, so the only thing used is a valid enumerable </p>
<pre><code>if !value[/^[0-9]+\.\.[0-9]+$/].nil?
ends = value.split('..').map{|d| Integer(d)}
value = ends[0]..ends[1]
end
</code></pre>
<p>It essentially rewrites your string value to a enumerable value. This comes in handy if you add a enumerable field in a yaml config file.</p>
<p>If you need it for your application, you could extend the regex with an optional third literal dot, that could be optional.</p>
| 7,692
|
<p>I have built a 3D printer with Marlin bugfix-2.0.x forked from github.</p>
<p>I am attempting to set the default value for junction deviation so that I don't have to change it through the printer's screen/interface every time I power cycle the printer, but what I thought would set it properly isn't doing the trick.</p>
<p>My thought was that uncommenting this in Configuration_adv.h would work:</p>
<pre><code>#define JUNCTION_DEVIATION_MM 0.02
</code></pre>
<p>I have tried setting this define inside of and outside of the default <code>if</code> block in which it appears, just to make sure the issue wasn't because I didn't have something else set, and I get the same behavior when this <code>define</code> statement is either protected or unprotected by an <code>if</code></p>
<p>Also, the default <code>if</code> block is this:</p>
<pre><code>#if ENABLED( JUNCTION_DEVIATION )
#define JUNCTION_DEVIATION_MM 0.02
#endif
</code></pre>
<p>Uncommenting <code>#define JUNCTION_DEVIATION</code> leaves me with a compiler error telling me that I don't need to do that, so I'm not seeing anything that I am supposed to enable to get it to use the JUNCTION_DEVIATION_MM setting. In other words, I can't actually enable "JUNCTION_DEVIATION" any more, so I HAVE to break the JUNCTION_DEVIATION_MM setting out of the <code>if</code> but it still has no effect.</p>
<p>After setting this parameter, when I power cycle the printer, the junction deviation is set to 0 (although one touch of the adjustment knob makes it jump to 0.010, so I think that what is displayed as "0" may actually mean "unset"), which is causing a significant stop/start jerk on every angle change until I manually set the junction deviation.</p>
<p>My current <a href="https://github.com/appideasDOTcom/Marlin/blob/printerx/Marlin/Configuration.h" rel="nofollow noreferrer">Configuration.h</a> and <a href="https://github.com/appideasDOTcom/Marlin/blob/printerx/Marlin/Configuration_adv.h" rel="nofollow noreferrer">Configuration_adv.h</a> are taken from <a href="https://github.com/appideasDOTcom/Marlin/tree/printerx/Marlin" rel="nofollow noreferrer">this Marlin fork</a>.</p>
<p>In case it matters, I'm running this on an SKR V1.3 with TMC2208 drivers at 24V.</p>
<p>Any ideas what I'm missing? I'm sure it's something simple, I just haven't found it.</p>
<p><strong>UPDATE:</strong> Still no solution after 10 days. Here is additional information from another forum where I posted this request:</p>
<blockquote>
<p>Did you run <code>M502</code> and <code>M500</code> after updating your firmware?</p>
</blockquote>
<p>I dug into this a little more, and I am either running into a bug, or I'm simply not understanding what I'm supposed to be seeing.</p>
<p>I send this command:</p>
<p><code>M205 J0.020</code></p>
<p>Then verify that junction deviation is set correctly (it is)
Then this:</p>
<p><code>M500</code></p>
<p>And that responds with:</p>
<p><code>Settings Stored (616 bytes; crc 51371)</code></p>
<p>Then I send this:</p>
<p><code>M503</code></p>
<p>And the report for M205 is missing the setting I just confirmed to have changed and been working:</p>
<p><code>...
M205 B20000.00 S0.00 T0.00
...</code></p>
<p>And power cycling or resetting the controller leads to the same result: Junction Deviation is reset to 0.</p>
<p>Shouldn't I see "J0.020" in the M205 line immediately after changing the setting, and verifying that it works?</p>
|
<p>I've bought an SKR Pro V1.1 which is suffering from the same problem. It has actually to do with a shortcoming or design flaw (of the "HAL" or "Hardware Abstraction Layer" addressing of SPI devices) of Marlin and access to the SD card; I <a href="https://github.com/MarlinFirmware/Marlin/pull/16260" rel="nofollow noreferrer">quote</a>:</p>
<blockquote>
<p>The problem: On board SD-Card on SKR-PRO 1.1 can't be used. </p>
</blockquote>
<p>After the SD card has been inserted, the firmware binary is loaded into memory, and all access to the SD card is gone. The initial connection is by hardware design of the SKR boards.</p>
<p>Basically, there is a bug in the Marlin code/SKR boards preventing storing (to the SD card) any alterations after the firmware is loaded. There is a <a href="https://github.com/MarlinFirmware/Marlin/pull/16260" rel="nofollow noreferrer">PR on Marlin</a> that fixes it, but it has not been merged into Marlin yet.</p>
<p>There are 2 options, </p>
<ol>
<li>Every change to the firmware has to be compiled and uploaded to the board by placing a hex (firmware.bin) on the SD card;</li>
<li>Compile a firmware version from the sources from the fore mentioned PR.</li>
</ol>
|
<p>For the SKR, to store the new Marlin definitions it is necessary to send the comand <code>M502</code> to restore to the factory settings (will use the configuration on the SD card) and send the comand <code>M500</code> to save the configurations.</p>
| 1,497
|
<p>I am using <a href="http://www.hibernate.org/" rel="noreferrer">Hibernate</a> in a Java application to access my Database and it works pretty well with MS-SQL and MySQL. But some of the data I have to show on some forms has to come from Text files, and by Text files I mean Human-Readable files, they can be CSV, Tab-Delimited, or even a key, value pair, per line since my data is as simple as this, but my preference of course is XML files.</p>
<p>My question is: Can I use hibernate to read those files using HQL, Query , EntityManager and all those resources Hibernate provides me to access files. Which file format should I use and How I configure My persistence.xml file to recognize files as Tables?</p>
|
<p>Hibernate is written against the JDBC API. So, you need a JDBC driver that works with the file format you are interested in. Obviously, even for read-only access, this isn't going to perform well, but it might still be useful if that's not a high priority. On a Windows system, you can set up ODBC datasources for delimited text files, Excel files, etc. Then you can set up the JdbcOdbcDriver in your Java application to use this data source.</p>
<p>For most of the applications I work on, I would not consider this approach; I would use an import/export mechanism to convert from a real database (even if it's an in-process database like Berkeley DB or Derby) to the text files. Yes, it's an extra step, but it could be automated, and the performance isn't likely to be much worse than trying to use the text files directly (it will likely be much better, overall), and it will be more robust and easy to develop.</p>
|
<p>Like erickson said, your only hope is in finding a JDBC driver for that task. There is maybe <del><a href="https://xlsql.dev.java.net/" rel="nofollow noreferrer">xlsql</a></del> (CSV, XML and Excel driver) which could fit the task. After that, you just have to either find or write the most simple Hibernate Dialect which fits your driver.</p>
| 5,347
|
<p>I recently discovered the org-mode in emacs and it works very well for me. I also like www.RememberTheMilk.com. I would like to be able to sync my org-mode file and RTM list. I know that RTM has its API exposed as web services. I am currently looking for a HTTP library that I could use to write my script. I found a couple of links but I am still not entirely satisfied. </p>
<p><a href="http://www.koders.com/lisp/fidB46CCCA8D57FBD093BAF6E08289CFB4DA7624B2B.aspx?s=TV+Raman" rel="nofollow noreferrer">http://www.koders.com/lisp/fidB46CCCA8D57FBD093BAF6E08289CFB4DA7624B2B.aspx?s=TV+Raman</a>
<a href="http://www.emacswiki.org/cgi-bin/wiki/http-post-simple.el" rel="nofollow noreferrer">http://www.emacswiki.org/cgi-bin/wiki/http-post-simple.el</a></p>
<p>Any pointers in doing web service interactions with emacs would be very useful. Also please keep in mind that I'm not a seasoned emacs expert. I have broken the initial barriers of emacs and can find my way around elisp. So, be gentle. :-) </p>
|
<p>Emacs ships with url.el and url-http.el. Although http-get.el, http-post.el and http-cookies.el are in vogue today. Here's the GitHub link where you can get it from.</p>
<p><a href="http://github.com/wfarr/dotfiles/tree/master/.elisp" rel="nofollow noreferrer">http://github.com/wfarr/dotfiles/tree/master/.elisp</a></p>
<p>Any other suggestions are also welcome.</p>
|
<p>If I were to work on this, I'd use <a href="http://pymacs.progiciels-bpi.ca/" rel="nofollow noreferrer">Pymacs</a> to interface Emacs to Python and then use the existing <a href="http://repo.or.cz/w/pyrtm.git" rel="nofollow noreferrer">Python API kit</a> for Remember the Milk. Why re-implement all the HTTP crud yourself?</p>
| 2,747
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.