instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I’ve just found out that the execution plan performance between the following two select statements are massively different:</p> <pre><code>select * from your_large_table where LEFT(some_string_field, 4) = '2505' select * from your_large_table where some_string_field like '2505%' </code></pre> <p>The execution pl...
<p>More generally speaking, you should never use a function on the LEFT side of a WHERE clause in a query. If you do, SQL won't use an index--it has to evaluate the function for every row of the table. The goal is to make sure that your where clause is "<a href="http://en.wikipedia.org/wiki/Sargable" rel="noreferrer">S...
<p>As @BradC mentioned, you shouldn't use functions in a WHERE clause if you have indexes and want to take advantage of them.</p> <p>If you read the section entitled "Use LIKE instead of LEFT() or SUBSTRING() in WHERE clauses when Indexes are present" <a href="http://cc.davelozinski.com/sql/optimizing-sql-strategies" ...
49,880
<p>I want to develop JavaScript on my Windows machine. Do you know a browser where I can turn off <em>Same Origin Policy</em> so I can develop locally? Firefox would be optimal.</p> <p>Or if you know a proxy I could use for a SOAP/WSDL site it would be great too.</p> <p>I am trying to work with the <a href="http://ww...
<p><strong>UPDATE 6/2012: This used to work at the time of the writing, but obviously no more. Sorry.</strong></p> <p>In Firefox (might apply to other Gecko-based browsers as well) you can use the following JavaScript snippet to allow cross-domain calls:</p> <pre><code>if (navigator.userAgent.indexOf("Firefox") != -1...
<p>You can also redirect a local port to the remote server and port via ssh.</p>
42,804
<p>I'm developing an application with a feature that allows users to mark places on a map (events, locations etc.). I'm not allowed to use the basic google maps api because it requires pages that implement the maps to be publicly available. Does anyone know of any alternative with rich layers (including Europe, Asia, e...
<p>Have you checked out <a href="http://www.openstreetmap.org/" rel="nofollow noreferrer">OpenStreetMap</a>?</p>
<p>For a private page you might well find it more cost-effective to license some proper maps. Might not be that expensive for a limited userbase.</p> <p>Do you actually need maps as such, how about some of the other geolocation sources like gazetteers, etc. List of some sources <a href="http://wiki.openstreetmap.org/w...
49,209
<p>Are there any VS.NET plugins that will format a selection of code for printing or emailing and is also free?</p>
<p>Have you checked the inbuilt formatting provided by VS? Select code and enter key chord Ctrl+K, Ctrl+F.</p> <p>Or goto (menu)Edit->Advanced->FormatSelection or Edit->Advanced->FormatDocument</p>
<p>Use some kind of tabs-to-spaces function, and make sure the print or email uses a <code>monospaced</code> (aka. typewriter or console) font.</p> <p>I'm pretty sure VisualStudio had a (little well hidden) function to convert indenting from tabs to spaces and vice versa.</p> <p>I'm normally using <a href="http://www...
44,289
<p>My app needs to build a buffer from all the selected cells on a worksheet. I have it working correctly when the selected cells are all one contiguous group, but if the user selects a group of cells, then holds down the control key and selects other cells that are not contiguous to the first set of cells, the Worksh...
<p>The Address property returns selected ranges (separated by comma)</p> <p>When I select B4 to D10 and then H9 to 016 (by holding ctrl), Selection.Address returns $B$4:$D$10,$H$9:$O$16.</p>
<p>The Address property returns selected ranges (separated by comma)</p> <p>When I select B4 to D10 and then H9 to 016 (by holding ctrl), Selection.Address returns $B$4:$D$10,$H$9:$O$16.</p>
43,110
<p>I'm trying to run a 3d array but the code just crashes in windows when i run it, here's my code;</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main(){ int myArray[10][10][10]; for (int i = 0; i &lt;= 9; ++i){ for (int t = 0; t &lt;=9; ++t){ for (int x ...
<p>You twice have the line</p> <pre><code>for (int x = 0; x &lt;= 9; ++t){ </code></pre> <p>when you mean</p> <pre><code>for (int x = 0; x &lt;= 9; ++x){ </code></pre> <p>Classic copy-and-paste error.</p> <p>BTW, if you run this in a debugger and look at the values of the variables, it's pretty easy to see what's ...
<p>David's answer is correct.</p> <p>Incidentally, convention is to use i,j,and k for nested iterator indices, and also to use &lt; array_length rather than &lt;= array_length -1 as the terminator.</p> <p>If you do that, then you can make the array size a constant and get rid of some magic numbers.</p> <p>Also, an a...
47,042
<p>This UpdatePanel is contained by an UserControl. When the LinkButton is pressed arow should be added in another GridView. When an user is logged in this control is working well. The problems appears when an user is not logged in and try to push that button. No event triggers. Someone suggested me to give a permissio...
<p>I solved the problem in a tricky way. I deleted the LinkButton and before TemplateField I put a ButtonField and all is working fine. Now the code looks like:</p> <pre><code> &lt;Columns&gt; &lt;asp:ButtonField Text="Add" CommandName="Select" /&gt; &lt;asp:TemplateField&gt; ........
<p>Don't forget to give the webresource.axd enough rights in the web.config?</p>
47,045
<p>I could have sworn I read somewhere that when printing with TPU to make sure the part cooling fan is blowing. But I just did a quick Googling and couldn't find anything stating such on Matter Hackers or All3dp.</p> <p>I currently don't have a part cooling fan attached (waiting for square nuts to come in). I've been...
<p>You'll probably be fine printing TPU with no fan. I just started printing with TPU, and did a lot of test prints to find out what settings work. Fan made little difference. With hotend at 230 °C, which I started out with, 0-20% fan was fine. I eventually increased temperature to 250 °C, which made extrusion more con...
<p>Sharing fan percentages like in <a href="/a/11852/">this answer</a> is only helpful if you use the same printer model, cooling fan and cooling duct. As there are many 3D printers and many cooling fans, ducts and solutions, this cannot be readily adopted to every 3D printer.</p> <p>So, in such a case I would rely on...
1,564
<p>Following Alan Green's "<a href="http://www.bright-green.com/blog/2003_02_25/naming_java_classes_without_a.html" rel="nofollow noreferrer">Naming Java classes without Manager</a>" I've started hunting *Manager classes in my own code.</p> <p>How would you rename the following class? ServiceLoader, maybe? but it does...
<p>Does the Manager part add anything? Why not just 'Service'.</p> <p>edit:</p> <p>To clarify, it doesn't seem like this manages, or controls, or does anything to, a service. It reads like it is the service. </p> <p>If it was doing anything to, or for, a service, then I'd expect to be able to get the service object ...
<ul> <li>ServiceMonitor?</li> <li>ServiceController?</li> </ul>
49,971
<p>I would like to declare a dropdown box in a view in an ASP.NET MVC application, for letting the user select a lookup value. I know how to declare plain text boxes but is there an official helper for declaring dropdown boxes (date time pickers and the rest)?.</p> <p>I also don't know what structure I should pass to ...
<p>If you have a table of Product Types with description and a value ( id ) that you want to map to your dropdown then do the following inside your action in the controller.</p> <pre><code>//Lets assume you retrieve your product types somehow here ViewData["ProductTypes"] = new List&lt;ProductType&gt;(); </code></pre...
<p>You might check out this blog entry by Scott Guthrie about <a href="http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-mvc-framework-part-4-handling-form-edit-and-post-scenarios.aspx" rel="nofollow noreferrer">Handling Form Edit Post Scenarios</a>. He uses a drop down list in an example of his.</p> <p>You ca...
23,948
<p>This is a low-level systems question.</p> <p>I need to mix 32 bit and 16 bit code because I'm trying to return to real-mode from protected mode. As a bit of background information, my code is doing this just after GRUB boots so I don't have any pesky operating system to tell me what I can and can't do.</p> <p>Anyw...
<p>The problem turned out to be that I wasn't setting up my descriptor tables correctly. I had one bit flipped wrong so instead of going to 16-bit mode I was going to 32-bit mode (with segments that happened to have a limit of one meg). </p> <p>Thanks for the suggestions!</p> <p>Terry</p>
<p>You weren't kidding about this being low-level!</p> <p>Have you checked the generated opcodes / operands to make sure that nasm is honoring your BITS directives correctly? Also check to make sure the jump targets are correct - maybe nasm is using the wrong offsets.</p> <p>If it's not a bug in nasm, maybe there is ...
3,894
<p>I'm just learning about SVG, and it seems great but I'm not sure about browser support - have people successfully got around this, or is it still too early?</p>
<p><a href="http://raphaeljs.com/" rel="noreferrer">Raphael</a> is a cross-browser vector graphics library which might be worth a look.</p>
<p>I'd say your best bet is to create the image in whatever format you're most comfortable with, then convert it to SVG with something like ImageMagick. You could write PostScript by hand or with a library, or directly create the image from simple text/shape primitives using the ImageMagick API. There's pretty good d...
22,887
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/200545/attempted-sql-injection-attack-what-are-they-trying-to-do">Attempted SQL injection attack - what are they trying to do?</a> </p> </blockquote> <p>I have seen this SQL injection attempt on my site many ti...
<p>Note: my first explanation was incorrect because I didn't actually read through the whole thing...</p> <p>here's what that translates to. It searches your database for text or varchar columns (b.xtype in 99,35,231,167) and then injects a javascript file into all text columns in your database. A bit more malicious t...
<p>Further to Jimmy's post: you can also use a hex-ascii translator to get this:</p> <pre><code>DECLARE @T varchar(255)'@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name'b.name from sysobjects a'syscolumns b where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) OP...
48,324
<p>What is a fast way to select a random row from a large mysql table?</p> <p>I'm working in php, but I'm interested in any solution even if it's in another language.</p>
<p>Grab all the id's, pick a random one from it, and retrieve the full row.</p> <p>If you know the id's are sequential without holes, you can just grab the max and calculate a random id.</p> <p>If there are holes here and there but mostly sequential values, and you don't care about a slightly skewed randomness, grab ...
<h1>Quick and dirty method:</h1> <pre><code>SET @COUNTER=SELECT COUNT(*) FROM your_table; SELECT PrimaryKey FROM your_table LIMIT 1 OFFSET (RAND() * @COUNTER); </code></pre> <p>The complexity of the first query is O(1) for MyISAM tables.</p> <p>The second query accompanies a table full scan. Complexity = O(n)</p> <h1>...
25,961
<p>I tried printing from an STL file on the <em>QIDI TECHNOLOGY 3DP-QDA16-01 Dual Extruder Desktop 3D Printer QIDI TECH I</em>. They recommend using the MakerBot software with the <em>Replicator(Dual)</em> profile. The 3D print that I tried is messed up.</p> <p>The material used is <strong>PLA</strong>.</p> <p>Could ...
<p>Your print isn't cooling fast enough. With small, thin prints like this, PLA needs a fair bit of airflow to solidify before the next layer goes down. Your printer doesn't appear to have a proper print-cooling fan, so I have two suggestions:</p> <ul> <li>Print two or even three of the part at the same time, spaced a...
<p>I agree with <a href="https://3dprinting.stackexchange.com/questions/1511/irregular-3d-printed-part/1513#1513">RyanCarlyle</a> on this:</p> <blockquote> <p>Your print isn't cooling fast enough.</p> </blockquote> <p>Please regard <a href="https://3dprinting.stackexchange.com/questions/540/mushy-small-top-layers/5...
343
<p>How do I prevent code from executing in the SelectedValueChange event of a combobox when the combobox is being loaded for the first time? I need the code to execute when the user has selected a new value.</p>
<p>You have a few options.</p> <ol> <li><p>Rather than letting the designer hookup the event handler you can do it yourself after loading</p></li> <li><p>You can set a flag in your application for "loading" and put code inside your SelectedValueChange event to check !loading before continuing.</p></li> </ol> <p>Perso...
<p>I prefer the SelectedIndexChanged event as its behaviour seems to better model that of the underlying Win32 API making it predictable.</p> <p>Some of the more esoteric events offered by the controls simply do not model the behaviour that one would expect from their name.</p>
33,286
<p>I'm trying to do the following in infopath: I have to choose between 2 options (with bullets), and depending on this, if we choose Option1, I need to display a text field to enter more details, but if Option2 is chosen, I don't need this additional field.</p> <p>I'm not sure about how to enter a Rule to define this...
<p>In 2010, you do this with 'Rules' (changed from 2007). Open the Home tab in the ribbon, open Manage Rules from there. Then select your control, and add / edit rules in the rules pane for each control to achieve what you're trying to do.</p>
<p>In InfoPath 2013, you can: You can hide Controls on the basics of a condition using Formating Rules. <br> 1. Click on the control<br> 2. Add Rule<br> 3. Select Formatting<br> 4. Add Condition<br> 5. Check Hide Control<br> </p>
17,642
<p>In C#, how do I set the Identity of a Thread?</p> <p>For example, if I have Thread MyThread, which is already started, can I change MyThread's Identity?</p> <p>Or is this not possible?</p>
<p>You can set the Identity of a thread by creating a new Principal. You can use any Identity that inherits from <a href="https://msdn.microsoft.com/en-us/library/system.security.principal.iidentity(v=vs.110).aspx" rel="noreferrer">System.Security.Principal.IIdentity</a>, but you need a class that inherits from <a href...
<p>Yes, using <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx" rel="nofollow noreferrer">impersonation</a> literally</p> <pre><code>using (new Impersonation()) { // your elevated code } </code></pre> <p>and the class is as follows, for settings I use cas...
32,320
<p>I want to create a linked server in one sql server to another using the sp_addlinkedserver procedure. When i access the remote server I would like it to logon as me (i.e. using my windows account). How do I do this?</p>
<p>You can do this with the sp_addlinkedsrvlogin procedure:</p> <pre><code>EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'&lt;your linked server name&gt;', @useself=N'True', @locallogin=NULL, @rmtuser=NULL, @rmtpassword=NULL </code></pre> <p>This assumes you log in to the server on ...
<p>Use SQL Management Studio to see the properties for the linked server. There you will find your logon information</p>
44,234
<p>How do I turn a python program into an .egg file?</p>
<p><a href="http://peak.telecommunity.com/DevCenter/setuptools" rel="noreferrer">Setuptools</a> is the software that creates <a href="http://peak.telecommunity.com/DevCenter/PythonEggs" rel="noreferrer">.egg files</a>. It's an extension of the <a href="http://docs.python.org/lib/module-distutils.html" rel="noreferrer">...
<p>Python has its own package for creating distributions that is called distutils. However instead of using Python’s distutils’ setup function, we’re using setuptools’ setup. We’re also using setuptools’ find_packages function which will automatically look for any packages in the current directory and add them to the e...
7,161
<p>What type of stream I need to use to write a connect request message over a tcp socket, to jabber. I'mwriting a string with xml format. It should worked with the default socket stream or a dataoutputstream but it doesn't.</p>
<p>Use the <a href="http://www.igniterealtime.org/projects/smack/index.jsp" rel="nofollow noreferrer">Smack</a> client library to connect to a Jabber server, such as OpenFire. It is quite simple to use, you can connect and send/receive messages in a few lines of code.</p>
<p>Jabber is a pretty comprehensive protocol, so I don't think it's really analogous to opening a stream. On the other hand, it's a very well supported protocol, so you have your choice of libraries to help. Here is a link to the relevant information on <a href="http://www.jabber.org/web/Libraries#Java" rel="nofollow...
23,808
<p>I have an application that has Powershell 1 embedded into it, but we need to be able to use Powershell STAThreaded which is available in Powershell 2 CTP. Currently, System.Management.Automation is at 1.0.0.0. Does anyone know how to get Visual Studio to use the newer dll?</p>
<p>I'll look into it, but you realize that there is absolutely no guarantee that anything in the CTP will stay the way that it is right now? Most likely it will, but I wouldn't develop against it right now.</p> <p>EDIT: As a matter of fact this is a quote from the CTP download page:</p> <blockquote> <p><strong>This...
<p>I'm not sure if you can yet, to use powershell V1.0 you needed to download "Windows SDK for Windows Server 2008 and .NET Framework 3.5" to get the dll file that you referenced. You would now need to find a SDK that has the dll for the CPT file(Maybe the CPT includes the dll, I think it's called System.Management.Au...
24,817
<p>.NET's <code>SslStream</code> class does not send the <code>close_notify</code> alert before closing the connection.</p> <p>How can I send the <code>close_notify</code> alert manually?</p>
<p>Thanks for this question. It pointed me into the right direction, that there is a bug in .Net, which I do not very often think about.</p> <p>I bumped into this problem during writing of my implementation of FTPS server and Filezilla (or GnuTLS probably) client was complaining "GnuTLS error -110 in gnutls_record_rec...
<p>For the record, SslStream at least in .NET 2.0 also doesn't appear to response to a close_notify from the other side. This means that calling OpenSSL's SSL_Shutdown() properly, i.e. twice - once to initiate the shutdown and again to wait for the response - will hang on the second call.</p>
29,420
<p>I have an array of 1000 or so entries, with examples below:</p> <pre><code>wickedweather liquidweather driveourtrucks gocompact slimprojector </code></pre> <p>I would like to be able to split these into their respective words, as:</p> <pre><code>wicked weather liquid weather drive our trucks go compact slim proje...
<p>Can a human do it?</p> <pre> farsidebag far sidebag farside bag far side bag </pre> <p>Not only do you have to use a dictionary, you might have to use a statistical approach to figure out what's most likely (or, god forbid, an actual HMM for your human language of choice...)</p> <p>For how to do statistics that m...
<p>I may get downmodded for this, but <strong>have the secretary do it</strong>.</p> <p>You'll spend more time on a dictionary solution than it would take to manually process. Further, you won't possibly have 100% confidence in the solution, so you'll still have to give it manual attention anyway.</p>
23,691
<p>I have the following problem using template instantiation [*]. </p> <p>file <strong>foo.h</strong></p> <pre><code>class Foo { public: template &lt;typename F&gt; void func(F f) private: int member_; }; </code></pre> <p>file <strong>foo.cc</strong></p> <pre><code>template &lt;typename F&gt; Foo::func...
<p>The answer to this is compiler dependent. Some versions of the Sun C++ compiler would handle this automatically by building a cache of template function implementations that would be shared across separate translation units. </p> <p>If you're using Visual C++, and any other compiler that can't do this, you may as w...
<p>I believe Earwicker is correct. The problem with explicitly instantiating the template member function func in this case is that the type returned by boost::bind is implementation dependent. It is <em>not</em> a boost::function. A boost::function can <em>contain</em> a boost:bind because it has a template assignment...
28,223
<p>We have a TIBCO EMS solution that uses built-in server failover in a 2-4 server environment. If the TIBCO admins fail-over services from one EMS server to another, connections are supposed to be transfered to the new server automatically at the EMS service level. For our C# applications using the EMS service, this...
<p><em>This post should sum up my current comments and explain my approach in more detail...</em></p> <p>The TIBCO 'ConnectionFactory' and 'Connection' types are heavyweight, thread-safe types. TIBCO suggests that you maintain the use of <strong>one</strong> ConnectionFactory (per server configured factory) and <stron...
<p>Client applications may receive notification of a failover by setting the tibco.tibjms.ft.switch.exception system property</p> <p>Perhaps the library needs that to work?</p>
22,765
<p>I'm not very experienced at using ASP.NET, but I've used built in membership providers for simple WebForms application, and I found them PITA when trying to extend the way they work (add/remove few fields and redo controls accordingly). Now I'm preparing for MVC (ASP.NET MVC or Monorail based) project, and I'm think...
<p>The Membership Provider in ASP.NET is very handy and extensible. It's simple to use the "off the shelf" features like Active Directory, SQL Server, and OpenLDAP. The main advantage is the ability to not reinvent the wheel. If your needs are more nuanced than that you can build your own provider by extending overr...
<p>Have you considered using ActiveDirectory for this? Or, perhaps, <a href="http://www.voxgratia.org/docs/windows_openldap.html" rel="nofollow noreferrer">OpenLDAP</a>? You can manage each user's groups, permissions, 'authority', and so on.</p>
20,378
<p>When I connect to a MySQL database using PDO, the way I need to connect is:</p> <pre><code>$pdoConnection = new PDO("mysql:host=hostname;dbname=databasename",user,password); </code></pre> <p>But, for PostgreSQL, the DSN is more standard (IMO):</p> <pre><code>$pdoConnection = new PDO("pgsql:host=hostname;dbname=da...
<p>As the person that implemented both, I can tell you that the reason is that by passing the string through as-is to postgres (and ODBC) the PDO driver code for those databases does not need to be updated as the underlying library adds new features.</p> <p>Since MySQL does not have its own connection string parsing c...
<p>This question is more than 10 years old, but I still end up here every time I create a new project that uses PDO... I'm writing my solution here so that I can save myself the trouble next time :P</p> <pre class="lang-php prettyprint-override"><code>class MyPDO extends PDO { public function __construct($dsn, $op...
29,378
<p>I have an object created in a host application and can access it remotely using remoting, is there any way I can test the connection to ensure it is still "alive"? Maybe an event I can use that fires if the remoting connection gets disconnected, or some property that can tell me the state of the remoting connection....
<p>I generally add another method to the remoting server MarshallByRef class, (I generally name it Ping(), as in: </p> <pre><code> public void Ping() {} </code></pre> <p>that does nothing, and returns nothing.. Then to "test" my connection, I call this method... If it throws a System.Net.Sockets.Exception, I have ...
<p>What benefit will you have to check the connection? Even if you ping it, it does not mean that in the next moment the connection will still be alive when you make your remoting call.</p> <p>Just try/catch you remoting calls and you will know.</p> <p>This type of checks are meaningless (net connection, file locking...
36,580
<p>In Win32, is there any way to get a unique cpu cycle count or something similar that would be uniform for multiple processes/languages/systems/etc.</p> <p>I'm creating some log files, but have to produce multiple logfiles because we're hosting the .NET runtime, and I'd like to avoid calling from one to the other to...
<p>You can use the <a href="http://en.wikipedia.org/wiki/RDTSC" rel="noreferrer">RDTSC</a> CPU instruction (assuming x86). This instruction gives the CPU cycle counter, but be aware that it will increase very quickly to its maximum value, and then reset to 0. As the Wikipedia article mentions, you might be better off u...
<p>Use the GetTickCount and add another counter as you merge the log files. Won't give you perfect sequence between the different log files, but it will at least keep all logs from each file in the correct order.</p>
16,815
<p>What is the window which is displayed when you first install Eclipse called, and how can I find it?</p>
<p>Help -> Welcome</p> <p>That thing?</p>
<p>Do you mean the splash screen?</p> <p>You can change it if you need (for example, your own RCP or a version of Eclipse like IBM's WSAD). Read about branding your application</p> <p>(eg.,<a href="http://www.eclipse.org/articles/Article-Branding/branding-your-application.html" rel="nofollow noreferrer">http://www.ec...
17,447
<p>How do I remove a USB drive using the Win32 API? I do a lot of work on embedded systems and on one of these I have to copy my programs on a USB stick and insert it into the target hardware.</p> <p>Since I mostly work on the console I don't like to use the mouse and click on the small task-bar icon hundred times a d...
<p>You can use the <code>CM_Request_Device_Eject()</code> function as well as some other possibilities. Consult the following projects and articles:</p> <p>DevEject: Straightforward. <a href="http://www.withopf.com/tools/deveject/" rel="nofollow noreferrer">http://www.withopf.com/tools/deveject/</a></p> <p>A useful Cod...
<pre class="lang-c prettyprint-override"><code>#include&lt;SetupAPI.h&gt; #include &lt;windows.h&gt; #include&lt;initguid.h&gt; #include &lt;newdev.h&gt; #include &lt;Cfgmgr32.h&gt; #pragma comment(lib, &quot;Cfgmgr32.lib&quot;) #pragma comment(lib, &quot;Setupapi.lib&quot;) #pragma comment(lib, &quot;Newdev.lib&quo...
11,120
<p>Is there an easy method to restore a minimized form to its previous state, either Normal or Maximized? I'm expecting the same functionality as clicking the taskbar (or right-clicking and choosing restore).</p> <p>So far, I have this, but if the form was previously maximized, it still comes back as a normal window....
<p>I use the following extension method:</p> <pre><code>using System.Runtime.InteropServices; namespace System.Windows.Forms { public static class Extensions { [DllImport( "user32.dll" )] private static extern int ShowWindow( IntPtr hWnd, uint Msg ); private const uint SW_RESTORE = 0x...
<p>The above code did not quite work for me in all situations</p> <p>After checking the flags I also have to check showcmd=3 and if so maximise else restore</p>
46,175
<p>Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend?</p>
<p>I got it working quite well with emacs 23. The only open issue is the focus not returning to the python buffer after sending the buffer to the iPython interpreter.</p> <p><a href="http://www.emacswiki.org/emacs/PythonMode#toc10" rel="nofollow noreferrer">http://www.emacswiki.org/emacs/PythonMode#toc10</a></p> <pre...
<p>I've used ipython with emacs cvs (which has been emacs 23 for some time now) in my python development. I, however, use it the other way around: I call emacs from the ipython promt through the $EDITOR environment variable. I tried it the other way around, but got a bit tired of all the process buffers and what not.</...
39,067
<p>I'm having a hard time coding understanding the format of the specifier and string functions.</p> <p>My aim is to use <code>%[]</code> to readin all characters and spaces and then use the strcpy function followed by the strcat function.</p> <p>So far i've managed to enter individual characters and print them out, ...
<p>I assume you want to read a string with a maximum length of 29 characters from the standard input up to the ENTER key.</p> <p>To do that you can use the following code:</p> <pre><code>char phrase[30]; printf("Enter a phrase: "); scanf("%29[^\n]", phrase); printf("You just entered: '%s'\n", phrase); </code></pre> ...
<p>words[i] is a single character in the string words and you are trying to store a string 's' in it.<br> To read a single character use %c.</p>
26,877
<p>I'm trying to write a wstring to file with ofstream in binary mode, but I think I'm doing something wrong. This is what I've tried:</p> <pre><code>ofstream outFile("test.txt", std::ios::out | std::ios::binary); wstring hello = L"hello"; outFile.write((char *) hello.c_str(), hello.length() * sizeof(wchar_t)); outFil...
<p>I suspect that sizeof(wchar_t) is 4 in your environment - i.e. it's writing out UTF-32/UCS-4 instead of UTF-16. That's certainly what the hex dump looks like.</p> <p>That's easy enough to test (just print out sizeof(wchar_t)) but I'm pretty sure it's what's going on.</p> <p>To go from a UTF-32 wstring to UTF-16 yo...
<p>You should look at the output file in a hex editor such as <a href="http://www.download.com/WinHex/3000-2352_4-10057691.html" rel="nofollow noreferrer">WinHex</a> so you can see the actual bits and bytes, to verify that the output is actually UTF-16. Post it here and let us know the result. That will tell us wheth...
25,449
<p>If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?</p> <p>I'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their cu...
<p>As python is in kind of an transition phase towards python 3 with breaking backward compatibility I don't think it is a good idea to go python 3 only. Based on the <a href="http://www.python.org/dev/peps/pep-3000/#timeline" rel="nofollow noreferrer">time line</a> there will be at least one or two following releases ...
<p>If the project is going to be mainstream and will be run on Linux the <strong>only</strong> sensible choise is 2.4 - just because it is a pain to get anything else installed as default on Enterprise Linuxes.</p> <p>In any case, any <em>modern</em> OS will/can have 2.4 or newer.</p>
6,938
<p>I want to commit a large amount of XML files which have been modified. However, within the directory that I want to recursively search through, there are many folders/files which have been added locally, these I do not want to commit.</p> <p>Is there a way to do this on the command line?</p> <p>Update: I should ha...
<p>Have you tried using an svn:ignore property on the local files/folders? But unless you svn add them, they won't get committed...</p> <p>typically --force will allow you to steal the file lock.</p>
<p><em>EDIT</em>: I'm rewriting this answer based on some of the information you updated in your questions.</p> <p>First, to forcibly unlock files it's not enough to simply --force the commit. You use --force with the unlock command and you have to use it on the exact URL that you want to unlock. Unfortunately, this i...
36,667
<p>I have a KML file overlay on an embedded Google Map using the GGeoXml object. I'd like to be able to access specific placemarks in the KML file from Javascript (for example to highlight a selected polygon on the map in response to user action). </p> <p>Ideally what I'd like to do is something like this (pseudo-code...
<p>Have you looked at <a href="http://www.dyasdesigns.com/geoxml/" rel="nofollow noreferrer">GeoXML</a>?</p>
<p>You can figure that out by simply looking into the object as follows:</p> <pre><code>GEvent.addListener(map, 'addoverlay', function(obj) { if (!obj) { alert("Cannot describe a null object"); return; } var str = ""; for ( var prop in obj) { str += prop + " = " + obj[prop]...
25,894
<p>Some of the controls I've created seem to default to the old Windows 95 theme, how do I prevent this? Here's an example of a button that does not retain the Operating System's native appearance (I'm using Vista as my development environment):</p> <pre><code>HWND button = CreateWindowEx(NULL, L"BUTTON", L"OK", WS_VI...
<p>I believe it has got nothing to do with your code, but you need to set up a proper <strong>manifest</strong> file to get the themed controls.</p> <p>Some info here: <a href="http://msdn.microsoft.com/en-us/library/aa374191(VS.85).aspx" rel="nofollow noreferrer">@msdn.com</a> and here: <a href="http://blogs.msdn.com...
<p>I believe it has got nothing to do with your code, but you need to set up a proper <strong>manifest</strong> file to get the themed controls.</p> <p>Some info here: <a href="http://msdn.microsoft.com/en-us/library/aa374191(VS.85).aspx" rel="nofollow noreferrer">@msdn.com</a> and here: <a href="http://blogs.msdn.com...
13,684
<p>Is there a .net equivalent to the C++ unexpected()/set_unexpected() functionality?</p> <hr> <p><strong>Edit:</strong> Sorry--I omitted some details previously:</p> <p>Language: C# 2.0</p> <p>I have some legacy apps that seem to be throwing some unhandled exception somewhere. I just want to put something in pla...
<p>There 3 possible scenarios for handling unhandled exceptions, based on the type of the application:</p> <ol> <li>For windows forms application, hook an event handler to <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx" rel="nofollow noreferrer">Application.Threa...
<p>These handlers should catch most unexpected exceptions in your mixed-mode application.</p> <pre><code>private delegate long UnhandledExceptionFilter(IntPtr exception); [DllImport("KERNEL32.DLL", SetLastError = true)] private static extern IntPtr SetUnhandledExceptionFilter([MarshalAs(UnmanagedType.FunctionPtr)] Un...
30,655
<pre><code>a:3:{i:0;i:4;i:1;i:3;i:2;i:2;} </code></pre> <p>Am I right to say that this is an array of size 3 where the key value pairs are <code>0-&gt;4</code>, <code>1-&gt;3</code>, and <code>2-&gt;2</code>?</p> <p>If so, I find this representation awfully confusing. At first, I thought it was a listing of values (o...
<p>Yes that's <code>array(4, 3, 2)</code></p> <p><code>a</code> for array, <code>i</code> for integer as key then value. You would have to count to get to a specific one, but PHP always deserialises the whole lot, so it has a count anyway.</p> <p>Edit: It's not too confusing when you get used to it, but it can be so...
<p>Why don't you use the <a href="http://uk.php.net/unserialize" rel="nofollow noreferrer">unserialize()</a> function to restore the data to how it was before?</p>
30,779
<p>At the moment I use the <a href="http://msdn.microsoft.com/en-us/library/ms646310.aspx" rel="nofollow noreferrer"><code>SendInput()</code></a> function but if you install a low level mouse hook the <code>LLMHF_INJECTED</code> is set indicating that the input was injected into the stream. Is there a way of sending mo...
<p>You want to create a complete graph with each student as a node, then randomly select edges and insert them into a unique set.</p> <p>On the next "pull", you want to do the same thing, except now if the edge has already been selected, discard and reselect.</p>
<p>I don't know if it's exactly what you asked for, but here my take on it in simple python. It spits out each unique grouping you can have for (in my example) 10 students.</p> <p>It is not the fastest thing there is i guess, but its very easy to implement and to follow.</p> <pre class="lang-py prettyprint-override">...
24,348
<p>I'm using Windows and I'm trying to get ANT to work.</p> <p>When I do an ant build from the command line, I get: <code>C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.</code></p> <p>I look into the <code>build.xml</code> file and I find: <code>appserver.home=${user.home}/apache-tomcat-6.0.14</code> (which I ...
<p>Change it to </p> <pre><code>appserver.home="C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0" </code></pre>
<p>In addition to escaping the windows directory separator also make sure that all paths that you type in should be with correct capitalisation, Windows is not case sensitive but case presrving, while Ant is case sensitive.</p>
7,913
<p>Is there any way to manually create fold points in code in Eclipse? I know how to enable folding and how to set the auto preferences, but i like being able to set my own fold points so I can ignore certain parts of my code. Think regions in VS.<br> I know there is in VS and NetBeans, but I cannot find a way to set ...
<p>I don't think Eclipse has built in manual folding, but I did use a previous version of the following plugin for it.</p> <p>Per the comment: The plugin has been recompiled for Eclipse 3.5 and is available at <a href="http://incubator.apache.org/isis/ide-support.html" rel="nofollow noreferrer">the Apache Isis site</a...
<p>No, eclipse does not have any option to provide manual folding plugins.</p>
25,256
<p>I'm trying to create a build script for my current project, which includes an Excel Add-in. The Add-in contains a VBProject with a file modGlobal with a variable version_Number. This number needs to be changed for every build. The exact steps:</p> <ol> <li>Open XLA document with Excel.</li> <li>Switch to VBEdit...
<p>An alternative way of handling versioning of an XLA file is to use a custom property in Document Properties. You can access and manipulate using COM as described here: <a href="http://support.microsoft.com/?kbid=224351" rel="nofollow noreferrer">http://support.microsoft.com/?kbid=224351</a>.</p> <p>Advantages of t...
<p>You can modify the code in the xla programmatically from within Excel. You will need a reference to the 'Microsoft Visual Basic for Applications Extensibility..' component.</p> <p>The examples on <a href="http://www.cpearson.com/excel/vbe.aspx" rel="nofollow noreferrer">Chip Pearson's excellent site</a> should get ...
11,228
<p>While testing a console app, I set the properties of the console window to be only 3 lines high. </p> <p>This change has somehow stuck, meaning that new console windows default to 3 lines high. If I create a new shortcut on the desktop, and point it to cmd.exe, the window that opens is 3 lines high. </p> <p>Of cou...
<p>Instead of using the Properties menu item - Use the defaults menu item.</p>
<p>They're stored in the Registry:</p> <pre><code>HKEY_CURRENT_USER\Console </code></pre>
36,687
<p>I am hacking up a tagging application for emacs. I have got a tag cloud/weighted list successfully displaying on a buffer, but i am running into a snag. I need to be able to properly word-wrap the buffer, but I haven't a clue where to start.</p> <p>The font I am using is a variable width font. On top of that, ea...
<p>You probably want to track <a href="http://www.gnu.org/software/emacs/elisp/html_node/Accessing-Events.html#index-posn_002dat_002dpoint-1273" rel="nofollow noreferrer"><code>posn-at-point</code></a> and <a href="http://www.gnu.org/software/emacs/elisp/html_node/Accessing-Events.html#index-posn_002dat_002dx_002dy-127...
<p>Can you use <code>(fill-paragraph)</code> or <code>(fill-region)</code> or similar? They wrap at a column, so don't have variable width font smarts, but if the fill column is low they might work for next to no effort. At least until you get a pixel-perfect solution sorted out :-) (maybe YAGNI...)</p>
31,485
<p>On my Centos server Python's mimetypes.guess_type("mobile.3gp") returns (None, None), instead of ('video/3gpp', None).</p> <p>Where does Python get the list of mimetypes from, and is it possible to add a missing type to the list?</p>
<p>On my system (Debian lenny) its in /usr/lib/python2.5/mimetypes.py in the list <code>knownfiles</code> you can supply your own files for the <code>init()</code> function.</p>
<p>In python 3.6 find that file: <code>C:\Users\Me\AppData\Local\Programs\Python\Python36\Lib\mimetypes.py</code></p> <p>Search for <code>mp3</code> (to get the list of extension). Add your file (it's intuitive)</p>
45,410
<p>I've been creating some applications with SQLExpress and find myself, scripting the database creation, tables and other entities etc. after application installation. Is this the normal way? </p> <p>Thanks</p>
<p>Making a template database and restoring that works only if you do not need to upgrade your database while keeping (most of) the data.</p> <p>Even though it is cumbersome, I actually use a few classes that check the database versions and run the necessary scripts (either installation of SQLExpress, installing the d...
<p>A faster way would be to make a backup of a template database, and restore that as part of the install. </p> <p>AFAIK, thats how MS and Orcl (especially) do it. </p>
30,818
<p>I generally use a manual process:</p> <ol> <li>Look at the page, figure out the semantic elements, and build the HTML</li> <li>Slice up the images I think I'll need</li> <li>Start writing CSS</li> <li>Tweak and repeat different steps as necessary</li> </ol> <p>Got a better approach, or a tool?</p>
<p>I have a fairly natural way of coding. The key is to treat the page like a document or an article. If you think of it like this the following becomes logically clear:</p> <ol> <li><p>The page title is a top level heading </p> <ul> <li>Whether you make the site title or actual page title the h1 is up to you - perso...
<p>Some of the designers i know, usually uses Illustrator to make the design elements.</p>
3,997
<p>I have a WPF application and I want to be able to save the output of the application to a PDF document, the item I want to save can be a Visual a Drawing or a FixedDocument (I can create it as any of those options, and it's easy to convert between them).</p> <p>Is there any library that can convert directly from WP...
<p>If you got your WPF visual tree rendered in to XPS then try this XPS to PDF converter <a href="http://nixps.blogspot.com/2008/04/convert-xps-to-pdf.html" rel="noreferrer">NIXPS</a>.</p>
<p>We have just released a new library that facilitates this: <a href="http://nixps.com/nipdf/index.html" rel="nofollow noreferrer">NiPDF v1.0</a></p> <p><a href="http://nixps.com/nipdf/example0001.html" rel="nofollow noreferrer">Here is a link</a> to an example on our site that converts WPF to PDF.</p> <p>It is a 10...
15,076
<p>Why does the PRINT statement in T-SQL seem to only sometimes work? What are the constraints on using it? It seems sometimes if a result set is generated, it becomes a null function, I assumed to prevent corrupting the resultset, but could it's output not go out in another result set, such as the row count?</p>
<p>So, if you have a statement something like the following, you're saying that you get no 'print' result?</p> <pre>select * from sysobjects PRINT 'Just selected * from sysobjects'</pre> <p>If you're using SQL Query Analyzer, you'll see that there are two tabs down at the bottom, one of which is "Messages" and that's...
<p>Do you have variables that are associated with these print statements been output? if so, I have found that if the variable has no value then the print statement will not be ouput.</p>
33,677
<p><strong>What "Hidden Features" of JavaScript do you think every programmer should know?</strong></p> <p>After having seen the excellent quality of the answers to the following questions I thought it was time to ask it for JavaScript.</p> <ul> <li><a href="https://stackoverflow.com/questions/954327/">Hidden Feature...
<p>You don't need to define any parameters for a function. You can just use the function's <code>arguments</code> array-like object.</p> <pre><code>function sum() { var retval = 0; for (var i = 0, len = arguments.length; i &lt; len; ++i) { retval += arguments[i]; } return retval; } sum(1, 2, 3...
<p>Well, it's not much of a feature, but it is very useful:</p> <p>Shows selectable and formatted alerts:</p> <pre><code>alert(prompt('',something.innerHTML )); </code></pre>
8,621
<p>In C# you can get the original error and trace the execution path (stack trace) using the inner exception that is passed up. I would like to know how this can be achieved using the error handling try/catch in sql server 2005 when an error occurs in a stored procedure nested 2 or 3 levels deep. </p> <p>I am hoping...
<p>The best way to handle this is using OUTPUT parameters and XML. The sample code below will demonstrate how and you can modify what you do with the XML in the TopProcedure to better handle your response to the error.</p> <pre><code>USE tempdb go CREATE PROCEDURE SubProcedure @RandomNumber int, @XMLErrors XML OUTPUT ...
<p>One way you could do this would be to create an in memory table and insert rows into it when you catch an exception. You would then re-raise the exception and the next function up the chain would then have a chance to handle the exception or also log the exception to the in memory table. It's nasty, but unfortunat...
11,363
<p>This should be easy, but I'm having a hard time finding the easiest solution.</p> <p>I need an <code>NSString</code> that is equal to another string concatenated with itself a given number of times.</p> <p>For a better explanation, consider the following python example:</p> <pre><code>&gt;&gt; original = "abc" "a...
<p>There is a method called <code>stringByPaddingToLength:withString:startingAtIndex:</code>:</p> <pre><code>[@"" stringByPaddingToLength:100 withString: @"abc" startingAtIndex:0] </code></pre> <p>Note that if you want 3 abc's, than use 9 (<code>3 * [@"abc" length]</code>) or create category like this:</p> <pre><cod...
<p>If you're using Cocoa in Python, then you can just do that, as PyObjC imbues <code>NSString</code> with all of the Python <code>unicode</code> class's abilities.</p> <p>Otherwise, there are two ways.</p> <p>One is to create an array with the same string in it <code>n</code> times, and use <code>componentsJoinedByS...
32,624
<p>I have a small to medium project that is in C++/CLI. I really hate the syntax extensions of C++/CLI and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other?</p> <p><strong>EDIT:</strong> When I said Managed c++ before I apparently meant c++/CLI</p>
<p>You can only translate Managed C++ code (and C++/CLI code) to C# if the C++ code is pure managed. If it is not -- i.e. if there is native code included in the sources -- tools like .NET Reflector won't be able to translate the code for you.</p> <p>If you do have native C++ code mixed in, then I'd recommend trying ...
<p>Such projects are often done in c++/cli because C# isn't really an elegant option for the task. e.g. if you have to interface with some native C++ libraries, or do very high performance stuff in low level C. So just make sure whoever chose c++/cli didn't have a good reason to do it before doing the switch.</p> <p>H...
9,953
<p>We are using Google Charts for render the chart images, but 500 requests/day became not enough. What PHP classes/frameworks are worth looking at?</p>
<p><a href="http://jpgraph.net/" rel="nofollow noreferrer">JpGraph</a> and <a href="http://graphpite.sourceforge.net/" rel="nofollow noreferrer">GraPHPite</a> are the most developed open-source packages available. I recommend GraPHPite in particular, it has a somewhat better API and produces better looking graphs.</p> ...
<p>While not a PHP solution, we're using <a href="http://www.amcharts.com/" rel="nofollow noreferrer">amCharts</a> for the graphs within our application. They're Flash based, but look fantastic and allow your users to zoom in to the graph further. Graphs are drawn simply by generating XML with your data.</p>
42,112
<p>I have a prusa i3 with Mendel firmware and a RAMPS board. Recently it has been randomly stopping during prints. The LCD screen will lock up, the print will stop, and the heating elements will turn off. Pressing the reset button on the RAMPS restarts the system and it works fine.</p> <p>In addition to stopping du...
<p>It could be several things.</p> <p>Your ramps board is overheating or has to much load on it. If you're not cooling the ramps board adding a fan may help the issue. </p> <p>I know Robo3D had this issue and started shipping with a fan to cool the ramps board.</p> <p>The ramps/arduino board could be faulty, the fir...
<p>I had the same thing, the printer was not heating the nozzle anymore after starting the print. I fixed this by reinstalling the firmware.</p> <p>It could also be that your stepper drivers are overheating. you can add a fan to cool them.</p> <p>The SD card could be bad, maybe try an other card or another .gcode fi...
257
<p>I'm trying to create a horizontal navigation bar in css with 5 evenly spaced links. The html hopefully will remain like this:</p> <pre><code>&lt;div id="footer"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="one.html"&gt;One&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="two.html"&gt;Two&lt;/a&gt;&lt;/li&gt; ...
<p>I've had this happen to me. Unfortunately it is caused by the browser taking the line breaks between the list items and rendering them as spaces. To fix, change your HTML to:</p> <pre><code>&lt;div id="footer"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="one.html"&gt;One&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="tw...
<pre><code>div#footer ul{ margin:0; padding:0; list-style:none; } div#footer li{ width:155px; float:left; display:block; } </code></pre> <p>This code positioned li horizontally while the spaces between them. If you want to adding space between li elements: </p> <pre><code>div#footer ...
34,842
<p>If I have the following code (this was written in .NET)</p> <pre><code>double i = 0.1 + 0.1 + 0.1; </code></pre> <p>Why doesn't <code>i</code> equal <code>0.3</code>?<br> Any ideas?</p>
<p>You need to read up on floating point numbers. Many decimal numbers don't have an exact representation in binary so they won't be an exact match.</p> <p>That's why in comparisons, you tend to see:</p> <pre><code>if (abs(a-b) &lt; epsilon) { ... </code></pre> <p>where epsilon is a small value such as 0.00000001, ...
<p>Have a look at this thread:</p> <p><a href="https://stackoverflow.com/questions/177506/why-do-i-see-a-double-variable-initialized-to-some-value-like-214-as-2139999961">Why do I see a double variable initialized to some value like 21.4 as 21.399999618530273?</a></p>
28,316
<p>How can I go about hosting flash content inside a WPF form and still use transparency/alpha on my WPF window? Hosting a WinForms flash controls does not allow this.</p>
<p>Unless the control you use to display the Flash content is built in WPF, you will run in to these &quot;airspace&quot; issues. Every display technology from Win32 to WinForms used HWNDs &quot;under the hood&quot;, but WPF uses DirectX. The Window Manager in Windows however, still only understands HWNDs, so WPF apps ...
<p>Just have been struggling with same problem of how to upload &amp; Make WPF transparent with ability of displaying Flash, because if you enable on your MainWindow "Allow transparency" Flash will not show once the application will run.</p> <p><strong>1)</strong> I used WebBrowser Control to play Flash(.swf) files. T...
9,273
<p>I'm trying to assign application pool to one web site in IIS7 using vb script:</p> <pre><code>' Connect to the WMI WebAdministration namespace.' Set oWebAdmin = GetObject("winmgmts:root\WebAdministration") ' Retrieve the application and display its Web site name and path.' Set oApp = oWebAdmin.Get("Application.Sit...
<p>Are you setting the app pool on a web site or a virtual directory?</p> <p>i.e., "Default Web Site/site" (virtual directory) or just "Site" (web site).</p> <p>If you trying to set it on a web site, not a virtual directory, you need to do something like:</p> <pre><code>Set oWebAdmin = GetObject("winmgmts:root\WebAd...
<p>The correct way is:</p> <pre><code>Set oWebAdmin = GetObject("Application.Path='/site',SiteName='Default Web Site'") </code></pre> <p>instead of:</p> <pre><code>Set oWebAdmin = GetObject("Application.SiteName='Default Web Site',Path='/site'") </code></pre>
26,421
<p>I'm trying to implement an outdent of the first letter of the first paragraph of the body text. Where I'm stuck is in getting consistent spacing between the first letter and the rest of the paragraph. </p> <p>For example, there is a huge difference in spacing between a "W" and an "I"</p> <p><img src="https://i.sta...
<p>Apply this to <code>p.outdent:first-letter</code>:</p> <pre><code>margin-left: -800px; padding-right: 460px; float: right; </code></pre> <p>This will position the first letter on the right edge of the paragraph, then shove it left it by more or less the width of the paragraph, then move both the letter and all the...
<p>I tried using a fix-width font like 'courier new' and since the characters are more or less the same width it made it a lot less noticeable.</p> <p>Edit - this font is decent but might only work for windows</p> <pre class="lang-css prettyprint-override"><code>p.outdent:first-letter { font-family: ms mincho; ...
13,260
<p>I stumbled over this passage in the <a href="http://www.djangoproject.com/documentation/tutorial01/" rel="noreferrer">Django tutorial</a>:</p> <blockquote> <p>Django models have a default <strong>str</strong>() method that calls <strong>unicode</strong>() and converts the result to a UTF-8 bytestring. This means ...
<blockquote> <p>what is a "Unicode string" in Python? Does that mean UCS-2?</p> </blockquote> <p>Unicode strings in Python are stored internally either as UCS-2 (fixed-length 16-bit representation, almost the same as UTF-16) or UCS-4/UTF-32 (fixed-length 32-bit representation). It's a compile-time option; on Windows...
<p>From <a href="http://en.wikipedia.org/wiki/UTF-8" rel="nofollow noreferrer">Wikipedia on UTF-8</a>: </p> <blockquote> UTF-8 (8-bit UCS/Unicode Transformation Format) is a <strong>variable-length character encoding for Unicode. It is able to represent any character in the Unicode standard</strong>, yet the initial e...
4,215
<p>With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values?</p> <p>This is to deal with a legacy table that has a unique key which can have null values but no primary key.</p> <p>I realise that I could just add a new primary key column to the table, but I'...
<p>No. Primary keys can not be null.</p>
<p>Why would you want to do that? Your composite ID should map the primary key of your table, and it doesn't sound wise to put null values in a key, does it?</p> <p><strong>EDIT:</strong> Hibernate does not allow to do so; you might put the property outside the key and tweak the DAO a little to take the field into acc...
9,637
<p>It is typical to have something like this in your cshrc file for setting the path:</p> <pre><code>set path = ( . $otherpath $path ) </code></pre> <p>but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication?</p> <p>EDIT: This is one unclean way of doing it:</...
<p>Im surprised no one used the <code>tr ":" "\n" | grep -x</code> techique to search if a given folder already exists in $PATH. Any reason not to?</p> <p>In 1 line:</p> <pre><code>if ! $(echo "$PATH" | tr ":" "\n" | grep -qx "$dir") ; then PATH=$PATH:$dir ; fi </code></pre> <p>Here is a function ive made myself to ...
<p>I always set my path from scratch in .cshrc. That is I start off with a basic path, something like:</p> <pre><code>set path = (. ~/bin /bin /usr/bin /usr/ucb /usr/bin/X11) </code></pre> <p>(depending on the system).</p> <p>And then do:</p> <pre><code>set path = ($otherPath $path) </code></pre> <p>to add more st...
16,435
<p>Is there a Delphi equivalent of the C# #if(DEBUG) compiler directive?</p>
<p>Use this:</p> <pre><code>{$IFDEF DEBUG} ... {$ENDIF} </code></pre>
<p>These control directives are available:</p> <pre><code>{$IFDEF} {$ELSE} {$ENDIF} {$IFNDEF} //if *not* defined </code></pre> <p>and they can be used as shown here:</p> <pre><code>procedure TfrmMain.Button1Click(Sender: TObject); begin {$IFDEF MY_CONDITIONAL} ShowMessage('my conditional IS defined!'); {$ELSE}...
17,789
<p>I want to clear the Firebug console of the JavaScript already sent.</p> <p>Does something like <code>console.clear()</code> exist and work?</p>
<p><code>console.clear();</code></p> <p>works for me</p>
<p>You can type clear(); in the Firebug command line. I don't think there's a way to do it from a web page though. </p>
19,150
<p>I have a form that tries to modify a JComponent's graphics context. I use, for example,</p> <pre><code>((Graphics2D) target.getGraphics()).setStroke(new BasicStroke(5)); </code></pre> <p>Now, immediately after I set the value and close the form, the change is not visible. Am I not allowed to modify a JComponent's ...
<p>There are several problems with that approach. The first is that most components will set these things themselves when ever they are asked to repaint themselves. This means that your change will be lost every time the component gets to the point where it would actually use it. But, on an even more fundamental level ...
<p>OK, I've worked around the problem like this: The custom JComponent now holds a Stroke object, which is set by the "Choose stroke" form when the user clicks OK. Then, in the paint method of the JComponent, I set the stroke of the graphics context passed as parameter to paint to the one contained in the object. </p> ...
34,781
<p>Alright.</p> <p>So I figure it's about time I get into unit testing, since everyone's been banging on about it for long enough. I've installed NUnit and gone through a few "intro to unit testing" type tutorials.</p> <p>I'm currently putting together a small framework to help with the rebuild of one of our web app...
<p>You can do model-view-controller or model-view-presenter type architectures without using a full blown framework. You already found out that unit-testing ui-components is difficult. There are ways around that but you probably don't want to go that route. Usually this will make your tests very hard to maintain, more ...
<p>The MVC framework mentioned above is the best way to test what the control does. However testing how it works is a bit different.</p> <p>This is totally off the cuff but you could make the user control expose some protected methods and properties to return validation information and then have a testing user contro...
5,105
<p>What ports or modes of communication do you need to open up for SQL Server 2005 Transactional Replication? Main and slave are geographically separated.</p>
<p>Make sure you enable encryption, otherwise your replicated data could be sniffed by any one in between. The better solution would be to set up a VPN between your two locations to off load the encryption from SQL Server and also provide better security.</p>
<p>(Not an Answer)</p> <p>I regretted using SQL Replication back during the SQL Server 7 days. From what I've seen of SQL Server 2005, The tools have become more unusable.</p> <p>If I were in your position, I would look at some form of Transaction server that supports replication and set it up as a middle tier betwe...
39,563
<p>We are using OpenLDAP client library to conect to an LDAP server. The problem is that if there is no activity for some time, server (or firewall in the middle) drops TCP connection.</p> <p>Our current implementation of "keep-alive" just does search for baseDN from time to time - any better ideas ? </p>
<p><code>LDAP_OPT_RECONNECT</code> is not available in OpenLdap</p>
<p>The only alternative seems to be reconnect:</p> <pre><code>ldap_set_option( ld, LDAP_OPT_RECONNECT, LDAP_OPT_ON ); </code></pre>
40,429
<p>I've been a C# programmer for about 2 years total, and professionally for a little more than 1. I work at a company as a developer on an application that began before the days of .NET 2. My question is this:</p> <p>What is the benefit to use databinding from sql queries directly to a control over querying and manua...
<p>I personally find that using the </p> <pre><code>control.DataSource = YourSource; control.DataBind(); </code></pre> <p>process is much easier, you don't have to do the iteration, and overall reduces LOC.</p> <p>If working with DropDownLists and other controls you will most likely set the DataValueField and DataTe...
<p>It can be useful to manually bind if you've got a complex input scenario. With databound input controls you can find that you only know you've got bad data when it hits the DB and throws an exception (badly formatted date/time, integer out of correct range etc). </p> <p>You can obviously handle this with the variou...
31,301
<p>I have several log files of events (one event per line). The logs can possibly overlap. The logs are generated on separate client machines from possibly multiple time zones (but I assume I know the time zone). Each event has a timestamp that was normalized into a common time (by instantianting each log parsers calen...
<ol> <li><p>Read the first line from each of the log files</p></li> <li><p>LOOP</p> <p>a. Find the "earliest" line.</p> <p>b. Insert the "earliest" line into the master log file</p> <p>c. Read the next line from the file that contained the earliest line</p></li> </ol> <p>You could check for duplicates between b and...
<p>Read only one line at a time from both source files. Compare the lines and write the older one to the output file (and advance to the next line). Do this until you have reached the end of both files and you've merged the files.</p> <p>And make sure to remove duplicates :)</p> <p>I guess this code in C# may illustr...
15,587
<p>Is there a way to find out when in a LAN anyone plugs in a pendrive to the USB port? Programatically (in C# preferably) or through some tool. Basically I'd imagine a client application sits on each terminal and monitors the USB ports and sends the information to the server. </p> <p>a.) Can I get the details of the...
<p>[Assuming Windows, given the C# remark. Please tag accordingly]</p> <p>Yes, this is possible. And it is possible to get the details of the file. It will require programming, though. Watch for <a href="http://msdn.microsoft.com/en-us/library/aa363480(VS.85).aspx" rel="noreferrer">WM_DEVICECHANGE</a> and re-enumerate...
<p>Are you trying to prevent the use of USB thumb drives? If so there is a Group Policy that allows you to restrict access.</p>
34,213
<p>I initially designed my system following the s# architecture example <a href="http://wwww.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">outlined in this codeproject article</a> (Unfortunately, I am not using NHibernate). The basic idea is that for each domain object that wo...
<p>I recommend against the simple approach other than in simple systems, usually I think your better creating a custom repository for each aggregate and encapsulating as much suitable logic as you can within it. </p> <p>So my approach would to have a repository for each aggregate that needs it, such as CustomerReposit...
<p>The main draw back to the second approach is in unit testing -- mocking out big factory methods like your SimpleObjectRepository requires more work than mocking out just ICustomerDao. But, my project goes with the second approach for highly related objects (where most will be used in any unit tests) because it light...
17,427
<p>Is it possible to implement the <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="noreferrer">Visitor Pattern</a> respecting the <a href="http://en.wikipedia.org/wiki/Open/closed_principle" rel="noreferrer">Open/Closed Principle</a>, but still be able to add new visitable classes?</p> <p>The Open/Closed P...
<p>In C++, <a href="https://condor.depaul.edu/dmumaugh/OOT/Design-Principles/acv.pdf" rel="nofollow noreferrer">Acyclic Visitor</a> (pdf) gets you what you want.</p>
<p>You might want to check out research on "the expression problem", see e.g.</p> <p><a href="http://lambda-the-ultimate.org/node/2232" rel="nofollow noreferrer">http://lambda-the-ultimate.org/node/2232</a></p> <p>I think the problem is mostly academic, but it's something that has been studied a lot, so there's a bit...
20,705
<p>I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice? A good example of this would be the badges on stack overflow, or the operating system field in bugzilla. Any subset of the flags may be set fo...
<p>If you really need an unbounded selection from a closed set of flags (e.g. stackoverflow badges), then the "relational way" would be to create a table of flags and a separate table which relates those flags to your target entities. Thus, users, flags and usersToFlags.</p> <p>However, if space efficiency is a serio...
<p>Came across this when I was pondering best way to store bitmask flags (similar to OP's original use of integers) in a database.</p> <p>The other answers are all valid solutions, but I think its worth mentioning that you may not have to resign yourself to horrible query problems if you choose to store bitmasks direct...
15,176
<p>I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer :)</p> <p>I have an attribute that looks like:</p> <pre><code>public class L...
<p><strong>This is not possible with the present version of PostSharp.</strong></p> <p>PostSharp works by transforming assemblies prior to being loaded by the CLR. Right now, in order to do that, two things have to happen:</p> <ul> <li>The assembly must be about to be loaded into the CLR; you only get one shot, and you...
<p>If you're trying to intercept calls within the framework (i.e., not in your own code), it won't work. PostSharp can only replace code within your own assembly. If you're trying to intercept calls you're making, then it looks like it should work. Do you see PostSharp running in the build output?</p>
12,323
<p>I'm running a strange problem sending emails. I'm getting this exception:</p> <pre><code>ArgumentError (wrong number of arguments (1 for 0)): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `...
<p>The problem is with the model that ar_mailer is using to store the message. You can see in the backtrace that the exception is coming from ActiveRecord::Base.create when it calls initialize. Normally an ActiveRecord constructor takes an argument, but in this case it looks like your model doesn't. ar_mailer should be...
<p>Check that email_class is set correctly: <a href="http://seattlerb.rubyforge.org/ar_mailer/classes/ActionMailer/ARMailer.html#M000002" rel="nofollow noreferrer">http://seattlerb.rubyforge.org/ar_mailer/classes/ActionMailer/ARMailer.html#M000002</a></p> <p>Also don't use instance variables. Try:</p> <pre><code>clas...
16,062
<p>I've got around 750+ users that I'm going to create mailboxes for. Should I sleep for a bit between creates to not overload the exchange server or does it not matter? I've read that the actual mailbox is not created until the user accesses it or they get mail. I'm using CDOEXM and DirectoryServices in .NET 2.0.</p> ...
<p>I'd just go for it. I wouldn't expect only 750 to cause any sort of operational problem on anything resembling a modern server.</p>
<p>Exchage defers most of the work until the user logs in for the first time, so creating the mailboxes shouldn't be much work.</p>
47,387
<p>What is the <code>@</code> symbol mean in <a href="/questions/tagged/oracle" class="post-tag" title="show questions tagged &#39;oracle&#39;" rel="tag">oracle</a>? </p> <p>For example:</p> <pre><code>select * from question_answer@abcd where id = '45' </code></pre>
<p>It refers to a non-local table, the bit behind the @ is the db descriptor.</p> <pre><code>select * from question_answer@abcd where id = '45' </code></pre> <p>Means select not from the local <code>question_answer</code> table, but from the table on the db designated as <code>abcd</code>. The keyword to google for is ...
<p>This is the syntax for accessing a table via a database link called "abcd" See the documentation for <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_5005.htm#SQLRF01205" rel="noreferrer">CREATE DATABASE LINK</a>, or to see the defined db links: </p> <pre><code>SELECT * FROM all_db...
37,885
<p>I'm playing about with <a href="http://en.wikipedia.org/wiki/Lighttpd" rel="nofollow noreferrer">lighttpd</a> on a small virtual private server. I two domains pointing to the server. I am using the latest version of lighttpd and mod_evhost on Ubuntu 8.10.</p> <ol> <li><p>I'm trying to set up a rule such that if any...
<p>Your regexes seem to be a bit overdone.</p> <p>Here is what I would use:</p> <pre><code>// regex to match sub.domain.com $HTTP["host"] =~ "^[^.]+\.[^.]+\.[^.]+$" { evhost.path-pattern = "/webroot/%0/%3/" } // regex to match domain.com $HTTP["host"] =~ "^[^.]+\.[^.]+$" { evhost.path-pattern = "/web...
<p>For your first one, matching <strong>domain.com</strong> and <strong>www.domain.com</strong>: <code>^\b([wW]{3}\.)?[\w\d]*\.com\b$</code>, and for the second one, I am unsure if regex can determine if a subdomain/page exists, as it is for identifying strings of text of interest. Hopefully that will help you out a b...
32,758
<p>What is the best way to get the Max value from a LINQ query that may return no rows? If I just do</p> <pre><code>Dim x = (From y In context.MyTable _ Where y.MyField = value _ Select y.MyCounter).Max </code></pre> <p>I get an error when the query returns no rows. I could do</p> <pre><code>Dim x ...
<p>Since <code>DefaultIfEmpty</code> isn't implemented in LINQ to SQL, I did a search on the error it returned and found a <a href="http://www.interact-sw.co.uk/iangblog/2007/09/10/linq-aggregates" rel="noreferrer">fascinating article</a> that deals with null sets in aggregate functions. To summarize what I found, you ...
<p>I just had a similar problem, my unit tests passed using Max() but failed when run against a live database. </p> <p>My solution was to separate the query from the logic being performed, not join them in one query.<br> I needed a solution to work in unit tests using Linq-objects (in Linq-objects Max() works with nu...
44,351
<p>Generally when I use ClickOnce when I build a VB.NET program but it has a few downsides. I've never really used anything else, so I'm not sure what my options are.</p> <p>Downsides to ClickOnce:</p> <ul> <li>Consists of multiple files - Seems easier to distribute one file than manageing a bunch of file and the dow...
<p>Have you seen WiX yet?</p> <p><a href="http://wix.sourceforge.net/" rel="noreferrer">http://wix.sourceforge.net/</a></p> <p>It builds windows installers using an XML file and has additional libraries to use if you want to fancify your installers and the like. I'll admit the learning curve for me was medium-high in...
<p>Creating an installer project, with a dependency on your EXE (which in turn depends on whatever it needs) is a fairly straightforward process - but you'll need at least VS Standard Edition for that.</p> <p>Inside the installer project, you can create custom tasks and dialog steps that allow you to do anything you c...
2,564
<h3>Duplicate:</h3> <blockquote> <p><a href="https://stackoverflow.com/questions/242177/what-is-aspect-oriented-programming">What is aspect-oriented programming?</a></p> </blockquote> <p>Every time I here a podcast or read a blog entry about it, even here, they make it sound like string theory or something. Is the bes...
<p>Laymans terms so let me give you an example. Let's say you have a web application, and you need to add error logging / auditing. One implementation would be to go into every public method and add your try catch blocks etc...</p> <p>Well Aspect oriented says hogwash with that, let me inject my method around your met...
<p>I currently use <a href="http://www.postsharp.org/" rel="nofollow noreferrer">Post Sharp</a>, i would read the info from their website. I use it to provide a security around method calls.</p> <blockquote> <p>"PostSharp is an open platform for the analysis and transformation of .NET assemblies. It comes with PostS...
41,334
<p>I have a protected Excel worksheet, without a password. What I'd like to do is trap the event that a user unprotects the worksheet, so that I can generate a message (and nag 'em!). I can setup event checking for the application, for when new workbooks are opened, etc., but not for Unprotect.<br> Does anyone have an...
<p>It is possible to modify the menu using Tools->Customize. Protect/Unprotect can be set to run a macro, for example:</p> <pre><code>Sub UnprotectTrap() If ActiveSheet.ProtectContents = True Then MsgBox "Tut,tut!" ActiveSheet.Unprotect Else ActiveSheet.Protect End If End Sub </code></pre>
<p>There is no way to trap the user unprotecting the sheet, but you can warn them if they save the workbook without reprotecting the sheet(s).</p> <p>In the Workbook module, put this code, or something like it</p> <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If Sheets("My...
30,378
<p>I got some legacy code with that caption spread out as comment almost in every field. Also appearing is "<code>Setter for property xyz</code>". </p> <p>Just out of curiosity, which Java tool generated this stubs?</p>
<p>It uses the user that your Application Pool is running as, the default being 'NT AUTHORITY\NETWORK SERVICE'</p> <p>The title of the question should be "What user account will ASP.NET use when I connect to SQL Server using trusted___connection". Trusted_connection uses the current process' (or impersonated) credenti...
<p>It will use the credential of the currently logged in user. The reason you see NETWORK Service is because IIS app pools (by default) runs as that account.</p>
36,247
<p>Recently I've been seeing a lot of this:</p> <pre><code>&lt;a href='http://widget-site-example.com/example.html'&gt; &lt;img src='http://widget-site-example.com/ross.jpg' alt='Ross&amp;#39;s Widget' /&gt; &lt;/a&gt; </code></pre> <p>Is it valid to use single quotes in HTML? As I've highlighted above it's also ...
<p>It's certainly valid to use single quotes (<a href="http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2" rel="noreferrer">HTML 4.01, section 3.2.2</a>). I haven't noticed such a trend, but perhaps there's some framework that powers web sites you've visited that happens to quote using single quotes.</p>
<h1>You should avoid quotes altogether.</h1> <p>In your example only one quoted attribute actually needed quotes.</p> <pre><code>&lt;!-- best form --&gt; &lt;a href=http://widget-site-example.com/example.html&gt; &lt;img src=http://widget-site-example.com/ross.jpg alt='Ross&amp;#39;s Widget' /&gt; &lt;/a&gt; </code><...
30,065
<p>I'm currently working on a large implementation of Class::DBI for an existing database structure, and am running into a problem with clearing the cache from Class::DBI. This is a mod_perl implementation, so an instance of a class can be quite old between times that it is accessed. From the man pages I found two opt...
<p>The "<a href="http://wiki.class-dbi.com/wiki/Common_problems" rel="nofollow noreferrer">common problems</a>" page on the <a href="http://wiki.class-dbi.com/wiki" rel="nofollow noreferrer">Class::DBI wiki</a> has a <a href="http://wiki.class-dbi.com/wiki/Common_problems#Old_data_due_to_object_index" rel="nofollow nor...
<p>I should note that Class::DBI is deprecated and you should port your code to <a href="http://search.cpan.org/dist/DBIx-Class/" rel="nofollow noreferrer">DBIx::Class</a> instead.</p>
5,595
<p>What do you think is the best way to present a hierarchical list of functionality to users within your traditional WinForms application? (A menu system - Assume functionality can be split into a small number of modules and sub-modules but with no fixed depth in terms of those sub-modules).</p> <p>Do you like the tr...
<p>An important thing to consider in your design is <a href="http://haacked.com/archive/2008/11/06/usability-vs-discoverability.aspx" rel="nofollow noreferrer">Usability vs Discoverability</a>.</p> <p>The <em>best</em> solution depends strongly on who you users are. The UI requirements for a kiosk application for tour...
<p>You could always opt for the increasingly ribbon control. Microsoft/Office interfaces have a habit of becoming the user's expectation of norm (eventually).</p>
41,864
<p>I have this huge legacy database that I'm trying to get under source control. I looked around here on stackoverflow and decided to use the Visual Studio 2008 database project, then committing stuff on svn. I successfully imported the schema into the project, but I can't find any way to use the user-friendly table de...
<p>I'd use <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en" rel="nofollow noreferrer">Microsoft® Visual Studio Team System 2008 Database Edition GDR</a>. Which scripts every object in it's own file so makes it easy to track in version control.</...
<p>Try opening the Server Explorer (View > Server Explorer). You may need to add a connection and then you can to the database tables, right click them and choose "Show table data".</p> <p>0nce you're there you get the Query Designer toolbar and you're able to use the table designers.</p>
20,243
<p>The point of this question is to collect a list of examples of hashtable implementations using arrays in different languages. It would also be nice if someone could throw in a pretty detailed overview of how they work, and what is happening with each example. </p> <p><strong>Edit:</strong> </p> <p>Why not just use...
<p>A hash table a data structure that allows lookup of items in constant time. It works by hashing a value and converting that value to an offset in an array. The concept of a hash table is fairly easy to understand, but implementing is obviously harder. I'm not pasting the whole hash table here, but here are some s...
<p>I went and read some of the Wikipedia-page on hashing: <a href="http://en.wikipedia.org/wiki/Hash_table" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Hash_table</a>. It seems like a lot of work, to put up code for a hashtable here, especially since most languages I use allready have them built in. Why woul...
4,494
<p>I have an ASP.Net MVC Ajax.BeginForm that submits and updates my page properly when I click the submit button. </p> <p>The problem is I need additional events to do the same thing, like when they change the text of an input. The additonal events do properly submit the form but they circumvent the onsubmit javascr...
<p>Decided to just use a regular form and then the jQuery.Form plugin and this worked in 2 seconds! Wish i would have just went this route orginally.</p> <pre><code>var options = { target: '#updatedContent', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit cal...
<p>This is a bit of a tricky issue in the current Beta of MVC. You can't use the "submit()" function because it won't trigger the onsubmit handler. Instead, you should call the onsubmit handler directly. The only trick is you need to pass an argument to onsubmit() when you call it. This argument is what becomes the...
33,244
<p>If I have a for loop which is nested within another, how can I efficiently come out of both loops (inner and outer) in the quickest possible way?</p> <p>I don't want to have to use a boolean and then have to say go to another method, but rather just to execute the first line of code after the outer loop.</p> <p>Wh...
<p>Well, <code>goto</code>, but that is ugly, and not always possible. You can also place the loops into a method (or an anon-method) and use <code>return</code> to exit back to the main code.</p> <pre><code> // goto for (int i = 0; i &lt; 100; i++) { for (int j = 0; j &lt; 100; j++) { ...
<p>I think unless you want to do the "boolean thing" the only solution is actually to throw. Which you obviously shouldn't do..!</p>
42,064
<p>How can I round a decimal number (floating point) to the nearest integer? </p> <p>e.g.</p> <pre><code>1.2 = 1 1.7 = 2 </code></pre>
<p>Output of <a href="http://perldoc.perl.org/perlfaq4.html#Does-Perl-have-a-round%28)-function%3f--What-about-ceil()-and-floor()%3f--Trig-functions%3f" rel="noreferrer"><code>perldoc -q round</code></a></p> <blockquote> Does Perl have a round() function? What about ceil() and floor()? Trig functions? <p> Remember th...
<pre><code>cat table | perl -ne '/\d+\s+(\d+)\s+(\S+)/ &amp;&amp; print "".**int**(log($1)/log(2))."\t$2\n";' </code></pre>
21,519
<p>The CSS Friendly Control Adapters for ASP.NET are great for creating markup that is easy to style. A big benefit of the GridView adapter is that it generates THEAD, TBODY, and TFOOT tags, which allow you to do some really great things with libraries like jQuery - for instance, <a href="http://tablesorter.com/docs/"...
<p>I just did something similar to this after doing a little research</p> <p>you need to subclass the control you want to use (gridview in your case, radiobuttonlist in my case)</p> <pre><code>public class UlRadioButtonList : RadioButtonList { protected override void Render(System.Web.UI.HtmlTextWriter wr...
<p>CSS Friendly...</p> <blockquote> <p>Disabling Adapters</p> <p>If you explicitly add AdapterEnabled="false" to your server-side tag, these sample adapters will attempt to use the ASP.NET framework's native rendering for the control. Beware: this is not supported and often does not work well. Fun...
34,643
<p>Trying to make a MySQL-based application support MS SQL, I ran into the following issue:</p> <p>I keep MySQL's auto_increment as unsigned integer fields (of various sizes) in order to make use of the full range, as I know there will never be negative values. MS SQL does not support the unsigned attribute on all int...
<p>When is the problem likely to become a real issue?</p> <p>Given current growth rates, how soon do you expect signed integer overflow to happen in the MS SQL version?</p> <p>Be pessimistic.</p> <p>How long do you expect the application to live?</p> <p>Do you still think the factor of 2 difference is something you...
<p>I would say this.. "How do we normally deal with differences between components?"</p> <p><strong>Encapsulate what varies</strong>..</p> <p>You need to create an abstraction layer within you data access layer to get it to the point where it <em>doesn't care</em> whether or not the database is MySQL or MS SQL..</p>
4,942
<p>It's been a while since I've had to do any HTML-like code in <code>Vim</code>, but recently I came across this again. Say I'm writing some simple <code>HTML</code>:</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;This is a title&lt;/title&gt;&lt;/head&gt;&lt;/html&gt; </code></pre> <p>How do I write those clos...
<p>Check this out..</p> <p>closetag.vim </p> <pre><code>Functions and mappings to close open HTML/XML tags </code></pre> <p><a href="https://www.vim.org/scripts/script.php?script_id=13" rel="nofollow noreferrer">https://www.vim.org/scripts/script.php?script_id=13</a></p> <p>I use something similar.</p>
<p>allml (now Ragtag ) and Omni-completion ( &lt;C-X&gt;&lt;C-O&gt; ) doesn't work in a file like .py or .java.</p> <p>if you want to close tag automatically in those file, you can map like this.</p> <pre> imap &lt;C-j&gt; &lt;ESC&gt;F&lt;lyt&gt;$a&lt;/^R"&gt; </pre> <p>( ^R is Contrl+R : you can type like this Cont...
15,878