instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>How can I make this java generic cast ?</p> <pre><code>public interface IField { } class Field implements IField { // package private class } public class Form { private List&lt;Field&gt; fields; public List&lt;IField&gt; getFields() { return this.fields; } } </code></pre> <p>The return statemen...
<p>A better solution, IMO, is to change the signature of your method to use a bounded wildcard:</p> <pre><code>public List&lt;? extends IField&gt; getFields() </code></pre> <p>This will let the caller treat anything coming "out" of the list as an IField, but it won't let the caller add anything into the list (without...
<p>Sunlight is right, you can just cast it.</p> <p>Another fix is to double-check that you really need a <code>List&lt;Field&gt;</code>, or whether you can change your internal <code>fields</code> variable to <code>List&lt;IField&gt;</code>.</p> <p>As long as you only ever use methods on the contents of the list that...
40,512
<p>I have a string of test like this:</p> <pre><code>&lt;customtag&gt;hey&lt;/customtag&gt; </code></pre> <p>I want to use a RegEx to modify the text between the "customtag" tags so that it might look like this:</p> <pre><code>&lt;customtag&gt;hey, this is changed!&lt;/customtag&gt; </code></pre> <p>I know that I c...
<p>I wouldn't use regex either for this, but if you must this expression should work: <code>&lt;customtag&gt;(.+?)&lt;/customtag&gt;</code></p>
<pre><code>//This is to replace all HTML Text var re = new RegExp("&lt;[^&gt;]*&gt;", "g"); var x2 = Content.replace(re,""); //This is to replace all &amp;nbsp; var x3 = x2.replace(/\u00a0/g,''); </code></pre>
38,442
<p>My G29 command reports</p> <pre><code>+0.178 +0.281 +0.830 -0.614 -0.012 +0.371 -1.208 -0.849 -0.351 </code></pre> <p>So should I tighten up the screw of the bed, close to 0,0 position or loosen it?</p> <p>I have a feeling that when I loosen it, it gets away from zero and I expect the opposite to happen.</p> <p>...
<p>Using Repetier Host V2.1.2 and slicing with Slic3r (or with CuraEngine), there is an "edit Gcode" button under the Print Preview tab. It is located at the top right of the screen. With that button you can access, examine and change the Gcode of the project you are working on.</p>
<p>After you use the Slice Now button (and the slicing progress bar shows completed), select the preview tab. To the right of the window you will see a pair of vertical sliders. Each slider changes the start and finish locations for the filament layers.</p> <p>You can slide the left one to the bottom, which will "empt...
944
<p>I've been playing with RSS feeds this week, and for my next trick I want to build one for our internal application log. We have a centralized database table that our myriad batch and intranet apps use for posting log messages. I want to create an RSS feed off of this table, but I'm not sure how to handle the volum...
<p>If you are building a system with notifications that must not be missed, then a pub-sub mechanism (using XMPP, one of the other protocols supported by ApacheMQ, or something similar) will be more suitable that a syndication mechanism. You need some measure of coupling between the system that is generating the notifi...
<p>Without knowing your application, I can't offer specific advice. </p> <p>That said, it's common in these sorts of systems to have a level of severity. You could have a query string parameter that you tack on to the end of the URL that specifies the severity. If set to "DEBUG" you would see every event, no matter ho...
8,478
<p>[EDIT]In Short: How would you write an automatic spell checker? The idea is that the checker builds a list of words from a known good source (a dictionary) and automatically adds new words when they are used often enough. Words which haven't been used a while should be phased out. So if I delete part of a scene whic...
<p>So you want to write a spelling checker. Here's <a href="http://norvig.com/spell-correct.html" rel="nofollow noreferrer">Peter Norvig's paper about writing a spelling corrector</a>. It describes a simple and robust spelling corrector. You can use the already-written part of the book, plus a reference list (say from ...
<p>The structure you should use is a trie. Tail/suffix compression will help with memory. You can use a pseudo reference counting GC for keeping track of usage.</p> <p>For the actual nodes, you would probably need no more than a 32-bit integer, 21-bits for unicode, and the rest for various other tags and information.<...
43,365
<p>As far as I can tell there's no simple way of retrieving a character offset from a TextRange object in Internet Explorer. The W3C Range object has a node, and the offset into the text within that node. IE seems to just have pixel offsets. There are methods to create, extend and compare ranges, so it would be possibl...
<p>I'd suggest <a href="http://code.google.com/p/ierange/" rel="nofollow noreferrer">IERange</a>, or just the <code>TextRange</code>-to-<code>DOM Range</code> algorithm from it.</p> <h2>Update, 9 August 2011</h2> <p>I'd now suggest using my own <a href="http://code.google.com/p/rangy" rel="nofollow noreferrer">Rangy<...
<p>You can iterate through the body element's <code>TextRange.text</code> property using <code>String.substring()</code> to compare against the TextRange for which you want the character offset.</p> <pre><code>function charOffset(textRange, parentTextRange) { var parentTxt = parentTextRange.text; var txt = t...
19,842
<p>The problem is you can't tell the user how many characters are allowed in the field because the escaped value has more characters than the unescaped one.</p> <p>I see a few solutions, but none looks very good:</p> <ul> <li>One whitelist for each field <em>(too much work and doesn't quite solve the problem)</em></l...
<p>Don't build your application around the database - build the database for the application!</p> <p>Design how you want the interface to work for the user first, work out the longest acceptable field length, and use that.</p> <p>In general, don't escape before storing in the database - store raw data in the database...
<p>This is an interesting problem.</p> <p>I think the solution will be a problem if you assign any responsibility to them because of the sanitization. If they are responsible for guessing the maximum length, then they may well give up and pick something else (and not understand why their input was invalid).</p> <p>H...
20,570
<p>I'm not sure why the TSpeedButton has this property but when a TSpeedButton is the only button of a given groupindex, it doesn't stay pressed, whether or not "AllowAllUp" is pressed. Maybe a Jedi control would suffice, but hopefully there's some fix. Any help or anecdotes are appreciated.</p> <p>BTW, I'm (still) ...
<p>I have no D7 here, but in D2006 a Speedbutton stays down if the GroupIndex has a value > 0.</p> <p>If this is not the behaviour you wish, you can set the Down-Property manually in the OnClick-Eventhandler (make sure, that the GroupIndex is 0).</p>
<p>I was searching for a solution for my problem and I think this is kind of the same one. I wanted to make a SpeedButton toggle the up and down state just like a switch, and I managed this by setting the properties: </p> <pre><code>AllowAllUp := True; GroupIndex := 1; </code></pre> <p>Then in the <code>OnClick</cod...
24,792
<p>I have a "Status" class in C#, used like this:</p> <pre><code>Status MyFunction() { if(...) // something bad return new Status(false, "Something went wrong") else return new Status(true, "OK"); } </code></pre> <p>You get the idea. All callers of MyFunction <em>should</em> check the returned Status:...
<p>I know this doesn't answer your question directly, but if "something went wrong" within your function (unexpected circumstances) I think you should be throwing an exception rather than using status return codes.</p> <p>Then leave it up to the caller to catch and handle this exception if it can, or allow it to propo...
<p>You can throw an exception by:</p> <pre><code>throw MyException; [global::System.Serializable] public class MyException : Exception { // // For guidelines regarding the creation of new exception types, see // http://msdn.microsoft.com/library/default.asp?url=/library/en-...
4,001
<p>I'd like to build a real quick and dirty administrative backend for a Ruby on Rails application I have been attached to at the last minute. I've looked at activescaffold and streamlined and think they are both very attractive and they should be simple to get running, but I don't quite understand how to set up either...
<p>I think namespaces is the solution to the problem you have here:</p> <pre><code>map.namespace :admin do |admin| admin.resources :customers end </code></pre> <p>Which will create routes <code>admin_customers</code>, <code>new_admin_customers</code>, etc.</p> <p>Then inside the <code>app/controller</code> direc...
<p>Use <a href="https://github.com/sferik/rails_admin" rel="nofollow">https://github.com/sferik/rails_admin</a>.</p>
13,309
<p>Difficult question. The answer is probably no, if all I found in the Intertubes is right, but it is worth a try. I need to override the <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Esc</kbd> and the <kbd>Ctrl</kbd> + <kbd>Esc</kbd> combinations. It would be good to be able to override the <kbd>Win</kbd> key combination...
<p>You can override <kbd>Ctrl</kbd> + <kbd>Esc</kbd> (I just tried in AutoHotkey, it works), but not <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Esc</kbd>, no more than <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Del</kbd>.</p> <p>So using policies is probably the way to go... No experience in this field, I fear.</p>
<p>So you need do override Hotkeys on your application? Then the answer is probably yes, how? No idea, but if this(<a href="http://www.inchwest.com/mapkeyboard.aspx" rel="nofollow noreferrer">http://www.inchwest.com/mapkeyboard.aspx</a>) program can, so can you </p>
23,412
<p>I have a table cell, and I want a div within it to always be at the bottom left corner. The following works fine in IE and Safari, but Firefox is positioning the <code>div</code> absolutely on the page, not within the cell (code based on the solution solution <a href="https://stackoverflow.com/questions/104953/posi...
<p>According to the <a href="http://www.w3.org/TR/CSS21/visuren.html#propdef-position" rel="noreferrer">W3C</a>, position:relative has no effect on table cells:</p> <blockquote> <p>"The effect of 'position:relative' on table-row-group, table-header-group, table-footer-group, table-row, table-column-group, tabl...
<p><code>position: relative</code> is apparently not globally supported for the <code>td</code> tag. I couldn't find definitive sources unfortunately.</p> <p>You might want to put a <code>div</code> block into the <code>td</code> with the desired size and apply <code>position: relative</code> to that instead.</p>
37,008
<p>As per c99 standard, size of <code>long long</code> should be minimum 64 bits. How is this implemented in a 32 bit machine (eg. addition or multiplication of 2 <code>long long</code>s). Also, What is the equivalent of <code>long long</code> in C++.</p>
<p>On the IA32 architecture, 64-bit integer are implemented in using two 32-bit registers (eax and edx).</p> <p>There are platform specific equivalents for C++, and you can use the stdint.h header where available (boost provides you with <a href="http://www.boost.org/doc/libs/1_37_0/boost/cstdint.hpp" rel="noreferrer"...
<p>If you care about bit-sizes, you should use</p> <pre><code>#include &lt;stdint.h&gt; int32_t n; </code></pre> <p>and friends. This works for C++ as well.</p> <p>64-bit numbers on 32-bit machines are implemented as you think, by 4 extra bytes. You could therefore implement your own 64-bit datatype by doing some...
42,796
<p>I am inside of...</p> <pre><code>public class bgchange : IMapServerDropDownBoxAction { void IServerAction.ServerAction(ToolbarItemInfo info) { Some code... </code></pre> <p>and after "some code" I want to trigger</p> <pre><code>[WebMethod] public static void DoSome() { } </code></pre> <p>Which trig...
<p>I'm not sure I fully understand the sequence of what you are trying to do, what's client-side and what's not....</p> <p>However, you could add a Start-up javascript method to the page which would then call the WebMethod. When calling a WebMethod via javascript, you can add a call-back function, which would then be...
<p>hmmm... the question changed dramatically since my original answer.</p> <p>Now I think the answer is no. But I might be wrong.</p>
18,571
<p>I knew of some performance reasons back in the SQL 7 days, but do the same issues still exist in SQL Server 2005? If I have a resultset in a stored procedure that I want to act upon individually, are cursors still a bad choice? If so, why?</p>
<p>Because cursors take up memory and create locks.</p> <p>What you are really doing is attempting to force set-based technology into non-set based functionality. And, in all fairness, I should point out that cursors <em>do</em> have a use, but they are frowned upon because many folks who are not used to using set-bas...
<p>The basic issue, I think, is that databases are designed and tuned for set-based operations -- selects, updates, and deletes of large amounts of data in a single quick step based on relations in the data.</p> <p>In-memory software, on the other hand, is designed for individual operations, so looping over a set of d...
8,255
<p>Is there a way to take a class name and convert it to a string in C#? </p> <p>As part of the Entity Framework, the .Include method takes in a dot-delimited list of strings to join on when performing a query. I have the class model of what I want to join, and for reasons of refactoring and future code maintenance, I...
<p>You can't use <code>.GetType()</code> without an instance because <code>GetType</code> is a method.</p> <p>You can get the name from the type though like this:</p> <pre><code>typeof(Foo).Name </code></pre> <p>And as pointed out by Chris, if you need the assembly qualified name you can use</p> <pre><code>typeof(F...
<p>You can use an <code>DbSet&lt;contact&gt;</code> instead of <code>ObjectSet&lt;contact&gt;</code>, so you can use lambda as a parameter, eg <code>tblBar.Include(a =&gt; a.foo)</code></p>
21,676
<p>I am attempting to build a simple method that creates an XML file from a database in ruby on rails. I feel like my code is right but I am not seeing all of the users in the XML.<br> I am a complete newbie to RoR.</p> <p>Here's my code:</p> <pre><code>def create_file @users = User.find(:all) file = File.ne...
<p>There's a bug in your code. In each iteration you create an element with <a href="http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXML/Element.html#M003015" rel="nofollow noreferrer"><code>add_element</code></a> and then try to access that element with <a href="http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/clas...
<p>You ought to investigate <code>@users.to_xml</code> to see if it is something you could use instead of rolling your own solution. Read more about it in the <a href="http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Array/Conversions.html#M000798" rel="nofollow noreferrer">Rails API docs</a>.</p>
32,089
<p>I'll phrase this in the form of an example to make it more clear.</p> <p>Say I have a vector of animals and I want to go through the array and see if the elements are either dogs or cats?</p> <pre><code>class Dog: public Animal{/*...*/}; class Cat: public Animal{/*...*/}; int main() { vector&lt;Animal*&gt; stuff;...
<p>As others has noted, you should neither use the <code>typeid</code>, nor the <code>dynamic_cast</code> operator to get the dynamic type of what your pointer points to. virtual functions were created to avoid this kind of nastiness. </p> <p>Anyway here is what you do if you <strong>really</strong> want to do it (not...
<p>You can use the <code>typeid</code> operator to do this, e.g.</p> <pre><code>if (typeid(stuff[i].getClass())==typeid(Dog)) </code></pre> <p>This can't catch if it's a derived class of <code>Dog</code>, though. You can use a <code>dynamic_cast</code> for that. However, any use of <code>typeid</code> or <code>dynami...
43,163
<p>In a fictitious web application ...</p> <ol> <li>The user clicks a link </li> <li>The server starts to prepare the response, but it takes several seconds</li> <li>The user cancels the page load</li> </ol> <p>What happens to the request? Does the server continue to prepare the response? Does the response arrive t...
<p>The server will continue to prepare the response. When it tries to send the response to the client, it'll fail. When this actually happens will probably depend on the actual application server implementation, whether the response is buffered etc.</p> <p>In Java EE app servers (Tomcat and WebLogic, probably others a...
<p>I would think that the actual TCP connection is closed by the browser and therefore the web-server will be unable to send data, and unless it is specifically programmed to detect broken connections whilst preparing the data, then the page will be fully processed even if the user cancels.</p> <p>I have little knowle...
30,488
<p>I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently.</p> <p>Is there are way to do something like this:</p> <pre><code>installutil.exe myservice.exe /customarg1=username /customarg2=password </code></p...
<p>Bravo to my co-worker (Bruce Eddy). He found a way we can make this command-line call:</p> <pre><code>installutil.exe /user=uname /password=pw myservice.exe </code></pre> <p>It is done by overriding OnBeforeInstall in the installer class:</p> <pre><code>namespace Test { [RunInstaller(true)] public class T...
<p>You can also force your service to run as User using <strong>ServiceProcessInstaller::Account = ServiceAccount.User</strong>;</p> <p>A popup asking "[domain\]user, password" will appear during service installation.</p> <pre><code>public class MyServiceInstaller : Installer { /// Public Constructor for Windows...
16,947
<p>I have an auditing trigger that automatically places the time something was updated and the user that updated in fields in all my tables. I have another set of triggers that write event information from updates to an events table. The issue is when someone updates something, the event information is fired twice beca...
<p>Look into TRIGGER_NESTLEVEL function. It returns the current level of trigger nesting. You can check that to prevent the duplicates.</p>
<p>Disabling trigger-fires-trigger behavior can also be done in SS2005 by going into SS Mgt Studio and selecting the icon of the server in question, right-clicking, then select "Properties". Then select "Advanced" from the list on the left and set the value for "Allow Triggers to Fire Others" to 'False'.</p>
35,337
<p>I have Flex based consumer <a href="http://www.rollingrazor.com" rel="nofollow noreferrer">website</a> where I would like to change various look and feel type settings based on random and other criteria, and then track these through to what results in the most sales. </p> <p>For instance I might completely switch o...
<p>Ok, this is very tricky. The reason for me to say that is because you are asking for two things:</p> <ul> <li>relaxed repository schema so that you can store various data and change what gets saved dynamically later</li> <li>fixed database schema so that you can query data effectively</li> </ul> <p>The solution wi...
<p>This is a classic case for using a NoSQL database. It could be used to store various key value pairs with ease and without any predefined schema. </p>
18,829
<p>I have written a KornShell (ksh) script that sets an array the following way:</p> <pre><code>set -A fruits Apple Orange Banana Strawberry </code></pre> <p>but when I am trying to run it from within cron, it raises the following error:</p> <pre><code>Your "cron" job on myhost /myScript.sh produced the following o...
<p>Although I'm not sure it's the best way to do it, I've managed to solve it this way:</p> <p>Attempt 4:</p> <pre><code>0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script &amp;&amp; ksh ./myScript.sh </code></pre>
<p>Although I'm not sure it's the best way to do it, I've managed to solve it this way:</p> <p>Attempt 4:</p> <pre><code>0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script &amp;&amp; ksh ./myScript.sh </code></pre>
39,429
<p>Does NetworkStream.DataAvailable know whether the sender's send buffer is empty? Or does it simply indicate whether the receiver's read buffer has data? My assumption is the latter...</p> <p>Specifically, for some socket work involving an ongoing conversation, I currently use a length-prefix so the the receiver kno...
<p>One side of a connection is not going to know whether the other side's send buffer is empty.</p> <p><code>DataAvailable</code> only indicates whether there is incoming data to be read. You could use that prior to <code>Read()</code>, but it alone doesn't give you the information you want. It doesn't tell you the be...
<p>If you are needing to know when the receiver has received all of the data for a particular message then you definitely need to length prefix.</p> <p>I typically define a struct similar to this that goes out at the front of any binary messages i send.</p> <pre><code>struct Header { int packetIdentifier; int pro...
20,115
<p>I have two XML files with two different XSD schemas and different namespaces. They have both an identical substructure. And now i need to copy that node (and all childs) from one XML document to the other one. </p> <p>Clone would do, if the namespaces were the same. Is there a nice way to do it? (The substructure ...
<p>Basically, you need an XSL transformation that creates new elements with equal names, but a different namespace.</p> <p>Consider the following input XML:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;test xmlns="http://tempuri.org/ns_old"&gt; &lt;child attrib="value"&gt;text&lt;/child&gt; &lt...
<p>Not sure if this applies, but I've done something similar working with two xml docs in vb.net:</p> <pre><code>Private Shared Sub CopyElement(ByVal FromE As Xml.XmlElement, ByVal ToE As Xml.XmlElement) CopyElement(FromE, ToE, Nothing) End Sub Private Shared Sub CopyElement(ByVal FromE As Xml.XmlElement, ByVal To...
31,085
<p>How do I write a decorator that restores the current working directory to what it was before the decorated function was called? In other words, if I use the decorator on a function that does an <code>os.chdir()</code>, the cwd will not be changed after the function is called.</p>
<p>The answer for a decorator has been given; it works at the function definition stage as requested.</p> <p>With Python 2.5+, you also have an option to do that at the function <em>call</em> stage using a context manager:</p> <pre><code>from __future__ import with_statement # needed for 2.5 ≤ Python &lt; 2.6 import ...
<pre><code>def preserve_cwd(function): def decorator(*args, **kwargs): cwd = os.getcwd() result = function(*args, **kwargs) os.chdir(cwd) return result return decorator </code></pre> <p>Here's how it's used:</p> <pre><code>@preserve_cwd def test(): print 'was:',os.getcwd() os.chdir('...
20,404
<p>Is there a way in Ruby to find the version of a file, specifically a .dll file?</p>
<p>For Windows EXE's and DLL's:</p> <pre><code>require "Win32API" FILENAME = "c:/ruby/bin/ruby.exe" #your filename here s="" vsize=Win32API.new('version.dll', 'GetFileVersionInfoSize', ['P', 'P'], 'L').call(FILENAME, s) p vsize if (vsize &gt; 0) result = ' '*vsize Win32API.new('version.dll', 'G...
<p>For any file, you'd need to discover what format the file is in, and then open the file and read the necessary bytes to find out what version the file is. There is no API or common method to determine a file version in Ruby.</p> <p>Note that it would be easier if the file version were in the file name.</p>
10,210
<p>With LINQ to SQL most likely going to not get as much active development as Entity Framework do you think it's best to switch to Entity Framework?</p> <p>I've personally found EF to be very clunky and hard to use compared to LINQ to SQL which feels very natural.</p> <p>EDIT: I recently posted an article on my blog...
<p>IMO, not at the moment.</p> <p>It is clear (from <a href="http://blogs.msdn.com/adonet/archive/2008/10/31/clarifying-the-message-on-l2s-futures.aspx" rel="nofollow noreferrer">recent announcements</a> especially) that EF is in for some heavy revisions as the "<a href="http://codebetter.com/blogs/ian_cooper/archive/...
<p>Recently, i had to research which ORM project should use. At first - tried L2S. It wasn't bad at all, but it's already obsolete (MS won't support it anymore), that's why i started to check out L2E. I'm fine with generated code, but creating fake views, entities and mappings between them just to make stored procedure...
34,857
<p>I've just run into a display glitch in IE6 with the ExtJS framework. - Hopefully someone can point me in the right direction.</p> <p>In the following example, the bbar for the panel is displayed 2ems narrower than the panel it is attached to (it's left aligned) in IE6, where as in Firefox it is displayed as the sam...
<h3>2015 update: the flexbox approach</h3> <p>There are two other answers briefly mentioning <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes" rel="noreferrer">flexbox</a>; however, that was more than two years ago, and they don't provide any examples. The specification for flexbox has de...
<p>it <strong>never worked for me in other way then with use of the JavaScript</strong> as NICCAI suggested in the very first answer. I am using that approach to rescale the <code>&lt;div&gt;</code> with the Google Maps. </p> <p>Here is the full example how to do that (works in Safari/FireFox/IE/iPhone/Andorid (works ...
11,559
<p>I've inherited a WSDL file for a web service on a system that I don't have access to for development and testing.</p> <p>I need to generate a web service that adheres to that WSDL. The wrapper is .NET, but if there's an easy way to do this with another platform, we might be able to look at that. The production web ...
<p>You may find useful the <a href="http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx" rel="noreferrer">command line utility <code>wsdl.exe</code></a> of .NET by using the <code>/serverInterface</code> option. According to the documentation:</p> <blockquote> <p>Generates interfaces for server-side imple...
<p>Try mock the wrapper interface using <a href="http://ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">RhinoMocks</a> and <a href="http://structuremap.sourceforge.net/Default.htm" rel="nofollow noreferrer">StructureMap</a> .</p>
29,080
<p>I want to create two piece labels for storage containers. The main piece would be the “badge” which would have text cut out of it (e.g. “Paint”, “Electrical” etc.). The second piece would be a positive of the text which is would be in a different colour, and would fit inside the cut out on the badge. Because of the ...
<p>In OpenSCAD, apply the <code>offset</code> transformation to inset the letter outlines before extruding them. However you may find it works better to fill the sunken letter shapes with nail polish then remove the overflow with acetone; see my question &amp; answer <a href="https://3dprinting.stackexchange.com/a/1087...
<p>You will need to run test prints to see how your printer behaves with your choice of filaments. Then you'll know how much narrower the letter-lines (not the letter dimensions) need to be to fit. </p> <p>The problem with that is one of making letters with narrow solid parts but without "shrinking" the open parts ...
1,555
<p>I recently changed filament and for starters it worked perfectly well, but quickly I got some problems with my first layer. It's like droplets are forming on the surface (finished item + 3 undersides):</p> <p><a href="https://i.stack.imgur.com/qgPyl.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qgPyl.jp...
<p>Mine is more of an educated guess than a definitive diagnosis, but <strong>it looks to me like if your printer may be overextruding</strong> (it's difficult to say with certainty with this particular picture, but your top layers too do not look as good as they should).</p> <p><strong>I wonder if you have <a href="h...
<p>Mine is more of an educated guess than a definitive diagnosis, but <strong>it looks to me like if your printer may be overextruding</strong> (it's difficult to say with certainty with this particular picture, but your top layers too do not look as good as they should).</p> <p><strong>I wonder if you have <a href="h...
804
<p>How does one do namespaced controllers in Merb, for instance to create an admin section to the site? In Rails one would use Admin::CategoriesController, is this similar in Merb or is this another recommended way of doing it?</p>
<p>The namespace method seems to do it.</p> <p>This is placed in the routes file (router.rb):</p> <pre><code>namespace :admin do resources :categories end </code></pre> <p>This generates routes like:</p> <pre> edit_admin_category - /admin/categories/:id/edit(.:format) delete_admin_category - /admin/categories/:id...
<p>The above answer is correct, but for what it's worth, I had a hard time trying to make use of the new route with link_to in my views.</p> <p>I ended up getting this to work:</p> <pre><code>&lt;%= link_to("Categories Admin", resource(:admin, :categories) %&gt; </code></pre>
35,788
<p>Is there a way, in Axapta/Dynamics Ax, to create an Extended Data Type of type integer which only allows enering values in a specified range (i.e., if the extended data type is meant for storing years, I should be able to set a range like 1900-2100), or do I have to manage the range using X++ code?</p> <p>And if I ...
<p>I suggest you use the ''validateField'' of the corresponding table. Search for the method in AOT\Data Dictionay\Tables to see many examples.</p>
<p>You can can't specify the range on the extended data type itself. If the type is used for a table field, you can add code to the insert and update methods of the table, in order to validate the value whenever the record is updated. This approach could however have a cost in terms of performance.</p> <p>You can also...
47,659
<p>What is the best way of ensuring that a user supplied password is a strong password in a registration or change password form?</p> <p>One idea I had (in python)</p> <pre><code>def validate_password(passwd): conditions_met = 0 conditions_total = 3 if len(passwd) &gt;= 6: if passwd.lower() != pa...
<p>Depending on the language, I usually use regular expressions to check if it has:</p> <ul> <li>At least one uppercase and one lowercase letter</li> <li>At least one number</li> <li>At least one special character</li> <li>A length of at least six characters</li> </ul> <p>You can require all of the above, or use a st...
<p>Password strength checkers, and if you have time+resources (its justified only if you are checking for more than a few passwords) use Rainbow Tables.</p>
10,066
<p>I have a class which extends SWFLoader, I use it like a normal SWFLoader:</p> <pre><code>var loader:MySWFLoader = new MySWFLoader(); loader.load("myFile.SWF"); myScene.addChild(loader); </code></pre> <p>The loading works OK, except that it remains 0 because the width &amp; height never change from 0. I had to over...
<p>I'm not sure if this applies for SWF loading, but whenever I'm loading content, i cannot access width and height before the whole thing is loaded.</p> <p>So make an event listener that listens when the loading is completed, and then read the height/width.</p> <p>Also take a look at the loaderInfo class in AS3</p>
<p>By default the SWFLoader scales the content to the size of the loader, so you have to set the size of the loader. If you want the loader to scale to the size of the content then you have to set the scaleContent property to false.</p>
25,511
<p>I have a really long 3 column table. I would like to </p> <pre><code>&lt;table&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Start&lt;/td&gt;&lt;td&gt;Hiding&lt;/td&gt;&l...
<p>Something like this could work:</p> <pre><code>&lt;table&gt; &lt;tbody&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr class="Show_Rows"&gt;&lt;td&gt;Start&lt;/td&gt;&lt;td&gt...
<p>I'd probably do it like this:</p> <pre><code>&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Col1&lt;/th&gt; &lt;th&gt;Col2&lt;/th&gt; &lt;th&gt;Col3&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;data1&lt...
26,450
<p>I am hosting <a href="http://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference" rel="nofollow noreferrer">SpiderMonkey</a> in a current project and would like to have template functions generate some of the simple property get/set methods, eg:</p> <pre><code>template &lt;typename TClassImpl, int32 TClassImpl::*...
<p>Pretty sure VC++ has "issues" here. Comeau and g++ 4.2 are both happy with the following program:</p> <pre><code>struct X { int i; void* p; }; template&lt;int X::*P&gt; void foo(X* t) { t-&gt;*P = 0; } template&lt;void* X::*P&gt; void foo(X* t) { t-&gt;*P = 0; } int main() { X x; foo&lt;...
<p>Try changing the JSObject * to another pointer type to see if that reproduces the error. Is JSObject defined at the point of use? Also, maybe JSObject* needs to be in parens.</p>
13,766
<p>I have a large query in a PostgreSQL database. The Query is something like this:</p> <pre><code>SELECT * FROM table1, table2, ... WHERE table1.id = table2.id... </code></pre> <p>When I run this query as a sql query, the it returns the wanted row.</p> <p>But when I tries to use the same query to create a view, it ...
<p>That happens because a view would have two id named columns, one from table1 and one from table2, because of the select *.</p> <p>You need to specify which id you want in the view.</p> <pre><code>SELECT table1.id, column2, column3, ... FROM table1, table2 WHERE table1.id = table2.id </code></pre> <p>The query wo...
<p>No built-in way in the language to solve it (and frankly, * is a bad practice in general because it can cause latent defects to arise as the table schemas change - you can do table1.*, table2.acolumn, tabl2.bcolumn if you want all of one table and selectively from another), but if PostgreSQL supports INFORMATION_SCH...
25,498
<p>The question sort of says it all.</p> <p>Whether it's for code testing purposes, or you're modeling a real-world process, or you're trying to impress a loved one, what are some algorithms that folks use to generate interesting time series data? Are there any good resources out there with a consolidated list? No con...
<p>I believe the following will work:</p> <pre><code>Dim b As CommandButton Set b = ocx.GetButton("btnPrint") b = True </code></pre> <p><code>CommandButton</code>s actually have two functions. One is the usual click button and the other is a toggle button that acts similar to a <code>CheckBox</code>. The default prop...
<p>Do you have access to the OCX code? You shouldn't really be directly invoking the click of a button. You should refactor the code so that the OCX button click code calls a function, e.g.</p> <pre><code>CMyWindow::OnLButtonDown() { this-&gt;FooBar(); } </code></pre> <p>Then from your VB6 app, directly call the Fo...
6,238
<p>What are the advantages/disadvantages to running time based jobs using:</p> <ol> <li><p>windows services</p></li> <li><p>Application_BeginRequest to start seperate threads / timers.</p></li> </ol> <p>One disadvantage of running the jobs in the context of a asp.net web appplication is during .net recycling things w...
<p>To my mind, there's no real benefit to doing time-based things in a web app. Go straight to a windows service. You know the process should be up and running all the time.</p> <p>The ASP.NET site may simply unload, and will only operate again once someone starts browsing. The lifecycle is all wrong -- it's much 'cho...
<p>If you have administrative access to the server, I would either run a Windows Service or a scheduled SQL job depending on what you are trying to achieve. </p> <p>It is nice to be able to stop/start and log these jobs independent of your web application. Also, if you have problems or errors in the job, it could adve...
39,317
<p>Environment: Windows 2003 Server (32 bit); IIS6, ASP.NET 2.0 (3.5); 4Gb Ram; 1 Worker Process </p> <p>We have a situation where we have a very large System.XmlDocument is being loaded into memory, and then it heads into a complied XSL transform. What is happening is when a web request comes in the server is sitting...
<p>1) I would guess at the worker process but this should be configurable within IIS to the limit of memory that a worker process can use. Another factor is what level of bits does your software use, e.g. 32 bit has a physical limit of 4 GB since this is the total address space.</p> <p>2) Probably but don't forget th...
<p>I'm sure there are some bright heads here that can answer your specific questions, but have you asked yourself if there is another way to do what you want? I specifically mean that you probably do not want to process a very large XML document, but you probably more specifically want to return something back to the c...
49,282
<p>Do you know any applications to synchronize two databases - during development sometimes it's required to add one or two table rows or new table or column. Usually I write every sql statement in some file and during uploading path I evecute those lines on my production database (earlier backing it up). I work with ...
<p>You asked for a tool or application answer, but what you really need is a a process answer. The underlying theme here is that you should be versioning your database DDL (and DML, when needed) and providing change scripts to be able to update any version of your database to a higher version.</p> <p>This set of link...
<p>Siebel (CRM, Sales, etc. management product) has a built-in tool to align the production database with the development one (dev2prod).</p> <p>Otherwise, you've got to stick with manually executed scripts.</p>
31,933
<p>I am looking for a specific desgin pattern.</p> <p>For example i have an article class, clsArticle. This class contains member variables like Id, title, author, article, and so on. Imagine i want to show all the articles in a list. So somewhere i have to create a method getAllArticles(). Since clsArticle is not res...
<p>Yeap. That's correct. </p> <p>It may be either an AbstractFactory or a DataAccessObject.</p> <p>The first is when you want to let the implementation return different kinds of articles</p> <p>For instance let's say you have a condition where the articles behave different according with the platform.</p> <pre><cod...
<p>Well, create a static class for that purpose:</p> <pre><code>public static class clsArticles { public static clsArticles[] GetAllArticles() { /* actual code */ } } </code></pre>
46,790
<p>For an application (*) I'm developing I need a mixture of dynamically generated and static pages. It would be cool to use a wiki such that once a dynamic page has been accessed for the first time it becomes a static page that can be annotated by a user just like any other static wiki page.</p> <p>In other words, I ...
<p>I've seen this done with <a href="http://www.pmwiki.org/" rel="nofollow noreferrer">pmwiki</a>.</p>
<p>The direct answer to your question is: Almost any OpenSource Wiki should be easily modifiable - pick the one (wiki or language) you are most familiar with. </p> <p>I known that <a href="http://www.jspwiki.org" rel="nofollow noreferrer">jspwiki</a> provides this feature out of the box if I understood your question c...
23,930
<p>I have a field on a table in MS Access, tblMyTable.SomeID, and I want to set the default value as a user preference in tblUserPref.DefaultSomeID. It doesn't appear that I can set the default value to use a query in the table definition of tblMyTable. I have a form where records are entered into tblMyTable. I've t...
<p>I'm not certain I've understood the problem, but I think you're asking to insert a value in the field that is drawn from a different table, based on some runtime information (such as the user name). In that case, you could use the domain lookup function, DLookup(), and you'd pass it the name of the field you want re...
<p>He're a suggested alternative approach. Rather than explicitly INSERTing the default when the user has not specified an explicit value, instead leave that value as missing (I'd probably model this in a dedicated table and model the missing value by, well, not INSERTing a row, but I know many people aren't averse to ...
19,082
<p>Are there any ways to secure stored procedure consistency at the software level, so as to be sure that they're going to do what they're expected to do?</p> <p>I'm reluctant to use sprocs because reading and modifying them is so easy as long as you have administrative access to the computer and a copy of Management ...
<p>Its possible to encrypt stored procedures using the <a href="http://msdn.microsoft.com/en-us/library/aa258259(SQL.80).aspx" rel="nofollow noreferrer">WITH ENCRYPTION</a> hint - there are cons such as the stored proc then being extremely difficult to decrypt.</p> <p>Another option would be to use an ORM tool (or sim...
<p>I use Stored Procedures as 'interfaces' .Apart from the performance benefits (Stored procs almost always outperform ad hoc queries) , it allows loose coupling between my db and the UI code. </p>
49,915
<p>I upgraded to a dual Mk9 extruder, and quickly discovered how critical it is to get the ends of both nozzles exactly level with each other -- that is, equally distant from the build plate at all times. Otherwise the lower one will crash against the plastic just extruded by the higher one.</p> <p>So, what's a good p...
<ol> <li>Make sure that the <strong>bed is level</strong>. As the saying goes, a level bed is next to godliness or something like that. Pay extra attention to the direction the nozzles are offset by (if one nozzle is offset on the X-axis, pay extra attention to the bed leveling along the X-axis). <a href="http://wiki.s...
<p>Another option, that I found was the simplest one that worked for me: </p> <ol> <li>Level your bed using just the first nozzle (temporarily lock the 2nd nozzle higher than the 1st one).</li> <li>Move the printhead at the center of the bed</li> <li>Loosen the grub screws on both nozzles (IMPORTANT, don't skip this s...
155
<p>I have a self-signed root certificate with just the code signing extension (no other extensions) in my Mac keychain; I use it to sign all code coming out of ∞labs using Apple's codesign tool and it works great.</p> <p>I was looking to expand myself a little and doing some Java development. I know Apple provides a K...
<p>I think that your keystore entry alias must be wrong. Are you using the alias name of a keystore object with an entry type of "keyEntry"? The same command works perfectly for me.</p> <p>From the jarsigner man page:</p> <blockquote> <p>When using jarsigner to sign a JAR file, you must specify the alias for the k...
<p>Have you tried to export the key from the apple keychain and import it via keytool? Perhaps Apple hasn't properly integrated keytool with their keychain (not like they have a stellar track record with supporting Java).</p> <p>Edit:</p> <p>Hmm... I just tried taking a key that worked from the java store that I imp...
15,069
<p>A curious thing happens in Java when you use an abstract class to implement an interface: some of the interface's methods can be completely missing (i.e. neither an abstract declaration or an actual implementation is present), but the compiler does not complain.</p> <p>For example, given the interface:</p> <pre><c...
<p>That's because if a class is abstract, then by definition you are required to create subclasses of it to instantiate. The subclasses will be required (by the compiler) to implement any interface methods that the abstract class left out.</p> <p>Following your example code, try making a subclass of <code>AbstractThi...
<p>Abstract classes are not required to implement the methods. So even though it implements an interface, the abstract methods of the interface can remain abstract. If you try to implement an interface in a concrete class (i.e. not abstract) and you do not implement the abstract methods the compiler will tell you: Eith...
24,089
<p>I've come across a few different applications that monitor my usage while on the computer, but what have you used, and like? whether it be writing down your activities in a composition notbook or install an app that reports silently to a server? what do you like?</p>
<p>For explicit time tracking for projects I use <a href="http://slimtimer.com" rel="nofollow noreferrer">SlimTimer</a>. I also run <a href="http://www.rescuetime.com/" rel="nofollow noreferrer">RescueTime</a> to track my time implicitly, but I end up not looking at that data very often.</p>
<p>I prefer writing the times down using pen and paper. That way you can more fairly weigh things that would have been miscalculated if you were recording them with a stopwatch or timer.</p> <p>If you start on something and have to get up for a few minutes, a timer may count that toward your working time had you negl...
9,893
<p>My Django app has a Person table, which contains the following text in a field named <code>details</code>:</p> <p><code>&lt;script&gt;alert('Hello');&lt;/script&gt;</code></p> <p>When I call <code>PersonForm.details</code> in my template, the page renders the script accordingly (a.k.a., an alert with the word "Hel...
<p>You need to mark the values as | safe I think (I'm guessing that you're filling in the value from the database here(?)):</p> <pre><code>{{ value|safe }} </code></pre> <p>Could you post a sample of the template? Might make it easier to see what's wrong</p> <p><strong>[Edit]</strong> ..or are you saying that you <e...
<p>Found the problem. The JSON string I'm using to render data to some Ext widgets is the culprit. Big thanks to Jon Cage. Answer accepted despite the problem being caused by another source.</p>
18,608
<p>I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus?</p>
<p>Hmmm, isn't simply overriding Form.ShowWithoutActivation enough?</p> <pre><code>protected override bool ShowWithoutActivation { get { return true; } } </code></pre> <p>And if you don't want the user to click this notification window either, you can override CreateParams:</p> <pre><code>protected override Create...
<p>When you create a new form using </p> <pre><code>Form f = new Form(); f.ShowDialog(); </code></pre> <p>it steals focus because your code can't continue executing on the main form until this form is closed.</p> <p>The exception is by using threading to create a new form then Form.Show(). Make sure the thread is g...
18,881
<p>I just wonder what options there are to properly measure/profile/optimize ASP.net 2.0 Web Parts, especially the ones for Sharepoint 2007?</p> <p>As Web Parts are a layer on another layer of technology, getting resource usage, open handles and stuff only for the web part seems to be a bit difficult.</p> <p>Does any...
<p>Back when we started with SP2003, we used to worry about not closing connection in apps or web parts. We used the following query to check if the base number of connections (not counting the initial spike) would increase as the app is used on the development server:</p> <p>SELECT hostname, sysdatabases.name , sysp...
<p>I have found seperating out all the business logic in to a seperate DLL that is easily unit testable has been the easiest method for me. But to be honest there is really no good way that I have found, besides what I have just mentioned. The same has been true for me with Facebook applications recently. I think th...
4,020
<p>Hi I am trying to find a way to read the cookie that i generated in .net web application to read that on the php page because i want the users to login once but they should be able to view .net and php pages ,until the cookie expires user should not need to login in again , but both .net and php web applications are...
<p>You mention that :</p> <blockquote> <p>but both .net and php web applications are on different servers</p> </blockquote> <p>Are both applications running under the same domain name? (ie: www.mydomain.com) or are they on different domains?</p> <p>If they're on the same domain, then you can do what you're trying ...
<p>any cookie given to a browser will be readable by server processing the request --- they're language agnostic.</p> <p>try $_COOKIE in PHP </p>
11,342
<p>A question that occasionally arises is what is the best way to determine the changelist that you last synced to in Perforce. This is often needed for things like injecting the changelist number into the revision info by the automatic build system.</p>
<p>I recommend the opposite for automatic build systems: you should first get the latest changelist from the server using:</p> <pre><code>p4 changes -s submitted -m1 </code></pre> <p>then sync to that change and record it in the revision info. The reason is as follows. Although <a href="https://portal.perforce.com/s/...
<p>I am not sure if you got the answer you needed but I had a similar problem. The goal was to write in our logger the specific version of the project. The problem was that while we are making our own makefile, the overall build system is controlled by our configuration management. This means that all the solutions whi...
6,920
<p>Problem:<br/></p> <ol> <li>html file on local server (inside our organization) with link to an exe on the same server.</li> <li>clicking the link runs the exe on the client. Instead I want it to offer downloading it.</li> </ol> <p>Tried so far:<br/></p> <ol> <li>Changed permissions on the exe's virtual directory ...
<p>You need to set <code>content-disposition</code> in the HTTP header.</p> <p><a href="http://support.microsoft.com/kb/260519" rel="nofollow noreferrer">This Microsoft Knowledge Base entry</a> has more detail on how to do this.</p>
<p>Whether a file is downloaded or opened automatically is a browser, not a server, side setting.</p> <p>The other way of doing it would be to change the MIME type for the file to something like application/octet-stream or similar to try and force your browser to download it.</p>
10,791
<p>Sorry if this is a little off-topic for regular stackoverflow questions, but we're tearing our hair out on this one. We've got a batch of about 3500 3-page PDFs to print (all ok so far) the problem we've got is that it's vital they print in a specific order (ascending by filename). Our spooler seems to randomize th...
<p>Thanks all, I some advice over a techrepublic with regards to a printer setting called 'Print spooled documents first' unticking the box seems to have honoured the order the files were sent.</p>
<p>You should be able to use a PDF library and some simple-ish scripting to turn them into one unholy document. One PDF to rule them all, one PDF to find them, one PDF to bring them all, and in the darkness bind them... so to speak.</p> <p>Edit: As an easier option, you can get software that will do your evil bidding ...
48,030
<p>I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:</p> <pre><code>var blah = xmlres.getElementsB...
<p>You do, indeed, need to implement a closure here. This <em>should</em> work (let me know - I didn't test it)</p> <pre><code>var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) { var td = document.createElement('td'); var select = document.createElement('select'); sel...
<p>Just change the &quot;var&quot; in the for loop to &quot;let&quot; and it works like a charm.</p> <p>reference: <a href="https://softauthor.com/javascript-for-loop-click-event-issues-solutions/" rel="nofollow noreferrer">JavaScript For Loop Click Event Solution #4</a></p>
44,418
<p>For obvious productivity reasons, I make an effort of learning and using as many of the keyboard shortcuts for the various Re# commands. </p> <p>However, it seems that the unit test runner does not have any associated shortcut keys. I want to be able to select certain tests and be able to run or debug them without ...
<p>ReSharper adds items to Visual Studio's keyboard settings dialog box.</p> <p>Go to: </p> <blockquote> <p>Tools -> Options, Environment -> Keyboard</p> </blockquote> <p>In the search bar, type "resharper" and see the vast options that you can control with the keyboard.</p> <p>Specifically, there is one to lau...
<p>It writes shortcuts in itself or website. Run Unit Tests: <kbd>Ctrl</kbd>+<kbd>T</kbd>, <kbd>R</kbd><br> Debug Unit Tests: <kbd>Ctrl</kbd>+<kbd>T</kbd>, <kbd>D</kbd><br> Run All Tests From Solution: <kbd>Ctrl</kbd>+<kbd>T</kbd>, <kbd>Ctrl</kbd>+<kbd>L</kbd><br> Run Current Session: <kbd>Ctrl</kbd>+<kbd>T</kbd>, <kbd...
21,115
<p>Can we achieve 100% decoupling between components of a system or different systems that communicate with each other? I don't think its possible. If two systems communicate with each other then there should be some degree of coupling between them. Am I right?</p>
<p>If components are 100% decoupled, it means that they don't communicate with each other.</p> <p>Actually there are <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_science%29" rel="nofollow noreferrer">different types of coupling</a>. But the general idea is that objects are not coupled if they don't depen...
<p>You can achieve that. Think of two components that communicate with each other through network. One component can run on Windows while other on Unix. Isn't that 100% decoupling?</p>
9,586
<p>What's the best way to implement user controls that require AJAX callbacks? </p> <p>I want to accomplish a few things:</p> <ul> <li>Have events done in the browser (eg, drag and drop) trigger an AJAX notification that can raise a control event, which causes code on the page using the control to do whatever it need...
<p>Look into implementing ICallbackEventHandler in your Page -- it's a simple way to make a call back to a page function from JavaScript.</p> <p>Here's a good tutorial:</p> <p><a href="http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=119" rel="nofollow noreferrer">http://www.ajaxprojects.com/ajax/tutoriald...
<p>You might want to check out; <a href="http://ra-ajax.org/samples/Combining.aspx" rel="nofollow noreferrer">Ra-Ajax UserControl Sample</a> and combine that knowledge with <a href="http://ra-ajax.org/samples/Behaviors.aspx" rel="nofollow noreferrer">Ra-Ajax Drag and Drop</a></p> <p>Click the "Show code" C# icon to th...
25,941
<p>Environment: Rails 2.2.2, Oracle 10g</p> <p>Most of the columns declared "date" in my ActiveRecord models are exactly that: dates: they don't care about time at all.</p> <p>So with a model declared thus:#</p> <pre><code>class MyDateOnlyModel &lt; ActiveRecord::Migration def self.up create_table :my_date_onl...
<p>The answer is now to create a <code>@ClassRule</code> within your suite. The rule will be invoked before or after (depending on how you implement it) each test class is run. There are a few different base classes you can extend/implement. What is nice about class rules is that if you do not implement them as anonymo...
<p>As an aside, it's a bad idea to have unit tests actually calling external resources like webservices, databases, etc.</p> <p>Unit tests should be super-quick to run and a delay of 'a couple of minutes' for each run of the suite will mean it won't be run as much as it should.</p> <p>My advice:</p> <p>Look at mocki...
45,520
<p>We are looking for a free solution to compress our SQL Server backups for SQL Server 2005. I am aware of SQL Safe freeware edition, but I was wondering what others thought of storing backup files in compressed folders to achieve the desired result. This would allow us to use the native SQL backup tasks and native ...
<p>Quick hint from google: <a href="http://clay.lenharts.net/blog/2008/01/28/backing-up-to-a-ntfs-compressed-folder/" rel="nofollow noreferrer">backing-up-to-a-ntfs-compressed-folder</a>. Seems that database size may create problems.</p> <p>What about freeware solutions then you can run 7zip in scheduled batch after b...
<p>I use <a href="http://www.2brightsparks.com/downloads.html#freeware" rel="nofollow noreferrer">Syncback Freeware</a> to automatically copy and compress the files to another folder. You save tons of space this way. I have been doing this for several years and it has worked perfectly.</p>
38,970
<p>I would like to be able to spawn a linux process that would only have access to stdin, stdout, and stderr (nothing more and nothing less). Can I do this at the process level itself? I am also implicitly stating (oxymoron) that I don't want the spawned process to be able to change the "thing" that the other end of th...
<p>As stated in another answer SELinux does have various permissions that help lock down any process.</p> <p>The kernel manages access to certain objects (with associated set of permissions) for example a file is an object, a directory is an object, a unix datagram socket is an object and many more.</p> <p>probably t...
<p>If you're root, you can chroot to a directory, drop privileges so that you no longer have filesystem write access, then exec. That will prevent a program from creating new files. But there's no way to prevent a program from creating pipes and sockets (well, no-sockets is possible with SELinux), and there's no way ...
22,381
<p>I needed to re-install my computer but I didn't think about exporting the data from mysql 5. </p> <p>How do I get the data from the old installation into the new installation, is this just copying the data directory or do I have to take other steps to get to the data?</p>
<p>For MyISAM tables you can generally get away with copying them across. (Whilst the server's stopped, obviously.) For InnoDB, it can work, but you'll have to have the same basic block size settings. If you can use the same major version of MySQL and the same my.cnf you stand a good chance of having it work.</p> <p>A...
<p>I would export your data as a sql file from mysql (ie: with phpmyadmin) and then import it into the new installation. Your db should be built and filled with data pretty easily.</p> <p>You said that you "didn't think about exporting the data". Does that mean you don't have access to the old installation any more?<...
31,238
<p>I have now 1gb ram at work(i hope that will change soon) and jboss takes almost half of it and that is too much, i turned off logging to file, what more can i do to reduce memory usage ?</p>
<p>You can limit the maximum memory used using the -Xmx parameter, as in any java process. Edit the $JBOSS_HOME/bin/run.conf and set this parameter to the desired maximum memory you want to allocate to JBoss.</p> <p>Also, you can remove from the deploy directory of the server configuration you are using, the services ...
<p>You could try using the latest version of JBoss (version 6). I think it uses less memory, though I could be wrong.</p>
31,558
<p>I have several databases, one of which contains utility functions called from the other databases. Is there a way in the utility functions to determine which database a function is being called from?</p>
<p>Did you try: SELECT db_name() ?</p>
<p>You'd run a trace in SQL Profiler, but that might not give you complete list. So, you also should query the information_schema.routines &amp; information_schema.tables views in each database to see which tables and view use that function and could call it and compare the list to the trace. </p>
40,862
<p>I'm the leader of a small web development team, and I have a feeling that we will have a couple telecommuters joining the team pretty soon (either new employees, or existing employees that will begin telecommuting). Any idea how to effectively manage and collaborate with developers working remotely?</p> <p>Most of...
<p>I freelance a lot and in doing so work remotely a lot of the time. These are the things that make my life as easy as possible (so might be things you want to "suggest"). I think they're mostly common-sense, but you never know...</p> <ol> <li><p>[Everyone] Communicate well. When you're having a conversation face-to-...
<p>I've generally used some time of community based software such as a wiki, blog, or forum to handle the documentation areas. We also have a Cisco phone system and use some capabilities of the system. I'd also recommend live meeting or webex to do frequent team meetings. Skype and IM clients such as Live Messenger are...
15,051
<p>I am working in a company that develops computing kernels. Their design is simple : it's a library in c++ which only has one function available to compute results out of available data. </p> <p>There are essentially four steps in every one of these kernels :</p> <ul> <li><p>retrieve xml content (format has been de...
<p>You would get huge benefits by switching to C#/LINQ in terms of working with the XML and even with a lot of the math. There would be a slight learning curve (so that's a con), but in just a couple of weeks, I'm sure you'll be laughing at how much easier coding C#3/LINQ is.</p> <p>I say this from experience... and I...
<p>I say that any C++ application developer should take a good look at C#. In my opinion, many of the problems that you solve in C++ can be solved much quicker in C#. It is not a hard language to learn coming from C++ at all. I would say, before you decide, check out C# for a week or so and see how much <em>you</em> li...
32,020
<p>I have a very simple problem which requires a very quick and simple solution in SQL Server 2005.</p> <p>I have a table with x Columns. I want to be able to select one row from the table and then transform the columns into rows.</p> <pre><code>TableA Column1, Column2, Column3 </code></pre> <p>SQL Statement to rutu...
<p>You should take a look at the UNPIVOT clause.</p> <p><strong>Update1</strong>: GateKiller, strangely enough I read an article (about something unrelated) about it this morning and I'm trying to jog my memory where I saw it again, had some decent looking examples too. It'll come back to me I'm sure.</p> <p><strong>...
<p><a href="http://msdn.microsoft.com/en-us/library/ms180026.aspx" rel="nofollow noreferrer">UNION</a> should be your friend:</p> <pre><code>SELECT Column1 FROM table WHERE idColumn = 1 UNION ALL SELECT Column2 FROM table WHERE idColumn = 1 UNION ALL SELECT Column3 FROM table WHERE idColumn = 1 </code></pre> <p>but i...
2,559
<p>What is the simplest, fastest way to complete the PHP code below such that the output is in a user-friendly format (for example, "October 27, 2006")?</p> <pre><code>$result = mysql_query("SELECT my_timestamp FROM some_table WHERE id=42", $DB_CONN); $row = mysql_fetch_array($result); $formatted_date = ???($row['my_t...
<p>You could use MySQL to do this for you,</p> <pre><code>$result = mysql_query("SELECT DATE_FORMAT(my_timestamp, '%M %d, %Y) AS my_timestamp FROM some_table WHERE id=42", $DB_CONN); $row = mysql_fetch_array($result); $formatted_date = $row['my_timestamp']; echo $formatted_date; </code></pre> <p>Or use PHP,</p> <pre...
<p>I use: </p> <p>date("F j, Y", strtotime($row['my_timestamp']))</p> <p>or you can change the SELECT to: DATE_FORMAT(field,'%d %M, %Y') as datetime</p>
29,450
<p>Please let me know how can I remove default banner of web server from response - Apache http1.1 coyote</p>
<p>If you're talking about the generated line at the bottom of apache generated pages, you have to update your httpd.conf with this command:</p> <pre><code>ServerSignature Off </code></pre> <p>See <a href="http://httpd.apache.org/docs/2.2/mod/core.html#serversignature" rel="nofollow noreferrer">http://httpd.apache.or...
<p>In server.xml there will be a <code>&lt;Connector&gt;</code> element. Add a <code>server</code> attribute to it. For example:</p> <pre><code>&lt;Connector executor="tomcatThreadPool" port="80" protocol="HTTP/1.1" server=" " ... /&gt; </code></pre> <p>Unfortunately, setting the <code>server</code> att...
41,836
<p>I have a lot of spare intel linux servers laying around (hundreds) and want to use them for a distributed file system in a web hosting and file sharing environment. This isn't for a HPC application, so high performance isn't critical. The main requirement is high availability, if one server goes offline, the data ...
<p>check also <a href="http://www.gluster.org/" rel="noreferrer">GlusterFS</a></p> <p><strong>Edit (Aug-2012):</strong> <a href="http://ceph.com/" rel="noreferrer">Ceph</a> is finally getting ready. Recently the authors formed <a href="http://www.inktank.com/" rel="noreferrer">Inktank</a>, an independent company to s...
<p><a href="http://ceph.newdream.net/" rel="nofollow noreferrer">Ceph</a> looks to be a promising new-ish entry into the arena. The site claims it's not ready for production use yet though. </p>
33,804
<p>Is there a way to implement a singleton object in C++ that is:</p> <ol> <li>Lazily constructed in a thread safe manner (two threads might simultaneously be the first user of the singleton - it should still only be constructed once).</li> <li>Doesn't rely on static variables being constructed beforehand (so the sing...
<p>Basically, you're asking for synchronized creation of a singleton, without using any synchronization (previously-constructed variables). In general, no, this is not possible. You need something available for synchronization.</p> <p>As for your other question, yes, static variables which can be statically initiali...
<p>I suppose saying don't do this because it's not safe and will probably break more often than just initializing this stuff in <code>main()</code> isn't going to be that popular.</p> <p>(And yes, I know that suggesting that means you shouldn't attempt to do interesting stuff in constructors of global objects. That's ...
2,860
<p>I thought that there was some way in .net 3.0 to give an array list a type so that it didnt just return Object's but I'm having trouble doing so. Is it possible? If so, how?</p>
<p><code>List&lt;T&gt;</code> was introduced with generics in .NET 2.0:</p> <pre><code>using System.Collections.Generic; var list = new List&lt;int&gt;(); list.Add(1); list.Add("string"); //compile-time error! int i = list[0]; </code></pre>
<p>If you have to use ArrayList and can't start using List, and you know the type of every element in that ArrayList you can do:</p> <pre><code> string[] stringArray = myArrayList.ToArray(typeof(string)) as string[]; </code></pre> <p>If something in myArrayList wasn't a string, in this case, you would get an Invalid...
17,434
<p>I have an external stylesheet that has specific IE-hacks. Every so often my site will fail to build due to these hacks (it is the hash-hack; for example <strong><code>#margin-top:-2px;</code></strong>). This is the error:</p> <blockquote> <p>Unexpected character sequence. Expected a property name for the " : ...
<p>I'm not sure about 2008, but in 2005 (IIRC), you can go to:</p> <pre><code> Tools | Options | Text Editor | CSS | CSS Specific </code></pre> <p>and then untick <strong>Detect Errors</strong></p> <p>I remember having exactly the same problem on 100% valid CSS which MS didn't recognise (big shock), flicked this sw...
<p>The easiest thing is to close the file in the editor and it should stop complaining. </p>
42,893
<p>I am attempting to write a basic slicer for some objects I am working with. I need to write a custom slicer as the objects are not polygonal based (they are implicit objects) and therefore cannot be plugged into slic3r. I can easily obtain the perimeter/shell of the objects I am working with and have a few successfu...
<p>The answer to this is pretty much basic algebra: The software tackles the problem by using a set of functions that generate the infill pattern for ALL the build volume, then discard anything outside the shells. Which is determined by algebra:</p> <h1>Basics</h1> <h3>Outline Function</h3> <p>Assume the outline of the...
<p>simple answer is math but you know that for sure</p> <p>more descriptive answer (but still simple and with no math) is more or less as follows</p> <ul> <li>slice an object with a plane to form (calculate) outline perimeter</li> <li>create a grid of infill according to your needs (ie: lines, grids or honeycombs)</l...
1,029
<p>What's the easiest way to truncate a C++ <code>float</code> variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable?</p>
<p>First it is important to know that floating point numbers are approximated. See the link provided by @Greg Hewgill to understand why this problem is not fully solvable. </p> <p>But here are a couple of solutions to the problem that will probably meet your need:</p> <p>Probably the better method but less efficien...
<p>Here is a function using the advice in other answers and an example of its use:</p> <pre><code>#include &lt;iostream&gt; #include &lt;cmath&gt; static void Truncate(double&amp; d, unsigned int numberOfDecimalsToKeep); int main(int, char*[]) { double a = 1.23456789; unsigned int numDigits = 3; std::cout &l...
39,062
<p>What is the best way to call C/C++ from other languages such as Java, Python, Perl, PHP, etc?</p>
<h2>From Perl</h2> <p><a href="http://search.cpan.org/perldoc?Inline::C" rel="nofollow noreferrer">Inline::C</a><br> <a href="http://search.cpan.org/perldoc?Inline::CPP" rel="nofollow noreferrer">Inline::CPP</a><br> <a href="http://search.cpan.org/perldoc?Inline::Java" rel="nofollow noreferrer">Inline::Java</a><br> <a ...
<p>Use Swig, it allows you to generate code for multiple languages that calls any C/C++ functions. <a href="http://www.swig.org/" rel="nofollow noreferrer">http://www.swig.org/</a></p>
34,642
<p>In python how do you read multiple files from a mysql database using the cursor or loop one by one and store the output in a separate table?</p>
<p>I don't understand your question (what are files?, what's your table structure?), but here goes a simple sample:</p> <pre><code>&gt;&gt;&gt; import MySQLdb &gt;&gt;&gt; conn = MySQLdb.connect(host="localhost", user="root", password="merlin", ...
<p>Here is an example, assuming you have created the table you want to move to, with descriptive names:</p> <pre><code>&gt;&gt;&gt; import MySQLdb &gt;&gt;&gt; conn = MySQLdb.connect(user='username', db='dbname') &gt;&gt;&gt; cur = conn.cursor() &gt;&gt;&gt; cur.execute('select files from old_table where conditions=me...
27,783
<p>Part of the series of controls I am working on obviously involves me lumping some of them together in to composites. I am rapidly starting to learn that this takes consideration (this is all new to me!) :)</p> <p>I basically have a <code>StyledWindow</code> control, which is essentially a glorified <code>Panel</code...
<p>I don't see you adding your controls to the Controls collection anywhere, which would explain why they can't access the Page (since they've never been officially placed on the page).</p>
<p>Right, I got playing and I figured that there was something wrong with my control instantiation, since Longhorn was right, I should be able to create script references at <code>OnLoad</code> (and I couldn't), and Brad was right in that I need to ensure my <code>Controls</code> hierarchy was maintained by adding to t...
15,555
<p>How to set internationalization to a <code>DateTimepicker</code> or <code>Calendar WinForm</code> control in .Net when the desire culture is different to the one installed in the PC?</p>
<p>It doesn't seem to be possible to change the culture. See this <a href="http://support.microsoft.com/Default.aspx?scid=kb%3ben-us%3b889834&amp;x=18&amp;y=19" rel="noreferrer">KB article</a>. </p>
<p>I think there is detour.</p> <ol> <li>set event handler "ValueChanged"</li> <li><p>code</p> <pre><code>dateTimePicker.Format = DateTimePickerFormat.Custom; string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture); dateTimePicker.CustomFormat = formats[0]; </code></pre></li> </ol>
29,953
<p>I'm a Linux guy and I'm used to copying directory trees with <code>cp -a</code>. OS X doesn't have <code>-a</code> option on <code>cp</code>... but it does have the <code>ditto</code> command. I'm reading the man on <code>ditto</code> now, but is there anything I should specifically be looking out for?</p>
<p>According to the <strong>cp</strong> man page <strong>cp -a</strong> is the same as <strong>cp -dpR</strong> which is</p> <pre><code>-p = preserve mode,ownership,timestamps -R = recursive -d = no dereference and preserve links </code></pre> <p>The OS X equivalent would be</p> <p><strong>cp -pPR</strong></p> <pre...
<p>As j04t pointed out that should be <code>cp -pR</code></p> <p><strike>On OS X, you would do</p> <pre><code>cp -dRL src target </code></pre> <p></strike> cp preserves resources in newer version of OS X (was it 10.3 when that happened?)</p> <p>Hey d is kinda like an upsidedown p, right ;)</p>
19,372
<p>Let's say you have a text file like this one: <a href="http://www.gutenberg.org/files/17921/17921-8.txt" rel="noreferrer">http://www.gutenberg.org/files/17921/17921-8.txt</a></p> <p>Does anyone has a good algorithm, or open-source code, to extract words from a text file? How to get all the words, while avoiding spe...
<p>This sounds like the right job for regular expressions. Here is some Java code to give you an idea, in case you don't know how to start:</p> <pre><code>String input = "Input text, with words, punctuation, etc. Well, it's rather short."; Pattern p = Pattern.compile("[\\w']+"); Matcher m = p.matcher(input); while ( ...
<p>You could try regex, using a pattern you've made, and run a count the number of times that pattern has been found.</p>
34,873
<p>I'm embedding an IE control into my C++ application. The problem is that although system-wide, ClearType is disabled, IE7 has its own separate setting, and unless I specifically disable that too, text inside the IE control will be antialiased while the rest of the app will not.</p> <p>The same goes for IE7's font s...
<p>It would be quite trivial to do this yourself.</p> <ol> <li><p>Create a webform where the user can type in their email address. You could protect it with a captcha to prevent bots from hitting it.</p></li> <li><p>On submission, save the email address to a database along with a GUID, DateTime timestamp and IsActivat...
<p>There are several levels of email validation and I've got source to do them all. However, I despise your line of business and would never share them with you...</p> <p>Just to clarify - I don't despise you, Jeff... Just your line of business.</p>
36,202
<p>I am trying to create an XML schema representing an 'order' for a shopping cart</p> <p>I want this to completely abstract away my shopping cart's implementation -- and eventually support partners sending us orders using this schema. (yes i'm planning on integrating this schema into our existing cart)</p> <p>It wil...
<p>UBL (Universal Business Language) defines schemas for business documents (purchase orders, invoices, etc.). It is an OASIS standard, see:</p> <p><a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ubl" rel="nofollow noreferrer">http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ubl</a></p>
<p>If you are looking for ideas about how to structure the shopping cart:<br /> <a href="https://stackoverflow.com/questions/360959/database-table-structure-for-shopping-cart">Database Table Structure for Shopping Cart</a></p>
48,815
<p>I have a MySQL (v 5, MyISAM) query that returns different rows depending on date string format.</p> <pre><code>(1) IFNULL(date1, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) &gt; '2008-10-31 23:59:59' (2) IFNULL(date1, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) &gt; '2008/10/31 23:59:59' (3) date1 &gt; '2008...
<p>Short answer: Use <code>CAST(... AS DATE)</code></p> <p>Long answer:</p> <p>From <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html" rel="nofollow noreferrer">MySQL DATE type</a>:</p> <blockquote> <p>A “relaxed” syntax is allowed: Any punctuation character may be used as the delimiter between dat...
<p>I don't know much about mysql but is it possible that the "/"-based date is interpreted as "YYYY/DD/MM" and so is just completely invalid? In SQL Server I would expect an exception in that case, but if mysql substitutes some kind of "invalid date"-value that could maybe explain the difference.</p> <p>YYYY-MM-DD is ...
36,457
<p>I'm trying to serialize a Type object in the following way:</p> <pre><code>Type myType = typeof (StringBuilder); var serializer = new XmlSerializer(typeof(Type)); TextWriter writer = new StringWriter(); serializer.Serialize(writer, myType); </code></pre> <p>When I do this, the call to Serialize throws the followin...
<p>I wasn't aware that a Type object could be created with only a string containing the fully-qualified name. To get the fully qualified name, you can use the following:</p> <pre><code>string typeName = typeof (StringBuilder).FullName; </code></pre> <p>You can then persist this string however needed, then reconstruc...
<p>Just looked at its definition, it is not marked as Serializable. If you really need this data to be serialize, then you may have to convert it to a custom class that is marked as such.</p> <pre><code>public abstract class Type : System.Reflection.MemberInfo Member of System Summary: Represents type declaration...
3,336
<p>In all of my other .net apps my build process (a mixture of nant and custom tasks) automatically updates the [AssemblyVersionAttribute] AssemblyInfo.cs with the current build number before the call to msbuild, stamping in the build number in the version number.</p> <p>I'm now working on my first BizTalk project and...
<p>I'm sorry to disappoint you but I've been down the exact some road I had to give up. I guess it could be possible to achieve it but it would require a lot of changes to both the binding files and other XML files (as you mentioned and even more if you have published services etc).</p> <p>Maybe it could be possible t...
<p>Gutted, thought that might be the case. Maybe BizTalk 2009 projects will play more nicely when updating references when changing version numbers.</p> <p>I started to go through and automate it manually, and when I realised what needed to be done, I took a biiig step back when I realised just how many places I'd hav...
33,690
<p>As far as I know resin trays have a Teflon coat that allows prints to stick to the build plate easier than the resin tray but this Teflon coat wears over time. </p> <p>I am new to the SLA scene and am currently troubleshooting a Draken Facture and trying to hone in my setting but my print keep sticking to the bott...
<p>It depends on tray and resin type you are using.</p> <p><strong>PDMS</strong></p> <p>If you are using PDMS (eg. sylgard 184) coating for your tray. (B9 and similar printers using this type of tray). </p> <p>Life of tray PDMS coating depends mainly on:</p> <ul> <li>How long you print without breathing floor.</li>...
<p>I did some research and the life of the resin and resin tray appears to be dependent on how you use it. For example, regarding the resin, 3dfacture states <a href="http://3dfacture.com/faq/" rel="nofollow noreferrer">"We see almost unlimited shelf life of the resin as long as it is kept out of light"</a>.</p> <p>I...
640
<p>I'm just trying to do simple scripting with F#, and Math.PI seems to have 'disappeared'. I've referenced FSharp.PowerPack.dll, but still can't find it.</p>
<p>The constant pi is System.Math.PI, if you want to use, Math.PI just open System, in your fsharp file:</p> <pre><code>open System Math.PI </code></pre>
<p>You know, you could just do this:</p> <pre><code>let PI = 3.141592653589 </code></pre>
45,842
<p>OK, first for context look at the Windows desktop; You can take items (folders, files) on the desktop and drag them around to different places and they "stay" where you dragged them. This seems to be a pretty useful feature to offer users so as to allow them to create their own "groupings" of items.</p> <p>My que...
<p>You can do this with a standard ListView control by implementing drag-and-drop. Here's a sample control that does this:</p> <pre><code>using System; using System.Drawing; using System.Windows.Forms; public class MyListView : ListView { private Point mItemStartPos; private Point mMouseStartPos; public MyLis...
<p>Windows uses <code>ListView32</code>, an internal control with drag n' drop placeholder features, custom borders...</p> <p>The icon location can be stored in a XML file, or in the application settings (by putting the XML as string and converting it to file when needed).</p> <p>You can do, for example:</p> <pre><c...
28,463
<p>I need to retrieve the browser and OS through php coding.</p> <p>I had used <code>$_SERVER['HTTP_USER_AGENT']</code>, but its shows the following </p> <pre><code>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; IEMB3) </code></pre> <p>How can I separate the browser and OS ...
<p>You could use the <a href="http://code.google.com/p/phpbrowscap/" rel="nofollow noreferrer">Google code Browscap class</a>. It essentially does the same thing as PHP's get_browser(), but you don't have to worry about keeping your browscap.ini up to date.</p> <p>This worked for me:</p> <pre><code>require('Browscap....
<p>you can use simple explode();</p> <pre><code>&lt;?php $ex=explode(' ',$_SERVER['HTTP_USER_AGENT']); echo 'OS: '.$ex[4].' '.$ex[5].' '.$ex[6].'/n'; echo 'Browser: '.$ex[0]; ?&gt; </code></pre>
44,603
<p>In C#, is it possible to extend a class that has no constructors?</p> <p>Maybe I'm thinking about this incorrectly and just need a kick in the crotch. I have a Silverlight class that extends System.Windows.Media.Transform, With the official release of Silverlight 2, Transform now has no constructor. So, when I c...
<p>The sole constructor to Transform is internal, so you can't derive from it yourself.</p>
<p>Hiding all public constructors is a technique used to prevent subclassing and force developers to use the class as intended. It may be the implementor wants you to use an Adapter or Facade or even a Proxy at the time of extension.</p> <p>There may be important lifecycle details in the constructor that require the ...
27,039
<p>I'm using Eclipse as an IDE for Ruby/Rails development (using Aptana plugin). I have one very, very large file that encompasses an initial data load of several thousand rows of data. When this file is open, everything grinds to a halt (on both Windows and Linux), presumably because Eclipse is tied up trying to parse...
<p>I'm not exactly sure what you are trying to achieve here, but I think what you want is:</p> <pre><code>// query... $records = array(); while($r = mysql_fetch_array($result)) { $records[] = $r; } return $records; </code></pre>
<p>By default <a href="http://it.php.net/mysql_fetch_array" rel="nofollow noreferrer">mysql_fetch_array</a> returns both normal and associative arrays, so you can access the values by position ($result[0]) or by name ($result['user_name'])':</p> <pre><code>array mysql_fetch_array ( resource $result [, int $result_ty...
45,636
<p>How can I know if a device is supported on a running Linux and if so, which device driver controls it? For instance, <code>lspci</code> on a server (PowerEdge 2900) gives:</p> <pre class="lang-none prettyprint-override"><code>00:00.0 Host bridge: Intel Corporation 5000X Chipset Memory Controller Hub (rev 12) 00:02....
<p>I don't think you can get a 100% clear-cut answer that you can get in Windows device manager.</p> <ul> <li>A device may be controlled by several kernel modules (say <code>nvidia</code> + <code>agpgart</code>).</li> <li>A kernel module may control more than one device (<code>usbhid</code>).</li> <li>You can also hav...
<p>The following script will tell you which dynamically loaded drivers are running, although I would also like an automated way of figuring out which compiled in modules are actually in use also so I could de-bloat my kernel some more.</p> <pre><code>#!/bin/bash /sbin/lsmod | tail -n+2 | cut -d" " -f1 | xargs /sbin/mo...
20,237
<p>What is a good way of parsing command line arguments in Java?</p>
<p>Check these out:</p> <ul> <li><a href="http://commons.apache.org/cli/" rel="noreferrer">http://commons.apache.org/cli/</a></li> <li><a href="http://www.martiansoftware.com/jsap/" rel="noreferrer">http://www.martiansoftware.com/jsap/</a></li> </ul> <p>Or roll your own:</p> <ul> <li><a href="http://docs.oracle.com/jav...
<p>For Spring users, we should mention also <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/SimpleCommandLinePropertySource.html" rel="nofollow noreferrer">https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/env/SimpleCommandLinePropertySource.htm...
47,990
<p>I have to develop a tool for monitoring helpdesk agents. I can figure out how to capture keyboard events and mouse events; however I need to capture the control that emitted/consumed the event too. Is it possible to find that out?</p>
<p>You need windows hooks to pick up the events. These are really the province of native code. Try asking again with Win32 tag replacing the C# tag.</p>
<p>I used the code from <a href="http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx" rel="nofollow noreferrer">Stephen Toub's blog</a> to add a shortcut to my application in the system tray. The comments were quite useful as well.</p>
24,608
<p>Is there a way to find the name of the program that is running in Java? The class of the main method would be good enough.</p>
<p>Try this:</p> <pre><code> StackTraceElement[] stack = Thread.currentThread ().getStackTrace (); StackTraceElement main = stack[stack.length - 1]; String mainClass = main.getClassName (); </code></pre> <p>Of course, this only works if you're running from the main thread. Unfortunately I don't think ther...
<p>Or you could just use getClass(). You can do something like:</p> <pre><code>public class Foo { public static final String PROGNAME = new Foo().getClass().getName(); } </code></pre> <p>And then PROGNAME will be available anywhere inside Foo. If you're not in a static context, it gets easier as you could use t...
6,329