instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm looking for ideas on how to draw a skinnable "button" in a game application. If I use a fixed sprite non-vector image for the button background, then I can't size the button easily. If I write code to draw a resizable button (like Windows buttons are drawn), then the programmer has to get involved -- and it make... | <p>If you really want to accomplish this, the way to do it is with texture coordinates. Much like you would make a stretchable button/panel design in HTML with a table, you simply define the UV coordinates for the corners, the top stretchable area, the bottom stretchable area, the side stretchable areas, and then the ... | <p>Yes. I am working on an Editor. It's a XAML-like language (or OpenLaszlo-like, if you prefer) for XNA. So the buttons can be resized by the editor. The buttons might also be resized by a style sheet. </p>
<p>I guess you're right that it's likely that the buttons will all be the same size in a real design. But even ... | 2,867 |
<p>I have a set of EJBs and other Java classes which need to be configured differently based on the system environment in which they are deployed: production, test, or lab. The configuration information includes stuff like URLs and database connection information.</p>
<p>We'd like to deploy the same exact product (EAR... | <p>The best, IMHO, is to use JNDI entries.</p>
<p>You may have to recode some parts of your application in order to use theses entries instead of plain vars, but with this setup:</p>
<ul>
<li>Configuration is server-independant: each vendor provides its own implementation, but spec is a standard.</li>
<li>In a cluste... | <p>How database connection pool information is stored / configured depends on the app server vendor. Put other variable stuff in property files on the classpath.</p>
| 39,997 |
<p>I'm planning to set up log shipping to a remote site for disaster recovery but I still want to take a nightly full backup so I can copy it to our backup tape and also use it to restore onto our reporting server. Can I do that without breaking the cycle of log backups?</p>
| <p>Yes you can. You start the log shipping process from a restore of a full backup, and from then on you only need to restore transaction log backups. You can take as many diffs or full backups as you like and it doesn't affect the LSN and therefore does not interfere with the log shipping process as long as the logs a... | <p>Here's the SQL Backup overview
<a href="http://msdn.microsoft.com/en-us/library/ms175477(SQL.90).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms175477(SQL.90).aspx</a></p>
<p>FULL, and DIFFERENTIAL backups do not break the LSN log chain, so you are safe to take these backup anytime withou... | 44,727 |
<p>I have a very large table (8gb) with information about files, and i need to run a report against it that would would look something like this:</p>
<pre><code>(select * from fs_walk_scan where file_path like '\\\\server1\\groot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file... | <p>What kind of indexes do you have on that table? This index:</p>
<p>CREATE INDEX fs_search_idx ON fs_walk_scan(file_path, file_size desc)</p>
<p>would speed this query up significantly... if you don't already have one like it.</p>
<p>Update:</p>
<p>You said there are already indexes on file_path and file_size...... | <p>How about something like this (haven't tested it, but looks close):</p>
<pre><code>select * from fs_walk_scan where file_path like '\\\\server' and file_path like 'root$\\%' order by file_size desc
</code></pre>
<p>This way you're doing a pair of comparisons on the individual field which will generically match w... | 19,821 |
<p>Is there a way to customize Firebug's keyboard shortcuts? I love being able to step through JavaScript code using Firebug's <em>Script</em> panel, but it looks like I'm limited to either using the default keyboard shortcuts for stepping over/into/out of code or using the mouse to click the appropriate button. </p>... | <p>You can change them manually. Go to this directory:</p>
<p>In recent versions the extension comes in a single file with the extension XPI. Just rename it to ZIP, create a directory and extract its contents into it.</p>
<p>Linux:</p>
<pre><code>.mozilla/firefox/*****.default/extensions/firebug@software.joehewitt.c... | <p>While it is possible to <a href="https://github.com/firebug/firebug/blob/master/extension/content/firebug/debugger/script/scriptPanel.js#L1552-L1556" rel="nofollow noreferrer">change the shortcuts within Firebug's source code</a>, there is also a way to add different keys for those actions without touching the sourc... | 33,607 |
<p><P>How can I instantiate a JMS queue listener in java (JRE /JDK / J2EE 1.4) that only receives messages that match a given JMSCorrelationID? The messages that I'm looking to pick up have been published to a queue and not a topic, although that can change if needed.</P>
Here's the code that I'm currently using to pu... | <p>The queue connection setup is the same, but once you have the QueueSession, you set the selector when creating a receiver.</p>
<pre><code> QueueReceiver receiver = session.createReceiver(myQueue, "JMSCorrelationID='theid'");
</code></pre>
<p>then</p>
<pre><code>receiver.receive()
</code></pre>
<p>or </p>
<pr... | <pre><code>String filter = "JMSCorrelationID = '" + msg.getJMSMessageID() + "'";
QueueReceiver receiver = session.createReceiver(queue, filter);
</code></pre>
<p>Here the receiver will get the messages for which <code>JMSCorrelationID</code> is equal to <code>MessageID</code>. this is very helpful in request/ response... | 17,960 |
<p>We have an application where our clients are connecting to a SQL Server 2005 database - via a SQL Native Client ODBC data source. We are having some difficulties with the ODBC connection getting severed during program execution. After questioning a tech support person, he said that he had seen this type of error bef... | <p>Note you can set the protocol used in the connection string, there is no need to configure the machine. I would recommend NOT changing the machine configuration using cliconfg, since this impacts all applications running on the machine.</p>
<p>So there are 2 ways to set the network protocol.</p>
<ol>
<li><p>Use ... | <ol>
<li><p>Not sure about Named Pipes being any sort of an answer for ODBC connection breaking. Without first identifying the source of the problem, I wouldn't count on named pipes. I might be wrong though. Can you see any error that may explain this problem? This may be network related.</p></li>
<li><p>Otherwise, I t... | 43,435 |
<p>I am looking for something like like FCKEditor that allows users to follow links by left clicking them.</p>
<p>For example, the markdown editor in StackOverflow does not allow you to click the links you add as you are entering data into the editor. I would like to render a text area pre-populated with some links t... | <p>both tinyMCE and fck editor will highlight the links with blue color and if you ctrl+click on them, will open in a new tab/window (depends of you browser configuration)</p>
| <p>Most HTML richtext don't do anything to the link (with the exception that you can place the cursor in them with a single left click, in order to edit their text) that would prevent you from, for instance, right-clicking to open the link, copy it, or whatever your browser allows.</p>
| 24,129 |
<p>Let's say I'm developing a new desktop application for Windows. Is there a list somewhere that I can consult (either from Microsoft or a 3rd party) of keyboard shortcuts that all Windows applications should support?</p>
<p>(Note: When I say "all Windows applications" here, I really mean "all Windows applications w... | <p><a href="http://msdn.microsoft.com/en-us/library/ms971323.aspx#atg_keyboardshortcuts_complying_with_standard_keyboard_navigation" rel="noreferrer">Guidelines for Keyboard User Interface Design</a>. It contains recommendations for creating keyboard interfaces and contains, towards the bottom of the article, a list o... | <p>For Windows 8 Store apps, there is another set of guidelines for keyboard shortcuts on MSDN:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh700405.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/apps/hh700405.aspx</a></p>
| 34,941 |
<p>I want to create a simple box with a header bar containing a title and some tool buttons. I have the following markup:</p>
<pre><code><div style="float:left">
<div style="background-color:blue; padding: 1px; height: 20px;">
<div style="float: left; background-color:green;">title</di... | <p>Specify width in outermost div.
If that width in your content div means this is the total width of your box, simply add it to the outermost div, and (optionally) remove it from content, like this:</p>
<pre><code><div style="float:left; width: 200px;">
<div style="background-color:blue; padding: 1px; h... | <p>Make this <code><div style="background-color:blue; padding: 1px; height: 20px;></code> the parent of the 2 floating divs also <code>clear:all</code></p>
| 22,680 |
<p>The prompt says that if I install the software into a directory with spaces:</p>
<blockquote>
<p>the rebuild build tool used by the D Shared Source System will fail to build</p>
</blockquote>
<p>and that I will be</p>
<blockquote>
<p>forced to reinstall in a different location</p>
</blockquote>
<p>However, I... | <p>You can also use <a href="http://elsdoerfer.name/=ntfslink" rel="nofollow noreferrer">NTFS Link</a> to create junction points (symlinks for all intents and purposes) and hard links on NTFS file systems. The functionality is built into the NTFS drivers, but an interface was never implemented for it, presumably to avo... | <p>You could install it into C:\Program Files, and then use the <code>subst</code> command to make it appear as a new drive letter:</p>
<pre><code>subst x: "c:\program files\d"
</code></pre>
| 17,459 |
<p>I have an SP that takes 10 seconds to run about 10 times (about a second every time it is ran). The platform is asp .net, and the server is SQL Server 2005. I have indexed the table (not on the PK also), and that is not the issue. Some caveats:</p>
<ul>
<li>usp_SaveKeyword is not the issue. I commented out that en... | <p>Why are you using <code>top 1 @SearchID</code> instead of <code>max (SearchID)</code> or <code>where exists</code> in this query? <code>top</code> requires you to run the query and retrieve the first row from the result set. If the result set is large this could consume quite a lot of resources before you get out... | <p>Triggers!</p>
<p>They are insidious indeed.</p>
| 14,714 |
<p>So I build an array of various dates. Birthdays, anniversaries, and holidays. I'd like to order the array by which one is happening next, essentially sort October to September (wrapping to next year)</p>
<p>so if my array is </p>
<pre><code>$a = ([0]=>"1980-04-14", [1]=>"2007-06-08",
[2]=>"2008-12-25",... | <pre><code>function relative_year_day($date) {
$value = date('z', strtotime($date)) - date('z');
if ($value < 0)
$value += 365;
return $value;
}
function cmp($a, $b)
{
$aValue = relative_year_day($a);
$bValue = relative_year_day($b);
if ($aValue == $bValue)
return 0;
... | <p>Don't compare strings, instead use seconds since 1970 (ints):</p>
<pre><code>$date1 = split("-", $a);
$date2 = split("-", $b);
$seconds1 = mktime(0,0,0,$date1[1],$date1[2],$date1[0]);
$seconds2 = mktime(0,0,0,$date2[1],$date2[2],$date2[0]);
// eliminate years
$seconds1 %= 31536000;
$seconds2 %= 31536000;
return $se... | 20,288 |
<p>Below is part of the XML which I am processing with <a href="http://php.net/XSLTProcessor" rel="nofollow noreferrer">PHP's XSLTProcessor</a>:</p>
<pre><code><result>
<uf x="20" y="0"/>
<uf x="22" y="22"/>
<uf x="4" y="3"/>
<uf x="15" y="15"/>
</result>
</code></pr... | <pre><code><xsl:value-of select="count(/result/uf[@y=@x])" />
</code></pre>
| <pre><code>count('/result/uf[@x = @y]')
</code></pre>
| 12,823 |
<p>I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of <strong><em>memory and speed</em></strong>, way of doing this? </p>
<p>A dict of dicts is more flexible and simpler to im... | <p>I would strongly advocate you look at <a href="http://networkx.github.com/" rel="noreferrer">NetworkX</a>. It's a battle-tested war horse and the first tool most 'research' types reach for when they need to do analysis of network based data. I have manipulated graphs with 100s of thousands of edges without problem o... | <p>No doubt NetworkX is the best data structure till now for graph. It comes with utilities like Helper Functions, Data Structures and Algorithms, Random Sequence Generators, Decorators, Cuthill-Mckee Ordering, Context Managers</p>
<p>NetworkX is great because it wowrs for graphs, digraphs, and multigraphs. It can wri... | 2,359 |
<p>I have a home built RepRap with all sides open..</p>
<p>Would there be any advantage to enclosing the print area in acrylic?</p>
| <p>It is hard to tell whether you personally should enclose your printer. However, you asked for the advantages and I will name some of them on which one can base a decision.</p>
<p>A 3D printer enclosure</p>
<ul>
<li>helps to keep the temperature of the whole print at controlled levels, if you use a heating element,... | <p>If you will be printing PLA, <strong>no</strong>, or at least not without active cooling of the chamber. PLA's glass transition temperature is sufficiently low that the ambient temperature matters a lot to whether layer N can cool enough before layer N+1 is laid, in order to have a firm surface to extrude against an... | 310 |
<p>I'd like to have a job that runs nightly, or even just once a week, that generates a script of our dev databases. They tend to be tinkered with, and developers have a habit of making changes without scripting them, or documenting them.</p>
<p>I'd like to create a job that will essentially mimic what happens when I ... | <p>I'd suggest a different approach that has worked well for me. Run a nightly job that drops the development databases, restores them from a known configuration, and then applies all the change scripts that have been committed to source control.</p>
<p>Advantages of this approach:</p>
<ul>
<li>Your change scripts ar... | <p><a href="http://www.codeplex.com/sqlhost/wiki/view.aspx?title=database%20publishing%20wizard" rel="nofollow noreferrer">Database Publishing Wizard</a> which can be run from the command line.</p>
| 33,862 |
<p>From the MSDN article on STAThread:</p>
<blockquote>
<p>Indicates that the COM threading model for an application is single-threaded apartment (STA).</p>
</blockquote>
<p>(For reference, that's <a href="http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx" rel="noreferrer">the entire article</a... | <p>Apartment threading is a COM concept; if you're not using COM, and none of the APIs you call use COM "under the covers", then you don't need to worry about apartments.</p>
<p>If you do need to be aware of apartments, then the details can get <a href="http://msdn.microsoft.com/en-us/library/ms693344(VS.85).aspx" rel... | <p>STAThread is written before the Main function of a C# GUI Project. It does nothing but allows the program to create a single thread.</p>
| 19,973 |
<p>Whenever a 3D printer that uses linear rails is announced (case in point: the <a href="https://www.cetus3d.com/cetus-3d-printer.html" rel="noreferrer">cetus</a>), the Internet (well... at least that corner of it dealing with 3D printing) gets abuzz with excitement.</p>
<p>I researched a bit the topic myself, and wh... | <p>The following is a compilation of the input from a number of sources.</p>
<p>Linear rails in general are mechanical components that - when designing equipment - offer great flexibility.</p>
<p><strong>The profile of the rail can be designed in nearly infinite ways.</strong> This in turn allows for:</p>
<ul>
<li><... | <p>Linear rails will always produce a high degree of accuracy and stability and more so than round rod with PTFE bushings and/or bearings. </p>
<p>One may argue the fact however even as a product developer and one who is involved with the mechanicals and development of machinery on a day to day basis comparing the two... | 783 |
<p>This is similar to my previous posting. But this time I want to call a function that exists on the main mxml page.</p>
<p>This is my main mxml page:</p>
<p>main.mxml</p>
<pre><code><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*">
<mx:Script>
<![... | <p>Add this to menu: </p>
<pre><code> <mx:Metadata>
[Event(name="buttonClicked", type="flash.events.Event")]
</mx:Metadata>
<mx:Button x="10" y="10" width="80" label="Show" id="btnOne" click="this.showLabel=true;dispatchEvent(new Event("buttonClicked"));"/>
</code></pre>
<p>Change m... | <p>there is a simpler way, just use parentDocument.</p>
<p>Change this: </p>
<pre><code><mx:Button x="181" y="10" width="80" label="Run Function" id="btnThree" click="{changeText('changeText')}"/>
</code></pre>
<p>to:</p>
<pre><code><mx:Button x="181" y="10" width="80" label="Run Function" id="btnThree" cl... | 25,160 |
<p>Is there a way to determine who is logged on to a particular (remote) machine given the IP address (or the workstation name) of the machine?</p>
<ul>
<li>The machines in question are on an Active Directory Domain</li>
<li>The user running the script probably won't have any special rights on either their local or th... | <p>PSloggedon from SysInternals will provide this from a batch file, however the user would require admin access on the remote machine. I doubt you can get this information without Administrator access.</p>
| <p>Difficult to do depending on the permissioning on the machine. One way is to query WMI on the remote machine and check the owner of the explorer.exe process.</p>
| 19,327 |
<p>I want to be able to use a function such as <code>writefln()</code> but without having to add <code>import std.stdio</code> at the top of the file.</p>
<p>Another way to explain it is the way you do it in C++. You can type <code>std::cout << "Test";</code> and that will stop you from having to add <code>using... | <p>You have to use the import part. However it is possible to address a method/function/whatever with the full module path in front of it. For example std.stdio.writefln("...") would be valid if you import std.stdio (and use Phobos). This can be useful if you have more then one function that is called "writefln".</p>
| <p>You can import separate functions / classes (not sure about syntax):</p>
<pre><code>import std.stdio: writef, writefln;
</code></pre>
| 26,432 |
<p>What is the best and easiest way of taking HTML and converting it into a PDF, similar to use CFDOCUMENT on ColdFusion?</p>
<p><strong>UPDATE:</strong> I really appreciate all the comments and suggestions that people have given so far, however I feel that people leaving their answers are missing the point.</p>
<p>1... | <p>The gem, <a href="https://github.com/mileszs/wicked_pdf" rel="noreferrer">WickedPDF</a>, does <em>exactly</em> that.</p>
| <p>If you want to have really good quality (think, proper layout/CSS etc) you need to create a process embedding a real webbrowser rendering it offscreen and printing it via PDF printer driver.</p>
| 46,578 |
<p>I have a DataGrid with 5 template columns,</p>
<p>However when I try and add some dynamically created controls into the grid, it fails, as there are no rows.</p>
<p>-Can i add a blank row in and use that? and how?
-Or any other way?</p>
| <p>When I hear those terms this is what comes to mind:</p>
<ul>
<li>Patch - Publicly released update to
fix a known bug/issue </li>
<li>Hotfix - update to fix a very
specific issue, not always publicly
released</li>
<li>Maintenance Release - Incremental
update between service packs or
software versions to fix multiple... | <p>I'd like to point to <a href="http://semver.org/" rel="noreferrer">http://semver.org/</a> for an attempt to define version numbers in sane manner, and the definitions given there actually fit closely to how I use version numbers (or how I wish I used them :))</p>
<p>As for the term definitions, I find patch and hot... | 33,831 |
<p>I'm not a fan of the Designer, I prefer to code straight to the ASPX page. However, since a reformat (and leading up to the reformat), the <code>designer.cs</code> files have not been updating correctly when manually coding to the .aspx file. This means my <a href="http://en.wikipedia.org/wiki/ASP.NET#Code-behind_mo... | <p>This happened to me when I installed the sp1 in visual studio 2008.
The way i got my code behind to recognise my controls was by viewing the aspx page in designer mode, then changing back to code view.</p>
<p>This seemed to give visual studio the slap it needed to start automatically populating my designers.</p>
... | <p>I've found closing and reopening the page (both the HTML and code behind) forces it to repopulate everything.</p>
| 22,766 |
<p>how do i determine what a mysql db's charset is set to? in the cli?</p>
| <pre><code>SHOW CREATE DATABASE db-name
</code></pre>
<p>Will show you the default character set for the database,</p>
<pre><code>SHOW CREATE TABLE db-name.table-name
</code></pre>
<p>Will show you the character set for a specific table (along with a lot of other information).</p>
| <p>You can use the command "show table status", </p>
<p>it will show you a lot of information (including character set) about your tables</p>
<p>mysql> show table status;</p>
| 31,836 |
<p>I've recently started using code coverage tools (particularily Emma and EclEmma), and I really like the view that it gives me as to the completeness of my unit tests - and the ability to see what areas of the code my unit tests aren't hitting at all. I currently work in an organization that doesn't do a lot of unit ... | <p>I use code coverage to give me hints on places where I may have an incomplete set of tests. For example, I may write a test for some given functionality, then go develop the code that satisfies that functionality, but in doing so actually write code that does more than it is supposed to -- say it might catch an exc... | <p>As I've said elsewhere, low code-coverage is a problem, but high code-coverage doesn't mean that you're writing pure gold.</p>
<p>If you weren't concerned about code-coverage, then I'd suggest that you'd need tests for <code>equals()</code> and <code>getValue()</code> - depending on how and where <code>hashCode()</... | 31,610 |
<p>I've created a windows form control which works successfully hosted in Internet Explorer. I'd like to give it an event and be able to respond to the event through javascript. I found a link that talks about it <a href="http://msdn.microsoft.com/en-ca/magazine/cc301932.aspx" rel="nofollow noreferrer">here</a>. It ... | <p>You are implementing it wrong in your CardReader class:</p>
<pre><code>public event Error;
public event Success;
protected void OnError()
{
if(Error != null)
Error();
}
protected void OnSuccess()
{
if(Success != null)
Success();
}
</code></pre>
<p>If your ICardReaderEvents interface chang... | <p>So, now you need to know how to hook it in the Javascript? Here is how I know how to do it:</p>
<pre><code><object id="CR" ...></object>
<script type="text/javascript">
function CR::Error()
{
alert("Error!");
}
function CR::Success()
{
alert("Success");
}
</script>
</c... | 38,372 |
<p>Can anyone recommend a program to create user manuals with? Not a markup language (like LaTeX or DocBook) but more something interactive like Scribus. As I'm not the only one that will update the manual the software should be something that's easy for a novice to pick up but still has some advanced features (like ... | <p><strong>Technical Publishing Software - Views on <a href="http://www.adobe.com/products/framemaker.html" rel="nofollow noreferrer">FrameMaker</a> and Its Alternatives</strong></p>
<p>I've done spec documents with LaTeX and Framemaker, and designed a Framemaker workflow to support a team of 5 analysts producing a sp... | <p>Word (or your favorite word processor)</p>
<p>I make all my user manuals (not to be confused with user HELP files) in Word. Then I can determine if they need to be in PDF, RTF, DOC or even converted to HTML. To solve the multi-user updating issue, I store the file in Source Control which handles all those fun thin... | 48,575 |
<p>Is it possible to convert an image image to STL file format? </p>
<p><img src="https://i.stack.imgur.com/Y6SYj.png" alt="png image"></p>
<p>E.g. I don't need the coloring, I need the lines.</p>
| <p>I suggest your objective can best be accomplished by converting the image to a single color vector file. You can do this with Inkscape (free, Linux, Windows, Mac) by combining the built-in bitmap tracing feature with some manual editing. I attempted to do so, but the coarseness of the image would result in excessive... | <p>For things like a coat of arms, you do not require a full 3D conversion, essentially all you need is a lithograph-like effect. The best program I've found for such conversions is 3D Builder which is a free Microsoft download for windows users (yes, I was surprised too). It can use either color or degrees of greyscal... | 1,590 |
<p>Please list <strong>one</strong> site which allows Flash/Silverlight access via crossdomain.xml file. Vote for your favorite sites.</p>
<p>The goal is to build an up to date list of sites which can be directly accessed via Flash/Silverlight without a server-side proxy. </p>
| <p>The feeds a <a href="http://www.feedburner.com/fb/a/home" rel="nofollow noreferrer">http://www.feedburner.com</a> are accessable via the <a href="http://feeds.feedburner.com/crossdomain.xml" rel="nofollow noreferrer">CrossDomain</a> file. All rss feeds can be read with Silverlight.</p>
<p>(This may help the search ... | <p>Yahoo Pipes (<a href="http://pipes.yahoo.com/pipes/" rel="nofollow noreferrer">http://pipes.yahoo.com/pipes/</a>) allow access to a lot of pages and feeds that don't have crossdomain.xml files. It'll access just any page which allows indexing (robots.txt).</p>
| 45,843 |
<p>I'm considering moving a number of small client sites to an unmanaged VPS hosting provider. I haven't decided which one yet, but my understanding is that they'll give me a base OS install (I'd prefer Debian or Ubuntu), an IP address, a root account, SSH, and that's about it.</p>
<p>Ideally, I would like to create a... | <p>Quick Answer: <a href="http://www.riastats.com" rel="nofollow noreferrer">www.riastats.com</a></p>
<p>This site compares the different RIA plugins using graphical charts and graphs.</p>
<p>It gets its data from small snippets of javascripts running on sites accross the web (approx 400,000 last time I looked)</p>
... | <p>The larger question is how many users will your site lose if implemented in Silverlight. And, it very much depends on your audience.</p>
<p>If you're running a site about the joys of Linux kernel hacking or the virtues of Internet security, you'll probably lose a significant chunk of your audience. If you're runnin... | 8,495 |
<p>As a follow-up to <a href="https://stackoverflow.com/questions/269812/how-to-quickly-get-started-at-using-and-learning-emacs">this question</a>, it's trying to find out how to do something like this which should be easy, that especially stops me from getting more used to using Emacs and instead starting up the edito... | <ol>
<li><code>M-x find-name-dired</code>: you will be prompted for a root directory and a filename pattern.</li>
<li>Press <code>t</code> to "toggle mark" for all files found.</li>
<li>Press <code>Q</code> for "Query-Replace in Files...": you will be prompted for query/substitution regexps.</li>
<l... | <p>It's not Emacs, but xxdiff comes with a tool called xx-rename which will do that for multiple strings at a time (e.g. From To from to FROM TO), with interactive prompting, save backups of all the modified files, and produce a short log of changes made with context. That's what I tend to use when I do large/global r... | 34,062 |
<p>I'd like to copy the files that have a specific file extension to a new folder. I have an idea how to use <code>os.walk</code> but specifically how would I go about using that? I'm searching for the files with a specific file extension in only one folder (this folder has 2 subdirectories but the files I'm looking fo... | <pre><code>import glob, os, shutil
files = glob.iglob(os.path.join(source_dir, "*.ext"))
for file in files:
if os.path.isfile(file):
shutil.copy2(file, dest_dir)
</code></pre>
<p>Read the <a href="http://www.python.org/doc/2.5.2/lib/module-shutil.html" rel="noreferrer">documentation</a> of the shutil modu... | <p>Copy files with extension "extension" from srcDir to dstDir...</p>
<pre><code>import os, shutil, sys
srcDir = sys.argv[1]
dstDir = sys.argv[2]
extension = sys.argv[3]
print "Source Dir: ", srcDir, "\n", "Destination Dir: ",dstDir, "\n", "Extension: ", extension
for root, dirs, files in os.walk(srcDir):
for ... | 37,874 |
<p>I have an instance of a <code>System.Drawing.Bitmap</code> and would like to make it available to my WPF app in the form of a <code>System.Windows.Media.Imaging.BitmapImage</code>.</p>
<p>What would be the best approach for this?</p>
| <p>How about loading it from MemoryStream?</p>
<pre><code>using(MemoryStream memory = new MemoryStream())
{
bitmap.Save(memory, ImageFormat.Png);
memory.Position = 0;
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption... | <p>I came to this question because I was trying to do the same, but in my case the Bitmap is from a resource/file. I found the best solution is as described in the following link:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx" rel="nofollow">http://msdn.microsoft... | 12,006 |
<p>Note - I have not delved very deeply into Apple's iPhone SDK yet.</p>
<p>However, based on another <a href="https://stackoverflow.com/questions/350067/how-can-i-run-an-app-at-a-specified-time-on-the-iphone">question</a> asked recently, I'm wondering if, since the iPhone is running some stripped-down edition of Mac ... | <p>Seems that cron runs by default on the iPhone, you just need to be able to edit the crontab file - <strike>either</strike> the root one<strike> or the user one</strike> but not the user one apparently.</p>
<p>There are issues with sleep and cron, but there's a good discussion at that link.</p>
| <p>You can't use cron on an un-jailbroken iPhone.</p>
<p>Maybe you could take advantage of the Push Notification service: Have cron (or some other scheduler) running on another machine which sends notifications to the phone at the appropriate time.</p>
| 45,567 |
<p>I'm new to the 3D printing world and got my first Ender 3 (with the 32-bit controller board).</p>
<p>I have a problem with every single print. I've upgraded to the newest Marlin firmware, did the mesh leveling then started printing and fix the Z bed option in "Tune - Z bed" during the print (so the first l... | <p>It sounds like your bed is unstable. This is what I had to do with my Tronxy X1, and I fixed it by installing a decent bed stabiliser. Now that I have a stable bed, I only have to re-level it occasionally. However, the Tronxy X1 is a cantilever printer with a single rail for the bed, not an Ender 3.</p>
<p>I would s... | <p>Thanks everybody for their help, but apparently it was a slicer/software/gcode (i don't really know :D) issue...</p>
<p>So i just added this line M420 S1 after the G28 command to my Cura printer settings and now the nozzle height is always at the point i set before, no changing every print.</p>
<p>Hope my solve will... | 1,902 |
<p>How do you draw a polygon by mouse with openGL in C++?</p>
| <p>Start by conditioning the mouse to recognize the shape of a polygon and be able to complete one it sees on a computer screen. You can use operant conditioning (by rewarding the mouse with a food pellet) to train it to an acceptable level of proficiency. </p>
| <p>Maybe go to class, pay attention, and learn what the teacher says? Or look at the NeHe tutorials, which you can find through five minutes of using the almighty Google?</p>
| 47,463 |
<p>Why would you do an automatic HTML post rather than a simple redirect?</p>
<p>Is this so developers can automatically generate a login form that posts directory to the remote server when the OpenID is known?</p>
<p>eg.</p>
<ol>
<li>User is not logged in and visits your login page.</li>
<li>You detect the user's o... | <p>The primary motivation was, as Mark Brackett says, the limits on payload size imposed by using redirects and GET. Some implementations are smart enough to only use POST when the message goes over a certain size, as there are certainly disadvantages to the POST technique. (Chief among them being the fact that your ... | <p>The same approach is used for the SAML Web Browser SSO profile. The primary motivations of using HTML Post redirection are :</p>
<ul>
<li><p>Virtually unlimited length of the payload : in SAML the payload is a XML document signed with XMLDSig and base64 encoded. It is larger than the usual 1024 characters limitatio... | 5,493 |
<pre class="lang-cpp prettyprint-override"><code>double r = 11.631;
double theta = 21.4;
</code></pre>
<p>In the debugger, these are shown as <code>11.631000000000000</code> and <code>21.399999618530273</code>.</p>
<p>How can I avoid this?</p>
| <p>These <a href="http://en.wikipedia.org/wiki/Floating_point_number#Accuracy_problems" rel="noreferrer">accuracy problems</a> are due to the <a href="http://en.wikipedia.org/wiki/Floating_point_number#Internal_representation" rel="noreferrer">internal representation</a> of floating point numbers and there's not much y... | <p>Refer to <a href="http://speleotrove.com/decimal/#summary" rel="nofollow noreferrer">General Decimal Arithmetic</a></p>
<p>Also take note when comparing floats, see <a href="https://stackoverflow.com/questions/17333/most-effective-way-for-float-and-double-comparison#17467">this answer</a> for more information.</p>
| 21,383 |
<p>I'm exploring the possibility of running a Java app on a machine with very large amounts of RAM (anywhere from 300GB to 15TB, probably on an SGI Altix 4700 machine), and I'm curious as to how Java's GC is likely to perform in this scenario.</p>
<p>I've heard that IBM's or JRockit's JVMs may be better suited to this... | <p>On the Sun JVM, you can use the option -XX:UseConcMarkSweepGC to turn on the Concurrent mark and sweep Collector, which will avoid the "stop the world" phases of the default GC algorithm almost completely, at the cost of a little bit more overhead. </p>
<p>The advise to use more than on VM on such a machine is IMHO... | <p>Surely the answer as to how the GC's going to perform is "who cares?" ;-)</p>
| 44,729 |
<p>How do I calculate the last business day of month in VBScript? It is for a Reporting Services report.</p>
<p>Thanks</p>
| <p>How about:</p>
<pre><code>intMonth=11
'Use zero to return last day of previous month '
LastDayOfMonth= dateserial(2008,intMonth+1,0)
'Saturday '
If WeekDay(LastDayOfMonth,1)=7 Then LastDayOfMonth=LastDayOfMonth-1
'Sunday '
If WeekDay(LastDayOfMonth,1)=1 Then LastDayOfMonth=LastDayOfMonth-2
Msgbox LastDayOfMonth &... | <p>If you mean the last <strong>week</strong> day of the month (M-F), then try:</p>
<pre><code>Dim d
d = DateAdd("m", 1, Now)
d = Month(d) & "/1/" & Year(d)
d = DateAdd("d", -1, d)
If Weekday(d) = 7 Then
d = DateAdd("d", -1, d)
ElseIf Weekday(d) = 1 Then
d = DateAdd("d", -2, d)
End If
MsgBox d
</co... | 38,865 |
<p>I currently have 2 domain names that I want to setup different websites for. I am currently looking at using some free hosting that works well for my current needs but doesn't give me any way to point "mydomain.com" to the actual site. Instead I have to give users a longer, harder to remember url.</p>
<p>My propose... | <p>Here is one way to do it (as recommended by 1and1.com if you host multiple domains). Put this at the root of your web space. All of your websites will point to this root. The script below will forward the requests to the proper subfolder. It's kind of a hack, but if you don't have complete control over the IIS s... | <p>From asp.net code you can access the host from the request object:</p>
<pre><code>if(Request.Url.Authority == "www.site1.com")
Response.Redirect(...);
</code></pre>
<p>If you have access to the IIS server you can also set up two sites with different binding host names and have each redirect as you like.</p>
| 34,704 |
<p>Is there any way to disable a system device from C#.NET.</p>
<p>Basically emulating when you go to Device Manager and disable a device that way?</p>
<p>I am assuming there is a WinAPI function that I can invoke, but I don't know which one it is?</p>
<p>The reason I need to do this is that I need to disable and st... | <p>To futher Mel Green's answer, the hardware helper library uses interop to call the Windows API (setupapi), specifically the SetupDiSetClassInstallParams method. Of course there are other calls here which are used to look up the device details etc.</p>
<p>One thing to consider that if you are running as a standard u... | <p>I know this is an old question but I came across it with the same problem. To solve it, I had to use the new DevCon available at the <a href="http://social.technet.microsoft.com/wiki/contents/articles/how-to-obtain-the-current-version-of-device-console-utility-devcon-exe.aspx" rel="nofollow">TechNet wiki</a>. The C... | 31,418 |
<p>I would like to do the equivalent of the following:</p>
<pre><code>#define print_max(TYPE) \
# ifdef TYPE##_MAX \
printf("%lld\n", TYPE##_MAX); \
# endif
print_max(INT);
</code></pre>
<p>Now the <code>#ifdef</code> or any nested preprocessor directive is
not allowed as far as I can see in a function macro.... | <p>The <a href="http://www.boost.org/doc/libs/1_37_0/libs/preprocessor/doc/index.html" rel="noreferrer">Boost Preprocessor</a> (which works for C as well as C++, even though Boost as a whole is a C++ library) library can help with this kind of task. Instead of using an #ifdef within a macro (which isn't permitted), it... | <p>I don't think it's a case of the ## operator not being allowed in an #ifdef. I tried this:</p>
<pre><code>#define _print_max(TYPE) \
#ifdef TYPE \
printf("%lld\n", _TYPE); \
#endif
#define print_max(TYPE) _print_max(MAX##_TYPE)
void main()
{
print_max(INT)
}
</code></pre>
<p>and it still didn't work (it di... | 38,725 |
<p>I've always assumed that before I can use the Dvorak layout I need to purchase a Dvorak keyboard. But I can't find one on Amazon. Is it simply a matter of popping the keys off a Qwerty keyboard and moving them around?</p>
| <p>To help you learn your way around the keyboard layout, you can physically rearrange the keys on your Qwerty keyboard. Or you can simply re-label the keys with stickers. I personally learned to type using the Dvorak layout without re-labeling or re-arranging keys, and found that it was not difficult.</p>
<p>Most mo... | <p>You'll have trouble getting the keys to fit (perhaps you could just draw over them) but yeah, you should be able to switch layout within the OS.</p>
| 19,972 |
<p>When compiling my C++ .Net application I get 104 warnings of the type:</p>
<pre><code>Warning C4341 - 'XX': signed value is out of range for enum constant
</code></pre>
<p>Where XX can be</p>
<ul>
<li>WCHAR</li>
<li>LONG</li>
<li>BIT</li>
<li>BINARY</li>
<li>GUID</li>
<li>...</li>
</ul>
<p>I can't seem to remove... | <p>This is a <a href="http://forums.msdn.microsoft.com/en-US/vclanguage/thread/7bc77d72-c223-4d5e-b9f7-4c639c68b624/" rel="nofollow noreferrer">compiler bug</a>. Here's <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=159519&SiteID=1" rel="nofollow noreferrer">another post</a> confirming it's a known... | <p>Either wait for a compiler fix or dont <code>#include</code> code that triggers it.</p>
<p>[A verbose way of saying you probably can't.]</p>
| 3,838 |
<p>Does somebody know how to recover a never-starting eclipse when the error "org.eclipse.swt.SWTError: Item not added" is raising againg and again?</p>
<p>I'm using WebSphere Studio Site Developer (Windows) 5.1.0</p>
<p>The only stack trace in the .metadata/log file is:</p>
<p><code>SESSION ------------------------... | <p>Does restarting your computer resolve the problem with being able to open the workspace? There is a forum post (<a href="http://forums.sun.com/thread.jspa?messageID=3131484#3131484" rel="nofollow noreferrer">http://forums.sun.com/thread.jspa?messageID=3131484#3131484</a>) that describes a similar problem with an id... | <p>Well, some things you can try are:</p>
<ol>
<li>Delete workspace .metadata dir. Obviously you will lose your workbench configuration.</li>
<li>Rename your .metadata dir. Start Eclipse, and you will have a new .metadata dir. Close Eclipse, delete the new dir, and rename back the original dir. It sometimes works.</li... | 10,966 |
<p>Anyone have any idea? And any open source sofware which also seens to perform this kind of functionality?</p>
| <p>I'm not sure what you need, but would <a href="http://www.nagios.org/" rel="nofollow noreferrer">http://www.nagios.org/</a> be enough for your purposes?</p>
| <p>What database? What platform?</p>
<p>If it's MySQL, there are many monitoring applications around - for example, the <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html" rel="nofollow noreferrer">MySQL GUI Tools</a> include a Health Monitor widget (on OS X)</p>
<p>Also, phpMyAdmin shows statistics from the ... | 17,813 |
<p>What is the JSON (JavaScript Object Notation) format?</p>
| <blockquote>
<p><strong>JSON (JavaScript Object Notation) is a lightweight data-interchange format</strong>. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a ... | <p>In my opinion when one wants to access webservice of different service provider such as Twitter,facebook etc over HTTP.</p>
<p>Then one must create a url and request for connection .When connection established a large amount of data comes from requesting site .</p>
<p><strong>Example</strong> </p>
<p><7b226665... | 36,495 |
<p>I would like to find out where I would be able to find the MP3 library, for implementation in an Operating System.</p>
| <p>Are you looking for <a href="http://lame.sourceforge.net/" rel="nofollow noreferrer">Lame</a>?</p>
| <p>If you want an officially-licensed MP3 library, you probably ought to contact <a href="http://www.mp3licensing.com" rel="nofollow noreferrer">Thompson</a>, who are handling patent licensing for Fraunhofer.</p>
| 21,776 |
<p>Using a web service is often an excellent architectural approach. And, with the advent of WCF in .Net, it's getting even better.</p>
<p>But, in my experience, some people seem to think that web services should always be used in the data access layer for calls to the database. I don't think that web services are the... | <p>Web Services are an absolutely horrible choice for data access. It's a ton of overhead and complexity for almost zero benefit.</p>
<p>If your app is going to run on one machine, why deny it the ability to do in-process data access calls? I'm not talking about directly accessing the database from your UI code, I'm... | <p>For a small-scale web app (You have to ask the question, "Will it always remain small scale?" though) using web services, separate business layers, data layers, and so on and so forth can be overkill.</p>
<p>Before anyone shoots me, I do agree that separation of logic between layers along with unit tests, continuou... | 25,057 |
<p>My users want data from my application in Excel. The data resides in a SQL Server database but I don't want the users to have direct access to the database, I would rather provide them a web service to get the data. What is the best way to move data from SQL Server to Excel via a web service?</p>
| <p>You can do it as a straight asp.net page and return a .csv file. If you change the mimetype to text/csv, it should default to open in excel. This would be the easiest approach, and one that I've used in the past with great success.</p>
| <p>I'm in favor of Excel Web Query (Data/Import External)
Also, there is a way to post data from Excel back to the web site. At least it's working in MS Sharepoint</p>
| 31,473 |
<p>I need to know if a variable in Python is a string or a dict. Is there anything wrong with the following code?</p>
<pre><code>if type(x) == type(str()):
do_something_with_a_string(x)
elif type(x) == type(dict()):
do_somethting_with_a_dict(x)
else:
raise ValueError
</code></pre>
<p><strong>Update</stro... | <p>What happens if somebody passes a unicode string to your function? Or a class derived from dict? Or a class implementing a dict-like interface? Following code covers first two cases. If you are using Python 2.6 you might want to use <a href="https://docs.python.org/2/library/collections.html#collections.Mapping" rel... | <p><code>*sigh*</code></p>
<p>No, typechecking arguments in python is not necessary. It is <strong>never</strong>
necessary.</p>
<p>If your code accepts either a string or a dict object, your design is broken.</p>
<p>That comes from the fact that if you don't know already the type of an object
in your own program, ... | 49,639 |
<p>Whenever I use a macro in Visual Studio I get an annoying tip balloon in the system tray and an accompanying "pop" sound. It says:</p>
<blockquote>
<p>Visual Studio .NET macros</p>
<p>To stop the macro from running, double-click the spinning cassette.<br>
Click here to not show this balloon again.</p>
</bl... | <p>This will disable the pop up:</p>
<p>For Visual Studio 2008:</p>
<pre>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0<br>
DWORD DontShowMacrosBalloon=6</pre>
<p>For Visual Studio 2010 (the DWORD won't be there by default, use <code>New | DWORD value</code> to create it):</p>
<pre>HKEY_CURRENT_USER\Software... | <p>Okay, I found a way to make the balloon clickable, and clicking it does indeed stop it from popping up again. (On the other site I referenced in the original question the question asker claims that this is not the case. Though he was in VS2005 and I'm using VS2008.)</p>
<p>Anyway, I inserted a pause line in the mac... | 7,090 |
<p>I am trying to run the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en" rel="nofollow noreferrer">VS 2008 SP1 installer</a>, but it says that I need 6,366MB of available space, and my C drive currently only has 2,452MB available. Is there any ... | <p>Burn it to a DVD and install it from there. Also remove any development software that you don't need from Visual Studio, such as C++, VB.NET, Crystal Reports, etc.</p>
| <p>You can have Visual Studio install components onto a separate hard drive from your primary but be warned, you still end up with a lot of data on your primary drive.</p>
<p>I tried to install VS 2008 on a machine with 2gb of hard drive space on the primary and a lot of the secondary, you still end up with about 1gb ... | 3,704 |
<p>I have a scenario in a system which I've tried to simplify as best as I can. We have a table of (lets call them) artefacts, artefacts can be accessed by any number of security roles and security roles can access any number of artefacts. As such, we have 3 tables in the database - one describing artefacts, one descri... | <p>Since I was looking for this answer and found this thread on google (without an answer) I figured I'd post my solution to this. With three tables: Role, RolesToAccess(ManyToMany), Access.</p>
<p>Create the following mappings:
Access:</p>
<pre><code><bag name="Roles" table="RolesToAccess" cascade="none" lazy="f... | <p>You could make a mapping for the association table, and then call delete on that table where the Role_id is the value you are about to delete, and then perform the delete of the role itself. Should be fairly straightforward to do this.</p>
| 26,173 |
<p>I've been reading a little about temporary tables in MySQL but I'm an admitted newbie when it comes to databases in general and MySQL in particular. I've looked at some examples and the MySQL documentation on how to create a temporary table, but I'm trying to determine just how temporary tables might benefit my app... | <p>Temporary tables are often valuable when you have a fairly complicated SELECT you want to perform and then perform a bunch of queries on that...</p>
<p>You can do something like:</p>
<pre><code>
CREATE TEMPORARY TABLE myTopCustomers
SELECT customers.*,count(*) num from customers join purchases using(customerID)... | <p>I've used them in the past when I needed to create evaluated data. That was before the time of views and sub selects in MySQL though and I generally use those now where I would have needed a temporary table. The only time I might use them is if the evaluated data took a long time to create.</p>
| 14,182 |
<p>My application needs to store the users email address in a cookie so that I can pre-populate a login form <code>(username == email address)</code>. I set the cookie value in JavaScript. If I read it from JavaScript, I get <code>foo@bar.com</code>. If I look at it in the cookie viewer in Firefox I get <code>foo@bar.c... | <p>From the <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/Cookie.html#setValue(java.lang.String)" rel="nofollow noreferrer">javax.servlet.http.Cookie</a> doco for setValue(String):</p>
<blockquote>
<p>Assigns a new value to a cookie after
the cookie is created. If you use a
binary value, you ... | <p>You need to escape the value part of your cookie.</p>
<pre><code>document.cookie = name + "=" +escape( value )
+ ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" )
+ ( ( path ) ? ";path=" + path : "" )
+ ( ( domain ) ? ";domain=" + domain : "" )
+ ( ( secure ) ? ";secure" : "" );
</c... | 34,078 |
<p>I want to tackle an experiment with the following goal:</p>
<blockquote>
<p>Determine the correlations between printing parameters (temperatures,
speeds, humidity, perimeters, infill, etc.) and tensile strength using
a specific 3D printer, test specimen, and filament brand/model.</p>
</blockquote>
<p>This go... | <p>For these kind of tests you could rely on the <a href="https://www.astm.org/" rel="nofollow noreferrer">ASTM</a> standards. They define test procedures and test specimen sizes for different types of tests. Or you can derive a specimen yourself based on these standards (e.g. for my bachelor's degree I used an alterna... | <p>A reliable and repeatable test can be performed by printing cylinders, tapping them to M4 thread and then testing the resulting bolts.</p>
<p>My Tech Fun <div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/ZiQek0wei1g?start=0"></iframe>
... | 996 |
<p>Are there any safety risks inherent to PLA plastics used for 3D printing?</p>
<p>The material safety data sheet of some PLA plastics indicates low risks at a toxicological level, but I'd like to make sure some other factor isn't overlooked.
(<a href="https://printparts.com/datasheets/PLA-MSDS.pdf" rel="nofollow nore... | <p>Extrusion of PLA through a nozzle can cause microparticles to be generated (referenced as "dust" in your document) which can be temporarily airborne. If ingested through breathing for an extended period of time, this can cause respiratory distress. Your document claims "no acute toxicity" from ... | <p>If you are concerned about inhalation (and I think you should be), you should use a hierarchy of controls to mitigate the risk.</p>
<p>NIOSH (part of the CDC) have a <a href="https://www.cdc.gov/niosh/docs/2020-115/default.html" rel="nofollow noreferrer">good document outlining how to mitigate the risks of 3D printi... | 2,180 |
<p>Maven spews out far too many lines of output to my taste (I like the Unix way: no news is good news).</p>
<p>I want to get rid of all <code>[INFO]</code> lines, but I couldn't find any mention of an argument or config settings that controls the verbosity of Maven.</p>
<p>Is there no LOG4J-like way to set the log lev... | <p>You can try the <a href="http://maven.apache.org/ref/current/maven-embedder/cli.html" rel="noreferrer"><code>-q</code> switch</a>.</p>
<blockquote>
<p><code>-q</code>,<code>--quiet</code> Quiet output - only show errors</p>
</blockquote>
| <p>Maven 3.1.x uses SLF4j for logging, you can find instructions how to configure it at <a href="https://maven.apache.org/maven-logging.html" rel="nofollow noreferrer">https://maven.apache.org/maven-logging.html</a></p>
<p>In short: Either modify <code>${MAVEN_HOME}/conf/logging/simplelogger.properties</code>, or set ... | 9,650 |
<p>Is it possible?</p>
<p>I have a listview with several gridviewcolumns. The last column has a dynamic header. I dont know what the column header will be at design time. It's actually a number I want to display as a string. </p>
<pre><code> <GridViewColumn Header="{Binding Path=SomeValue}"
... | <p>I think your problem is the source of the "SomeValue" property. If you are binding to a list of objects, it wouldn't make sense to have the header determined by a property on that object, because then you could have a different header for every object. Essentially what you are saying is "Bind the header of the colum... | <ol>
<li>read a post
<a href="http://blogs.infragistics.com/blogs/josh_smith/archive/2008/06/26/data-binding-the-isvisible-property-of-contextualtabgroup.aspx" rel="nofollow">http://blogs.infragistics.com/blogs/josh_smith/archive/2008/06/26/data-binding-the-isvisible-property-of-contextualtabgroup.aspx</a></li>
</ol>
... | 41,683 |
<p>Continuing <a href="https://stackoverflow.com/questions/308481/writing-the-f-recursive-folder-visitor-in-c-seq-vs-ienumerable">my investigation</a> of expressing F# ideas in C#, I wanted a pipe forward operator. For anything wrapped in a IEnumerable, we already have it, as you can .NextFunc() to your heart's content... | <p>I haven't bothered with a raw pipe, but I have tried making all references into the Maybe monad:</p>
<pre><code>public static class ReferenceExtensions
{
public static TOut IfNotNull<TIn, TOut>(this TIn v, Func<TIn, TOut> f)
where TIn : class
... | <p>While it's not quite the same thing, you might be interested in my <a href="http://msmvps.com/blogs/jon_skeet/archive/2008/01/04/quot-push-quot-linq-revisited-next-attempt-at-an-explanation.aspx" rel="nofollow noreferrer">Push LINQ</a> framework. Basically where <code>IEnumerable<T></code> requires the interes... | 43,688 |
<p>Yes, <a href="http://en.wikipedia.org/wiki/There_is_more_than_one_way_to_do_it" rel="noreferrer">There's More Than One Way To Do It</a> but there must be a canonical or most efficient or most concise way. I'll add answers I know of and see what percolates to the top.</p>
<p>To be clear, the question is how best to ... | <p>How about this:</p>
<pre><code>use File::Slurp;
my $text = read_file($filename);
</code></pre>
<p>ETA: note <a href="https://rt.cpan.org/Ticket/Display.html?id=83126" rel="noreferrer">Bug #83126 for File-Slurp: Security hole with encoding(UTF-8)</a>. I now recommend using <a href="https://metacpan.org/pod/File::Sl... | <p>Candidate for the worst way to do it! (See comment.)</p>
<pre><code>open(F, $filename) or die "OPENING $filename: $!\n";
@lines = <F>;
close(F);
$string = join('', @lines);
</code></pre>
| 25,318 |
<p>How can i go about programaticaly getting the IP address of my network as seen from the Internet? Its obviously a property that my router has access to when it connects to the ISP. Is there any way to get this info from a router using a standard protocol. My only other option is to either find a WS which returns my ... | <p>Don't scrape whatismyip.com, see <a href="http://whatismyip.com/automation.asp" rel="noreferrer">here</a> for how you can call their API which just returns your address.</p>
<p>If you don't use this, you have to write something like it yourself, i.e. a host beyond your router which can report back your apparent add... | <p>I don't see a language specifacation but I did it here in python: <a href="https://stackoverflow.com/questions/166545/finding-a-public-facing-ip-address-in-python">Finding a public facing IP address in Python?</a><br />Basicly there is no way of doing it without relying on an external server, in this case I use <a h... | 21,373 |
<p>I am working on a plugin system that loads .dll's contained in a specified folder. I am then using reflection to load the assemblies, iterate through the types they contain and identify any that implement my <code>IPlugin</code> interface. </p>
<p>I am checking this with code similar to the following: </p>
<pre><c... | <p>That typically happens when there's a mismatch between the assembly which contains the type IPlugin that the current assembly references, and the assembly which is referenced by the assembly containg the types you're iterating over.</p>
<p>I suggest you print:</p>
<pre><code>typeof (IPlugin).Module.FullyQualifiedN... | <p>The name of the Type.IsAssignableFrom method is vague and confusing when applied to testing inheritance or detecting interface implementations. The following wrapper for these purposes would make a lot more sense:</p>
<pre><code> public static bool CanBeTreatedAsType(this Type CurrentType, Type TypeToCompareWit... | 44,943 |
<p>How do I calculate the time period between 2 dates in C (any library, etc.)? </p>
<p>The program should take two (local) dates as input and provide the duration period between them as output. </p>
<p>For example,</p>
<pre><code>startDate = OCT-09-1976 and endDate = OCT-09-2008
should show a duration of 32 years.... | <p>Convert the dates into two struct tm structures with <a href="http://www.manpagez.com/man/3/strptime/" rel="nofollow noreferrer">strptime</a></p>
<p><a href="http://www.manpagez.com/man/3/difftime/" rel="nofollow noreferrer">Difftime</a> gives you the difference between the two in seconds.</p>
<p>Convert that into... | <p>I did something very similar recently using <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/date_time/gregorian.html" rel="nofollow noreferrer">Boost.Date_Time</a>, and presenting the resulting function as C, but this of course requires using the C++ linker.</p>
<p>Actually, the example leaves a little to be... | 42,463 |
<p>I have an MS sql server database. There is a table with one of the column of the "image" type. Now, the customer wants to read the data from an MS access. He wants to display the images in a form.
I have never used access and have no idea of how to do simple things there. Any help will be greatly appreciate.</p>
<p... | <p>Rather than write out the stored images to files in order to display them, it may be possible to use ASP to display the image and a web browser control on the Access form to display the page. I have not tried this.</p>
<p>How To Display Images Stored in a BLOB Field: <a href="http://support.microsoft.com/kb/173308"... | <p>I think you can do this by using streams. Stream the image from the field to an unbound image control. We use the same process for opening documents and other binary data stored in an SQL Server database.</p>
<hr>
<p>On the other hand, Access had an Image control that can be linked to a field in a table. That shou... | 37,680 |
<p>I'm working on a java web-application, trying to be xml-friendly and writing my jsp files using the jspx/xml syntax. It took me hours of dissecting examples and configuration files to find out that with tomcat 5.5 files using the new syntax should end in .jspx, or tomcat won't translate tag libraries and stuff.</p>
... | <p>There are additional configurations for servlets that can affect behavior. I haven't tried it, but would assume that you could just override some of the default configurations for *.jsp to use that of *.jspx.</p>
<p>Try adding a <strong>jsp-property-group</strong> definition for <strong>*.jsp</strong> with <stron... | <p>Not one to give up easily, I found this explanation in the <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajq.html" rel="nofollow noreferrer">Java5 EE Tutorial</a>, </p>
<blockquote>
<p>Although the jsp:root element is not required, it is still useful in these cases:</p>
<ul>
<li>When you want t... | 20,556 |
<p>I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an <code>ArrayList</code> of business objects bound to a Windows Forms <code>DataGrid</code>. I'd like the user to be able to edit the cells, and when finished, press a Save button. ... | <pre class="lang-cs prettyprint-override"><code>foreach(var row in DataGrid1.Rows)
{
DoStuff(row);
}
//Or ---------------------------------------------
foreach(DataGridRow row in DataGrid1.Rows)
{
DoStuff(row);
}
//Or ---------------------------------------------
for(int i = 0; i< DataGrid1.Rows.Count - 1; i+... | <p>Aha, I was really just testing everyone once again! :) The real answer is, you rarely need to iterate the datagrid. Because even when binding to an ArrayList, the binding is 2 way. Still, it is handy to know how to itereate the grid directly, it can save a few lines of code now and then. </p>
<p>But NotMyself ... | 2,817 |
<p>If I run the following query in SQL Server 2000 Query Analyzer:</p>
<pre><code>BULK INSERT OurTable
FROM 'c:\OurTable.txt'
WITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\t', ROWS_PER_BATCH = 10000, TABLOCK)
</code></pre>
<p>On a text file that conforms to OurTable's schema for 40 lines, but ... | <p><code>BULK INSERT</code> acts as a series of individual <code>INSERT</code> statements and thus, if the job fails, it doesn't roll back all of the committed inserts.</p>
<p>It can, however, be placed within a transaction so you could do something like this:</p>
<pre><code>BEGIN TRANSACTION
BEGIN TRY
BULK INSERT O... | <p>Try to put it inside user-defined transaction and see what happens. Actually it should roll-back as you described it.</p>
| 6,327 |
<p>I need to have a script read the files coming in and check information for verification.</p>
<p>On the first line of the files to be read is a date but in numeric form. eg: 20080923
But before the date is other information, I need to read it from position 27. Meaning line 1 position 27, I need to get that number ... | <pre><code>sed 1q $file | cut -c27-34
</code></pre>
<p>The <code>sed</code> command reads the first line of the file and the <code>cut</code> command chops out characters 27-34 of the one line, which is where you said the date is.</p>
<p><em>Added later:</em></p>
<p>For the more general case - where you need to read... | <p>You can extract the characters starting at position 27 of line 1 like so:</p>
<pre><code>datestring=`head -1 $file | cut -c27-`
</code></pre>
<p>You'd perform your next processing step on $datestring.</p>
| 14,758 |
<p>I already tried a lot settings in Cura and try to search for a solution but without success. Maybe someone got this issue and solved it.</p>
<p>I want to prevent Cura from printing such gaps at the wings to make it in one run. With ironing one run would (hopefully) bring better results. See the animation for what I ... | <p>That depends very much on what your goal is with the box. If it needs to be hollow and you don't need any access to the inside (and also prefer it to be printed in one piece) than the answer provided by user77232 would probably be the best.</p>
<p>Alternatively, if you need access to the inside of the box you would ... | <ol>
<li>Print it as a whole object</li>
<li>Use 20% infill.</li>
<li>Profit!</li>
</ol>
| 1,740 |
<p>I'm currently developing an OSGi based application (using Equinox) by trying to mavenize a web tutorial I've found on OSGi+Equinox. In this project, there are bundles depending on other bundles (quote-service depends on quote).
The compile phase does succeed, but the package phase does not. Maven complains the follo... | <p>The answer is quite simple : I removed the already defined manifest, and used bnd entries in the bundle plugin instructions. That works !</p>
| <p>I wrote a tool called auto-builder: <a href="http://code.google.com/p/auto-builder" rel="nofollow">http://code.google.com/p/auto-builder</a>. It introspects PDE-based projects and generates Ant build files; it supports transitive closure over dependencies and all that jazz. </p>
<p>I posted a write-up: <a href="h... | 49,090 |
<p>I bought new yellow PLA filament from XYZ (1.75 mm). </p>
<p>Over the past I have printed many objects with my da Vinci 1.0 (ABS only). I found that while the brim is being printing (using default configuration of XYZWare; the da Vinci machines give the user very little control over print parameters, if I reme... | <p>The answer to this specific instance appeared in the comments:</p>
<blockquote>
<p>Also, <a href="https://3dprinting.stackexchange.com/a/6092/">a thorough cleaning of the nozzle/hotend</a> might also be a good idea to get rid of all the stuck ABS residue inside. – 0scar Mar 26 at 8:44</p>
<p>The problem solv... | <p>That looks pretty bad for a number of reasons. If you've got an all-metal hotend, you can be pretty sure that your PLA issues are probably at least partially cooling-related. I'd recommend you try and find a better fan duct design for your hotend, if possible, and possibly upgrade to a better fan.</p>
<p>You can te... | 1,259 |
<p>Is it possible to modify the title of the message box the confirm() function opens in JavaScript? </p>
<p>I could create a modal popup box, but I would like to do this as minimalistic as possible.
I would like to do something like this:</p>
<pre><code>confirm("This is the content of the message box", "Modified tit... | <p>This is not possible, as you say, from a security stand point. The only way you could simulate it, is by creating a modeless dialog window.</p>
<p>There are many third-party javascript-plugins that you could use to fake this effect so you do not have to write all that code.</p>
| <p>You can't unfortunately. The only way is to simulate this with a window.open call.</p>
| 6,558 |
<p>I'd like to save some simple text data to a file from my Silverlight app - to a CSV file.</p>
<p>The user presses on a button, the code generates the contents of the file in memory (a string), then a prompt appears asking to either open the file or Save to disk, like through a normal web page.</p>
<p>I found a com... | <p>Right now Silverlight 2 doesn't support saving directly to the user's disk even with a prompt. It is a feature being considered for future versions, but the work around of having the server push out the data is the current solution.</p>
| <p>I do this right now with Silverlight 2.0, but the key is that the files are saved on the web server that hosts the Silverlight apps, by having the Silverlight app call web services.</p>
<p>Probably not what you are looking for, but this is an option.</p>
<ul>
<li>Silverlight app calls web service, that posts the s... | 36,570 |
<p>I have an <em>SQLite</em> table that contains prices for various products. It's a snapshot table, so it contains the prices on 5 minute intervals. I would like to write a query that would return the difference in price from one row to the next on each item.</p>
<p>The columns are id (auto inc), record_id (id of the... | <p>Yes, it is <strong>a bit late</strong>, but for completeness. <em>SQLite Release 3.25.0 in 2018 added support for window functions</em>. And the above task can now be completed by using the <a href="https://www.sqlite.org/windowfunctions.html" rel="noreferrer">LAG() and LEAD()</a> functions.</p>
<p>Taken from: <a h... | <p>I do not know if there are some limitations in SQLite, but you can try the following statements that are working in Sql Server. </p>
<p>If the time difference is constant (you state that it is 5 minutes), you can write:</p>
<pre><code>SELECT A.id, A.record_id, A.price, A.time, ISNULL(A.price - B.price, 0) AS diffe... | 29,237 |
<p>Is it possible to pass a query string to Namescape's <a href="http://www.namescape.com/Products/rDirectory/Default.aspx" rel="nofollow noreferrer">rDirectory</a>? I'd like to build a web-app that can do a search and display the results in rDirectory, rather than first launching rDirectory and doing said search.</p>
| <p>If you're dead-set on the single app instance, you can accomplish what you're after using a custom ConfigurationSection in your single web.config. For the basics, see:</p>
<ul>
<li><a href="http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-steps.aspx" rel="noreferrer">http://haacked.com/... | <p>Depending on what is actually in the web config, and what settings differ between customers, you could opt to use a single web config, and store other customer specific configuration options in a database or some other custom xml/text file. As long as the specific customer settings in the web.config don't have to ... | 42,073 |
<p>As I learn more and more about OOP, and start to implement various design patterns, I keep coming back to cases where people are hating on <a href="http://en.wikipedia.org/wiki/Active_record_pattern" rel="noreferrer">Active Record</a>.</p>
<p>Often, people say that it doesn't scale well (citing Twitter as their pri... | <p>There's <a href="http://en.wikipedia.org/wiki/Active_record_pattern" rel="noreferrer">ActiveRecord the Design Pattern</a> and <a href="http://api.rubyonrails.com/classes/ActiveRecord/Base.html" rel="noreferrer">ActiveRecord the Rails ORM Library</a>, and there's also a ton of knock-offs for .NET, and other languages... | <p>The problem that I see with Active Records is, that it's always just about <strong>one</strong> table. That's okay, as long as you really work with just that one table, but when you work with data in most cases you'll have some kind of join somewhere.</p>
<p>Yes, <strong>join</strong> usually is worse than <strong>... | 2,941 |
<p>When I type 'from' (in a <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="nofollow noreferrer">LINQ</a> query) after importing <a href="http://msdn.microsoft.com/en-us/library/system.linq.aspx" rel="nofollow noreferrer">System.Linq namespace</a>, it is understood as a keyword. How does this magi... | <p>In practice, yes - LINQ keywords map to extension methods. But actually, it is more interesting; it is literally as though the compiler substitutes directly for a few key methods, i.e.</p>
<pre><code>var qry = from cust in db.Customers
where cust.IsActive
select cust;
</code></pre>
<p>becomes:<... | <p>"from" is a language keyword (just like "if" or "foreach").</p>
<p>You don't even need to import System.Linq to use "from", but you need to use 3.5 framework.</p>
| 23,180 |
<p>is there a solution for batch insert via hibernate in partitioned postgresql table? currently i'm getting an error like this...</p>
<pre><code>ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual ... | <p>You might want to try using a custom Batcher by setting the hibernate.jdbc.factory_class property. Making sure hibernate won't check the update count of batch operations might fix your problem, you can achieve that by making your custom Batcher extend the class BatchingBatcher, and then overriding the method doExecu... | <p>I faced the same problem while inserting documents through hibernate after lot of search found that it is expecting that updated rows should be returned so instead of null change it to new in trigger procedure which will resolve the problem as shown below</p>
<p>RETURN NEW</p>
| 10,880 |
<p>I have some code that prints out databse values into a repeater control on an asp.net page. However, some of the values returned are null/blank - and this makes the result look ugly when there are blank spaces. </p>
<p>How do you do conditional logic in asp.net controls i.e. print out a value if one exists, else ... | <p>It's going to be a pretty subjective one this as it completely depends on where and how you like to handle null / blank values, and indeed which one of those two you are dealing with.</p>
<p>For example, some like to handle nulls at the database level, some like to code default values in the business logic layer an... | <p>I realise that this is a very old question, but I'd like to add that perhaps the best way of handling this issue is more at the database level, and yes - I know that the OP hasn't specified any type of data source.</p>
<p>I'm simply going to assume (yes - ass of you and me) that the current language being used is a... | 48,062 |
<p>It turns out install shield doesn't support file download resuming.</p>
<p>Is there a .net component that provides this functionality?</p>
| <p>We use the <a href="http://www.kineticjump.com/update/default.aspx" rel="nofollow noreferrer">AppLife Update component</a>. It is specifically for .NET and can resume interrupted downloads and do much more. We found it easy to use and flexible.</p>
| <p>I don't think so,but it's not that hard to write one . There are a lot of <strong>HTTP Clients</strong> already . All that you would need to do is checking to see if the web server actually supports resuming . Check this blog entry for a little info about HTTP and download resuming :</p>
<p><strong><a href="http://... | 31,211 |
<p>In the following code below:</p>
<pre><code>Image img = new Image();
img.Source = new BitmapImage(new Uri("http://someURL/somefilename.jpg", UriKind.Absolute));
</code></pre>
<p>how can I determine if the image successfully loaded (when there's a valid URI)? i.e., The URI is a valid format, but the file may not ex... | <p><code>Image</code> has an <code>ImageFailed</code> event.</p>
<p><code>BitmapSource</code> (base for <code>BitmapImage</code>) has an <code>IsDownloading</code> property, as well as <code>DownloadProgress</code>, <code>DownloadCompleted</code>, and <code>DownloadFailed</code> events.</p>
| <p>If you run your example code above (with a valid url but invalid image file) you will get an exception thrown:</p>
<pre><code>Error: Sys.InvalidOperationException: ImageError error #4001 in control 'Xaml1': AG_E_NETWORK_ERROR
</code></pre>
<p>So if you wrap your code in a try/catch block you can determine if the i... | 22,236 |
<p>I will be creating a small tube styled piece to use as a junction between two pieces of plastic. The idea is to reattach the two pieces and provide strength so they don't break apart again. I plan on using PLA.</p>
<p>My question is, will superglue (cyanoacrylate) work best for this or are there better choices for a... | <p>PLA is a nice one, and gluing has been a topic on some of our most favorite maker's channels. For example Stefan from CNC kitchen (<a href="https://www.youtube.com/watch?v=JSff8OMRHtw" rel="nofollow noreferrer">this video</a>) and Joel the 3DPrinting Nerd (<a href="https://www.youtube.com/watch?v=s1q2D_pK0BE" rel="n... | <p><a href="https://www.3dgloop.com/shop/pla-gloop" rel="nofollow noreferrer">PLA Gloop</a> is dedicated glue for PLA. It contains chloroform, so be careful.</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=gTtW_NXFMCY" rel="nofollow noreferrer">3D Gloop! // 3D Printing Adhesive Spotlight</a></li>
<li><a href="htt... | 1,011 |
<p>I am looking for an easy way to check if an object in C# is serializable.</p>
<p>As we know you make an object serializable by either implementing the <em>ISerializable</em> interface or by placing the <em>[Serializable]</em> at the top of the class.</p>
<p>What I am looking for is a quick way to check this withou... | <p>You have a lovely property on the <code>Type</code> class called <code>IsSerializable</code>.</p>
| <p>The exception object might be serializable , but using an other exception which is not.
This is what I just had with WCF System.ServiceModel.FaultException: FaultException is serializable but ExceptionDetail is not!</p>
<p>So I am using the following:</p>
<pre><code>// Check if the exception is serializable and al... | 10,742 |
<p>Compare</p>
<pre><code>String.Format("Hello {0}", "World");
</code></pre>
<p>with</p>
<pre><code>"Hello {0}".Format("World");
</code></pre>
<p>Why did the .Net designers choose a static method over an instance method? What do you think?</p>
| <blockquote>
<p>Because the Format method has nothing to do with a string's current value.</p>
</blockquote>
<p>That's true for <em>all</em> string methods because .NET strings are immutable.</p>
<blockquote>
<p>If it was non-static, you would need a string to begin with.</p>
</blockquote>
<p>It does: the format... | <p><code>String.Format</code> takes at least one String and returns a different String. It doesn't need to modify the format string in order to return another string, so it makes little sense to do that (ignoring your formatting of it). On the other hand, it wouldn't be that much of a stretch to make <code>String.Forma... | 4,324 |
<p>I have a page where search resuts are shown both in a grid and on a map (using KML generated on the fly, overlaid on an embedded Google map). I've wired this up to work as the user types; here's the skeleton of my code, which works:</p>
<pre><code>$(function() {
// Wire up search textbox
$('input.Search').b... | <p>Instead of calling <code>update()</code> directly, call a wrapper that checks to see if there are any pending delayed updates:</p>
<pre><code>$('input.Search').bind("keyup", delayedUpdate);
function delayedUpdate() {
if (updatePending) {
clearTimeout(updatePending);
}
updatePending = setTimeou... | <p>As a first approach, what about something like :</p>
<pre><code>$('input.Search').bind("keyup", function() { setTimeout(update, 5) } );
</code></pre>
<p>(not sure about the exact setTimeout syntax).</p>
<p>You can also keep a variable to track whether the timeout has already been scheduled or not.</p>
| 24,692 |
<p>If i do jQuery(expr).change( function), then I can get an event function to fire when the user makes a change to the value.</p>
<p>Is it possible to get this to fire if it's changed programatically, ie if I call jQuery(expr).val("moo").</p>
<p>or if some Plain old JavaScript changes it's value?</p>
<p>Thanks for ... | <p>After you've changed the value, you can fire the event yourself, and thus calling all the 'onchange' handlers.</p>
<pre><code>jQuery('#element').change();
</code></pre>
| <p>jQuery v1+ supports the programmatic triggering of handlers - I have used this method as opposed to the .change() method as it allows for multiple other handlers to be fired if needed (e.g. some custom handlers). <a href="http://api.jquery.com/trigger/" rel="nofollow" title="http://api.jquery.com/trigger/">API Docum... | 46,830 |
<p>When debugging I need to start an external program from the target directory of a build and am wondering if it can be accomplished using relative paths.</p>
<p>As a post-build event I have the following:</p>
<pre>
IF NOT "$(ConfigurationName)"=="Debug" GOTO End
:CopyExecutable
copy "$(SolutionDir)\Source\Lib\MyExe... | <p>The 'Start External Program' path is relative to your solution directory (in VS2005 anyway). So you could just put:</p>
<pre><code>Source\Lib\MyExecutable.exe
</code></pre>
<p>I see you asked this a while ago, but I just ran into the same problem, and this is how I solved it.</p>
| <p>Did you try something like $(TargetDir)\..\Lib ?</p>
| 43,355 |
<p>I've got three (relevant) models, specified like this:</p>
<pre><code>class User < ActiveRecord::Base
has_many :posts
has_many :comments
has_many :comments_received, :through => :posts, :source => :comments
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
class Com... | <p>Although the syntax to deinfe resource and model relationship is similar, you shouldn't be fooled into thinking that a resource maps to a model. Read what <a href="http://dablog.rubypal.com/2008/3/23/splitting-hairs-over-resource" rel="nofollow noreferrer">David Black has to say</a>.</p>
<p>The problem you're havi... | <p>I have to confess, I'm a little confused by the variable names, but first off, I'm surprised your has_many :through works at all the way it's defined. Do the models behave as you expect, setting aside the routes for a second?</p>
<p>Second, and this is where the variable names really come into play, the routes hav... | 35,719 |
<p>There are numerous topics found on first layers that do not adhere properly causing prints to fail or cause print quality defects.</p>
<p>The advice is often to properly level or tram the build surface. How does one tram the build surface?</p>
| <h3>Definition of leveling</h3>
<p>Tramming, often referred to as "leveling" in the 3D printer world ("tramming" and "leveling" is used interchangeably, but "tramming" is the correct nomenclature), is the process of creating a 2D <a href="https://en.wikipedia.org/wiki/Plane_(geo... | <p>For fine tuning I get good results by loading a model of any object with a rectangular footprint and scaling it to a size close to the printer's limits.</p>
<p>With the skirt set to around 10 passes, start the print job, let the skirt print then kill the job.</p>
<p>Peel the skirt from the bed and measure its thickn... | 2,115 |
<p>I have the following string:</p>
<pre><code>cn=abcd,cn=groups,dc=domain,dc=com
</code></pre>
<p>Can a regular expression be used here to extract the string after the first <code>cn=</code> and before the first <code>,</code>? In the example above the answer should be <code>abcd</code>. </p>
| <pre><code> /cn=([^,]+),/
</code></pre>
<p>most languages will extract the match as $1 or matches[1] </p>
<p>If you can't for some reason wield subscripts, </p>
<pre><code>$x =~ s/^cn=//
$x =~ s/,.*$//
</code></pre>
<p>Thats a way to do it in 2 steps.</p>
<p>If you were parsing it out of a log with sed </p>
<pre... | <p>Yeah, using perl/java syntax <code>cn=([^,]*),</code>. You'd then get the 1st group.</p>
| 12,257 |
<p>Is there an Iterator implementation that merges multiple iterators? </p>
<pre><code>class MergedIterator<T> implements Iterator<T>
{
MergedIterator(Iterator<T>... iters)
....
}
</code></pre>
<p>And the next method should move on to <code>iters[1]</code> when <code>!iters[0].hasNext()</c... | <p>I'd call that a ConcatenatedIterator myself - a MergedIterator should merge the results of several iterators e.g. based on sorting</p>
<p>Naming aside, I'm sure there'll be an implementation in a 3rd party library somewhere. Just off to check <a href="http://code.google.com/p/google-collections/" rel="nofollow nore... | <p>there's one in groovy: <a href="http://groovy.codehaus.org/Iterator+Tricks" rel="nofollow noreferrer">http://groovy.codehaus.org/Iterator+Tricks</a> - you can probably roll one up like this with a few more lines of code.</p>
| 39,270 |
<p>I've got a name of a method: "Garden.Plugins.Code.Beta.Business.CalculateRest"</p>
<p>How to run it? I think about this fancy reflection based solution like RunMethod(string MethodName)</p>
| <ul>
<li>Split it into type name and method name by splitting on the last dot</li>
<li>Get the type using <a href="http://msdn.microsoft.com/en-us/library/system.type.gettype.aspx" rel="nofollow noreferrer">Type.GetType</a> or <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettype.aspx" rel... | <p>It'll be slow, trust me. So don't put it in a critical place.</p>
<p>Other than that you'll just have to do it "by hand". Start enumerating through all the namespaces, classes, etc. until you find what you need. I don't think there is anything fancy pre-made that does this already. (Although I haven't searched)</p>... | 43,252 |
<p>I'm trying to set the group type for a new Active Directory Entry via VB.NET and DirectoryServices to create a distribution list.</p>
<p>How do I access the ADS_GROUP_TYPE enumerations?</p>
<p>Specifically I'm after ADS_GROUP_TYPE_GLOBAL_GROUP.</p>
| <p>You're correct, you can't actually get access to the enumerations. </p>
<p>Just a wee nitpick, this constant doesn't need to be an object, you can make it an int32 -</p>
<p>Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2</p>
| <p>I don't think I can access the enumerations via .NET so instead I created the specific constant I needed. For what it's worth here's my code:</p>
<blockquote>
<pre><code> Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2
adNewGroup.Properties("groupType").Value = ADS_GROUP_TYPE_GLOBAL_GROUP
</cod... | 3,098 |
<p>Why whenever I compile and run the following code in Visual Studio 2008:</p>
<pre><code>double value1 = 10.5;
double value2 = 15.5;
int whole_number = value1 + value2;
Console::WriteLine(whole_number);
</code></pre>
<p>I get an incorrect value of 26 while the answer is 25.</p>
<p>However when I use static casts o... | <p>It's absolutely right.</p>
<pre><code>double value1 = 10.5;
double value2 = 15.5;
int whole_number = value1 + value2; // int whole_number = 26.0;
Console::WriteLine(whole_number);
</code></pre>
<p>What would you expect instead? The compiler first evaluates the right side, and then implicitly converts to the int. T... | <p>Actually, you can not rely on floating point numbers to round of either way when doing an automatic conversion. If 26.0 is represented by 26.00005, it will be rounded to 26, if it is represented by 25.999995, it will be rounded to 25. If you want to be sure, use the standard C function <code>round</code>, defined in... | 40,367 |
<p>I try to write to a large file, but it seems like it does not work for files larger than 2GB.
I have tried with boost::iostreams::file_sink. Is this just a limit with the boost stream? Is there some other way I can write a large file on Win64 and win32?</p>
| <p>This depends on:</p>
<ul>
<li>The file system which you're using. Old file systems like FAT allow only files up to 2GB. Use NTFS.</li>
<li>Your library must be compiled to allow large files (64bit seek offsets). If they use 32bit ints to seek in file (check the arguments and results of the calls "seek" and "tell"),... | <p>In NTFS the only real limit is the size of the volume. If you want to test this out you can create a dummy file using the command-line:<br>
fsutil file createnew [filename] [validdatalength]<br>
Ex:<br>
fsutil file createnew TestFile.bin 65536000000<br>
That should create a 64GB file assuming you have an NTFS volume... | 38,765 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.