instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I have a few controls that inherit from <code>ASP.NET buttons</code> and use <code>onserverclick</code>.</p> <p>If the user clicks twice, the button fires two server side events. How can I prevent this?</p> <p>I tried setting <code>this.disabled='true'</code> after the click (in the <code>onclick</code> attribute)...
<p>See this example for disabling control on postback. It should help you do what you're trying to achieve.</p> <p><a href="http://encosia.com/2007/04/17/disable-a-button-control-during-postback/" rel="noreferrer">http://encosia.com/2007/04/17/disable-a-button-control-during-postback/</a></p>
<p>You can also try for example btnSave.Enable = false; when the button is hit and before the processing for the button is done in the Click Event routine. If you need it to be reset to allow it to be enabled have a separate button that resets the button for reuse. </p> <p>Another method is to set the button with ve...
7,323
<p>I have an Ender 5 Pro with a flexible build plate (The factory default one).</p> <p>There are multiple extremely thin tracks of melted PLA all over it. Too thin to easily peal off when cooled. Thin enough that you can run your finger over them and barely know that they are there.</p> <p>What is the best way to clean...
<h2>TL;DR:</h2> <p>Print more PLA on top of them, and pull it off together.</p> <h2>Preparation</h2> <p>First, of course, clean it well with IPA. This will both ensure there's no oil or other material on top of the PLA that will prevent it from bonding well with new PLA, and start to work underneath it to get it loose....
<p>If you can feel it with your finger, then you can scrape it off. Just be careful. Keep the scraper closer to horizontal and don't dig in. It doesn't really need much effort.</p> <p>If you can't feel it with your finger then it doesn't matter. Just clean as normal and carry on printing over it.</p>
2,116
<p>I currently use the following function to do a simple HTTP GET.</p> <pre><code>public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); ...
<p>In this case, I would do as you are doing (use a byte array for buffering and not one of the stream buffers).</p> <p>There are exceptions, though. One place you see buffers (output this time) is in the servlet API. Data isn't written to the underlying stream until <em>flush()</em> is called, allowing you to buffer ...
<p>My gut tells me that since you're already performing buffering by using the byte array, it's redundant to use the BufferedReader.</p>
5,131
<ul> <li>Plastic: Same Matterhacker PLA (filament I use every day)</li> <li>Printer: Anycubic i3 Mega (the one I use every day)</li> <li>Slicer: Ultimaker Cura 4.2.1</li> </ul> <p>I don't know what's causing it, I haven't changed any slicer settings to my knowledge, I haven't changed anything on the printers end, and ...
<p>There are 3 general factors about print adhesion you always have to keep in mind:</p> <ul> <li>Have a sufficient surface for the print to stick. A pyramid printed on the tip can't print properly.</li> <li>Check the leveling of your bed occasionally and relevel the bed. By removing prints, one can easily unlevel it ...
<p>This seems like a long-shot, but I've noticed at this time of year many 3D prints fail. We noticed 4 printers all went dead and had massive non-stick issues last year about this time. Turns out it was mostly around changes in temperature and humidity - the outside temperature changed inside AC settings/wind-flow, ...
1,463
<p>How do I calculate the distance between two points specified by latitude and longitude?</p> <p>For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available.</p>
<p>This <a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="noreferrer">link</a> might be helpful to you, as it details the use of the <a href="http://en.wikipedia.org/wiki/Haversine_formula" rel="noreferrer">Haversine formula</a> to calculate the distance.</p> <p>Excerpt:</p> <blockquote> <p>This s...
<p>Here's a simple javascript function that may be useful from this <a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="nofollow">link</a>.. somehow related but we're using google earth javascript plugin instead of maps</p> <pre><code>function getApproximateDistanceUnits(point1, point2) { var xs = 0...
4,760
<p>Is it possible (in Vb.Net 2005), without manually parsing the dataset table properties, to create the table and add it to the database?</p> <p>We have old versions of our program on some machines, which obviously has our old database, and we are looking for a way to detect if there is a missing table and then gener...
<p>See this MSDN Forum Post: <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/4929a0a8-0137-45f6-86e8-d11e220048c3/" rel="nofollow noreferrer">Creating a new Table in SQL Server from ADO.net DataTable</a>. </p> <p>Here the poster seems to be trying to do the same thing as you, and p...
<p>Here is the code: </p> <pre class="lang-cs prettyprint-override"><code>SqlConnection con = new SqlConnection("Data Source=.;uid=sa;pwd=sa123;database=Example1"); con.Open(); string sql = "Create Table abcd ("; foreach (DataColumn column in dt.Columns) { sql += "[" + column.ColumnName + "] " + "nvarchar(50)"...
3,715
<p>I have an issue with my Anet A8 printer and how it interlocks with Ultimaker Cura. </p> <p>I want to print this file named <code>Loki_hörner_v2.stl</code>and Cura slices it fine, but when it comes to printing all the preheat happens, but then it stops, not going on at all. What might be wrong here?</p>
<p>Special characters like <code>Ä</code> <code>Ö</code> or <code>Ü</code> in the stl-filename resulted in Ultimaker Cura creating a comment of the filename in the g-code that read like </p> <pre><code>;MESH:Loki_hörner_v2.stl </code></pre> <p>This apparently could not be parsed by the Anet A8, leading to an error an...
<h3>Avoid naming <code>.gcode</code> files with non-ASCII characters</h3> <em>(this includes <a href="https://en.wikipedia.org/wiki/Extended_ASCII" rel="nofollow noreferrer">EASCII</a>)</em> <p>I know of no firmware on a printer that can handle files that have characters not present in the set of 95 non-control <a href...
1,230
<p>We are in the initial planning stages of building out a mobile site for one of our clients. This mobile site will be in addition to the main site that we have already built for them. We've determined that the content is going to be a small subsection of the main site and will target the main audience that is expec...
<p>Newer phones come with WAP2 which uses HTML Mobile Profile (XHTML MP), which is quite similar to normal HTML. Older phones use Wireless Markup Language (WML). </p> <p>Depending on your audience I would consider making a mobile phone friendly version of the site using XHTML MP and drop WML completely. By mobile pho...
<p>I think the main difference with the 2.5G phones and the new 3G phones is that while 2.5G phones used their own browsers, browsers on 3G phones have become much more similar/accurate in their rendering capabilities.</p> <p>On the other hand, you can use CSS to render the same HTML in either a large screen format or...
3,086
<p>How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#?</p> <p>I know to do it using plan <code>String.Replace</code>, like:</p> <pre><code>myStr.Replace(&quot;\n&quot;, &quot;\r\n&quot;); myStr.Replace(&quot;\r\r\n&quot;, &quot;\r\n&quot;); </code></pre> <p>However, t...
<p>Will this do?</p> <pre><code>[^\r]\n </code></pre> <p>Basically it matches a '\n' that is preceded with a character that is not '\r'.</p> <p>If you want it to detect lines that start with just a single '\n' as well, then try</p> <pre><code>([^\r]|$)\n </code></pre> <p>Which says that it should match a '\n' but ...
<pre><code>myStr.Replace("([^\r])\n", "$1\r\n"); </code></pre> <p>$ may need to be a \</p>
5,091
<p>Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments. It seems like commenting is not allowed by default, how do I change this?</p> <p>I am using straight to PDF with pdflatex and acrobat reader...
<p>I think your problem is that acrobat reader doesn't allow commenting on documents not produced by abode approved products, which I don't think pdflatex would be. </p> <p>You should look at the free <a href="http://www.docu-track.com/home/prod_user/PDF-XChange_Tools/pdfx_viewer" rel="noreferrer">PDF-XChange Viewer</...
<p>I would definitely have a look at the <a href="https://rads.stackoverflow.com/amzn/click/com/0201433117" rel="nofollow noreferrer" rel="nofollow noreferrer">LaTeX Web Companion</a>. There is a whole section about generating PDF from LaTeX, including esoterica such as forms.</p>
4,708
<p>How do I load a Python module given its full path?</p> <p>Note that the file can be anywhere in the filesystem where the user has access rights.</p> <hr /> <p><sub><strong>See also:</strong> <a href="https://stackoverflow.com/questions/301134">How to import a module given its name as string?</a></sub></p>
<p>For Python 3.5+ use (<a href="https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly" rel="noreferrer">docs</a>):</p> <pre><code>import importlib.util import sys spec = importlib.util.spec_from_file_location(&quot;module.name&quot;, &quot;/path/to/file.py&quot;) foo = importlib.util.module...
<p>The best way, I think, is from the official documentation (<a href="https://docs.python.org/3.2/library/imp.html#examples" rel="nofollow">29.1. imp — Access the import internals</a>):</p> <pre><code>import imp import sys def __import__(name, globals=None, locals=None, fromlist=None): # Fast path: see if the mo...
9,318
<p>I have an actionscript file that defines a class that I would like to use inside a Flex application. </p> <p>I have defined some custom controls in a actionscript file and then import them via the application tag:</p> <pre> <code> &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:scorecard...
<p>You'd need to import the class inside a script tag.</p> <pre><code>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt; &lt;mx:Script&gt; import com.apterasoftware.scorecard.controls.*; // Other imports go here // Functions and other code go here &lt;/mx:Script&gt; &lt;!-- Componen...
<p>@Herms: To clarify a little, namespace declarations can be used to "import" AS classes as well, when you're going to instantiate them using MXML.</p> <p>For example, consider having a custom visual component you've written entirely in AS, let's say <code>com.apterasoftware.scorecard.controls.MathVisualizer</code>. ...
6,101
<p>I've tried to write a string replace function in C, which works on a <code>char *</code>, which has been allocated using <code>malloc()</code>. It's a little different in that it will find and replace strings, rather than characters in the starting string.</p> <p>It's trivial to do if the search and replace string...
<p>As a general rule, you should <strong>never</strong> do a free or realloc on a user provided buffer. You don't know where the user allocated the space (in your module, in another DLL) so you cannot use any of the allocation functions on a user buffer.</p> <p>Provided that you now cannot do any reallocation within y...
<p>My quick hints.</p> <p>Instead of:<br> <code>void strrep(char *input, char *search, char *replace)</code><br> try:<br> <code>void strrep(char *&amp;input, char *search, char *replace)</code></p> <p>and than in the body:<br> <code>input = realloc(input, strlen(input) + delta);</code></p> <p>Generally read about pa...
2,356
<p>I have my Wordpress install and MediaWiki <a href="https://stackoverflow.com/questions/33745" title="Thanks ceejayoz">sharing the same login information</a>. Unfortunately, users need to log into both separately, but at least they use the same credentials. </p> <p>What I would like to do is cause a successful log...
<p>The primary problem you are going to run into is that you'll have two login forms, and two logout methods. What you need to do is pick one of the login forms as the default, and redirect the other one over to it.</p> <p>I've been able to <a href="http://www.howtogeek.com" rel="nofollow noreferrer">successfully inte...
<p>You could consider some kind of single-sign-on software. I am unaware of any that are free and I've only ever used <a href="http://ca.com/us/internet-access-control.aspx" rel="nofollow noreferrer">SiteMinder</a> which is neither free nor good. <a href="http://www.atlassian.com/software/crowd/default.jsp" rel="nofoll...
5,800
<p>I am going to design and build a 3D printer. I want the highest quality and accuracy so nothing except that is important for me. Which cartesian design has the highest quality and accuracy? CoreXY, Prusa, or Gantry (Ultimaker)?</p> <p>Also, is it better to have a nozzle that moves in just direction &quot;X&quot;, di...
<p>The tradeoffs in these systems are all about quality achievable at particular speed and acceleration profiles. If you really don't care about speed at all and want maximum accuracy, you probably want some type of Cartesian setup with no belts, only rigid lead screws which you can take to as fine a pitch as you like,...
<p>The tradeoffs in these systems are all about quality achievable at particular speed and acceleration profiles. If you really don't care about speed at all and want maximum accuracy, you probably want some type of Cartesian setup with no belts, only rigid lead screws which you can take to as fine a pitch as you like,...
1,717
<p>I've seen these words a lot around Subversion (and I guess general repository) discussions.<br> I have been using <strong>SVN</strong> for my projects for the last few years, but I've never grasped the complete concept of these directories.</p> <p>What do they mean?</p>
<p>Hmm, not sure I agree with Nick re tag being similar to a branch. A tag is just a marker</p> <ul> <li><p><a href="http://svnbook.red-bean.com/en/1.8/svn.tour.importing.html#svn.tour.importing.layout" rel="noreferrer"><strong>Trunk</strong></a> would be the main body of development, originating from the start of the...
<p><strong>Trunk</strong> : After the completion of every sprint in agile we come out with a partially shippable product. These releases are kept in trunk.</p> <p><strong>Branches</strong> : All parallel developments codes for each ongoing sprint are kept in branches.</p> <p><strong>Tags</strong> : Every time we rele...
3,687
<p>Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists...
<p>This is probably a combination of impersonation and a mismatch of different authentication methods occurring.</p> <p>There are many pieces; I'll try to go over them one by one.</p> <p><strong>Impersonation</strong> is a technique to "temporarily" switch the user account under which a thread is running. Essentially...
<p>You can use <strong>Path.GetTempPath()</strong> to find out which directory to which it's trying to write.</p>
7,916
<p>A DB Audit Trail captures the User Last Modified, Modified Date, and Created Date.</p> <p>There are several possible implementations:</p> <ul> <li>SQL Server Triggers</li> <li>Add UserModified, ModifiedDate, CreatedDate columns to the database and include logic in Stored Procedures or Insert, Update statements acc...
<p>Depending on what you're doing, you might want to move the audit out of the data layer into the data access layer. It give you more control.</p> <p>I asked a similar question wrt NHibernate and SqlServer <a href="https://stackoverflow.com/questions/15917/data-auditing-in-nhibernate-and-sqlserver">here</a>.</p>
<p>Here is the implementation I use to audit tables: <a href="http://www.simple-talk.com/sql/database-administration/pop-rivetts-sql-server-faq-no.5-pop-on-the-audit-trail/" rel="nofollow noreferrer">Pop Rivett's SQL Server FAQ No.5: Pop on the Audit Trail</a></p>
8,601
<p>I have defined a Java function:</p> <pre><code>static &lt;T&gt; List&lt;T&gt; createEmptyList() { return new ArrayList&lt;T&gt;(); } </code></pre> <p>One way to call it is like so:</p> <pre><code>List&lt;Integer&gt; myList = createEmptyList(); // Compiles </code></pre> <p>Why can't I call it by explicitly pa...
<p>When the java compiler cannot infer the parameter type by itself for a static method, you can always pass it using the full qualified method name: Class . &lt; Type > method();</p> <pre><code>Object list = Collections.&lt;String&gt; emptyList(); </code></pre>
<p>@pauldoo Yes, you are quite right. It is one of the weaknesses with the java generics imho.</p> <p>I response to Cheekysoft I'd like to propose to also look at how it is done by the Java people themselves, such as T[] <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/AbstractCollection.html" rel="nofollow ...
4,463
<p>Can the performance of this sequential search algorithm (taken from <a href="http://books.google.co.uk/books?id=to6M9_dbjosC&amp;dq=the+practice+of+programming&amp;pg=PP1&amp;ots=3YH6Ggq0_a&amp;sig=F2-ajdO37xA4iRec2sCyQF55Jjc&amp;hl=en&amp;sa=X&amp;oi=book_result&amp;resnum=1&amp;ct=result" rel="noreferrer">The Pra...
<p>Yes, but only very slightly. A much bigger performance improvement can be achieved by using better algorithms (for example keeping the list sorted and doing a binary search).</p> <p>In general optimizing a given algorithm only gets you so far. Choosing a better algorithm (even if it's not completely optimized) can ...
<pre><code>/* there is no more quick */ int lookup(char *word, char*array[]) { int i; for(i=0; *(array++) != NULL;i++) if (strcmp(word, *array) == 0) return i; return -1; } </code></pre>
3,665
<p>Most program languages have some kind of exception handling; some languages have return codes, others have try/catch, or rescue/retry, etc., each with its own pecularities in readability, robustness, and practical effectiveness in a large group development effort. Which one is the best and why ?</p>
<p>I would say that depends on the nature of your problem. Different problem domains could require almost arbitrary error messages, while other trivial tasks just can return NULL or -1 on error. </p> <p><em>The problem with error return codes is that you're polluting/masking the error since it can be ignored (sometime...
<p>try/catch/finally does the job admirably. </p> <p>It allows the programmer to handle specific conditions as well as general failures gracefully.</p> <p>All said and done I'm sure that each is as good as any other.</p>
9,170
<p>I need to send and receive data over serial connections (RS-232 and RS-422).</p> <p>How do I set up and communicate with such a connection? How do I figure out what the configuration settings (e.g. baud rate) should be and how do I set them?</p> <p>In particular I am looking to do this in Java, C/C++, or one of t...
<p>Build a time machine and go back to 1987? Ho ho.</p> <p>Ok, no more snarky comments.</p> <blockquote> <p>How do I figure out what the configuration settings (e.g. baud rate) should be...</p> </blockquote> <p>Read the datasheet? Ok, ok. Seriously, last one. If you don't know the baud rate of the device you are t...
<p>I have been using purejavacomm: <a href="http://www.sparetimelabs.com/purejavacomm/index.html" rel="nofollow">It is an implementation of javax.comm written in pure java + JNA</a></p> <p>Unlike rxtx, you don't need to install a dll. It is written in pure Java + JNA, which solved the problem of portability between Wi...
2,519
<p>I have lots and lots of data in various structures. Are there any better platforms other than Excel charts which can help me. </p> <p>thanks</p>
<p>What about <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">google charts</a>?</p>
<p>Depends a bit what your objectives are and how technical you are willing to get.</p> <p><a href="http://incanter.org/" rel="nofollow">Incanter</a> is a great toolset that I can heartily recommend (I use it for visualisation in my own projects). It's a statistical computing and visualisation library for Clojure - wh...
7,862
<p>I have a new Creality Ender 2 Pro with a Creality 4.2.3 mainboard. I'm attempting to compile Marlin to fix a bug. How can I tell what driver chips I have on this board?</p> <p>I've narrowed it down to likely <code>A4988</code> or <code>TMC2208_STANDALONE</code> or possibly the <code>TMC2225</code>. Strangely Crealit...
<p>According to <a href="https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382" rel="nofollow noreferrer">'The-EG' comment</a> in this GitHub issue, <a href="https://github.com/MarlinFirmware/Configurations/pull/633" rel="nofollow noreferrer">Add Creality Ender 2 Pro config #633</a>, you can ...
<p>MS35775 appears to be TMC208 compatible. You can find the data sheet on relmon.com here is the overview:</p> <ul> <li>2-Phase stepping motor peak current of 2A</li> <li>Step / dir interface 2, 4, 8, 16, or 32 microstep</li> <li>Internal 256 micro steps</li> <li>Quiet mode</li> <li>Fast mode</li> <li>HS Rdson 0.29 Ω...
2,071
<p>I think this is specific to IE 6.0 but...</p> <p>In JavaScript I add a <code>div</code> to the DOM. I assign an <code>id</code> attribute. When I later try to pick up the <code>div</code> by the <code>id</code> all I get is <code>null</code>.</p> <p>Any suggestions?</p> <p>Example:</p> <pre><code>var newDiv = do...
<p>In addition to what the other answers suggest (that you need to actually insert the element into the DOM for it to be found via <code>getElementById()</code>), you also need to use a lower-case attribute name in order for IE6 to recognize it as the <code>id</code>:</p> <pre><code>var newDiv = document.createElement...
<p>newDiv.setAttribute( "ID", "obj_1000" );</p> <p>should be</p> <p>newDiv.id = "obj_1000";</p>
7,609
<p>I was working with quality yesterday doing some formal testing. In their procedure they were verifying all files on the test machine were pulled from the release. The way they were verifying these files were the same was by checking the size and the date/time stamp windows put on them in Windows Explorer. These h...
<p>The only 100% way to figure out if two files are equal is to do a binary comparison of the two.</p> <p>If you can live with the risk of false positives (ie. two files which aren't 100% identical but your code says they are), then the digest and checksum algorithms can be used to lessen the work, particularly if the...
<p>You should do a CRC check on each file... from the wiki:</p> <p><a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check" rel="nofollow noreferrer">Cyclic redundancy check</a>, a type of hash function used to produce a checksum, in order to detect errors in transmission or storage.</p> <p>It produces an almos...
2,668
<p>In Visual C++ a DWORD is just an unsigned long that is machine, platform, and SDK dependent. However, since DWORD is a double word (that is 2 * 16), is a DWORD still 32-bit on 64-bit architectures?</p>
<p>Actually, on 32-bit computers a word is 32-bit, but the DWORD type is a leftover from the good old days of 16-bit.</p> <p>In order to make it easier to port programs to the newer system, Microsoft has decided all the old types will not change size.</p> <p>You can find the official list here: <a href="http://msdn.m...
<p>Windows API defines DWORD sizes as follows:</p> <ul> <li><strong>x86:</strong> sizeof(DWORD) = <strong>4</strong></li> <li><strong>x64:</strong> sizeof(DWORD) = <strong>4</strong></li> </ul>
6,047
<p>I have a friend that has a little bit of a holiday coming up and they want ideas on what they should do during the holiday, I plan to suggest programming to them, what are the pros and cons that I need to mention?</p> <p>I'll add to the list below as people reply, I apologise if I duplicate any entries.</p> <p><st...
<h2>I do it for the ladies :D</h2> <p>Seriously though, for me</p> <h3>Pro's</h3> <ul> <li>Great challenge, every day really is a fresh challenge in some way, shape or form. Not many jobs can truly offer that.</li> <li>I like the way it makes me think.. I look at EVERYTHING more logically as my skills improve.. This he...
<p>You could tell him how into programmers girls are.. you know, lie.</p>
3,205
<p>Every time I publish the application in <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow noreferrer">ClickOnce</a> I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at th...
<p>We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj's <code>AfterCompile</code> target to trigger the ClickOnce publish with our preferred version number:</p> <pre class="lang-xml prettyprint-override"><code>&lt;MSBuild Projects="$(SolutionRoot)\MyProject\Myproject.csproj" ...
<p>You'll probably need to create a piece of code that updates AssemblyInfo.cs according to the version number stored in the .csproj file. (The ClickOnce deploy version is stored inside an XML tag.)</p> <p>You'd then change your .csproj file to run this bit of code when Publish|Release build is performed. The MSBuild ...
6,623
<p>I have a method in my Python code that returns a tuple - a row from a SQL query. Let's say it has three fields: (jobId, label, username)</p> <p>For ease of passing it around between functions, I've been passing the entire tuple as a variable called 'job'. Eventually, however, I want to get at the bits, so I've been...
<p>I'd say that a dictionary is definitely the best way to do it. It's easily extensible, allows you to give each value a sensible name, and Python has a lot of built-in language features for using and manipulating dictionaries. If you need to add more fields later, all you need to change is the code that converts th...
<p>How about this:</p> <pre><code>class TypedTuple: def __init__(self, fieldlist, items): self.fieldlist = fieldlist self.items = items def __getattr__(self, field): return self.items[self.fieldlist.index(field)] </code></pre> <p>You could then do:</p> <pre><code>j = TypedTuple(["jobid",...
6,308
<p>What .NET namespace or class includes both Context.Handler and Server.Transfer?</p> <p>I think one may include both and my hunt on MSDN returned null. </p>
<p>System.Web.</p> <pre><code>HttpContext.Current.Handler HttpContext.Current.Request.Server.Transfer </code></pre>
<blockquote> <p>Hmmmm, I talking about them as they are implemented here:</p> <p><a href="http://blog.benday.com/archive/2008/03/31/23176.aspx" rel="nofollow noreferrer">http://blog.benday.com/archive/2008/03/31/23176.aspx</a></p> <p>(at least Context.Handler there)</p> <p>I am still having trouble in ...
6,083
<p>Is there any shorthand way of defining and using generic definitions without having to keep repeating a particular generic description such that if there is a change I don't have to change all definitions/usages though out the codebase for example is something like this possible:</p> <pre><code>Typedef myGenDef = &...
<p>There's the <a href="http://www.ibm.com/developerworks/java/library/j-jtp02216/index.html" rel="nofollow noreferrer">pseudo-typedef antipattern</a>... </p> <pre><code>class StringList extends ArrayList&lt;String&gt; { } </code></pre> <p>Good stuff, drink up! ;-)</p> <p>As the article notes, this technique has som...
<p>No. Though, groovy, a JVM language, is dynamically typed and would let you write:</p> <pre><code>def map = new HashMap&lt;complicated generic expression&gt;(); </code></pre>
5,900
<p>I have an MFC application compiled with /clr and I'm trying to implement a final handler for otherwise un-caught managed exceptions. For native exceptions, overriding <code>CWinApp::ProcessWndProcException</code> works.</p> <p>The two events suggested in Jeff's <a href="http://www.codeproject.com/KB/exception/Excep...
<p>Taking a look around the internets, you'll find that you need to install a filter to get the unmanaged exceptions passing the filters on their way to your AppDomain. From <a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2007/12/30/clr-and-unhandled-exception-filters.aspx" rel="nofollow noreferrer">CLR and U...
<p>Using those two exception handlers should work. Are you sure you've added them in a place where they're going to be called and properly set (ie, in your application's <em>managed</em> entry point -- you did put one in, right?)</p>
3,019
<p>How does the comma operator work in C++?</p> <p>For instance, if I do:</p> <pre><code>a = b, c; </code></pre> <p>Does a end up equaling b or c? </p> <p>(Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.)</p> <p><strong>Update:</strong> This question has expos...
<p>It would be equal to <code>b</code>.</p> <p>The comma operator has a lower precedence than assignment.</p>
<p><strong>First things first:</strong> Comma is actually not an operator, for the compiler it is just a token which gets a meaning <em>in context</em> with other tokens.</p> <h2>What does this mean and why bother?</h2> <p><strong>Example 1:</strong></p> <p>To understand the difference between the meaning of the sam...
7,774
<p>Either I had a bad dream recently or I am just too stupid to google, but I remember that someone somewhere wrote that ASP.net has a Function which allows "merging" multiple JavaScript files automatically and only delivering one file to the client, thus reducing the number of HTTP Requests.</p> <p>Server Side, you s...
<p>It's called <a href="http://msdn.microsoft.com/en-us/library/cc837190.aspx" rel="noreferrer">Script Combining</a>. There is a video example from asp.net explaining it <a href="http://www.asp.net/Learn/3.5-SP1/video-296.aspx" rel="noreferrer">here</a>.</p>
<p>you can find <a href="http://www.codeproject.com/KB/aspnet/HttpCombine.aspx" rel="nofollow noreferrer">here</a> an usefull article for it</p>
7,027
<p>I'm trying to "install SGML::Parser::OpenSP" from the cpan shell, but it fails on the first "make test". I also get the same error if I go into the build directory and run make test.</p> <p>I believe this bit of the output below is the relevant part. Note the Symbol not found when perl gets to the "use" line for t...
<p>If you use the Settings for the project, you can mark each setting as either application or user.</p> <p>If they're set as user, they will be stored per-user and when you call the Save method it will be updated in the config for that user.</p> <p>Code project has a really detailed <a href="http://www.codeproject.c...
<p>app.config isn't what you want to use for user-tweakable data, as it'll be stored somewhere in Program Files (which the user shouldn't have write permissions to). Instead, settings marked with <code>a UserScopedSettingAttribute</code> will end up in a user-scoped .config file somewhere in %LocalAppData%.</p> <p>I f...
5,699
<p>I took the plunge and bought a resin printer. I was wondering if I could use full strength home-brew vodka at 90 % instead of using isopropyl alcohol before anything is added to clean prints with?</p> <p>I cannot seem to find anywhere or anyone that has tried this.</p>
<p>Isopropyl-Alcohol - Propan-2-ol - and Ethyl alcohol - Ethan-1-ol - are different chemically. As a secondary alcohol, Propan-2-ol has quite different solubility of different materials than ethyl-alcohol.</p> <p>Now, let's look at home made alcoholic destillate. That stuff is, if done in one refraction and without tos...
<p>Some manufacturers do recommend ethanol and not isopropanol. The problem would be getting relatively pure ethanol through distillation. When distilling you will get different fractions which may be full of methanol or water. You will probably need to do multiple runs. You could just buy some 95% ethanol and distill ...
1,746
<p>Originally I am looking for a solution in Actionscript. The point of this question is the algorithm, which detects the exact Minute, when a clock has to switch the Daylight Saving Time. </p> <p>So for example between the 25th and the 31th of October we have to check, if the actual date is a sunday, it is before or ...
<p>There is no real algorithm for dealing with Daylight Saving Time. Basically every country can decide for themselves when -and if- DST starts and ends. The only thing we can do as developers is using some sort of table to look it up. Most computer languages integrate such a table in the language.</p> <p>In Java you ...
<p>The <a href="https://stackoverflow.com/a/154765/642706">Answer by Richters</a> is correct and should be accepted.</p> <p>As Richters noted, there is no logic to <a href="https://en.wikipedia.org/wiki/Daylight_saving_time" rel="nofollow noreferrer">Daylight Saving Time (DST)</a> or other anomalies. Politicians arbit...
9,640
<p>I'm working on a visual studio 2005 vb.net windows forms project that's been around for several years. It's full of default textboxes, labels, dropdowns, datagrids, datetime pickers -- all the standard stuff. The end result is a very gray, old-looking project.</p> <p>What would be the best approach to making this...
<p>I was actually just sprucing up a dialog today. A lot of it depends on what kind of application you have, and what OS it is running on. A couple of these tips will certainly go a long way to jazzing things up.</p> <ol> <li><p>Ensure adequate spacing between controls — don't cram them all together. Space is appeal...
<p>This depends on how the existing "gray old looking" project is structured in terms of code. For example, is data access code separated from the UI in a Data Access Layer, is the business logic in a Business Logic Layer? If yes, then cleaning the UI for a snazzy look should be relatively simple.</p> <p>If everythi...
5,376
<p>Do you use ILMerge? Do you use ILMerge to merge multiple assemblies to ease deployment of dll's? Have you found problems with deployment/versioning in production after ILMerging assemblies together?</p> <p>I'm looking for some advice in regards to using ILMerge to reduce deployment friction, if that is even possibl...
<p>I use ILMerge for almost all of my different applications. I have it integrated right into the release build process so what I end up with is one exe per application with no extra dll's. </p> <p>You can't ILMerge any C++ assemblies that have native code. You also can't ILMerge any assemblies that contain XAML for...
<p>It seems to me like the #1 ILMerge Best Practice is Don't Use ILMerge. Instead, use <a href="http://www.red-gate.com/products/smartassembly/index.htm" rel="nofollow noreferrer">SmartAssembly</a>. One reason for this is that the #2 ILMerge Best Practice is to always run PEVerify after you do an ILMerge, because ILM...
3,080
<p>This came to my mind after I learned the following from <a href="http://www.stackoverflow.com/questions/8941/generic-type-checking">this question</a>:</p> <pre><code>where T : struct </code></pre> <p>We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.</p> <p>Som...
<p>This isn't C# per se, but I haven't seen anyone who really uses <code>System.IO.Path.Combine()</code> to the extent that they should. In fact, the whole Path class is really useful, but <strong>no one uses it!</strong></p> <p>I'm willing to bet that every production app has the following code, even though it should...
<p>I don't know if this is a hidden feature (""). Any string function.</p>
3,052
<p>I am currently in the process of restructuring my local Subversion repository by adding some new projects and merging legacy code and data from a couple of older repositories into it. </p> <p>When I have done this in the past I have usually put the legacy code in a dedicated "legacy" folder, as not to "disturb" the...
<p>All code becomes 'legacy' one day, why seperate it at all? Source control is by project/branch or project/platform/branch and that type of hierarchy. Who cares how long in the tooth it is?</p>
<p>Use <em>Externals Definitions</em> (<a href="http://svnbook.red-bean.com/en/1.7/svn.advanced.externals.html" rel="nofollow noreferrer">svn:externals</a> property) to reference your legacy code as you would a third-party repository. </p> <p>Then you can separate your refactoring work from your dependent projects an...
7,463
<p>Mac OS X ships with apache pre-installed, but the files are in non-standard locations. This question is a place to collect information about where configuration files live, and how to tweak the apache installation to do things like serve php pages.</p>
<p>Apache Config file is: /private/etc/apache2/httpd.conf</p> <p>Default DocumentRoot is: /Library/Webserver/Documents/</p> <p>To enable PHP, at around line 114 (maybe) in the /private/etc/apache2/httpd.conf file is the following line:</p> <pre><code>#LoadModule php5_module libexec/apache2/libphp5.so </code></pr...
<p>httpd.conf is in /private/etc/apache2</p> <p>Enable PHP by uncommenting line:</p> <pre><code> LoadModule php5_module libexec/apache2/libphp5.so </code></pre>
9,518
<p>Is there a way to call out from a TSQL stored procedure or function to a webservice?</p>
<p>Yes , you can create like this</p> <pre><code>CREATE PROCEDURE CALLWEBSERVICE(@Para1 ,@Para2) AS BEGIN Declare @Object as Int; Declare @ResponseText as Varchar(8000); Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; Exec sp_OAMethod @Object, 'open', NULL, 'get', 'http://www.webservicex.com/stockquot...
<p>If you're working with sql 2000 compatibility levels and cannot do clr integration, see <a href="http://www.vishalseth.com/post/2009/12/22/Call-a-webservice-from-TSQL-(Stored-Procedure)-using-MSXML.aspx" rel="nofollow noreferrer">http://www.vishalseth.com/post/2009/12/22/Call-a-webservice-from-TSQL-(Stored-Procedure...
5,348
<p><em>Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language.</em></p> <p>I am used to create my properties in C# using a private and a public field:</p> <pre><code>private string title; public string...
<p>We use them all the time in Stack Overflow.</p> <p>You may also be interested in a discussion of <a href="http://blog.codinghorror.com/properties-vs-public-variables/" rel="noreferrer">Properties vs. Public Variables</a>. IMHO that's really what this is a reaction to, and for that purpose, it's great.</p>
<p>I use CodeRush, it's faster than auto-properties.</p> <p>To do this:</p> <pre><code> private string title; public string Title { get { return title; } set { title = value; } } </code></pre> <p>Requires eight keystrokes total.</p>
3,073
<p>Assemblies A and B are privately deployed and strongly named. Assembly A contains references to Assembly B. There are two versions of Assembly B: B1 and B2. I want to be able to indicate for Assembly A that it may bind to either B1 or B2 -- ideally, by incorporating this information into the assembly itself. Wha...
<p>There are several places you can indicate to the .Net Framework that a specific version of a strongly typed library should be preferred over another. These are:</p> <ul> <li>Publisher Policy file</li> <li>machine.config file</li> <li>app.config file</li> </ul> <p>All these methods utilise the <a href="http://msdn...
<p>You can set version policy in your app.config file. Alternatively you can manually load these assemblies with a call to <code>Assembly.LoadFrom()</code> when this is done assembly version is not considered.</p>
7,816
<p>We have a large database on which we have DB side pagination. This is quick, returning a page of 50 rows from millions of records in a small fraction of a second.</p> <p>Users can define their own sort, basically choosing what column to sort by. Columns are dynamic - some have numeric values, some dates and some t...
<p>Most of the SQL-based solutions I have seen break when the data gets complex enough (e.g. more than one or two numbers in it). Initially I tried implementing a NaturalSort function in T-SQL that met my requirements (among other things, handles an arbitrary number of numbers within the string), but the performance wa...
<p>I still don't understand (probably because of my poor English).</p> <p>You could try:</p> <pre><code>ROW_NUMBER() OVER (ORDER BY dbo.human_sort(field_name) ASC) </code></pre> <p>But it won't work for millions of records.</p> <p>That why I suggested to use trigger which <em>fills</em> <em>separate</em> column wit...
5,477
<p>I've got it configured, but I want more from it...maybe Cygwin isn't the right tool, but I like how it provides a *nix-like environment within Windows.</p>
<p>I've found Cygwin to be very useful in the past. FWIW, lately however I've shied away from it in favor of the following:</p> <ol> <li><a href="http://www.apachefriends.org/en/xampp-windows.html" rel="nofollow noreferrer">XAMPP</a></li> <li><a href="http://unxutils.sourceforge.net/" rel="nofollow noreferrer">Unixut...
<p>I'm quite interested in this question myself. I've used the <a href="https://code.google.com/archive/p/jessies/wikis/CygwinSetup.wiki" rel="nofollow noreferrer">Cygwin Setup guide</a> to get set up, but it doesn't get you all the way. One thing that I learned from it, though, is that it recommends leaving the setup....
8,036
<p>I'm working on a command line application for Solaris, written in Java6. I'd like to be able to scroll through a history of previous commands using the up and down arrows like many Unix tools allow (shells, VIM command mode prompt, etc).</p> <p>Is there any standard way of achieving this, or do I have to roll my ow...
<p>Yes, use the <a href="http://tiswww.case.edu/php/chet/readline/rltop.html" rel="nofollow noreferrer">GNU readline</a> library.</p>
<p>There is a SourceForge project, <a href="http://java-readline.sourceforge.net/" rel="nofollow noreferrer">http://java-readline.sourceforge.net/</a>, that provides JNI-based bindings to GNU readline. I've played around with it (not used in an actual project), and it certainly covers all of the functionality.</p>
7,148
<p><a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="nofollow noreferrer">Ajax</a>, <a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="nofollow noreferrer">Flex</a> and <a href="http://en.wikipedia.org/wiki/Microsoft_Silverlight" rel="nofollow noreferrer">Silverlight</a> are a few ways to make more...
<p>Here's a quick rundown of each area (with lots of helpful links):</p> <h2>Cross-platform compatibility</h2> <p><a href="http://arstechnica.com/news.ars/post/20050808-5183.html" rel="nofollow noreferrer">Ajax</a> works in <a href="http://www.musingsfrommars.org/2006/03/ajax-dhtml-library-scorecard.html" rel="nofoll...
<p>Other than what's already been mentioned here, another huge thing to consider is what your UI is going to be.</p> <p>If you're going to be using a lot of advanced UI controls like trees, lists, tab controls, etc then consider the following:</p> <ul> <li><p>JavaScript/HTML - No native support for anything beyond th...
7,129
<p>I have a <code>List&lt;int&gt;</code> and a <code>List&lt;customObject&gt;</code>. The customObject class has an ID property. How can I get a <code>List&lt;customObject&gt;</code> containing only the objects where the ID property is in the <code>List&lt;int&gt;</code> using LINQ?</p> <p><strong>Edit</strong>: I acc...
<pre><code>var result = from o in objList where intList.Contains(o.ID) select o </code></pre>
<p>Please note that using the join instead of contains DOES NOT work when the count of items in the list exceeds 49! You will get the error: <code>Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.</code></p>
5,861
<p>I'm having a frustrating problem with my recent built custom 3D printer so every single print I made, from the third layer, the nozzle is &quot;rubbing&quot; on the already placed filament. This results in a complete mess, melting the previous layers with the nozzle / new extrusions coming, getting malformed and ou...
<p>I have made some learning on mechanical setup and discovered some issues on my printer, there are few:</p> <ol> <li>Bed warped, even with glass (thin thickness), making BAL confused with Z-movement over the bed.</li> <li>Overextrusion making layer oversized in terms of thickness.</li> <li>Some of missing mechanical...
<p>The first picture seems to show layer shift. Usual causes include:</p> <ol> <li>Missed Z movement, so the nozzle hits the build and the layer is offset.</li> <li>Bad acceleration in X/Y, so there is missed X/Y movement, and the layer is offset.</li> </ol> <p>Adjustment: reduce Z G0 speed, and reduce X/Y speeds (G0...
697
<p>When I print with a 0.4&nbsp; mm nozzle I have no problem with stringing at all but because I need a more detailed print I must use a 0.25&nbsp;mm nozzle.</p> <p>I use Ultimaker Cura and an Anycubic i3 Mega.</p> <p>What i tried so far:</p> <ul> <li>Enable/Disable Z hop</li> <li>Tried different retraction distance...
<p>First, you should change the <strong>nozzle diameter</strong> setting, not just the line width setting, in Cura. Both are involved in determining extrusion. Line width can be less than or greater than nozzle size, but setting it much larger or smaller is not going to work well.</p> <p>I suspect your main problem, t...
<p>What worked well for me in avoiding stringing is to increase the travel move speeds significantly, disable Z-hop and to decrease printing temperature</p>
1,344
<p>If there are any language designers out there (or people simply in the know), I'm curious about the methodology behind creating standard libraries for interpreted languages. Specifically, what seems to be the best approach? Defining standard functions/methods in the interpreted language, or performing the processing...
<p>The line between "interpreted" and "compiled" languages is really fuzzy these days. For example, the first thing Python does when it sees source code is compile it into a bytecode representation, essentially the same as what Java does when compiling class files. This is what *.pyc files contain. Then, the python run...
<p>As long as you are using a portable API for the compiled code base like the <a href="http://en.wikipedia.org/wiki/C_standard_library" rel="nofollow noreferrer">ANSI C standard library</a> or <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" rel="nofollow noreferrer">STL</a> in C++, then taking advanta...
3,452
<p>Consider the Oracle <code>emp</code> table. I'd like to get the employees with the top salary with <code>department = 20</code> and <code>job = clerk</code>. Also assume that there is no "empno" column, and that the primary key involves a number of columns. You can do this with:</p> <pre><code>select * from scott.e...
<p>The following is slightly over-engineered, but is a good SQL pattern for "top x" queries.</p> <pre><code>SELECT * FROM scott.emp WHERE (deptno,job,sal) IN (SELECT deptno, job, max(sal) FROM scott.emp WHERE deptno = 20 and job = 'CLERK' GROUP BY deptno, job ) </code></pr...
<p>That's great! I didn't know you could do a comparison of (x, y, z) with the result of a SELECT statement. This works great with Oracle.</p> <p>As a side-note for other readers, the above query is missing a "=" after "(deptno,job,sal)". Maybe the Stack Overflow formatter ate it (?).</p> <p>Again, thanks Mark.</p>
7,395
<p>I'm having issues getting the C sockets API to work properly in C++ on z/OS.</p> <p>Although I am including <code>sys/socket.h</code>, I still get compile time errors telling me that <code>AF_INET</code> is not defined.</p> <p>Am I missing something obvious, or is this related to the fact that being on z/OS makes my...
<p>Keep a copy of the IBM manuals handy:</p> <ul> <li><a href="http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CBCPG1A0/CCONTENTS?DT=20090606065305" rel="noreferrer"> z/OS V1R11.0 XL C/C++ Programming Guide</a> </li> <li><a href="http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EDCLB1A0/CCONTENTS...
<p>DISCLAIMER: I am not a C++ programmer, however I know C really well. I adapated these calls from some C code I have.</p> <p>Also markdown put these strange &#95; as my underscores.</p> <p>You should just be able to write an abstraction class around the C sockets with something like this:</p> <pre><code>class my_...
2,240
<p>Can anyone recommend a good server-side PDF generation tool that would work in a Linux environment. I want easy as possible, pass it a XHTML file (with images) and have it generate a PDF from the <strong>rendered</strong> source.</p> <p>I don't have a massive budget, but anything under $1000 should be alright.</p> ...
<p>I used <a href="http://www.easysw.com/htmldoc/" rel="nofollow noreferrer">HTMLDoc</a> about 8 years ago and it did a good job of turning HTML tables with some basic formatting into a decent PDF report. There also seems to be an <a href="https://www.msweet.org/projects.php?Z1" rel="nofollow noreferrer">open source ve...
<p>I did some searching, what about <a href="http://tbookdtd.sourceforge.net/" rel="nofollow noreferrer">tbookdtd</a>? It's downloadable <a href="http://sourceforge.net/project/showfiles.php?group_id=48834" rel="nofollow noreferrer">here</a> but it hasn't been active since 2005. It appears to convert the xml to Latex,...
3,570
<p>I have three tables <code>tag</code>, <code>page</code>, <code>pagetag</code></p> <p>With the data below</p> <p><strong><em>page</em></strong></p> <pre><code>ID NAME 1 page 1 2 page 2 3 page 3 4 page 4 </code></pre> <p><strong><em>tag</em></strong></p> <pre><code>ID NAME 1 ...
<blockquote> <p>Sergio del Amo:</p> <blockquote> <p>However, I am not getting the pages without tags. I guess i need to write my query with left outer joins.</p> </blockquote> </blockquote> <pre><code>SELECT pagetag.id, page.name, group_concat(tag.name) FROM ( page LEFT JOIN pagetag ON page.id = paget...
<p>I think you may need to use multiple updates.</p> <p>Something like (not tested):</p> <pre><code>select ID as 'PageId', Name as 'PageName', null as 'Tags' into #temp from [PageTable] declare @lastOp int set @lastOp = 1 while @lastOp &gt; 0 begin update p set p.tags = isnull(tags + ', ', '' ) + t.[Tagid]...
5,849
<p>What's the best way to get the contents of the mixed <code>body</code> element in the code below? The element might contain either XHTML or text, but I just want its contents in string form. The <code>XmlElement</code> type has the <code>InnerXml</code> property which is exactly what I'm after.</p> <p>The code as...
<p>I wanted to see which of these suggested solutions performed best, so I ran some comparative tests. Out of interest, I also compared the LINQ methods to the plain old <strong>System.Xml</strong> method suggested by Greg. The variation was interesting and not what I expected, with the slowest methods being <strong>mo...
<pre><code>public static string InnerXml(this XElement xElement) { //remove start tag string innerXml = xElement.ToString().Trim().Replace(string.Format("&lt;{0}&gt;", xElement.Name), ""); ////remove end tag innerXml = innerXml.Trim().Replace(string.Format("&lt;/{0}&gt;", xElement.Name), ""); return...
2,582
<p>I'd like to prefix this question with the fact that I know virtually nothing about 3D printers, aside from the general principles of how they work.</p> <p>I've recently seen that SLS printers have become more affordable, to the point where in a few years they might be a compelling investment. I'm mainly interested ...
<h2>Consumer Market?</h2> <p>While there are no &quot;consumer level&quot; SLS printers on the market currently, the question in itself is very interesting on a scientific level. The pricing edges for the consumer market for 3D printers can be somewhat estimated from the consumer electronics segment. This puts a maximu...
<p>It's difficult to tell from your photo the level of detail required. A scale reference in the form of a metric ruler would be valuable. If, for example, the metallic eye on the gunner is 2 mm diameter, that would be 40 layers of 50 micron grains, allowing for substantial detail.</p> <p>Consumer level SLS printers, ...
1,585
<p>What is the difference between a pointer variable and a reference variable?</p>
<ol> <li><p>A pointer can be re-assigned:</p> <pre><code>int x = 5; int y = 6; int *p; p = &amp;x; p = &amp;y; *p = 10; assert(x == 5); assert(y == 10); </code></pre> <p>A reference cannot be re-bound, and must be bound at initialization:</p> <pre><code>int x = 5; int y = 6; int &amp;q; // error int &amp;r = x; </code>...
<p>In short,</p> <blockquote> <p>Pointers: A pointer is a variable that holds the memory address of another variable. A pointer needs to be dereferenced with the * operator to access the memory location it points to. - Extracted from Geeks for Geeks</p> </blockquote> <blockquote> <p>References: A reference variable is ...
8,172
<p>Is there a way to <em>always</em> have LF line endings in Visual Studio? I can never seem to find it!</p>
<p>There'a an add-in for Visual Studio 2008 that converts the end of line format when a file is saved. You can download it here: <a href="http://grebulon.com/software/stripem.php" rel="noreferrer">http://grebulon.com/software/stripem.php</a></p>
<p>There's a plugin to VS called Strip'Em where you can choose which kind of new line type you want to auto convert all the line endings to when saving.</p> <p>(You can choose between LF, CRLF, CR.)</p>
6,702
<p>Has anyone had any experience in building a 'real world' application with the <a href="http://www.codeplex.com/smartclient" rel="noreferrer">Smart Client Software Factory</a>, from Microsofts Patterns and Practices group? I'm looking for advice on how difficult it was to master, whether it decreased your time to ma...
<p>We used SCSF for a real world app with about 10 developers. It was a steep learning curve to set up and develop a pattern of usage, but once it was set up, introducing new developers to the project was VERY easy. Using CAB and SCSF was very beneficial to our project especially getting each developer up to speed and ...
<p>We use the <a href="http://www.codeplex.com/servicefactory" rel="nofollow noreferrer">Web Service Software Factory</a>, and we really like it because it makes it easier for developers to follow standards and appropriate patterns. The learning curve for us wasn't bad - a few hours per developer at most.</p> <p>Other...
2,800
<p>There is a conversion process that is needed when migrating Visual Studio 2005 web site to Visual Studio 2008 web application projects.</p> <p>It looks like VS2008 is creating a .designer. file for every aspx when you right click on a file or the project itself in Solution Explorer and select 'Convert to Web Applic...
<p>They hold all the form designer stuff that used to go in the #Region " Web Form Designer Generated Code " section of the code. instead of putting it in the .aspx.vb file where people might edit it (mistakenly or not), it's been moved to a separate file, so that you don't have ever look at it.</p>
<p>What kibbee said. </p> <p>For the part of your question about existing on a release build, it depends on what kind of web site you have. If you have a pre-compiled web site, then <em>none</em> of code files (.vb, .cs, etc) need to be deployed the server. They are compiled into .dlls (assemblies) and deployed tha...
4,811
<p>I could have sworn I read somewhere that when printing with TPU to make sure the part cooling fan is blowing. But I just did a quick Googling and couldn't find anything stating such on Matter Hackers or All3dp.</p> <p>I currently don't have a part cooling fan attached (waiting for square nuts to come in). I've been...
<p>You'll probably be fine printing TPU with no fan. I just started printing with TPU, and did a lot of test prints to find out what settings work. Fan made little difference. With hotend at 230 °C, which I started out with, 0-20% fan was fine. I eventually increased temperature to 250 °C, which made extrusion more con...
<p>Sharing fan percentages like in <a href="/a/11852/">this answer</a> is only helpful if you use the same printer model, cooling fan and cooling duct. As there are many 3D printers and many cooling fans, ducts and solutions, this cannot be readily adopted to every 3D printer.</p> <p>So, in such a case I would rely on...
1,564
<p>I am building a server control that will search our db and return results. The server control is contains an ASP:Panel. I have set the default button on the panel equal to my button id and have set the form default button equal to my button id.</p> <p>On the Panel:</p> <pre><code> MyPanel.DefaultButton = SearchBut...
<p>Ends up this resolved my issue:</p> <pre><code> SearchButton.UseSubmitBehavior = False </code></pre>
<p>I might be wrong and this might not make a difference but have you tried:</p> <pre><code>Me.Page.Form.DefaultButton = SearchButton.ID </code></pre> <p>instead of</p> <pre><code>Me.Page.Form.DefaultButton = SearchButton.UniqueID </code></pre>
2,788
<p>I'm building a 3D printer and I've been looking around for materials suitable to make the frame.</p> <p>I have occasional access to a laser cutter which I could use to manufacture a ply box-type (UltiMaker) enclosure, but I like the ease of adjustment provided by the T-slot beam kits.</p> <p>I don't have any metal...
<p>Aluminum of almost every grade is very easy to cut with a hacksaw. I would suggest to mark clearly the cut line and to wrap masking tape at the edge of the cut. Consider to allow for about 2-3 millimeters (1/16") extra material for final finishing. Cut across the line, rotate the part ninety degrees and cut again. O...
<p>As an alternative solution, Misumi sells extrusions precision-cut to length for a very reasonable price. You'll get better quality ends and a more precisely square frame from Misumi than if you try to cut them yourself. The HFS-5 series of 2020 is perfect for 3D printers. </p>
222
<p>I'm looking for design\architectual guidance for modern text editors.</p> <p><em>Modern</em> text editor means that: </p> <ul> <li>It has support for syntax highlighting</li> <li>It has auto-completion (something like IntelliSense)</li> <li>It has advanced navigation capabilities (incremental search, etc.)</li> <...
<p>The ultimate text editor is, of course, emacs. I found <a href="http://www.finseth.com/craft/" rel="noreferrer">The Craft of Text Editing, or, Emacs for the Modern World </a> to be an excellent self-study guide for the basics of writing an editor. The examples are all in plain old C, and the text might look a bit da...
<p>Have you looked at vim? It supports autocompletion, syntax highlighting, incremental search, integrated building, etc, etc. It is modular and many of its more advanced features are implemented as plugins that either ship with it or can be found separately (e.g., svn integration, code indexing with cscope/ctags, tran...
8,309
<p>I have a <a href="http://en.wikipedia.org/wiki/JavaServer_Faces" rel="nofollow noreferrer">JSF</a> application that I am converting over to use webservices instead of straight up database queries. There are some extremely long lists that <em>before</em> could be returned easily with a simple SQL query. I'd like to f...
<p>I like Seam's Query objects: <a href="http://docs.jboss.com/seam/2.1.0.BETA1/reference/en-US/html_single/#d0e7527" rel="nofollow noreferrer">http://docs.jboss.com/seam/2.1.0.BETA1/reference/en-US/html_single/#d0e7527</a></p> <p>They basically abstract all the SQL/JPA in a Seam component that JSF can easily use.</p>...
<p>If you are getting all the results back from the webservice at once and can't include pagination into the actual web service call, you can try setting the list of items to a property on a managed bean. Then you can hook that up to the "value" attribute on a Tomahawk dataTable: </p> <p><a href="http://myfaces.apache...
9,531
<p>I have an Enumerable array</p> <pre><code>int meas[] = new double[] {3, 6, 9, 12, 15, 18}; </code></pre> <p>On each successive call to the mock's method that I'm testing I want to return a value from that array.</p> <pre><code>using(_mocks.Record()) { Expect.Call(mocked_class.GetValue()).Return(meas); } using(...
<p>There is alway static fake object, but this question is about rhino-mocks, so I present you with the way I'll do it. The trick is that you create a local variable as the counter, and use it in your anonymous delegate/lambda to keep track of where you are on the array. Notice that I didn't handle the case that GetVal...
<p>IMHO, yield will handle this. <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0%28VS.80%29.aspx" rel="nofollow noreferrer">Link</a>.</p> <p>Something like:</p> <pre><code>get_next() { foreach( float x in meas ) { yield x; } } </code></pre>
9,468
<p>For those of you in the Visual Studio environment, how do you feel about wrapping any of your code in #regions? (or if any other IDE has something similar...)</p>
<p>9 out of 10 times, code folding means that you have failed to use the <a href="http://en.wikipedia.org/wiki/Separation_of_concerns" rel="noreferrer">SoC principle</a> for what its worth.<br /> I more or less feel the same thing about partial classes. If you have a piece of code you think is too big you need to chop ...
<p>I prefer #regions myself, but an old coworker couldn't stand to have things hidden. I understood his point once I worked on a page with 7 #regions, at least 3 of which had been auto-generated and had the same name, but in general I think they're a useful way of splitting things up and keeping everything less clutter...
2,780
<p>I have a whole bunch of files with filenames using our lovely Swedish letters <strong>å å</strong> and <strong>ö</strong>. For various reasons I now need to convert these to an [a-zA-Z] range. Just removing anything outside this range is fairly easy. The thing that's causing me trouble is that I'd like to replace <s...
<p>You can use this code (Python)</p> <h1>Rename international files</h1> <pre><code># -*- coding: cp1252 -*- import os, shutil base_dir = "g:\\awk\\" # Base Directory (includes subdirectories) char_table_1 = "áéíóúñ" char_table_2 = "aeioun" adirs = os.walk (base_dir) for adir in adirs: dir = adir[0] + "\\...
<p>I would write this in C++, C#, or Java -- environments where I know for certain that you can get the Unicode characters out of a path properly. It's always uncertain with command-line tools, especially out of Cygwin.</p> <p>Then the code is a simple find/replace or regex/replace. If you can name a language it wou...
8,105
<p>I have a long print that keeps aborting. At some random point mid-print the printer says "Click to resume...". There is nothing in the G-code that asks for user confirmation. What could it be that triggers this? I noticed that sometimes (not every time) there is a blob of plastic in the way that should not be there....
<p>To answer your question directly, this action (<code>Click to resume...</code>) is triggered by a buffer overflow of the Marlin firmware that is caused by the repetitive sending of <code>M105</code> command by Ultimaker Cura (without checking the result).</p> <p>This problem is a <a href="https://github.com/Ultimak...
<p>Tonight I had faced the same problem.</p> <p>I've read somewhere (can't find the source now) that this is a Cura bug that has been fixed in Cura 3.6 beta</p>
1,070
<p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html" rel="noreferrer">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p> <pre><code>n = 5.59 round(n, 1) # 5.6 </code></pre> <p>But, in actuality, good...
<p>I can't help the way it's stored, but at least formatting works correctly: </p> <pre><code>'%.1f' % round(n, 1) # Gives you '5.6' </code></pre>
<p>What about:</p> <pre><code>round(n,1)+epsilon </code></pre>
8,093
<p>I need to set the height of every textbox on my form, some of which are nested within other controls. I thought I could do something like this:</p> <pre><code>private static IEnumerator&lt;TextBox&gt; FindTextBoxes(Control rootControl) { foreach (Control control in rootControl.Controls) { if (contr...
<p>As the compiler is telling you, you need to change your return type to IEnumerable. That is how the yield return syntax works.</p>
<p>If you are given an enumerator, and need to use it in a for-each loop, you could use the following to wrap it:</p> <pre> static public class enumerationHelper { public class enumeratorHolder&lt;T&gt; { private T theEnumerator; public T GetEnumerator() { return theEnumerator; } public...
2,548
<p>I have an <a href="https://www.thingiverse.com/thing:3723481" rel="nofollow noreferrer">STL</a> (Raspberry Pi 4 casing) that automatically places itself like below on the bed surface:</p> <p><a href="https://i.stack.imgur.com/0Xm8V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Xm8V.png" alt="en...
<p>The second placement is a better choice from an overall standpoint. In the vertical placement, adhesion is going to be more critical, although Prusa printers have good bonding for PLA and ABS, from my direct experience.</p> <p>The other aspect of more importance is that the holes are going to be distorted in the ver...
<p>You've already got the correct answer, but I want to address an additional misconception in your question: head movement efficiency. Most 3D print jobs are <em>acceleration-bound</em>, not <em>top-speed-bound</em>. Without really cranking up the acceleration limits (which requires Klipper and input shaper tuning), t...
2,024
<p>The following <strong>C++</strong> code uses a <strong>ifstream</strong> object to read integers from a text file (which has one number per line) until it hits <strong>EOF</strong>. Why does it read the integer on the last line twice? How to fix this?</p> <p><strong>Code:</strong></p> <pre><code>#include &lt;iostr...
<p>Just follow closely the chain of events.</p> <ul> <li>Grab 10</li> <li>Grab 20</li> <li>Grab 30</li> <li>Grab EOF</li> </ul> <p>Look at the second-to-last iteration. You grabbed 30, then carried on to check for EOF. You haven't reached EOF because the EOF mark hasn't been read yet ("binarically" speaking, its co...
<pre><code>int x; ifile &gt;&gt; x while (!iFile.eof()) { cerr &lt;&lt; x &lt;&lt; endl; iFile &gt;&gt; x; } </code></pre>
4,177
<p>Which <strong>standalone Windows GUI application</strong> do you recommend for use for accessing a Subversion repository?</p> <p>Edit: A lot of people are mentioning Tortoise, however I am looking for an application not a shell extension. Also people are questioning my reasoning behind not wanting to use a shell e...
<p><strong>Standalone Clients</strong></p> <p>For total stand alone <a href="http://www.syncrosvnclient.com/" rel="nofollow noreferrer">Synchro SVN</a> is a powerful and cross platform solution. It looks like the most native application on each of the platforms.</p> <p>The <a href="http://subversion.tigris.org/links...
<p>Memory and disk IO can be a problem with TSVNCache, which manages Tortoise's icon overlays. You can fix it by putting your checkouts in one or two directories and making the cache process only look at those directories, rather than your entire drive.</p> <p><a href="http://www.paraesthesia.com/archive/2007/09/26/o...
8,364
<p>Are there any VC++ settings I should know about to generate better PDB files that contain more information? </p> <p>I have a crash dump analysis system in place based on the project <a href="http://code.google.com/p/crashrpt/" rel="nofollow noreferrer">crashrpt</a>.</p> <p>Also, my production build server has the ...
<blockquote> <p>"Are there any VC++ settings I should know about"</p> </blockquote> <p>Make sure you turn off Frame pointer ommision. Larry osterman's blog has <a href="http://blogs.msdn.com/larryosterman/archive/2007/03/12/fpo.aspx" rel="noreferrer">the historical details</a> about fpo and the issues it causes wit...
<p>In case anyone is interested, a co-worker replied to this question to me via email:</p> <p>Artem wrote: </p> <blockquote> <p>There is a flag to MiniDumpWriteDump() that can do better crash dumps that will allow seeing full program state, with all global variables, etc. As for call stacks, I doubt they ca...
5,681
<p>When attempting to print using the SSRS Viewer Web Part in SharePoint I get the following error.</p> <blockquote> <p>An error occured during printing. (0x8007F303)</p> </blockquote> <p>The settings we are using in this box (production) are exactly the same as the settings in testing where this works perfectly fi...
<p>I found some ideas by Googling.</p> <ul> <li><a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=307315" rel="nofollow noreferrer">Someone had issue with "SSRS server configured for Sharepoint Integrated mode with Cumulative update package 3 for SQL Server 2005 Service Pack 2" but ...
<p>You may have a custom authentication in use for Reporting Services defined in your web.config. Check if that is the case, remove the custom authentication and try again.</p>
9,453
<p>Given two different image files (in whatever format I choose), I need to write a program to predict the chance if one being the illegal copy of another. The author of the copy may do stuff like rotating, making negative, or adding trivial details (as well as changing the dimension of the image).</p> <p>Do you know ...
<p>These are simply ideas I've had thinking about the problem, never tried it but I like thinking about problems like this!</p> <p><strong>Before you begin</strong></p> <p>Consider normalising the pictures, if one is a higher resolution than the other, consider the option that one of them is a compressed version of t...
<p>If you're willing to consider a different approach altogether to detecting illegal copies of your images, you could consider <a href="http://www.watermarkingworld.org/faq.html" rel="nofollow noreferrer">watermarking</a>. (from 1.4)</p> <blockquote> <p>...inserts copyright information into the digital object witho...
4,373
<p>I'd like to force Klipper to perform power on (using <code>M80</code>) before homing. For this purpose I'm trying to override <code>G28</code>:</p> <pre><code>[gcode_macro G28] rename_existing: G28_BASE gcode: M80 G28_BASE { rawparams } </code></pre> <p>But for some reason this does not work, I'm getting the fol...
<p>Because of the way parameters work differently (<code>Sx</code> vs <code>NAME=x</code>) for gcode style commands vs Klipper extended ones, the rename has to be to the &quot;same type&quot; of command. <code>G28_BASE</code> does not fit the pattern to be considered a &quot;gcode style&quot; one. Use <code>G9028</code...
<p>Besides using a different macro, it is also possible to use <a href="https://www.klipper3d.org/Config_Reference.html#homing_override" rel="nofollow noreferrer">[homing_override]</a> which allows you to redefine the homing sequence.</p> <p>You can write a simple homing_override like (untested!)</p> <pre><code>[homing...
2,108
<p>I was looking at the API documentation for stl vector, and noticed there was no method on the vector class that allowed the removal of an element with a certain value. This seems like a common operation, and it seems odd that there's no built in way to do this.</p>
<p><code>std::remove</code> does not actually erase elements from the container: it moves the elements to be removed to the end of the container, and returns the new end iterator which can be passed to <code>container_type::erase</code> to do the actual removal of the extra elements that are now at the end of the conta...
<p>If you want to do it without any extra includes: </p> <pre><code>vector&lt;IComponent*&gt; myComponents; //assume it has items in it already. void RemoveComponent(IComponent* componentToRemove) { IComponent* juggler; if (componentToRemove != NULL) { for (int currComponentIndex = 0; currComponen...
6,108
<p>I have an information retrieval application that creates bit arrays on the order of 10s of million bits. The number of "set" bits in the array varies widely, from all clear to all set. Currently, I'm using a straight-forward bit array (<code>java.util.BitSet</code>), so each of my bit arrays takes several megabytes....
<p>Unless the data is truly random <strong><em>and</em></strong> has a symmetric 1/0 distribution, then this simply becomes a lossless data compression problem and is very analogous to CCITT Group 3 compression used for black and white (i.e.: Binary) FAX images. CCITT Group 3 uses a Huffman Coding scheme. In the case o...
<p>Straight forward lossless compression is the way to go. To make it searchable you will have to compress relatively small blocks and create an index into an array of the blocks. This index can contain the bit offset of the starting bit in each block.</p>
5,676
<p>I'm doing something bad in my ASP.NET app. It could be the any number of CTP libraries I'm using or I'm just not disposing something properly. But when I redeploy my ASP.NET to my Vista IIS7 install or my server's IIS6 install I crash an IIS worker process.</p> <p>I've narrowed the problem down to my HTTP crawler, ...
<p>Download Debugging tools for Windows: <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" rel="noreferrer">http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx</a></p> <p>Debugging Tools for Windows has has a script (ADPLUS) that allows you to create dumps when a process CRASHES: <a hre...
<p>A quick search found <a href="http://www.iisfaq.com/default.aspx?view=P197" rel="nofollow noreferrer">IISState</a> - it relies on the <a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" rel="nofollow noreferrer">Windows debugging tools</a> and needs to be running when a crash occurs, but given th...
7,688
<p>My designer keeps throwing out the term "liquid" layout. What does this mean?</p> <p><strong>Thanks for the clarification, I have always just called this a percentage layout, and thought he was saying that the pieces could be moved around, and that was liquid</strong></p>
<p>A "liquid" layout is a site layout that expands to fill the entire available area as the browser window is resized. Typically this is done using CSS. Liquid layouts can be quite helpful for certain types of sites, but they also tend to be significantly more effort than fixed width layouts, and their usefulness depen...
<p>Liquid Layouts refer to the design concept of a website. A liquid layout will move in and out when you resize your browser window, due to is having percentages and relative widths in the CSS.</p>
8,772
<p>In FlashPrint there is an <strong>Extrusion Ratio</strong> setting. It's set to 97 % for the stock PLA profile and 107 % for the stock PETG profile.</p> <p>I would've thought these would be 100 % by default (and the same for all materials). Why is it that these defaults make sense and they differ? Why would you need...
<p>If your extruder uses spring tension to hold the filament against the hob, the effective diameter of the filament at the point the hob contacts, which determines the amount moved, is a function of the compressibility of the material. Thus, it makes sense to use a higher flow ratio for more compressible filaments. Ho...
<p>I may be entirely out of my league here, But I think it's related to Viscosity, or how thin or thick the fluid plastic is while hot and Temperature Expansion, how much larger in volume the fluid plastic will be hot compared to cold.</p>
2,006
<p>What is the best way to convert a UTC datetime into local datetime. It isn't as simple as a getutcdate() and getdate() difference because the difference changes depending on what the date is.</p> <p>CLR integration isn't an option for me either.</p> <p>The solution that I had come up with for this problem a few mo...
<p>Create two tables and then join to them to convert stored GMT dates to local time:</p> <pre><code>TimeZones e.g. --------- ---- TimeZoneId 19 Name Eastern (GMT -5) Offset -5 </code></pre> <p>Create the daylight savings table and populate it with as much information as you can (local laws...
<p>Maintain a TimeZone table, or shell out with an extended stored proc (xp_cmdshell or a COM component, or your own) and ask the OS to do it. If you go the xp route, you'd probably want to cache the offset for a day.</p>
4,442
<p>For a university project, my partner and I need to print the robot Poppy. This is an open source robotic project, <a href="https://www.poppy-project.org/fr/" rel="nofollow noreferrer">poppy-project.org</a>.</p> <p>We are printing it with a double extruder SpiderBot with PLA and HIPS as support material. Our princip...
<p>Having a bit more experience since my comment post above, I can offer up a possible solution. If your printer is able to print ABS, it works great with HIPS as support material. I've been printing boatloads of ABS models. When support is needed, the HIPS supports will bond reasonably well to the ABS, but when cooled...
<p>Why not try using PVA(Polyvinyl alcohol) for support material.</p> <p>I use it for my support material with PLA, and it dissolves in water.</p> <p>here is a link to some on Amazon.<br> <a href="https://smile.amazon.com/eSUN-1-75mm-filament-natural-0-5kg/dp/B00MVIQASU/ref=sr_1_3?s=industrial&amp;ie=UTF8&amp;qid=150...
579
<p>Is it possible to use an UnhandledException Handler in a Windows Service?</p> <p>Normally I would use a custom built Exception Handling Component that does logging, phone home, etc. This component adds a handler to System.AppDomain.CurrentDomain.UnhandledException but as far as I can tell this doesn’t achieve anyth...
<p>Ok, I’ve done a little more research into this now. When you create a windows service in .Net, you create a class that inherits from System.ServiceProcess.ServiceBase (In VB this is hidden in the .Designer.vb file). You then override the OnStart and OnStop function, and OnPause and OnContinue if you choose to. The...
<p>You can subscribe to the <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx" rel="nofollow noreferrer">AppDomain.UnhandledException event</a>. If you have a message loop, you can tie to the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threa...
8,264
<p>I'm not sure what the correct size should be.</p> <p>Many sites seem to repeat that the apple-touch-icon should be 57x57 pixels but cite a broken link as their source.</p> <p><a href="http://www.hanselman.com/blog/MakeYourWebsiteMobileAndIPhoneFriendlyAddHomeScreenIPhoneIconsAndAdjustTheViewPort.aspx" rel="norefer...
<p>It seems that Apple guidelines as of August 3, 2010 now include the "High resolution" images (for iPhone 4) in their "required" icon sizes.</p> <p>Looks like we need to provide both a 57x57 and a 114x114 image now, as well as a 640x960 title image.</p> <p>See <a href="http://developer.apple.com/iphone/library/docu...
<p>I don't think there is a "correct size". Since the iPhone really is running OSX, the icon rendering system is pretty robust. As long as you give it a high-quality image with the right aspect ratio and a resolution at least as high as the actual output will be, the OS will downscale very cleanly. My site uses a 158x1...
2,391
<p>Are there any documented techniques for speeding up mySQL dumps and imports?</p> <p>This would include my.cnf settings, using ramdisks, etc. </p> <p>Looking only for documented techniques, preferably with benchmarks showing potential speed-up.</p>
<ol> <li>Get a copy of <em>High Performance MySQL</em>. Great book. </li> <li>Extended inserts in dumps </li> <li>Dump with --tab format so you can use mysqlimport, which is faster than mysql &lt; dumpfile</li> <li>Import with multiple threads, one for each table.</li> <li>Use a different database engine if possible. i...
<p>Using indexes but not too much, activate query cache, using sphinx for big database, here is some good tips <a href="http://www.keedeo.com/media/1857/26-astuces-pour-accelerer-vos-requetes-mysql" rel="nofollow">http://www.keedeo.com/media/1857/26-astuces-pour-accelerer-vos-requetes-mysql</a> (In French)</p>
9,270
<p>Trying to do this sort of thing...</p> <pre><code>WHERE username LIKE '%$str%' </code></pre> <p>...but using bound parameters to prepared statements in PDO. e.g.:</p> <pre><code>$query = $db-&gt;prepare("select * from comments where comment like :search"); $query-&gt;bindParam(':search', $str); $query-&gt;execute...
<p>Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evaluated, and not worry about quoting it. So for example this works fine:</p> <pre><code>$str = "%$str%"; $query = $db-&gt;prepare("select * from comments where comment like :search"); $query-&gt;...
<p>5 years later, in case anyone else stumbles upon this, there is an alternative method I've discovered. The accepted solution wasn't really feasible for my situation, but this method seems to get the job done as well:</p> <pre><code>$query = $db-&gt;prepare("select * FROM table WHERE field LIKE CONCAT('%',:search,'%...
8,579
<p>I'm currently working on an internal sales application for the company I work for, and I've got a form that allows the user to change the delivery address.</p> <p>Now I think it would look much nicer, if the textarea I'm using for the main address details would just take up the area of the text in it, and automatic...
<p>Facebook does it, when you write on people's walls, but only resizes vertically.</p> <p>Horizontal resize strikes me as being a mess, due to word-wrap, long lines, and so on, but vertical resize seems to be pretty safe and nice.</p> <p>None of the Facebook-using-newbies I know have ever mentioned anything about it...
<p>Here is an extension to the Prototype widget that Jeremy posted on June 4th:</p> <p>It stops the user from entering more characters if you're using limits in textareas. It checks if there are characters left. If the user copies text into the textarea, the text is cut off at the max. length:</p> <pre><code>/** * P...
2,901
<p>I am looking for a (preferably) command-line tool that can reformat the C# source code on a directory tree. Ideally, I should be able to customize the formatting. Bonus points if the tool can be run on <a href="https://en.wikipedia.org/wiki/Mono_%28software%29" rel="nofollow noreferrer">Mono</a> (or Linux).</p>
<p>You could also try <a href="http://www.narrange.net" rel="nofollow noreferrer">NArrange</a> to reformat your code. The formatting options it supports are still pretty limited, but it can process an entire directory and is a command-line tool. Also, NArrange runs under Mono.</p>
<p>For completeness, check out <a href="http://uncrustify.sourceforge.net/" rel="nofollow noreferrer">http://uncrustify.sourceforge.net/</a></p>
4,690
<p>I have a framework written in Perl that sets a bunch of environment variables to support interprocess (typically it is sub process) communication. We keep a sets of key/value pairs in XML-ish files. We tried to make the key names camel-case <code>somethingLikeThis</code>. This all works well.</p> <p>Recently we...
<p>As far as I remember, using ALL_CAPS for environment variables is the recommended practice in both Windows and *NIX worlds. My guess is Perl is just using some kind of legacy API to access the environment, and thus only retrieves the upper-case-only name for the variable.</p> <p>In any case, you should never rely o...
<p>Jack M.: Agreed, it is not a problem on Windows. If I create an environment variable Foo I can reference it in Perl as $ENV{FOO} or $ENV{fOO} or $ENV{foo}. The problem is: I create it as Foo and dump the entire %ENV to a file and then read in the file from *NX to recreate the Environment hash and use the same scr...
6,220
<p>I've created a simple desktop application in C# 3.0 to learn some C#, wpf and .Net 3.5. My application essentially reads data from a csv file and stores it in a SQL server CE database. I use sqlmetal to generate the ORM code for the database. My first iteration of this app is ugly as hell and I'm in the process of r...
<p>I would start with the <a href="http://codeplex.com/CompositeWPF" rel="nofollow noreferrer">Composite Application Guidance for WPF</a> (<em>cough</em> PRISM <em>cough</em>) from Microsoft's P&amp;P team. With the download comes a great reference application that is the starting point for most of my WPF development t...
<p>I would say yes, it could easily be structured towards smaller applications. There is a learning curve towards getting started, but honestly, it helped me understand WPF better than attempting to start from scratch. After starting a project with CompositeWPF and then starting another project without it, I found myse...
6,770
<p>I have just got a Monoprice Maker Select 3d printer (which is really just a Wanhao Duplicator i3). </p> <p>I want to print a model that came on the included SD card (<code>1.gcode</code>) with ABS filament. I first press "<code>Preheat ABS</code>" and wait for the display to show the correct temperatures, 245°C for...
<p>The demo files are gcode files generated for use with the sample PLA that comes with the printer. If you want to print it with ABS select the file and set the temperature manually afterwards. </p>
<p>If you want to use the demo files, you can probably pause the print as soon as it starts, and manually set the extruder temperatures before resuming the print. Easier to generate new g-code though.</p>
465
<p>In the SSW rules to better SQL Server Database there is an example of a full database maintenance plan: <a href="http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerDatabases.aspx#MaintenancePlan" rel="noreferrer">SSW</a>. In the example they run both a Reorganize Index and then a Rebuild Index and then ...
<p>Doing a <code>REORGANIZE</code> and then a <code>REBUILD</code> on the same indexes is pointless, as any changes by the <code>REORGANIZE</code> would be lost by doing the <code>REBUILD</code>.</p> <p>Worse than that is that in the maintenance plan diagram from SSW, it performs a <code>SHRINK</code> first, which fra...
<p>My two cents... This method follows the spec outlined on tech net: <a href="http://technet.microsoft.com/en-us/library/ms189858(v=sql.105).aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/ms189858(v=sql.105).aspx</a></p> <pre><code>USE [MyDbName] GO SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF G...
2,912
<p>Lets say I have a loop in Bash:</p> <pre><code>for foo in `some-command` do do-something $foo done </code></pre> <p><code>do-something</code> is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 <code>do-something</code>'s at once.</p> <p>The naive approach seems to be:</p>...
<p>Depending on what you want to do xargs also can help (here: converting documents with pdf2ps):</p> <pre><code>cpus=$( ls -d /sys/devices/system/cpu/cpu[[:digit:]]* | wc -w ) find . -name \*.pdf | xargs --max-args=1 --max-procs=$cpus pdf2ps </code></pre> <p>From the docs:</p> <pre><code>--max-procs=max-procs -P ...
<p>$DOMAINS = "list of some domain in commands" for foo in <code>some-command</code> do</p> <pre><code>eval `some-command for $DOMAINS` &amp; job[$i]=$! i=$(( i + 1)) </code></pre> <p>done</p> <p>Ndomains=<code>echo $DOMAINS |wc -w</code></p> <p>for i in $(seq 1 1 $Ndomains) do echo "wait for ${job[$i]}...
5,906