instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Because of the weight of my Z-axis and the relative ease of its motion, when the Z-axis motor is powered down the bed has a tendency to slip and fall down.</p> <p>Obviously leaving the motor powered solves this problem, but that is not ideal.</p> <p>I am looking for some kind of solution that passively stops the Z...
<p>The simple way to do this is to use a self-locking screw pitch. Pretty much any single-start thread using a sliding nut cannot be back-driven so the load will not fall. Normal 8x8 trapezoidal thread screws will easily back-drive because of the steep pitch. </p> <p>Likewise, a worm drive between the motor and Z stag...
<p>If your stepper motors have shafts protruding from both ends then it may be possible to simply 3d print a fixture that allows a thumb screw to be tightened and clamp down on the unused part of the shaft.</p> <p>This would however be a very manual approach and would require you to be mindful that the screw must alwa...
344
<p>I've been having trouble to make a JFormattedTextField to use dates with the format dd/MM/yyyy. Specifically, as the user types, the cursor should "jump" the slashes, and get directly to the next number position.</p> <p>Also, the JFormattedTextField must verify if the date entered is valid, and reject it somehow if...
<p>try using JCalendar</p>
<p>try using JCalendar</p>
10,506
<p>I know that MSTest doesn't support <code>RowTest</code> and similar tests.</p> <p>What do <code>MSTests</code> users do? How is it possible to live without <code>RowTest</code> support? </p> <p>I've seen <code>DataDriven</code> test features but sounds like too much overhead, is there any 3rd party patch or tool w...
<pre><code>[TestMethod] Test1Row1 { Test1(1,4,5); } [TestMethod] Test1Row2 { Test1(1,7,8); } private Test1(int i, int j, int k) { //all code and assertions in here } </code></pre>
<p>Similar to DaTest(not updated since 2008) solution using PostSharp is described in blog <a href="http://blog.drorhelper.com/2011/09/enabling-parameterized-tests-in-mstest.html" rel="nofollow">http://blog.drorhelper.com/2011/09/enabling-parameterized-tests-in-mstest.html</a></p>
45,224
<p>How do you express an integer as a binary number with Python literals?</p> <p>I was easily able to find the answer for hex:</p> <pre><code>&gt;&gt;&gt; 0x12AF 4783 &gt;&gt;&gt; 0x100 256 </code></pre> <p>and octal:</p> <pre><code>&gt;&gt;&gt; 01267 695 &gt;&gt;&gt; 0100 64 </code></pre> <p><strong>How do you us...
<p>For reference&mdash;<em>future</em> Python possibilities:<br> Starting with Python 2.6 you can express binary literals using the prefix <strong>0b</strong> or <strong>0B</strong>:</p> <pre><code>&gt;&gt;&gt; 0b101111 47 </code></pre> <p>You can also use the new <strong>bin</strong> function to get the binary repre...
<p>As far as I can tell Python, up through 2.5, only supports hexadecimal &amp; octal literals. I did find some discussions about adding binary to future versions but nothing definite.</p>
2,385
<p>I'm developing an application for an internal customer. One of the requirements is that it be developed in such a way that it could potentially be sold to other organizations. The application is a tracking application for a fund-raising organization that will manage their donations, donors, participants, and event...
<p>I want to caution you against trying to make the "do everything" framework. This is a common mistake that a lot of developers make when trying to build their first few mass-market software apps.</p> <p>You have a customer already, and they are likely bankrolling the initial version of the application. You need to d...
<p>The most important thing is to design it in such a way that it is completely generic i.e. there is no client specific information hard coded or embedded. </p> <p>Anything client specific must be configurable through meta-data. How you do this is completely up to you, but the main ways are through XML, Database or ...
23,007
<p>I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?</p>
<pre><code>set print elements 0 </code></pre> <p><a href="http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_57.html#IDX353" rel="noreferrer">From the GDB manual</a>: </p> <blockquote><code>set print elements </code><i><code>number-of-elements</code></i></blockquote> <blockquote> Set a limit on how many elem...
<p>Using <code>set elements ...</code> isn't always the best way. It would be useful if there were a distinct <code>set string-elements ...</code>.</p> <p>So, I use these functions in my .gdbinit:</p> <pre><code>define pstr ptype $arg0._M_dataplus._M_p printf "[%d] = %s\n", $arg0._M_string_length, $arg0._M_datapl...
28,884
<p>Our user interface is communicating with another application on a different machine, often connecting using domain names. </p> <p>On our network, when IPv6 is installed, DNS name resolution works great, all machines can be pinged and contacted fine.</p> <p>When IPv6 is uninstalled, pinging the same DNS names retur...
<p>You've got multiple things going on here</p> <ol> <li>DNS Name resolution</li> <li>Windows Name resolution</li> <li>IP-IP ICMP communication</li> </ol> <p>You've written your question as if there's a problem with #3, but everything you describe points to the problem actually being with #1. If you take resolution ...
<p>I know this is a late answer, but in case someone else has the same problem, the key is the IP address, "24.28.193.9". A quick Google search reveals it seems to be related to your ISP completely breaking the DNS protocol by returning a fixed IP address for <em>all</em> non-existent domain names (the correct answer w...
19,867
<p>If I'm running a signed Java applet. Can I load additional classes from remote sources, in the same domain or maybe even the same host, and run them?</p> <p>I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too large to load them all at once....
<p>I think classes are lazy loaded in applets. being loaded on demand.</p> <p>Anyway, if the classes are outside of a jar you can simply use the applet classloader and load them by name. Ex:</p> <pre><code>ClassLoader loader = this.getClass().getClassLoader(); Class clazz = loader.loadClass("acme.AppletAddon"); </cod...
<p>Sounds like it should be possible (but I've never done it). Have you already had a look at Remote Method Invocation (<a href="http://java.sun.com/javase/technologies/core/basic/rmi/index.jsp" rel="nofollow noreferrer">RMI</a>)?</p>
8,536
<p>I want to be able to zip files from my non-gui C/C++ application, on several versions of Windows, Linux/Unix, and MacOS.</p> <p>The user will compile and run using this app using Eclipse + makefile or VisualStudio. I don't want the user to have to install something separately, or have my makefile install executable...
<p>Take a look at <a href="http://www.libarchive.org/" rel="nofollow noreferrer">Libarchive</a>. I spent a lot of time seeking for a cross-platform and LGPL licensed library with convenient interface. This the best of all I've seen. Very easy and powerful tool. Originally designed for Unix-like systems but there's also...
<p>ZLIB - the most portable library in the world. open source, very proven and reliable. The gold standard. why use anything else? </p>
32,909
<p>Designing a new system from scratch. I'll be using the STL to store lists and maps of certain long-live objects.</p> <p>Question: Should I ensure my objects have copy constructors and store copies of objects within my STL containers, or is it generally better to manage the life &amp; scope myself and just store t...
<p>Since people are chiming in on the efficency of using pointers.</p> <p>If you're considering using a std::vector and if updates are few and you often iterate over your collection and it's a non polymorphic type storing object "copies" will be more efficent since you'll get better locality of reference. </p> <p>Oto...
<p>This question has been bugging me for a while.</p> <p>I lean to storing pointers, but I have some additional requirements (SWIG lua wrappers) that might not apply to you.</p> <p>The most important point in this post is to <em>test it yourself</em>, using <em>your objects</em></p> <p>I did this today to test the s...
17,074
<p>My master page contains a list as shown here. What I'd like to do though, is add the "class=active" attribute to the list li thats currently active but I have no idea how to do this. I know that the code goes in the aspx page's page_load event, but no idea how to access the li I need to add the attribute. Please enl...
<p>In order to access these controls from the server-side, you need to make them runat="server"</p> <pre><code>&lt;ul id="nav" runat="server"&gt; &lt;li class="forcePadding"&gt;&lt;img src="css/site-style-images/menu_corner_right.jpg" /&gt;&lt;/li&gt; &lt;li id="screenshots"&gt;&lt;a href="screensho...
<p>If they were runat=server you could use the attributes property.</p>
22,627
<p>I want to get Visual Studio style tabs (you know, the ones where you can tab through the currently opened files).</p> <p>Is there a 3rd party component that does this?</p> <p>How hard would it be to do myself? </p>
<p>Try <a href="http://devexpress.com/free" rel="nofollow noreferrer">http://devexpress.com/free</a> - they have a bunch of cool looking, high quality WinForm controls. The one you will probably be most interested in is <a href="http://www.devexpress.com/Products/NET/Controls/WinForms/Editors/editors/XtraTabControl.xml...
<p>Divelements <a href="http://divelements.co.uk/net/controls/sanddock/" rel="nofollow noreferrer">SandDock</a> is the best choice for me. The controls are very targeted, simple to work with and well documented.</p>
36,668
<p>How can I build a numpy array out of a generator object?</p> <p>Let me illustrate the problem:</p> <pre><code>&gt;&gt;&gt; import numpy &gt;&gt;&gt; def gimme(): ... for x in xrange(10): ... yield x ... &gt;&gt;&gt; gimme() &lt;generator object at 0x28a1758&gt; &gt;&gt;&gt; list(gimme()) [0, 1, 2, 3, 4, 5, 6...
<p>Numpy arrays require their length to be set explicitly at creation time, unlike python lists. This is necessary so that space for each item can be consecutively allocated in memory. Consecutive allocation is the key feature of numpy arrays: this combined with native code implementation let operations on them execute...
<p>The <a href="https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.vstack.html" rel="nofollow noreferrer">vstack</a>, <a href="https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.hstack.html" rel="nofollow noreferrer">hstack</a>, and <a href="https://docs.scipy.org/doc/numpy-1.15.0/referenc...
47,974
<p>I have a report reading records out of a DMS system and I thought it would be nice to have a link to the documents that it is listing so that the users could view the actual documents. </p> <p>However when it displays a Word doc it allows you to make changes and then save them, which rather undermines the DMS syste...
<p>This is how we kick off our MBUnit test application (command line):</p> <pre><code>namespace UnitTest { class Program { static void Main(string[] args_) { // run unit test AutoRunner auto = new AutoRunner(); auto.Load(); auto.Run(); HtmlReport report = new HtmlReport(); ...
<p>Try stepping through the code manually with a debugger.</p>
40,566
<p>I'm looking to get some help on using the <a href="http://malsup.com/jquery/cycle/" rel="nofollow noreferrer">cycle</a> library for jQuery. I'm in the <a href="http://malsup.com/jquery/cycle/begin.html" rel="nofollow noreferrer">beginner</a> demos, and I got the absolute first one completed. This is the second one o...
<p>I will take a guess that this is just not working for you.<br> You need to balance your braces and parentheses.<br> <strong>Please</strong> help others to help you by saying what the actual problem is next time. </p> <p>Try this:</p> <pre><code>$(document).ready(function() { $('.pics').cycle({ fx: ...
<p>Is it OK to re-open this question? It's working OK but I'm having a rough time styling this. I'm trying to make images float left, and text wrap around it to the right like in the <a href="http://malsup.com/jquery/cycle/int2.html" rel="nofollow noreferrer">demo</a> (non image content).</p> <p>My script is:</p> <pr...
39,109
<p>I'm compiling a NAnt project on linux with TeamCity Continuous Integration server. I have been able to generate a test report by running NAnt on mono thru a Command Line Runner but don't have the options of using the report like a NAnt Runner. I'm also using MBUnit for the testing framework.</p> <p>How can I merge ...
<p><a href="http://blog.bits-in-motion.com/2008/10/announcing-gallio-and-mbunit-v304.html" rel="nofollow noreferrer">Gallio now has an extension</a> to output TeamCity service messages. Just use the included Gallio.NAntTasks.dll and enable the TeamCity extension. (this <a href="http://groups.google.com/group/gallio-dev...
<p>TeamCity Sidebar Gadget for Windows Vista, Windows 7 <a href="http://teamcity-gadget.com" rel="nofollow noreferrer">http://teamcity-gadget.com</a></p>
2,529
<p>I'm a bit lost here and I can't find much documentation.</p>
<p>.NET workflows or ones created using SharePoint designer?</p> <p>I've only got latter experience and they aren't really easy to debug, you really just have to do them 1 step at a time and test up to each step.</p> <p>You can view the workflow state as well in SharePoint when you go to the List Settings (sorry I do...
<p>As stated, your only real choice for debugging SharePoint Designer workflows is by either going through the painful process of converting them into .NET worklows, or doing things like writing out the History List after every single step so you can see what is failing.</p> <p>However, even .NET workflows are very di...
13,993
<p>I've been playing around with <code>OpenGL ES</code> development on Android. <code>OpenGL ES</code> applications seem to run slowly in the Emulator on my development machine. Does this reflect likely performance of actual hardware? I'm concerned about spending too much time developing an application if the graphics ...
<p>The emulator is super slow on my <code>Mobile Intel Pentium M 725, 1600 MHz</code>.</p> <p>I'm assuming the emulator isn't representative of real world performance.</p>
<p>With the new emulator of Android Studio 2.0, if you have good computer it runs quite smoothly, at leat for my application!</p> <p>Check the <a href="http://developer.android.com/intl/es/tools/devices/emulator.html" rel="nofollow">features</a>!</p>
12,891
<p><code>CString</code> is quite handy, while <code>std::string</code> is more compatible with STL container. I am using <code>hash_map</code>. However, <code>hash_map</code> does not support <code>CString</code>s as keys, so I want to convert the <code>CString</code> into a <code>std::string</code>.</p> <p>Writing a <...
<p>According to <a href="http://www.codeguru.com/forum/archive/index.php/t-231155.html" rel="noreferrer">CodeGuru</a>:</p> <p><code>CString</code> to <code>std::string</code>:</p> <pre><code>CString cs("Hello"); std::string s((LPCTSTR)cs); </code></pre> <p><strong>BUT:</strong> <code>std::string</code> cannot always...
<p>If you're looking to convert easily between other strings types, perhaps the <a href="http://msdn.microsoft.com/en-us/library/zthfhkd6(VS.71).aspx" rel="nofollow noreferrer"><code>_bstr_t</code></a> class would be more appropriate? It supports converstion between <code>char</code>, <code>wchar_t</code> and <code>BST...
32,204
<p>This has been troubling me for a few years, and was recently exacerbated by the introduction of Windows Vista (driver requirements &amp; UAC restrictions being major factors).</p> <p>There are many different flavours of Windows Vista (compared <a href="http://www.microsoft.com/windows/windows-vista/compare-edition...
<p>Use what you are most comfortable with. There's no single answer to this because it varies according to:</p> <ul> <li>What type of software you are developing </li> <li>Personal preferences</li> <li>Tolerance for pain</li> </ul> <p>Besides, if you write software to run in XP, Vista and Server you'll still have to ...
<p>The machine where you're typing in code and doing compiles should be a machine where you're comfortable typing in code and doing compiles. That's likely to be a server machine with suitable tweaks, or an XP machine with suitable tweaks.</p> <p>The machines where you're testing, maybe using Visual Studio there too ...
38,627
<p>In a text file, there is a string "I don't like this".</p> <p>However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use </p> <pre><code>f1 = open (file1, "r") text = f1.read() </code></pre> <p>command to do the reading.</...
<p>Ref: <a href="http://docs.python.org/howto/unicode" rel="noreferrer">http://docs.python.org/howto/unicode</a></p> <p><em>Reading Unicode from a file is therefore simple:</em></p> <pre><code>import codecs with codecs.open('unicode.rst', encoding='utf-8') as f: for line in f: print repr(line) </code></pr...
<p>Actually, U+2018 is the Unicode representation of the special character ‘ . If you want, you can convert instances of that character to U+0027 with this code:</p> <pre><code>text = text.replace (u"\u2018", "'") </code></pre> <p>In addition, what are you using to write the file? <code>f1.read()</code> should return...
17,791
<p>What is the right way to populate the model for the index page in a grails app? There is no IndexController by default, is there some other mechanism for getting lists of this and that into the model?</p>
<p>I won't claim that this is the right way, but it is one way to start things off. It doesn't take much to have a controller be the default. Add a mapping to UrlMappings.groovy:</p> <pre><code>class UrlMappings { static mappings = { "/$controller/$action?/$id?"{ constraints { // ...
<p>In grails 1.3.6 for just adding</p> <p><code>"/index.gsp"(uri:"/")</code></p> <p>to UrlMappings.groovy worked fine for me. It has the same effect as adding a new controller and mappings like described before.</p> <p>Below is my complete UrlMappings.groovy:</p> <pre><code>class UrlMappings { static mappings ...
24,243
<p>This is just to satisfy my own curiosity.</p> <p>Is there an implementation of this:</p> <pre><code>float InvSqrt (float x) { float xhalf = 0.5f*x; int i = *(int*)&amp;x; i = 0x5f3759df - (i&gt;&gt;1); x = *(float*)&amp;i; x = x*(1.5f - xhalf*x*x); return x; } </code></pre> <p>in C#? If it exis...
<p>You should be able to use the StructLayout and FieldOffset attributes to fake a union for plain old data like floats and ints.</p> <pre><code>[StructLayout(LayoutKind.Explicit, Size=4)] private struct IntFloat { [FieldOffset(0)] public float floatValue; [FieldOffset(0)] public int intValue; /...
<p>I don't see why it wouldn't be possible using the <strong>unsafe compiler option</strong>.</p>
33,747
<p>My problem is that I can't seem to get the image from my bundle to display properly. This method is in the view controller that controls the tableview. <em>headerView</em> is loaded with the tableview in the .nib file and contains a few UILabels (not shown) that load just fine. Any ideas?</p> <pre><code>- (void)vie...
<p>If you've already created an outlet and connected it to a view in Interface Builder, you should use that view, rather than creating a UIImageView on the fly. </p> <pre><code> //this assumes that headerView is an already created UIView, perhaps an IBOutlet //also, imageViewOutlet is an IB outlet hooked up to a...
<p>Adding the subview programatically worked, but it isn't correctly linked to the <em>UIImageView</em> in Interface Builder. The view I created is (I think) correctly linked to the UIView outlet in my <em>UITableViewController</em>, but when I init my imageView it creates a new view instead of putting the image in the...
25,374
<p>Having sorted out an issue with clickonce deployment the client has asked whether we can modify the installation sequences and pretty them up. Can anyone shed any light on how to customise the look and feel of the clickonce initial installer?</p>
<p>Are you are talking about the initial page (publish.htm) that users have to access to install the application? If so, it's just an html page that you can edit however you wish.</p> <p>If you are talking about a security warning that users have to click past in order to install your application, then you need to si...
<p>Once installed you can do all update by code, but I never found a way to skip the initial installation popup. </p>
34,231
<p>I'm not asking about converting a LaTeX document to html. </p> <p>What I'd like to be able to do is have some way to use LaTeX math commands in an html document, and have it appear correctly in a browser. This could be done server or client side.</p>
<p>MediaWiki can do what you are looking for. It uses Texvc (<a href="http://en.wikipedia.org/wiki/Texvc" rel="noreferrer">http://en.wikipedia.org/wiki/Texvc</a>) which "validates (AMS) LaTeX mathematical expressions and converts them to HTML, MathML, or PNG graphics." Sounds like what you are looking for.</p> <p>Chec...
<p>I would definitely encourage you to look at MathML if that fits what you're looking for but a little work with <a href="http://simile.mit.edu/wiki/JsTeX" rel="nofollow noreferrer">JsTeX</a> could give you everything you need.</p>
14,147
<p>This is my first experience using the Zend Framework. I am attempting to follow the <a href="http://framework.zend.com/docs/quickstart/introduction" rel="nofollow noreferrer">Quick Start</a> tutorial. Everything was working as expected until I reached the section on the <a href="http://framework.zend.com/docs/quicks...
<p>You have ErrorHandler.php. It should be ErrorController.php. Controllers all need to be named following the format of NameController.php. Since you don't have it named properly the dispatcher cannot find it.</p>
<p>Assuming that you have the ErrorController plugin loaded into your front controller, make sure that in your bootstrap that you do not have the following set:</p> <pre><code>$frontController-&gt;throwExceptions(true); </code></pre> <p>If this is set then Exceptions will <em>always</em> be thrown, regardless of whet...
11,456
<p>I am developing a collection of plugins on Eclipse 3.4 (official) on both mac and a PC.</p> <p>At present (I'm aware it is not the best practice) some of my common plugins export all of their packages. </p> <p>The problem is this: many of the listed packages are empty because subpackages are not, for example: pref...
<p>It's usually a good practice to use the same version of the JVM if you're developing plugins across multiple machines and platforms. </p> <p>If you are going to build the plugins on a PC and expect them to run on the Mac, you should standardize on Java 5. You can easily install and add additional JREs to Eclipse by...
<p>The problem could be the error/warning levels set in the preferences for Plug-In development. It could be that you have different settings in both machines, and that creates the problem.</p> <p>Under Preferences -> Plug-in Development -> Compilers there are several options regarding error and warning levels for di...
20,586
<p>The <a href="http://specs.xmlsoap.org/ws/2005/04/discovery/ws-discovery.pdf" rel="nofollow noreferrer">ws-discovery specifications</a> explains how to protect your network from </p> <ol> <li>message alteration</li> <li>Denial of service</li> <li>replay</li> <li>spoofing</li> </ol> <p>but what about man-in-the-midd...
<p>The only situation in which a nameless namespace in header can be useful is when you want to distribute code as header files only. For example, a large standalone subset of Boost is purely headers.</p> <p>The token <code>ignore</code> for tuples, mentioned in another answer is one example, the <code>_1</code>, <cod...
<p>If it's initialization, it would likely be an <code>iostream</code>s header (like <code>istream</code>, <code>ios</code>, etc.).</p>
46,625
<p>I was trying to test code using com class to display Word files but I cannot seem to get the answer and still searching. I get errors and sometimes, programs do not display anything at all. Please give me some ideas. I'm working with PHP 4.</p>
<p>If the site is hosted on a Windows machine with Word you may be able to use a COM extension to PHP that will give you access to Word documents. Using the automation methods exposed by Word's Automation model, you could probably do something like export a word document to HTML and then render that HTML to some fra...
<p>Do you mean you want to have the word plugin activated in the browser? Try the <a href="http://www.w3.org/TR/html401/struct/objects.html#edef-OBJECT" rel="nofollow noreferrer"><code>&lt;object&gt;</code></a> tag with the correct mime type.</p>
26,806
<p>I'm trying to copy both an image from a file and text from a file to the clipboard. My intention is to then open a word document or an outlook email and paste both the text and the image in one standard paste command (CTRL-V for example). I can do both separately easily enough, but doing them both in one operation d...
<p>You could use RTF, which could combine text and graphics. Note that you CAN have CF_BITMAP and CF_TEXT on the clipboard at the same time. But it's not useful. You'd get the text when you paste into notepad, you'd get the bitmap when you paste into Paint, and most other apps would pick one or the other, but never b...
<p>Adding specific code implementation; </p> <pre><code>// Load a bitmap without locking it. private Bitmap LoadBitmapUnlocked(string path) { using (Bitmap bm = new Bitmap(path)) { return new Bitmap(bm); } } </code></pre> <p>...</p> <pre><code>string path = @"C:\Windows\Web\Wallpaper\Architectur...
36,179
<p>Is it possible to define a class in C# such that</p> <pre><code>class GenericCollection&lt;T&gt; : SomeBaseCollection&lt;T&gt; where T : Delegate </code></pre> <p>I couldn't for the life of me accomplish this last night in .NET 3.5. I tried using</p> <p><code>delegate, Delegate, Action&lt;T&gt; and Func&lt;T, T&g...
<p>A number of classes are unavailable as generic contraints - Enum being another.</p> <p>For delegates, the closest you can get is ": class", perhaps using reflection to check (for example, in the static constructor) that the T <em>is</em> a delegate:</p> <pre><code>static GenericCollection() { if (!typeof(T).Is...
<p>According to <a href="https://msdn.microsoft.com/en-us/library/56b2hk61.aspx" rel="nofollow">MSDN</a> </p> <p><strong>Compiler Error CS0702</strong></p> <p>Constraint cannot be special class 'identifier' The following types may not be used as constraints: </p> <ul> <li>System.Object</li> <li>System.Array</li> <li...
23,318
<p>How can I add line numbers to a range of lines in a file opened in Vim? Not as in <code>:set nu</code>—this just <em>displays</em> line numbers—but actually have them be prepended to each line in the file?</p>
<p>With</p> <pre><code>:%s/^/\=line('.')/ </code></pre> <p>EDIT: to sum up the comments. </p> <p>This command can be tweaked as much as you want.</p> <hr> <p>Let's say you want to add numbers in front of lines from a visual selection (<code>V</code> + move), and you want the numbering to start at 42.</p> <pre><co...
<p>If someone wants to put a tab (or some spaces) after inserting the line numbers using the <a href="https://stackoverflow.com/a/253041/2956066">this excellent answer</a>, here's a way. After going into the escape mode, do:</p> <pre><code>:%s/^/\=line('.').' '/ </code></pre> <p><code>^</code> means beginning of a...
31,490
<p>When doing a <code>cvs update</code>, you get a nice summary of the state of the repository, for example:</p> <pre><code>M src/file1.txt M src/file2.txt C src/file3.txt A src/file4.txt ? src/file5.txt </code></pre> <p>Is there a way to get this without actually updating? I know there is <code>cvs status</code>, bu...
<p>You can use the -n flag to get the update output without actually updating the files. You can also add -q (quiet) to suppress any server messages.</p> <pre><code>cvs -q -n update </code></pre>
<p>@jmcnamara: Good tip!</p> <p>And all this time I've been using this bash script:</p> <pre><code>cvs -q status "$@" | grep '^[?F]' | grep -v 'Up-to-date' </code></pre>
26,036
<p>Let's say I have an aspx page with this calendar control:</p> <pre><code>&lt;asp:Calendar ID="Calendar1" runat="server" SelectedDate="" &gt;&lt;/asp:Calendar&gt; </code></pre> <p>Is there anything I can put in for SelectedDate to make it use the current date by default, without having to use the code-behind?</p>
<p>If you are already doing databinding:</p> <pre><code>&lt;asp:Calendar ID="Calendar1" runat="server" SelectedDate="&lt;%# DateTime.Today %&gt;" /&gt; </code></pre> <p>Will do it. This does require that somewhere you are doing a Page.DataBind() call (or a databind call on a parent control). If you are not doing ...
<p>I too had the same problem in VWD 2010 and, by chance, I had two controls. One was available in code behind and one wasn't accessible. I thought that the order of statements in the controls was causing the issue. I put 'runat' before 'SelectedDate' and that seemed to fix it. When I put 'runat' after 'SelectedDate' ...
11,189
<p>I need to select from a table and filter on dates greater than a specified date. </p> <p>The problem I'm having is that the dates are stored as nchar(20) and I can't seem to get it converted to date in the where clause. </p> <pre><code>SELECT CONVERT(DATETIME,log_time,20) from dbo.logs where CONVERT(DATETIME,lo...
<p>This should work.</p> <pre><code>select convert(datetime, cast(rtrim(log_time), nvarchar)) from dbo.logs where convert(datetime, cast(rtrim(log_time), nvarchar)) &gt; '10/20/2008' </code></pre>
<p>try this:</p> <pre><code>select convert(datetime, cast(trim(log_time), nvarchar)) from dbo.logs where convert(datetime, cast(trim(log_time), nvarchar)) &gt; '10/20/2008' </code></pre> <p>I think the trick is that you need to trim the string and cast to nvarchar</p>
28,567
<p>I have a table with game scores, allowing multiple rows per account id: <code>scores (id, score, accountid)</code>. I want a list of the top 10 scorer ids and their scores.</p> <p>Can you provide an sql statement to select the top 10 scores, but only one score per account id? </p> <p>Thanks!</p>
<p>First limit the selection to the highest score for each account id. Then take the top ten scores.</p> <pre><code>SELECT TOP 10 AccountId, Score FROM Scores s1 WHERE AccountId NOT IN (SELECT AccountId s2 FROM Scores WHERE s1.AccountId = s2.AccountId and s1.Score &gt; s2.Score) ORDER BY Score DESC </code><...
<p>I believe that PostgreSQL (at least 8.3) will require that the <code>DISTINCT ON</code> expressions must match initial <code>ORDER BY</code> expressions. I.E. you can't use <code>DISTINCT ON (accountid)</code> when you have <code>ORDER BY score DESC</code>. To fix this, add it into the <code>ORDER BY</code>:</p> ...
12,051
<p>I was wondering how i can force a user who has requested a page using Http to use the secure https version?</p> <p>I am using Websphere 6.1 as my application server and Rad 7 as my development environment</p> <p>Thanks Damien</p>
<p>One way that you could do this within your application rather than in the server configuration would be to use a <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Filter.html" rel="nofollow noreferrer">Filter</a> (specified in your web.xml) to check if <code>ServletRequest.getScheme()</code> is "http" or ...
<p>Websphere is not a complete http server. It does have 'Transport Chains', which act like an HTTP Server.</p> <p>Normally you will put a HTTP server in front. IBM provides IHS (IBM HTTP Server) which is a lightly modified Apache HTTP Server. The HTTP Server is configured with the httpd.conf file. There you add redir...
16,101
<p>When loading a page for the first time (!IsPostback), I am creating a button in code and adding it to my page, then adding an event handler to the click event.</p> <p>However, when clicking the button, after the page reloads, my event handler does not fire.</p> <p>Can anyone explain why?</p>
<p>@Brad: Your answer isn't complete; he's most likely doing it too late in the page lifecycle, during the Page_Load event.</p> <p>Okay, here's what you're missing.</p> <p>ASP.NET is stateless. That means, after your page is rendered and sent to the browser, the page object and everything on it is destroyed. There...
<p>That is because the event binding that happens needs to be translated in to HTML. This postback that happens if bound to the page between OnInit and OnLoad. So if you want the button to bind events correclty make sure you do the work in OnInit.</p> <p>See the Page Life Cycle explaination.</p> <p><a href="http://...
6,409
<p>I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page.</p> <p>I would like to kno...
<p>with jQuery it's very simple, and I would definitely recommend using it in ajax calls and etc. Let's say you have a table like this;</p> <pre><code>&lt;table&gt; &lt;?php // I'm using mysqli class by the way. $ga = $DB-&gt;query("SELECT something FROM table"); for ($a = 0; $a &lt; $ga-&gt;num_rows; $a++) { $a...
<p>You don't want it displayed, does that mean for security issues or something else. </p> <p>If you want to lose the primary key in the table you can go with a query cache placed into a session object and then just retreive by place in array. </p> <p>so something like: page1: </p> <ol> <li>create array with db obj...
39,821
<p>What would be the fastest way, to merge 2 XML files, so I would locate a node in first one, empty it, take all children from the same tag (same node) in second XML and put it in the first one.</p>
<p>You can load both files into two <code>XElement</code> objects, locate the target nodes in both objects and do the switch.</p> <p>Here is a sample:</p> <pre><code>var nodes1 = XDocument.Parse(file1).Element("test").Element("nodes"); var nodes2 = XDocument.Parse(file2).Element("test").Element("nodes"); nodes1.Node...
<p>Check out this article on MSDN: <a href="http://support.microsoft.com/kb/311530" rel="nofollow noreferrer">Article</a></p> <p>I think this is the bit of code you are looking for:</p> <pre><code>try { XmlTextReader xmlreader1 = new XmlTextReader("C:\\Books1.xml"); XmlTextReader xmlreader2 = new XmlTextReade...
44,534
<p>PHP has a number of opcode caches, which as i understand it are scripts that handle the caching aspects of an application. Is there something similar for classic asp, especially something that does not require component installation?</p> <p>Regarding the IIS caching behaviour, it seems from reading <a href="http://...
<p>Looking at your comments to the answers here so far and at your edit of your question you seem a little confused over caching.</p> <p>There are two types of caching we could be be talking about.</p> <ul> <li>Opcode or Template caching</li> <li>Output caching</li> </ul> <p><strong>Opcode or Template caching</stron...
<p>Maybe this class helps you caching some stuff. </p> <p><a href="http://www.webdevbros.net/2006/11/18/cache-object-for-classic-asp/" rel="nofollow noreferrer">http://www.webdevbros.net/2006/11/18/cache-object-for-classic-asp/</a></p> <p>It does not require any installed components and uses the application object as...
20,567
<p>How do I lock compiled Java classes to prevent decompilation?</p> <p>I know this must be very well discussed topic on the Internet, but I could not come to any conclusion after referring them.</p> <p>Many people do suggest obfuscator, but they just do renaming of classes, methods, and fields with tough-to-remember...
<p>Some of the more advanced Java bytecode obfuscators do much more than just class name mangling. <a href="http://www.zelix.com/" rel="noreferrer">Zelix KlassMaster</a>, for example, can also scramble your code flow in a way that makes it really hard to follow and works as an excellent code optimizer...</p> <p>Also m...
<p>Q: If I encrypt my .class files and use a custom classloader to load and decrypt them on the fly, will this prevent decompilation?</p> <p>A: The problem of preventing Java byte-code decompilation is almost as old the language itself. Despite a range of obfuscation tools available on the market, novice Java programm...
7,191
<p>I know this is a bit of a newbie question, but are there equivalents to C#'s string operations in Java?</p> <p>Specifically, I'm talking about <code>String.Format</code> and <code>String.Join</code>.</p>
<p>The Java String object has a <code>format</code> method (as of 1.5), but no <code>join</code> method.</p> <p>To get a bunch of useful String utility methods not already included you could use <a href="http://commons.apache.org/proper/commons-lang//apidocs/org/apache/commons/lang3/StringUtils.html" rel="noreferrer">...
<p>I would just use the string concatenation operator "+" to join two strings. <code>s1 += s2;</code></p>
22,741
<p>There are lots of tools for creating installers on Windows (InstallShield, InnoSetup, NSIS, just to name a few). All tools I've seen fall in one or both of these categories</p> <ul> <li>Point-and-click. Nice GUI for creating the installer, but the installer definition/project file can not be manually edited.</li> <...
<p><a href="http://wix.sourceforge.net/downloadv3.html" rel="nofollow noreferrer" title="WiX 3.0 beta">Wix 3.0 beta</a> has .NET support included for this purpose. I don't know how well it works but it includes documentation. It's a framework of types for manipulating the installation creation process and all that good...
<p>Well, there is the Windows Installer API which you could use to create MSI files directly, however I think you'd be better off using WiX.</p> <p>The "direct coding" will be much less than dealing with the Windows Installer API directly, I'm guessing that's probably going too "low level" for what you need. Depending...
19,909
<p>Will there be a functional language which does for the Java community what F# does for the .NET community?</p> <p>What functional programming languages are available, or in development, for the JVM?</p>
<p><a href="http://www.scala-lang.org/" rel="noreferrer">Scala</a> would be the language.</p> <p>Though not strictly functional (it's a mix of functional and object-oriented) and it is not strictly for Java (there is a <a href="http://www.scala-lang.org/node/168" rel="noreferrer">.NET version of Scala</a>), that would...
<p>Actually, I might be wrong, but I don't expect F# to be as mainstream as the other .NET languages; useful in a few circles (academic, compilers, a few other scenarios) - however, don't forget that <strong>C#</strong> offers FP usage - and it gets better each time: C# 1.2 has delegates; C# 2.0 has anonymous methods a...
20,492
<p>I have a drop down like this on my page:</p> <pre><code>&lt;p&gt; &lt;%= f.label :episode_id %&gt;&lt;br /&gt; &lt;%= f.collection_select(:episode_id, @episodes, :id, :show) %&gt; &lt;/p&gt; </code></pre> <p>An episode has an id and <code>belongs_to</code> to a show which has a name. In the dropdown, I'...
<p>One way to do this would be to create a method in your Episode class called <code>show_name</code> like so:</p> <pre><code>def show_name show.name end </code></pre> <p>The last symbol you are passing into collection_select is the name of the method that you want to call to get the option text.</p>
<p>I don't know if this would work, but did you try <code>episode.show.name</code>?</p>
25,873
<p>I'm using ganymede but I can't find the option to change mirror for the update sites. Is there a way to change this? </p>
<p>The all notion of <strong>mirrors</strong> is <a href="http://tronprog.blogspot.com/2008/07/eclipse-ganymede.html" rel="nofollow noreferrer">no more a first class citizen</a> of eclipse Ganymede update mechanism, but rather a simple property of a repositories (for <a href="http://wiki.eclipse.org/Equinox/p2/Concepts...
<p>If i am not mistaken, in "Help->Software Updates" you can manage all the eclipse repositories...</p>
44,641
<p>I think I understand unit testing. But I was wondering: is there a way to automate something visual, like making sure anti-aliasing works or that the rounded corners on a web site look how they are supposed to? I have a feeling that it just isn't practical, but I have little experience in the QA world.</p>
<blockquote> <p>"anti-aliasing works or that the rounded corners on a web site look how they are supposed to?"</p> </blockquote> <p>You could theoretically write automated tools to take snapshots of the renderings and somehow parse them and compare vs the mockup. </p> <p>You'd need some sort of "anchoring" mechanis...
<p>Do hallway usability testing. ;)</p> <p><a href="http://www.joelonsoftware.com/articles/fog0000000043.html" rel="nofollow noreferrer">http://www.joelonsoftware.com/articles/fog0000000043.html</a></p>
45,833
<p>If the major axis of the ellipse is vertical or horizontal, it's easy to calculate the bounding box, but what about when the ellipse is rotated?</p> <p>The only way I can think of so far is to calculate all the points around the perimeter and find the max/min x and y values. It seems like there should be a simpler ...
<p>You could try using the parametrized equations for an ellipse rotated at an arbitrary angle:</p> <pre><code>x = h + a*cos(t)*cos(phi) - b*sin(t)*sin(phi) [1] y = k + b*sin(t)*cos(phi) + a*cos(t)*sin(phi) [2] </code></pre> <p>...where ellipse has centre (h,k) semimajor axis a and semiminor axis b, and is rotated ...
<p>This code is based on the code user1789690 contributed above, but implemented in Delphi. I have tested this and as far as I can tell it works perfectly. I spent an entire day searching for an algorithm or some code, tested some that didn't work, and I was very happy to finally find the code above. I hope someone fin...
11,329
<p>I'm looking for a reliable design for handling assignments that have asynchronous requests involved. To further clarify, I have a class which handles Data Management. It is a singleton and contains a lot of top level data for me which is used throughout my iPhone application.</p> <p>A view controller might do somet...
<p>I solved this problem a couple ways in different apps. </p> <p>One solution is to pass an object and selector along to notify such as:</p> <pre><code>- (id)getUsersAndNotifyObject:(id)object selector:(SEL)selector </code></pre> <p>This breaks the nice property behavior however. If you want to keep the methods a...
<p>It took me a while to realize what the best way of handling this kind of typical task; it turns out the clue is in the design of many of Cocoa and CocoaTouch's own APIs: <strong>delegation</strong>.</p> <p>The reason so many of Cocoa's APIs use delegation is because it fits very well with the asynchronous nature of...
48,285
<p>I was looking for a good free debugger for STP (Stored Procedures) as I need to make changes to a few of them as a part of my recent project. The stored procedures are stored in independent <code>.sql</code> files and not in the code.</p> <p>A debugger would speed things up quite a it in my case. Could anyone recom...
<blockquote> <p>The stored procedures are stored in independent '.sql' files and not in the code.</p> </blockquote> <p>In order to debug a proc it has to be created in the RDBMS and then executed, how will you debug a proc stored in a file?</p>
<p>Yes, you are right. These stored procedures are called through code which has all the necessary libraries to connect to the database (RDBMS). </p> <p>However, what I am looking for is to understand what the stored procedures do. At the moment I am using dbVisualizer for this. I have set up the connections to the RD...
3,873
<p>which one of the two is more spread? I want to read out the version number from <a href="http://freshmeat.net/projects-xml/mysql/mysql.xml?branch_id=46519" rel="nofollow noreferrer">http://freshmeat.net/projects-xml/mysql/mysql.xml?branch_id=46519</a> but I want to use the one which more people have.</p> <p>If you ...
<p>For this kind of task, reading the document into a <a href="http://us2.php.net/domdocument" rel="noreferrer"><code>DomDocument</code></a> and using <a href="http://docs.php.net/manual/it/domxpath.query.php" rel="noreferrer"><code>DomXPath</code></a> is probably more suitable.</p> <p>To answer your question, both li...
<p>SimpleXML was introduced in PHP5 while XmlReader was only included by default in version 5.1, so the former is probably the best way to go:</p> <pre><code>$struct = simplexml_load_string($xml); $version = (string)$struct-&gt;project-&gt;latest_release-&gt;latest_release_version; </code></pre> <p>However if you're ...
37,381
<p>We have an enterprise web application where every bit of text in the system is localised to the user's browser's culture setting.</p> <p>So far we have only supported English, American (similar but mis-spelt ;-) and French (for the Canadian Gov't - app in English or French depending on user preference). During deve...
<p>Read <a href="https://web.archive.org/web/20080829004345/http://www.microsoft.com/globaldev/getwr/steps/WRGuide.mspx" rel="nofollow noreferrer">Globalization Step-by-Step</a> by Microsoft.</p> <p>I can answer the specifics on CJKV, but you probably want a book on this topic. I haven't read it but CJKV Information Pr...
<p>The directionality question is easy to answer for East Asian languages: websites are left-to-right, top-to-bottom as per usual.</p> <p>In fact, the general web design layout principles much the same. Have a look at the websites of a <a href="http://www.yomiuri.co.jp/" rel="nofollow noreferrer">newspaper</a> (name t...
3,424
<p>How to (programmatically, without xml config) configure multiple loggers with Log4Net? I need them to write to different files.</p>
<p><a href="http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200602.mbox/%3CDDEB64C8619AC64DBC074208B046611C769745@kronos.neoworks.co.uk%3E" rel="noreferrer">This thread at the log4net Dashboard details an approach</a>.</p> <p>To summarize a little, hopefully without ripping off too much code:</p> <pre><...
<p>I mixed together the code from Blair Conrad's answer and the code from Philipp M on this post:</p> <p><a href="https://stackoverflow.com/questions/16336917/can-you-configure-log4net-in-code-instead-of-using-a-config-file">stackoverflow.com/questions/16336917/can-you-configure-log4net-in-code-instead-of-using-a-conf...
39,730
<p>First off: I'm using a rather obscure implementation of javascript embedded as a scripting engine for Adobe InDesign CS3. This implementation sometimes diverges from "standard" javascript, hence my problem.</p> <p>I'm using <a href="http://ejohn.org/projects/javascript-diff-algorithm/" rel="nofollow noreferrer">Joh...
<p>You might be "asking the wrong question" (as Raymond Chen would say); rather than trying to avoid using the vanilla objects, try changing the way the associative array members are named.</p> <p>The way I'd try to approach this: instead of there being an array member ns["reflect"], change the way that jsdiff builds ...
<p>Well given objects in javascript are just associative arrays, there really isn't another built in solution for a hash. You might be able to create your own psuedo hashtable by wrapping a class around some arrays although there will probably be a significant performance hit with the manual work involved.</p> <p>Jus...
12,935
<p>After moving a project from .NET 1.1 to .NET 2.0, MsBuild emits lots of warnings for some COM objects.</p> <p>Sample code for test (actual code doesn't matter, just used to create the warnings):</p> <pre><code>using System; using System.DirectoryServices; using ActiveDs; namespace Test { public class Class1 ...
<p>According to a comment in the <a href="http://msdn.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx" rel="noreferrer">MDSN article about TLBIMP for 2.0</a>, you can't fix this problem w/o running TLBIMP yourself.</p> <p>It was easy to reproduce your problem using VS. I also reproduced it running TLBIMP manually fr...
<p>You can stop the warnings with:</p> <pre> #pragma warning disable warning-list #pragma warning restore warning-list </pre> <p>where warning list is a comma seperated list of warning numbers.</p> <p>The warning means that the typelib you are importing contains something untranslatable into managed code but...
33,786
<p>I'm in the process of adding CAPTCHA validation to one of my websites and need to know what open source solutions exist. Please note strengths and weaknesses and what platform they work with. I'm primarily interested in ASP.NET solutions but feel free to include PHP, Java, etc.</p>
<p><a href="http://recaptcha.net/whyrecaptcha.html" rel="nofollow noreferrer">ReCAPTCHA</a> is the same one StackOverflow uses. It has an <a href="http://recaptcha.net/plugins/aspnet/" rel="nofollow noreferrer">ASP.NET implementation</a>.</p> <p>It uses a webservice to provide the captcha images; this is an university...
<p>Have you taken a look at <a href="http://recaptcha.net/" rel="nofollow noreferrer">ReCAPTCHA</a>?</p>
30,268
<p>I'd like to get comments from people who have used or evaluated Coverity for statically analysing Java-code. I know it's popular in C/C++ world, but is it worth spending the money for Java analysis or am I better off with PMD, Findbugs and other Open Source tools?</p>
<p>If you aren't using anything today, I would start off with Findbugs and PMD. They are easy to install and use. Concentrate on reviewing and fixing correctness errors with Findbugs first - they recommend starting with High and Medium severity correctness errors as the checkers have very low false positives and you wi...
<p>As others have said, the best way to decide is to try all these tools out.</p> <p>Coverity recently announced a hosted static-analysis-as-a-service product called Code Spotter (<a href="https://code-spotter.com/" rel="nofollow">https://code-spotter.com/</a>), currently in beta. It's using the same analysis engine a...
20,937
<p>I saw this quote in <a href="https://stackoverflow.com/questions/221716/most-large-companies-prefer-wisa-over-lamp-why">this question</a>:</p> <blockquote> <p>MS support is poor, except when you've paid for a support contract... then its very very good. – gbjbaanb </p> </blockquote> <p>This got me thinking....
<p>Yes it has. If you have made an effort to solve the problem yourself, you have to get to at least the third person before you get anybody who will understand the issue, and maybe the fourth person can help.</p> <p>Once you get to that person, though -- I've found the support to be unbelievably good with a lot of f...
<p>Yes, I have had an opportunity to use paid support from Microsoft. I was working for a dot-com and we were having intermittent crashes on our main site which used ASP. I had been asked to run this utility to generate a crash dump when the error popped up on the site and had sent a few in to be analyzed. The analy...
27,391
<p>I'm working on some RSS feeds for a custom task system we have. The main feed will show a list of tasks assigned to the current user. The link attribute for each task returned points to the web page for that task. However, tasks themselves have an RSS feed for updates, and I want to be able to provide a link for ...
<p>Make the content of each item in the original RSS feed HTML. (I believe you'll have to CDATA escape the block). Within this content put a hyperlink to the updates feed RSS.</p>
<p>Why not add it to the entry summary as links?</p>
18,607
<p>I wrote a managed C++ class that has the following function:</p> <pre><code>void EndPointsMappingWrapper::GetLastError(char* strErrorMessage) { strErrorMessage = (char*) Marshal::StringToHGlobalAnsi(_managedObject-&gt;GetLastError()).ToPointer(); } </code></pre> <p>As you can see, this is a simple method to co...
<p>You are assigning the value of the passed parameter (strErrorMessage) instead of copying to that address the content of the buffer returned by Marshal::StringToHGlobalAnsi.</p> <p>A correct implementation should be:</p> <pre><code>void EndPointsMappingWrapper::GetLastError(char* strErrorMessage, int len) { char *...
<p>We use the following C++ Class to do the conversions for us and it works fine. You should be able to modify your method to use it.</p> <p><strong>H File</strong></p> <pre><code>public ref class ManagedStringConverter { public: ManagedStringConverter( System::String^ pString ); ~ManagedStringConverter(); pr...
33,921
<p>We have found out that Firefox (at least v3) and Safari don't properly cache images referenced from a css file. The images are cached, but they are never refreshed, even if you change them on the server. Once Firefox has the image in the cache, it will never check if it has changed.</p> <p>Our css file looks like t...
<p>I would just add a querystring value to the image url. I usually just create a "version number" and increment it every time the image changes:</p> <pre><code>div#news { background: url(images/newsitem_background.jpg?v=00001) no-repeat; ... } </code></pre>
<p>Try holding the SHIFT key while you click reload (or press <kbd>F5</kbd>).</p> <p>Otherwise, use a tool such as Firebug to check the HTTP request/response headers and observe the header values that control caching. I've never noticed this problem. Perhaps your server is returning a 304 response (not modified).</p...
24,457
<p>Does anyone know a way to auto-generate database tables for a given class? I'm not looking for an entire persistence layer - I already have a data access solution I'm using, but I suddenly have to store a lot of information from a large number of classes and I really don't want to have to create all these tables by...
<p>It's really late, and I only spent about 10 minutes on this, so its extremely sloppy, however it does work and will give you a good jumping off point:</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace TableGenerator { class Program { ...
<p>Try DaoliteMappingTool for .net. It can help you generate the classes. Download form <a href="http://www.idevlite.com/download/daolitemappingtool(net).zip" rel="nofollow noreferrer">Here</a></p>
6,946
<p>What is the SQL query to select all of the MSSQL Server's logins?</p> <p>Thank you. More than one of you had the answer I was looking for:</p> <pre><code>SELECT * FROM syslogins </code></pre>
<p>Is this what you're after?</p> <pre><code>select * from master.syslogins </code></pre>
<p>Have a look in the syslogins or sysusers tables in the master schema. Not sure if this still still around in more recent MSSQL versions though. In MSSQL 2005 there are views called sys.syslogins and sys.sysusers.</p>
5,793
<p>In the javadoc it says that EventListener is </p> <blockquote> <p>"A tagging interface that all event listener interfaces must extend."</p> </blockquote> <p>Why is that? What's the significance of making a custom listener implement EventListner? Is there any special handling for EventListner somewhere?</p>
<p>Probably used by <a href="http://java.sun.com/docs/books/tutorial/javabeans/introspection/index.html" rel="noreferrer">javabeans introspection</a>. </p> <p>For instance Netbeans beaninfo editor does not recognise the event if <code>extends EventListener</code> is missing from the Listener.</p>
<p>It’s only important if you want to use an <a href="http://java.sun.com/javase/6/docs/api/javax/swing/event/EventListenerList.html" rel="noreferrer">EventListenerList</a> or an <a href="http://java.sun.com/javase/6/docs/api/java/util/EventListenerProxy.html" rel="noreferrer">EventListenerProxy</a>. I like to use it o...
48,484
<p>How do I perform an <code>IF...THEN</code> in an <code>SQL SELECT</code> statement?</p> <p>For example:</p> <pre><code>SELECT IF(Obsolete = 'N' OR InStock = 'Y' ? 1 : 0) AS Saleable, * FROM Product </code></pre>
<p>The <code>CASE</code> statement is the closest to IF in SQL and is supported on all versions of SQL Server.</p> <pre><code>SELECT CAST( CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 END AS bit) as Saleable, * FROM Product </...
<p>There are multiple conditions.</p> <pre><code>SELECT (CASE WHEN RIGHT((LEFT(POSID,5)),4) LIKE '1001' THEN 'DM' WHEN RIGHT((LEFT(POSID,5)),4) LIKE '1002' THEN 'GS' WHEN RIGHT((LEFT(POSID,5)),4) LIKE '1003' THEN 'MB' WHEN RIGHT((LEFT(POSID,5)),4) LIKE '1004' THEN 'MP' WHEN RIGHT((LEFT(POSID,5)),4) LIKE '1005' THEN 'P...
8,892
<p>The CPU architecture landscape has changed, multiple cores is a trend that will change how we have to develop software. I've done multi-threaded development in C, C++ and Java, I've done multi-process development using various IPC mechanisms. Traditional approaches of using threads doesn't seem to make it easy, for...
<p>I'd suggest two paradigm shifts:</p> <h1>Software Transactional Memory</h1> <p>You may want to take a look at the concept of <em>Software Transactional Memory</em> (STM). The idea is to use <em>optimistic concurrency</em>: any operation that runs in parallel to others try to complete its job in an isolated transac...
<p><code>multiprocessing</code> is a python library that simplifies multi-core programming, as mentionned in another answer. </p> <p>Program written with python's <code>multiprocessing</code> can easily be modified to ship work on the cloud, instead of to local cores. <a href="http://www.picloud.com/" rel="nofollow"...
14,792
<p>I have a neural network written in Erlang, and I just bought a GeForce GTX 260 card with a 240 core GPU on it. Is it trivial to use <a href="http://en.wikipedia.org/wiki/CUDA" rel="noreferrer">CUDA</a> as glue to run this on the graphics card?</p>
<p>No, using CUDA is not a trivial matter. </p> <p>The CUDA programming model basically uses C (with some additions) but in order to get the most of the GPGPU's capabilities you would have to ensure that your algorithms follow the CUDA guidelines. (see <a href="http://developer.download.nvidia.com/compute/cuda/1_1/NVI...
<p>I wish I could tell you how to do this with Erlang... ;-), but at least, Satnam Singh at MS Research has done some very interesting work with Haskell (Lava) and F#. Perhaps this paper can give you some intuition for how it <em>could</em> be done:</p> <p><a href="http://research.microsoft.com/en-us/people/satnams/" ...
26,223
<p>I want to do the inverse of <a href="http://www.manpagez.com/man/1/sort/" rel="nofollow noreferrer">sort(1)</a> : randomize every line of <strong>stdin</strong> to <strong>stdout</strong> in Perl. </p>
<p>I bet real Perl hackers will tear this apart, but here it goes nonetheless.</p> <pre><code>use strict; use warnings; use List::Util 'shuffle'; my @lines = (); my $bufsize = 512; while(&lt;STDIN&gt;) { push @lines, $_; if (@lines == $bufsize) { print shuffle(@lines); undef @lines; } } pr...
<p>This perl snippet does the trick : </p> <pre><code>#! /usr/bin/perl # randomize cat # fisher_yates_shuffle code copied from Perl Cookbook # (By Tom Christiansen &amp; Nathan Torkington; ISBN 1-56592-243-3) use strict; my @lines = &lt;&gt;; fisher_yates_shuffle( \@lines ); # permutes @array in place foreach m...
36,442
<p>I want to plug in my drivers from the printer into my Raspberry Pi. I want to control the printer's axes by sending G-code directly from the Raspberry Pi command line (if possible) to the drivers.</p> <p>Is that possible and if yes does anyone know how? As I stated above without using any 3rd party program/software....
<p>A very dumb, simple way to send GCODE to your printer from the terminal can be achieved with:<br /> <code>echo &quot;gcode here&quot; &gt; /dev/ttyS0</code><br /> /dev/ttyS0 can vary, It may be /dev/ttyACM0, /dev/ttyUSB0, or any similar with a different number.</p> <p>You can figure out which path is correct for you...
<p>You can send the data to the serial port using <code>echo</code>, but you'll have to use <code>cat</code> to get the response.</p>
1,999
<p>I have a flag enum below.</p> <pre><code>[Flags] public enum FlagTest { None = 0x0, Flag1 = 0x1, Flag2 = 0x2, Flag3 = 0x4 } </code></pre> <p>I cannot make the if statement evaluate to true.</p> <pre><code>FlagTest testItem = FlagTest.Flag1 | FlagTest.Flag2; if (testItem == FlagTest.Flag1) { /...
<p>In .NET 4 there is a new method <a href="http://msdn.microsoft.com/en-us/library/system.enum.hasflag%28VS.100%29.aspx" rel="noreferrer">Enum.HasFlag</a>. This allows you to write:</p> <pre><code>if ( testItem.HasFlag( FlagTest.Flag1 ) ) { // Do Stuff } </code></pre> <p>which is much more readable, IMO.</p> <p...
<p>even without [Flags], you could use something like this</p> <pre><code>if((testItem &amp; (FlagTest.Flag1 | FlagTest.Flag2 ))!=0){ //.. } </code></pre> <p>or if you have a Zero value enum</p> <pre><code>if((testItem &amp; (FlagTest.Flag1 | FlagTest.Flag2 ))!=FlagTest.None){ //.. } </code></pre>
6,143
<p>Is there support in Linq to SQL for submitting changes to a single object? The SubmitChanges method sends all of the changes to the database, but what if I'm associating with an errorlog table and only want to save the records going into the errorlog without submitting all of the changes to my other tables?</p> <p...
<p><a href="http://west-wind.com/weblog/posts/246222.aspx" rel="nofollow noreferrer">Here</a> is a good article about how to manage the lifetime of the Linq to SQL DataContext, might help you...</p>
<p>You could refresh the changed entity collections using the Refresh() method on the DataContext with RefreshMode.OverwriteCurrentValues, then update your ActionError and submit changes.</p> <p>FWIW. I haven't done this, but looking at the docs this is what I would try.</p>
24,235
<p>How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code?</p> <p>Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would need to be compiled (and linked in) too.</p> <p>Also, yo...
<p>Try <a href="https://shedskin.readthedocs.io/en/latest/" rel="noreferrer">ShedSkin</a> Python-to-C++ compiler, but it is far from perfect. Also there is Psyco - Python JIT if only speedup is needed. But IMHO this is not worth the effort. For speed-critical parts of code best solution would be to write them as C/C++ ...
<p><a href="http://psyco.sourceforge.net/" rel="nofollow noreferrer">Psyco</a> is a kind of just-in-time (JIT) compiler: dynamic compiler for Python, runs code 2-100 times faster, but it needs much memory.</p> <p>In short: it run your existing Python software much faster, with no change in your source but it doesn't c...
16,775
<p>I'm new to CakePHP but I've been though their FAQs and guides to no avail. This is so simple that I just must not be thinking straight:</p> <p>How can I access a parameter sent through the URL within my view files? </p> <p>Example: <a href="http://example.com/view/6" rel="nofollow noreferrer">http://example.com/v...
<p>Parameters can be retrieved like this</p> <pre><code>$this-&gt;params['pass'] </code></pre> <p>Returns an array (numerically indexed) of URL parameters after the Action.</p> <pre><code>// URL: /posts/view/12/print/narrow Array ( [0] =&gt; 12 [1] =&gt; print [2] =&gt; narrow ) </code></pre>
<p>Use the code below in the view file :</p> <pre><code>$url=Router::url($this-&gt;here, true); $url_arr=explode("/",$url); </code></pre> <p>To see the content of <code>$url</code> been exploded simply print it using pr() as below :</p> <pre><code>pr($url_arr); </code></pre> <p>It will print associative array, thus...
29,081
<p>I’m listening to the Hanselminutes Podcast; "StackOverflow uses ASP.NET MVC - Jeff Atwood and his technical team". During the course of the Podcast they are speaking about SQL server and say something along the lines of 'The days of the Stored Procedure are over'. </p> <p>Now I'm not a DBA but this has taken me a b...
<p>On modern systems, parameterized queries are compiled and cached at the server, so they're just as fast as a stored procedure. They have most of the same security features as well.</p> <p>For databases that serve a single application, it makes more sense to have the query logic there at the relevant location in the...
<p>Bah!</p> <p>ORM, SPs, View, Magic Wands, or whatever.</p> <p>Each "tool" has its place in your belt, use the tools you have wisely. </p> <p>The only thing that has "changed" ( really improved ) is that some ORMs have nice caching tools already baked in and MySql and Sql 2005+ can handle dynamic or ad hoc query/e...
28,731
<p>I've written a helpdesk monitor application that is designed to sit on a big plasma screen in a support department, the application has 5 views that it revolves around, the content of most of those screens is different, but they have some common components, being one silverlight control and a css background image.</...
<p>Check the documentation for the plasma screen, I did hear that many of them countered burn in by running colour flashes at some points and it is not as big a problem with modern plasma screens.</p> <p>From what I've heard, this is a common complaint because of the annoying channel logos in the corner of screens so ...
<p>I think the risk of screen burn is much smaller than it used to be. </p> <p>And why even bother if the screen will only be used to display the same view all the time? If the same image is kept in place all the time, it doesn't really matter if it gets burnt into the screen or not :-)</p> <p>If you still would like...
39,716
<p>Are there any codes that allow for numerical formatting of data when using string.format?</p>
<p>Loads, stick <code>string.Format</code> into Google :-)</p> <p>A quite good tutorial is at <a href="http://web.archive.org/web/20150303084355/http://idunno.org:80/archive/2004/07/14/122.aspx" rel="nofollow noreferrer">iduno</a></p>
<p>As Keith said above. The most common one I use is currency:</p> <pre><code>String.Format("{0:c}", 12000); </code></pre> <p>Which would output £12,000.00</p>
3,011
<p>Let's say you have several maintenance branches for existing releases of your software. Some developers are making direct changes in the maintenance branches, and merging periodically into the trunk. Now comes an extensive refactoring in the trunk codeline, scheduled for an upcoming major release. But this makes the...
<p>I would consider it the responsibility of the branch maintenance developer to merge the appropriate change into the current state of the trunk. There are several possibilities:</p> <ol> <li>The code in the trunk has not changed and the patch applies without conflict.</li> <li>The code in the trunk has changed and t...
<p>I can only echo what others have said, while stressing the real pain in the a$$ that patch queues can become.</p> <p>If you have a predefined (and iron clad) merge window, you should only have two weeks of hell to deal with.</p>
30,312
<p>Is there a way to make a Radio Button enabled/disabled (not checked/unchecked) via CSS? </p> <p>I've need to toggle some radio buttons on the client so that the values can be read on the server, but setting the 'enabled' property to 'false' then changing this on the client via javascript seems to prevent me from po...
<p>Disabled is a html attribute, not a css attribute.</p> <p>Why can't you just use some jQuery</p> <pre><code>$('#radiobuttonname').attr('disabled', 'true'); </code></pre> <p>or plain old javascript</p> <pre><code>document.getElementById(id).disabled = true; </code></pre>
<p>if you look at the html generated by asp.net for a disabled radio button, you'll see that the button is embedded in a span tag, and the disabled attribute of the span is set to true. perhaps javascript to target an enclosing span will do the trick for you</p>
16,169
<p>In a asp.net web application, I want to write to a file. This function will first get data from the database, and then write out the flat file.</p> <p>What can I do to make sure only 1 write occurs, and once the write occurrs, the other threads that maybe want to write to the file don't since the write took place....
<p>Synchronize your writing code to lock on a shared object so that only one thread gets inside the block. Others wait till the current one exits.</p> <pre><code>lock(this) { // perform the write. } </code></pre> <p>Update: I assumed that you have a shared object. If these are different processes on the same machin...
<p>I'm not convinced that .NET's locking is applicable to different processes. Moreover, lock(this) will only exclude other threads that are running the method on the same instance of "this" - so other threads even in the same process could run at once on different instances.</p> <p>Assuming all your processes are run...
11,912
<p>I'm working on an app that needs to intercept when a program tries to connect to an specified IP address and redirects it to another IP.</p> <p>Is this possible?</p> <p>I'm using .net for this.</p> <p>thanks!</p>
<p>Your best bet is to use <a href="http://www.codeplex.com/easyhook" rel="nofollow noreferrer">EasyHook project</a> to hook the <a href="http://msdn.microsoft.com/en-us/library/ms737625(VS.85).aspx" rel="nofollow noreferrer">connect function</a>.</p>
<p>It might not fit the bill, but you could use the "hosts" file. ("hosts" file will only work for this purpose if the program is not connecting by IP address, but a host name)</p>
45,055
<p>MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class?</p> <p>Some people might have forgotten that:</p> <ol> <li><em>structs</em> can have methods.</li> <li><em>structs</em> cannot be inherited.</li> </ol> <p>I understand t...
<p>MSDN has the answer: <a href="http://msdn.microsoft.com/en-us/library/ms229017.aspx" rel="noreferrer">Choosing Between Classes and Structures</a>.</p> <p>Basically, that page gives you a 4-item checklist and says to use a class unless your type meets all of the criteria. </p> <blockquote> <p>Do not define a st...
<p>I think the best answer is simply to use struct when what you need is a collection of properties, class when it's a collection of properties AND behaviors.</p>
11,112
<p>In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project?</p>
<p>From <a href="http://msdn.microsoft.com/en-us/library/aa300858(VS.71).aspx" rel="nofollow noreferrer">MSDN</a></p> <p>The Find object allows you to search for and replace text in places of the environment that support such operations, such as the Code editor. </p> <p>It is intended primarily for macro recording pu...
<p>You would need to use reflection and it would be complicated.</p> <p>Why are you doing this programmaticly? You know that Visual Studio has a "Find all References" feature that can do this for you.</p>
16,558
<p>I have a bunch of *.TBC files from a very old application that runs in MS-DOS called TURBOLAB. Anyone know which DB System use files with a TBC extension. </p> <p>I've tried renaming the files to *.dbf to check if they are dBase files with no luck.</p> <p>Any idea?</p>
<p>Judging by the application and era (old MS-DOS) *.tbc is probably a fixed length binary record format written by the application's developers.</p> <p>Try opening up the file in a text editor like TextPad first and if you can read the contents, if so I have a fixed length text file reader that you can adapt to your ...
<p>I Googled this: <a href="http://www.adeptscience.co.uk/products/dataanal/flexpro/import.html" rel="nofollow noreferrer">FlexPro</a>. I hope it helps. Sounds pricey, I hope your data is worth it.</p>
31,338
<p><strong>EDIT:</strong> I also have access to <a href="http://www.exslt.org/" rel="nofollow noreferrer">ESXLT</a> functions.</p> <p>I have two node sets of string tokens. One set contains values like these:</p> <pre><code>/Geography/North America/California/San Francisco /Geography/Asia/Japan/Tokyo/Shinjuku </code>...
<p>This:</p> <pre><code>&lt;xsl:variable name="matches" select="$set1[starts-with(., $set2)]"/&gt; </code></pre> <p>will set <code>$matches</code> to a node-set containing every node in <code>$set1</code> whose text value starts with the text value of a node in $set2. That's what you're looking for, right?</p> <p><...
<p>I guess I couldn't make the XPath above work. I started with the following XML doc to initialize the two nodesets:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;sets&gt; &lt;set&gt; &lt;text&gt;/Geography/North America/California/San Francisco&lt;/text&gt; &lt;text&gt;/Geography/Asia/Japan/Tokyo/Shinjuk...
33,928
<p>When I've printed an object I've had to choose between high resolution and quick prints. What techniques or technologies can I use or deploy to speed up my high resolution prints?</p>
<p>You could experiment with slicing. For example, you might not need high resolution all over the object, but you can speed up some straight parts by using greater layer high there. See a <a href="http://manual.slic3r.org/expert-mode/variable-layer-height">part of Slic3r manual</a> about such thing.</p> <p>It is also...
<p>For FDM technologies in general with a single extruder, slicing modifications is your only options. However there will be a trade off between quality and speed. For ABS, changing to a machine with a enclosed build (such as a zortrax) chamber may help and a heated build chamber (Stratasys machine) will help the qual...
82
<p>Someone I know wants to use <a href="https://web.archive.org/web/20211020134116/https://www.4guysfromrolla.com/webtech/080101-1.shtml" rel="nofollow noreferrer">diconnected recordsets</a> in an application. To me it sounds like if I have a ORM tool there would really be no need to even touch disconnected recordsets....
<p>A fabricated ADO recordset can be a good choice of container object for data, as an alternative to a VBA Type (struct), Collection, Dictionary, etc i.e. strongly data typed nullable fields** with built-in support for filtering, sorting, searching, output to formatted text/xml/array, paging , cloning, etc. A fabricat...
<p>I'd consider using a recordset in small "assemble and forget" applications or when you have simple reporting needs like read-only grid views.</p> <p>That includes any application where it feels like the quickest thing you can do, and you don't see a reason it will change later on. </p> <p>However, if you are going...
47,402
<p>Why does the Ultimaker 3D Printer has a Heater + Heater transfer plate (aluminium) + Glass?</p> <p>I wonder why a glass plate, and if is possible to remove the glass and print directly in the aluminium plate adjusting the heating.</p> <p><a href="https://ultimaker.com/en/products/ultimaker-3" rel="nofollow norefer...
<p>Printing directly onto aluminum is something I've never seen before, likely due to the fact that PLA (and other materials) do not adhere reliably to aluminum. Instead, many opt to use blue tape, kapton tape, PEI, buildtak/commercial build surface, or an additional build surface, such as glass. When heated, clean gla...
<p>Printing directly onto aluminum is something I've never seen before, likely due to the fact that PLA (and other materials) do not adhere reliably to aluminum. Instead, many opt to use blue tape, kapton tape, PEI, buildtak/commercial build surface, or an additional build surface, such as glass. When heated, clean gla...
562
<p>In have a many-to-many linking table and I'm trying to set up two foreign keys on it. I run these two statements:</p> <pre><code>ALTER TABLE address_list_memberships ADD CONSTRAINT fk_address_list_memberships_address_id FOREIGN KEY index_address_id (address_id) REFERENCES addresses (id); ALTER TABLE address_list_m...
<p>I just tried it and it works fine for me. I copied and pasted the <code>ALTER</code> statements you wrote and here is what I get:</p> <pre><code>mysql&gt; show create table address_list_memberships; CREATE TABLE `address_list_memberships` ( `address_id` bigint(20) unsigned NOT NULL, `list_id` bigint(20) unsig...
<p>It doesn't really matter. You still have an index on list_id. MySQL requires any foreign key constraint to also have an index on the referencing fields. Since both index_list_id and fk_address_list_memberships_list_id are built on list_id, MySQL probably sees this and uses index_list_id as the index, renaming it to ...
40,797
<p>How can I give a general rule that includes all the expressions below? E.g one expression, another one for sub and one for mult. I need to use recursion but i got confused...</p> <pre><code>simplify :: Expr-&gt;Expr simplify (Mult (Const 0)(Var"x")) = Const 0 simplify (Mult (Var "x") (Const 0)) = Const 0 simpli...
<p>First up: I know reasonably little about Haskell, and my total time spent programming the language is no more than 8 hours spread over 5 years or so, though I have read plenty about the language. Thus, forgive my no doubt horrible style.</p> <p>I tackled this problem since it looked like an easy way to get into a l...
<p>The recursion comes in when you need to deal with nested expressions. For instance, how do you simply (Plus (Plus 2 3) (Plus 4 5))?</p> <p>One approach is to break it into two functions. Move the one level logic (which you show above) into its own function. The main simplify function might have a rule similar to...
41,999
<p>Actually <a href="https://stackoverflow.com/questions/564/what-is-the-difference-between-an-int-and-an-integer-in-javac">here</a> is a similar topic with little practical value. As far as I understand, primitives perform better and should be used everywhere except for the cases where Object-related features (e.g. <c...
<p>Do not forget that, since creating a new wrapper for every boxing occurrence is quite expensive, especially considering it usually being used at a single scope of a method, <a href="http://chaoticjava.com/posts/autoboxing-tips/" rel="nofollow noreferrer">Autoboxing</a> uses a pool of common wrappers.</p> <p>This is...
<p>I would say you should be worried about using primitives over wrappers only when you profile your application and see that the autoboxing is a performance or memory issue. In my experience memory becomes an issue before CPU cycles when talking about primitives vs wrapping objects.</p>
29,646
<p>Just curious here: is it possible to invoke a Windows Blue Screen of Death using .net managed code under Windows XP/Vista? And if it is possible, what could the example code be?</p> <p>Just for the record, this is not for any malicious purpose, I am just wondering what kind of code it would take to actually kill th...
<p>The keyboard thing is probably a good option, but if you need to do it by code, continue reading...</p> <p>You don't really need anything to barf, per se, all you need to do is find the KeBugCheck(Ex) function and invoke that.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms801640.aspx" rel="noreferrer">...
<p>Unfortunately, I know how to do this as a .NET service on our server was causing a blue screen. (Note: Windows Server 2008 R2, not XP/Vista).</p> <p>I could hardly believe a .NET program was the culprit, but it was. Furthermore, I've just replicated the BSOD in a virtual machine.</p> <p>The offending code, causes ...
35,089
<p>When first approaching a project is best to step back and think through everything or just dive in and start coding and polish at a later date? Essentially, do you design first or try to rapidly prototype?</p> <p>I have been burned by both methods, sometimes I try and think everything through but when I actually ge...
<p><strong>Go incrementally and iteratively.</strong></p> <p>Design a bit, implement a bit. </p> <p>Starting with a design you can suffer from a <em>tunnel effect</em> where you cannot have any real feedback before you actually implement something. </p> <p>Starting without design, you can take decisions you'll regre...
<p>Design first, unless you're willing to take the risk of throwing out all the work put into your prototype when you find it can't do what you need it to do. At a minimum, you should make some high level designs for your project that can help you make some decisions about how you're going to build your prototype so th...
36,109
<p>Has anyone implemented sorting a list of domain names?</p> <p>I have seen some applications sort them as flat strings, but the problem is that you end up scattering all the related hosts in a domain:</p> <p>a.me.com a.you.com b.me.com b.you.com</p> <p>So, the basic logic I came up with reverse the order of the la...
<p>I don't know about Java and Javascript in particular, but many languages provide some sort of array data structure that can be lexicographically sorted. So, like you said, convert "a.example.com" into {"com", "example", "a"}, and just let the default sorting rules run. A lexicographical sort will then do exactly w...
<p>You could split the domain names into individual fields and do successive sorts. You can create a domain name object to have three fields and create a list of domain names to sort. For each of the three fields, do a sort. At the end, you have a sort list of domain names with related hosts together.</p>
44,543
<p>I want my S60 Application to utilize the Stomp protocol.</p> <p>Although it would be fairly simple to implement myself (but nothing is ever as simple as I hope with Symbian) - I am wondering if anyone has any experience in this already.</p> <p>It seems a Stomp library exists in almost every other language already....
<p>In case this is still relevant - I've just finished my implementation of a STOMP client for Symbian, fully using the Active Scheduler framework. We're going to release it as opensource once I get something set up on Google Code.</p> <p>As Adam says - the implementation needed to be purely within the Symbian framewo...
<p>Maybe <a href="http://www.martynov.org/2009/03/stomp-messaging-for-non-java.html" rel="nofollow noreferrer">Stomp messaging for non-Java programmers</a> is of any help.</p>
46,362
<p>I know what I'm looking for is probably a security hole, but since I managed to do it in Oracle and SQL Server, I'll give it a shot:</p> <p>I'm looking for a way to execute a shell command from a SQL script on MySQL. It is possible to create and use a new stored procedure if necessary.</p> <p>Notice: I'm not looki...
<p>You might want to consider writing your scripts in a more featureful scripting language, like Perl, Python, PHP, or Ruby. All of these languages have libraries to run SQL queries.</p> <p>There is no built-in method in the stored procedure language for running shell commands. This is considered a bad idea, not onl...
<p>According to <a href="http://forums.mysql.com/read.php?10,198595,198899#msg-198899" rel="nofollow noreferrer">this post</a> at the forums.mysql.com, the solution is to use the <a href="http://forge.mysql.com/wiki/MySQL_Proxy" rel="nofollow noreferrer">MySQL_Proxy</a>. </p>
36,938
<p>I want to port few C/C++ libraries to Android, how feasible it would be</p> <p>e.g. OpenSSL can it be ported or suppose an application which depends on OpenSSL, what is the best way to port it to Android when Android I think itself has libssl.so</p> <p>what are the tools available e.g. Scratchbox, any alternatives...
<p>The <a href="http://groups.google.com/group/android-internals" rel="nofollow noreferrer">android internals wiki</a> is a good starting point, and includes <a href="http://benno.id.au/blog/2007/11/13/android-native-apps" rel="nofollow noreferrer">a link</a> explaining how to compile simple native applications.</p> <...
<p>There are obviously a good deal of enthusiasts who are working on improving the development environment for Android. But nothing is close enough to production quality yet.</p> <p>Dalvik and its java-based environment is the only thing that can be used right now.</p> <p>Hopefully, that situation will progressively ...
45,819
<p>I have a C# class the returns a List, using System.Collections.Generic Lists not F# List</p> <p>I want to iterate though the list to find a object or not find it. Here is how I would do it in C#. How would I accomplish the similar thing in F#</p> <pre><code>foreach (AperioCaseObj caseObj in CaseList) { if (...
<p>See this example for iterating an integer generic list:</p> <pre><code>#light open System.Collections.Generic let genList = new List&lt;int&gt;() genList.Add(1) genList.Add(2) genList.Add(3) for x in genList do printf "%d" x </code></pre>
<p>Using tryfind to match against a field in a record:</p> <pre><code>type foo = { id : int; value : string; } let foos = [{id=1; value="one"}; {id=2; value="two"}; {id=3; value="three"} ] // This will return Some foo List.tryfind (fun f -&gt; f.id = 2) foos // This will return None List.tryfind (fun f -&gt...
33,446
<p>It seems Scrum and Agile tests/assertions are becoming popular this year. For example, <a href="http://www.cedur.se/nokia_test2.html" rel="nofollow noreferrer">Nokia test for Scrum</a>. <a href="http://www.targetprocess.com/blog/2008/10/are-we-agile-yet-grrrrr.html" rel="nofollow noreferrer">I don't think it is a go...
<p>On the one hand, there are more and more people that claim they are agile, so such a test allows to sort out those in the line of "we're doing XP, we do not comment our code". </p> <p>But how can we be sure people will understand the question the right way and not answer "well, we have iterations. We often have to ...
<p>I just quickly took the test and found that the questions were good questions to ask anyone who claims to be doing Scrum. I'd also ask questions such as:</p> <ul> <li>Do you have an automated build process?</li> <li>How often does it run?</li> <li>What happens when the build breaks?</li> </ul> <p>OTOH, a test like...
28,540