input
stringlengths
51
42.3k
output
stringlengths
18
55k
How do display functions like sprintf convert numbers to strings? <p>I'm trying to extract the integer and decimal parts of a floating point value, and I seem to be running into some strange rounding problems, due probably to the imprecise way floats are stored. </p> <p>I have some code like this to extract the fracti...
<p><s>> However the result here instead of 1 comes out as one.</p> <p>What do you mean?</p> <blockquote> <p>2.099999...</p> </blockquote> <p>Or, more like <code>2.00999...</code></s></p> <p>As you've noted:</p> <pre><code>int frac = int(floor(number * 100)) % 100; </code></pre> <p>will be:</p> <pre><code>int f...
How do I handle a varying number of items from a database query? <p>Effectively a duplicate of: <a href="http://stackoverflow.com/questions/576498/how-can-i-display-data-in-table-with-perl">How can I display data in table with Perl</a></p> <p>The accepted answer there applies here. So do some of the alternatives.</p> ...
<p>Try:</p> <pre><code>print "&lt;table&gt;\n"; # display HTML header @cols = @{$sth-&gt;{NAMES_uc}}; print "&lt;tr&gt;".join("", map { "&lt;th&gt;${_}&lt;/th&gt;" } @cols)."&lt;/tr&gt;\n"; # display one HTML table row for each DB row while (my @row = $sth-&gt;fetchrow_array) { print "&lt;tr&gt;".join("", map { "&...
Declaring inherited generics with complex type constraints <p>I have an interface with a single generic type parameter:</p> <pre><code>public interface IDriveable&lt;T&gt; where T : ITransmission { ... } </code></pre> <p>I also have a class that has a type parameter that needs to be of that interface type:</p> <pre>...
<p>What is VehicleFactory going to <em>do</em> with T? Does it actually need the constraint in order to work, or is it just for the sake of developer sanity checking?</p> <p>One common way round this is to declare a non-generic interface (<code>IDriveable</code>) and then make your generic one extend that:</p> <pre><...
Get timezone from DateTime <p>Does the .Net DateTime contain information about time zone where it was created? </p> <p>I have a library parsing DateTime from a format that has "+zz" at the end, and while it parses correctly and adjusts a local time, I need to get what the specific time zone was from the DateTime objec...
<p>DateTime itself contains no real timezone information. It <em>may</em> know if it's UTC or local, but not what local really means.</p> <p>DateTimeOffset is somewhat better - that's basically a UTC time and an offset. However, that's still not really enough to determine the timezone, as many different timezones can ...
A standard Unix command-line tool for piping to a socket <p>I have some applications, and standard Unix tools sending their output to named-pipes in Solaris, however named pipes can only be read from the local storage (on Solaris), so I can't access them from over the network or place the pipes on an NFS storage for ne...
<p><a href="http://netcat.sourceforge.net/">Netcat</a> is great for this. Here's a <a href="http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/">page with some common examples</a>.</p> <p>Usage for your case might look something like this:</p> <ol> <li><p>Server listens for a connection, then sends...
I'd like to scrape the iTunes top X RSS feed and insert into a dB <p>Preferably I'd like to do so with some bash shell scripting, maybe some PHP or PERL and a MySQL db. Thoughts?</p>
<p>Here is a solution using Perl, with the help of (of course!) a bunch of modules.</p> <p>It uses SQLite so you can run it easily (the definition of the (simplistic) DB is at the end of the script). Also it uses Perl hashes and simple SQL statements, instead of proper objects and an ORM layer. I found it easier to pa...
Algorithms for Big O Analysis <p>What all algorithms do you people find having amazing (tough, strange) complexity analysis in terms of both - Resulting O notation and uniqueness in way they are analyzed?</p>
<p>I have (quite) a few examples:</p> <ul> <li>The <a href="http://en.wikipedia.org/wiki/Disjoint-set_data_structure">union-find</a> data structure, which supports operations in (amortized) inverse Ackermann time. It's particularly nice because the data structure is incredibly easy to code.</li> <li><a href="http://e...
Alternatives for JCIFS NTLM library <p>Are there any alternatives for JCIFS NTLM library?</p>
<p>Waffle - <a href="https://github.com/dblock/waffle" rel="nofollow">https://github.com/dblock/waffle</a></p> <p>Has filters, authenticators, supports spring-security, etc. Windows-only, but doesn't require native DLLs.</p>
Hardware Simulation <p>I'm working on a software project intended for recuperating old specific hardware, mostly for non-for-profit organizations and poor schools.</p> <p>I need a way to simulate old hardware so I can test the application before shipping it out. </p> <p>How can I do this?</p>
<p>I'm not sure exactly what the question is asking for. I think you are asking for a way to emulate certain HW? </p> <p>If that is the case, I've used <a href="http://wiki.qemu.org/Index.html" rel="nofollow">QEMU</a> in the past, and it has worked great. QEMU is an open source machine emulator and virtualizer.</p>
How do I design sms service? <p>I want to design a website that can send and receive sms.</p> <ol> <li>How should I approach the problem ?</li> <li>What are the resources available ?</li> <li>I know php,python what else do I need or are the better options available?</li> <li>How can experiment using my pc only?[somthi...
<p>You can take a look at <a href="http://www.kannel.org" rel="nofollow">Kannel</a>. It's so simple to create SMS services using it. Just define a keyword, then put in the URL to which the incoming SMS request will be routed (you'll get the info such as mobile number and SMS text in query string parameters), then whate...
System.IO.FileNotFoundException when loading web service <p>I've a simple, if not primitive, C++/CLI .NET 2.0 class library. It is used in order to wrap some C++ legacy code for the Web Service. The following facts appear to be true:</p> <ol> <li>Primitive C# test program calls class library and it works.</li> <li>If ...
<p>What calls are you replacing? Could it be the original code gracefully handles missing files (which may not even be important) and yours does not?</p>
Should I ignore the occasional Invalid viewstate error? <p>Every now and then (once every day or so) we're seeing the following types of errors in our logs for an ASP.NET 3.5 application</p> <ul> <li>Invalid viewstate</li> <li>Invalid postback or callback argument</li> </ul> <p>Are these something that "just happens"...
<p>Well it depends. Invalid viewstate can happen for a variety of reasons.</p> <ol> <li>Viewstate is too big and has not finished rendering before a user causes a postback on the page. The fix is generally to disable all controls that trigger postbacks and enable them client side once the page has finished loading - s...
TextField() - how to prevent mouse select <p>How can I prevent mouse selecting (and moving caret) with Editable TextField(), this one does not seem to fully work when SELECTING text, but it prevents clicking. I want to keep cursor in place where its going.</p> <pre><code>protected function handleMouseDEvent(evt:MouseE...
<p>if what you mean is to prevent the TextField for being selected, use:</p> <pre><code>TextField.selectable = false; </code></pre> <p>But if what you mean is to prevent the TextField from blocking object behind it, use:</p> <pre><code>TextField.mouseEnabled = false; </code></pre>
Preorder tree traversal copy folder <p>We have a database that contains several Trees. These trees are build using the "Preorder tree traversal" principle. This is a very powerful way of creating trees but it has one big disadvantage, adding multiple nodes at once.</p> <p>We have to create a copy function in our tree,...
<p>Could you not traverse the entire tree and insert it into a new binary tree? If you have multiple data sets that need to be combined you can just traverse each one in any order and have the tree rebuild itself.</p> <p>Could you give more information on what you mean with folder?</p> <p>I think this question needs ...
chrooted Apache+MsSQL on openBSD; Could not determine the server's fully qualified domain name <p>php generates GIFs on the web server using a databases on a second server. The the page shows 20 GIFs, so there is some load for a short time (multiple connections)</p> <p><hr /></p> <p>Some GIFs are loaded but some are ...
<p>The "Could not determine the server's fully qualified domain name" error can be ignored, that's an internal apache thing.</p> <p>Per <a href="http://dev.mysql.com/doc/refman/5.0/en/error-lost-connection.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/error-lost-connection.html</a> and <a href="http://bu...
How do I make a DBIx::Class relationship with a fixed join condition? <p>We have a link table that can handle multiple types of object on one side, and I can't work out how to get from one of these objects to the link table using has_many.</p> <p>Example: link table contains:</p> <blockquote> <pre><code>id link_id li...
<p>You should just make a wrapper method that calls the relationship with the required arguments:</p> <pre><code>Page-&gt;has_many(__all_links =&gt; 'Link', 'link_id'); sub links { shift-&gt;__all_links({link_table =&gt; 'page'}); } </code></pre> <p>This would be pretty easy to turn into a DBIx::Class component ...
Regex - I only want to match the start tags in regex <p>I am making a regex expression in which I only want to match wrong tags like: <code>&lt;p&gt; *some text here, some other tags may be here as well but no ending 'p' tag* &lt;/p&gt;</code></p> <pre><code> &lt;P&gt;Affectionately Inscribed &lt;/P&gt;&lt;P&gt;TO &lt...
<p>Regex is not always a good choice for xml/html type data. In particular, attributes, case-sensitivity, comments, etc all have a big impact.</p> <p>For xhtml, I'd use <code>XmlDocument</code>/<code>XDocument</code> and an xpath query.</p> <p>For "non-x" html, I'd look at the <a href="http://www.codeplex.com/htmlagi...
Creating new exception in C++ <p>I have a C++ class and I am trying to run it in Ubuntu:</p> <pre><code>#ifndef WRONGPARAMETEREXCEPTION_H_ #define WRONGPARAMETEREXCEPTION_H_ #include &lt;iostream&gt; #include &lt;exception&gt; #include &lt;string&gt; using namespace std; #pragma once class WrongParameterException:...
<p>First, <code>#pragma once</code> is the wrong way to go about it, learn about header include guards. <a href="http://stackoverflow.com/a/34884735/13986">Related question on SO</a> explains why using <code>#pragma once</code> is the wrong way to go about it. Wikipedia explains how to use <a href="https://en.wikipedia...
class loader <p>I'm having problem with class loaders. All the time. </p> <p>Sometimes it works, sometimes it doesn't work. </p> <p>When I started I've tested this works but not from *.jar:</p> <p>URL url = AcAnalyzer.class.getResource("../stuff/resource");</p> <p>//and this works even from jar file:</p> <p>URL ur...
<p>I'm not sure exactly what the question is in the first part, although I'd advise not using "../" in a resource path.</p> <p>For the second part, if you want to load a resource you shouldn't use FileInputStream - you should use <code>getResourceAsStream()</code> instead of <code>getResource().getFile()</code>. Just ...
ASP.Net TreeView Scrolling the selected node into view <p>Is there a way to scroll the selected node of an ASP.Net TreeView into view after a postback? </p> <p>In my parrticular scenario the control is repopulated after each postback.</p> <p>Thanks!</p>
<p>I figured it out. The TreeView control creates a javascript object on the client. It is named whatever you called the treeview with a '_Data' appended. The object lets you get a reference to the selected node.</p> <p>The code below uses the ASP.Net Ajax extensions. Just remember to change the TreeView name to whate...
MAP file analysis - where's my code size comes from? <p>I am looking for a tool to simplify analysing a linker map file for a large C++ project (VC6). </p> <p>During maintenance, the binaries grow steadily and I want to figure out where it comes from. I suspect some overzealeous template expansion in a library shared ...
<p><a href="http://www.sikorskiy.net/prj/amap/index.html">This</a> is a wonderful compiler generated map file analysis/explorer/viewer tool. Check if you can explore gcc generated map file.</p> <p><em>amap : A tool to analyze .MAP files produced by 32-bit Visual Studio compiler and report the amount of memory being us...
c# equivalent to php associative array? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1915347/c-sharp-associative-array">C# associative array</a> </p> </blockquote> <p>ive decided to learn c# recently. ive done some php before. i see c# has dictionaries. th...
<p>Dictionary doesn't <em>guarantee</em> to preserve insertion order, so no: you can't rely on that (although it is hard to force it to break this). If insertion order is important, you would need to create a hybrid class, perhaps encapsulating a <code>List&lt;T&gt;</code> for the inserted order, and a <code>Dictionary...
Sql Server Backup Sizes <p>Does anyone have real world experience of backup compression in Sql 2008, I'd like to know how it performs compared to Sql 2005 + winrar. Currently when I back up a I get a 14G file. Using rar shrinks it to &lt;400M, a massive saving. Most of the data is similar, being figures from the stock ...
<p>The figures I have seen suggest compression ratios in the range 3 - 4.5 times smaller, which is not as good as the figures you quoted for rar. See <a href="http://sqlcat.com/technicalnotes/archive/2008/04/21/tuning-the-performance-of-backup-compression-in-sql-server-2008.aspx" rel="nofollow">Tuning the Performance o...
Pair-wise iteration in C# or sliding window enumerator <p>If I have an IEnumerable like:</p> <pre><code>string[] items = new string[] { "a", "b", "c", "d" }; </code></pre> <p>I would like to loop thru all the pairs of consecutive items (sliding window of size 2). Which would be </p> <pre><code>("a","b"), ("b", "c"),...
<p>In .NET 4 this becomes even easier:-</p> <pre><code> var input = new[] { "a", "b", "c", "d", "e", "f" }; var result = input.Zip(input.Skip(1), (a, b) =&gt; Tuple.Create(a, b)); </code></pre>
DataGridViewComboBoxColumn - type of items in the drop down list <p>I have a DataGridView that has a ComboBox column. I populate this column's list with items of a type <strong>Field</strong>: </p> <pre><code>DataGridViewComboBoxColumn fieldsColumn = argumentsDataGridView.Columns["field"] as DataGridViewComboBoxColum...
<p>the solution was to create a property <strong>Self</strong> in class <strong>Field</strong>: </p> <pre><code>public Field Self { get { return this; } } </code></pre> <p>and set is as a ValueMember of the combo box column.<br /> I thought that without specifing ValueMember <em>this</em>...
Running xcodebuild from a forked terminal <p>I'm trying to setup an automated build server for an iPhone application. I'd like to be able to have nightly adhoc beta builds so that testers can follow the development.</p> <p>I've setted up xcode successfully xcode to perform adhoc builds and I can also launch the build ...
<p>I had te error <strong>User interaction is not allowed</strong> and solved it by unlocking the keychain first</p> <pre><code>security unlock-keychain /Users/yannooo/Library/Keychains/login.keychain </code></pre> <p>I've also tried to put my certs in the System's keychain and it was working. My final solution was t...
send(), returns Winsock Error 10038 <p><strong>Problem:</strong></p> <ul> <li>Call to <strong>send()</strong>, returns Winsock Error <strong>10038</strong> against socket handle</li> </ul> <p><strong>Illustration:</strong></p> <pre><code>acceptedSocket = accept (server, (sockaddr *)&amp;sin, &amp;len); </code></pre>...
<p>accept() returns you a handle to a new connection-specific socket. for server code it's 2+ sockets involved: one is in listen state you are calling accept() for and second is one returned from accept() - it's an incoming connection socket. Following accept() can return socket for second incoming connection etc. if a...
How can I make this Python recursive function return a flat list? <p>Look at this simple function</p> <pre><code>def prime_factors(n): for i in range(2,n): if n % i == 0: return i, prime_factors(n / i) return n </code></pre> <p>Here's the result of <code>prime_factors(120)</code></p> <pre><code...
<pre><code>def prime_factors(n): for i in range(2,n): if n % i == 0: return [i] + prime_factors(n / i) return [n] </code></pre>
Why does this integer overflow occur? <p>I've wrapped a dll method that has an integer as an out parameter in a web service. In testing I was finding that when I was expecting -1 I was getting 65,535 instead. I realised that the dll was using 16 bit integers and I was specifying the standard .NET 32bit integer when ref...
<p>A 16 bit integer "-1" has all 16 bits set. If you set the bottom 16 bits of a 32 bit integer, the value is 65,535. For an explanation of the internal representation of negative ints, have a look at <a href="http://en.wikipedia.org/wiki/Two_complement" rel="nofollow">this article</a>.</p>
JTextPane keeps throwing BadLocation <p>I have a JFrame that contains a JTextPane. The purpose of this JTextPane is to highlight words as I type them, something along the lines of a programmer's text editor. To accomplish this, I extended JTextPane, I implemented the <strong>KeyListener</strong> interface, and I had it...
<p>As you discovered, the<a href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#getText(int,%20int)">Document.getText()</a> takes a start and <em>length</em>, not a start and <em>end</em> argument. I thought I'd provide an answer and a link to the JavaDoc for others reading your question who mig...
Filtering DataGridView rows in .Net <p>I have a DataGridView that is displaying a List of objects (not DataSet). Is there an easy way to set a filter, so the DGV will only display rows that match the filter?</p> <pre><code>IList&lt;T&gt; log = ...; dgv.DataSource = log; </code></pre>
<p>Do you have LINQ available? If so, one option is:</p> <pre><code>dgv.DataSource = log.Where(x=&gt;x.IsActive &amp;&amp; x.Type == 3).ToList(); </code></pre> <p>However, new/removed rows won't update the original list (edits to existing rows are fine).</p> <p>If not LINQ, you can do the same with <code>List&lt;T&g...
Can file uploads time out in PHP? <p>Hi im quite new to PHP, i have created a form for very large csv files to be uploaded to my server. Some one mentioned to me that the browser can time out due to the uploading file being to big, is this true? and if so, can it be prevented?</p> <p>Thanks for your help!</p>
<p>You need a proper value for the following php.ini settings:</p> <ol> <li><a href="http://www.php.net/manual/en/info.configuration.php#ini.max-input-time">max_input_time</a> (<strong>not</strong> max_execution_time!)</li> <li><a href="http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize">upload_max_file...
Easiest way to create a scrollable area using wxPython? <p>Okay, so I want to display a series of windows within windows and have the whole lot scrollable. I've been hunting through <a href="http://docs.wxwidgets.org/stable/wx_wxscrolledwindow.html#wxscrolledwindow" rel="nofollow">the wxWidgets documentation</a> and a ...
<p>Oops.. turns out I was creating my child windows badly:</p> <pre><code>wind = MyCustomWindow(self) </code></pre> <p>should be:</p> <pre><code>wind = MyCustomWindow(self.scrolling_window) </code></pre> <p>..which meant the child windows were waiting for the top-level window (the frame) to be re-drawn instead of l...
Capture stdout in log4j/log4net <p>I have a library that writes to stdout in Java. I would like to capture this output in a log using log4j. (I didn't write this library, so I have no control over the code inside the library).</p> <p>Is there an easy way to do this? Is System.setOut the right approach? What do I p...
<p>One solution is to subclass <code>OutputStream</code>. You only have to implement <code>write( int b )</code>. Then create a <code>PrintStream</code> with your <code>OutputStream</code> in the constructor.</p> <p>It could look like :</p> <pre><code>public class L4JOS extends OutputStream { logger = Logger.getL...
Common Lisp equivalent to C enums <p>I'm trying to learn some Lisp (Common Lisp) lately, and I wonder if there is a way to give constant numbers a name just like you can do in C via enums. </p> <p>I don't need the full featureset of enums. In the end I just want to have fast <em>and</em> readable code.</p> <p>I've tr...
<p>The normal way to do enumerations in Lisp is to use symbols. Symbols get interned (replaced with pointers to their entries in a symbol table) so they are as fast as integers and as readable as enumerated constants in other languages.</p> <p>So where in C you might write:</p> <pre> enum { apple, orange, b...
Reading private keys from oracle wallet <p>We use Oracle wallet for scripting Oracle releases.</p> <p>Using mkstore I can add or delete private keys to Oracle wallet.</p> <p>Either using Java or C#, I want to read the private key sitting inside the Oracle wallet.</p> <p>Could someone share the sample code how to do ...
<p>Isn't the point of the wallet to prevent anything from reading the private key?</p>
URL query string convention for multiple sort <p>I have a RESTful web application that supports multiple sort fields on a collection of items. Is there a common convention for encoding these sort fields into the query string of a URL? I'm considering a pattern like the following: </p> <pre><code>http://myapp.com/books...
<p>I've done this before using the standard SQL sorting syntax. There are numerous parsing functions and techniques out there.</p> <pre><code>http://myapp.com/books?sort=author asc,datepublished desc&amp;count=12 </code></pre> <p>which would be encoded to </p> <pre><code>http://myapp.com/books?sort=author+asc,datep...
Sending Dates over RMI between machines in different regions <p>I'm having a problem sending java.util.Date objects over RMI, to and from machines in different timezones. </p> <p>For example, a client in Germany will send a date object to a server in the UK.</p> <ol> <li>User enters a date string e.g. 20090220.</li> ...
<p>I fail to see what your problem is here, those dates look correct to me- they're just being formatted to the locale in use. If you want the date entered by the user to be in GMT, specify the locale on the SimpleDateFormat constructor</p>
Are all these SQL joins logically equivalent? <p>I'm just wondering if all of the following joins are logically equivalent, and if not, why not?</p> <pre><code>SELECT t1.x, t2.y from t1, t2 where t1.a=t2.a and t1.b=t2.b and t1.c = t2.c; SELECT t1.x, t2.y from t1 join t2 on t1.a=t2.a where t1.b=t2.b and t1.c = t2.c; ...
<p>They are logically equivalent and should produce the same result. However, the last one is to be preferred as it states more correctly the semantics of the query - i.e. "join tables t1 and t2".</p> <p>The WHERE clause should be used for "filtering" results of the join - e.g.</p> <pre><code>... WHERE t2.some_col &...
Selecting an object on a WPF Canvas? <p>I have a WPF Canvas with some Ellipse objects on it (displayed as circles). Each circle is from a collection class instance which is actually a custom hole pattern class. Each pattern has a certain number of circles, and each circle then gets added to the canvas using an iteratio...
<p>All <code>FrameworkElements</code> have a <code>Tag</code> property which is of type object that can be used to hold arbitrary information. You could assign the <code>HolePattern</code> to the <code>Tag</code> property and easily use that later to get the associated collection.</p> <p>i.e.:</p> <pre><code>... Hol...
How to output the code itself? <p>How many ways are there to let the code output itself? </p> <p>For example, write the code below,</p> <pre><code>public class Test { public static void main(String[] args) { // some code } } </code></pre> <p>to output itself</p> <pre><code>public class Test { publ...
<p>This is called a programming quine, and has been extensively discussed on SO:</p> <p><a href="http://stackoverflow.com/search?q=quine">http://stackoverflow.com/search?q=quine</a></p> <p>Also see</p> <p><a href="http://en.wikipedia.org/wiki/Quine_(computing)" rel="nofollow">http://en.wikipedia.org/wiki/Quine_(comp...
How trustworthy is javascript's random implementation in various browsers? <p>I would like to do some experimenting with javascript and encryption and I got curious as to how unpredictable the implementation of the random function is. Has anyone done any hard tests?</p> <p>Clearly browsers have the ability to generat...
<p>Generally, the random function is not cryptographically strong, for that you need to make sure you are using a cryptographic pseudo-random-number generator.</p> <p>Generic random functions generally don't use cryptographically strong generation methods because they take longer than simple ones, (eg. Yarrow is more ...
AuiNotebook, where did the event happend <p>How can I find out from which AuiNotebook page an event occurred?</p> <p>EDIT: Sorry about that. Here are a code example. How do I find the notebook page from witch the mouse was clicked in?</p> <pre><code>#!/usr/bin/python #12_aui_notebook1.py import wx import wx.lib.ins...
<p>For a mouse click you can assume the current selected page is the one that got the click. I added a few lines to your code. See comments</p> <pre><code>def new_panel(self, nm): pnl = wx.Panel(self) # just to debug, I added a string attribute to the panel # don't you love dynamic languages? :) pnl.id...
Starting external process from ASP.NET <p>I need to start an external process from my web application. This means using <em>System.Diagnostics.ProcessStartInfo</em> to call out and execute a console app (exe). But I then need to somehow <strong><em>make sure nothing went wrong</em></strong> during it's execution <stron...
<p>It's not so hard with the Process class. Though, the prior poster was correct - you need to be concerned about permissions. </p> <pre><code>private string RunProcess(string cmd) { System.Diagnostics.Process p; p= new System.Diagnostics.Process(); if (cmd== null || cmd=="") { return "no command given."; ...
Use of return keyword in code block <p>What is the difference between saying:</p> <pre><code>if (abc == "a") { // do something here... return; } </code></pre> <p>and the same as above, but without the return keyword?</p> <p>I am a C# coder and I know that the return keyword followed by a type or variable returns tha...
<p>"return" exits from the <em>function</em>, not just the enclosing code block. So if your code block was in the context of a function, like so (I don't know C# so I'm using Java syntax):</p> <pre><code>int thisIsAFunction(int a) { if (abc == "a") { // do something here... return 1; } ...
I need platform-independent version of CharToOem. Does Boost have any? <p>I need to convert string to support multi-language messaging in my client-server app.<br> Can I find it in boost? </p>
<p>For platform-independent codepage conversions you can use <a href="http://www.gnu.org/software/libiconv/" rel="nofollow">libiconv</a> library. Anyway, why bother using codepages at all? Use unicode.</p>
What is the best way to expose a WCF service so that it can be easily consumed from Java/CXF? <p>We've written a WCF service to be used by a Java shop, who is using CXF to generate the adapters. We're not that familiar with Java, but have exposed the service using basicHttpBinding, SSL, and basic authentication. Inte...
<p>The "Two declarations cause a collision in the ObjectFactory class" error message usually has nothing to do with imports. That's a JAXB error message that is usually caused by having multiple elements or similar that cause the generated field names to be the same. For example, if you have elements like:</p> <p>...
indexes in mysql SELECT AS or using Views <p>I'm in over my head with a big mysql query (mysql 5.0), and i'm hoping somebody here can help. </p> <p>Earlier I asked how to get distinct values from a joined query <a href="http://stackoverflow.com/questions/508707/mysql-count-only-for-distinct-values-in-joined-query">htt...
<p>Starting fresh:</p> <p>Question - why are you grouping by both media.bid and media.date? Can a bid have records for more than one date?</p> <p>Here's a simpler version to try:</p> <blockquote> <pre><code>SELECT mdate.bid, mdate.fid, mdate.date, mdate.time, mdate.title, mdate.name, md...
Vi substitution command <p>Using vi, how do I substitute the current line number somewhere into the current line? For example, if the cursor is on line 10, I would like to put the number 10 somewhere on that line.</p>
<p>You want to physically insert the line number, not just display it in the margin? If so -</p> <pre><code>:s/$/\=line(".")/ </code></pre> <p>This will append it the the end of the line. Replace $ with ^ to prepend to the line.</p>
How to Prevent SQL Injection in Oracle SQLPlus? <p>Obviously if I am using JDBC/ODBC, I can use bind variables and prepared statements to prevent SQL injection. However, when data is passed to batch processes that end up invoking Oracle SQLPlus, is there a way to prevent SQL injection? For example:</p> <p>query.sql:</...
<p>If people have sql*plus access to your database and you have the user id and password of a privileged user out here in a script for them to read, then you've just dropped your pants to them anyway. SQL injection is the least of your worries.</p>
Plesk alternative for windows <p>I'm searching for a free alternative to Plesk for my windows server 2003. Anybody knows an alternative.</p>
<p>As far as I know there aren't any. Plesk bought Helm it's only major competitor in the Windows space. The only "ok" free panel I know is ISPConfig but it's only for Linux.</p> <p>Our company is also searching for an alternative to Plesk, for Windows hosting.</p> <p>Edit 25 Oct 2010: DotNetPanel renamed to WebsiteP...
formatting long numbers as strings in python <p>What is an easy way in Python to format integers into strings representing thousands with K, and millions with M, and leaving just couple digits after comma?</p> <p>I'd like to show 7436313 as 7.44M, and 2345 as 2,34K.</p> <p>Is there some % string formatting operator a...
<p>I don't think there's a built-in function that does that. You'll have to roll your own, e.g.:</p> <pre><code>def human_format(num): magnitude = 0 while abs(num) &gt;= 1000: magnitude += 1 num /= 1000.0 # add more suffixes if you need them return '%.2f%s' % (num, ['', 'K', 'M', 'G', ...
How do you see the client-side URL in ColdFusion? <p>Let's say, on a ColdFusion site, that the user has navigated to <a href="http://www.example.com/sub1/" rel="nofollow">http://www.example.com/sub1/</a></p> <p>The server-side code typically used to tell you what URL the user is at, looks like: <a href="http://#cgi.se...
<p>I suppose this won't be possible. </p> <p>If the client requests "GET /", it will be translated by the web server to "GET /{whatever-default-file-exists-fist}" before ColdFusion even gets invoked. (This is necessary for the web server to know that ColdFusion has to be invoked in the first place!)</p> <p>From ColdF...
HOW? Controller return nothing/current view <p>SHORT:<br> How do I make a controller return the current view or just simply do nothing?</p> <p>LONG:<br> I have a partial view where i've created an imageslider. It contains a link which sends a request to a controller to get the next image (using ajax). The controller f...
<p>You can return an EmptyResult if you want it to do nothing...</p> <pre><code>return new EmptyResult(); </code></pre> <p>If you're using the AjaxHelper you can avoid the update by supplying an unsuccessful status code (e.g. 404 or whatever is most appropriate), that'll stop it replacing your div as the javascript i...
Load Testing with AB ... fake failed requests (length) <p>To do some load testing, for my own curiosity, on my server I ran:</p> <pre><code>ab -kc 50 -t 200 http://localhost/index.php </code></pre> <p>This opens up 50 keep-alive connections for 200 seconds and just slams my server with requests for index.php</p> <p>...
<p>Nevermind. The "length failure" merely indicates that about half the time the length of the response was different.</p> <p>Since the contents are dynamic, it's probably the session identifier or something like that.</p>
Loading/Using Resource Dictionaries from a WinForms hosted WPF control <p>I have a Windows Forms application that needs to host a WPF control at runtime. I have the basic hosting and interaction complete (using an ElementHost control) and everything works fine until I try to do something that requires the WPF control t...
<p>Assuming you know what resources you need (sounds like you do), you should just be able to "inject" them yourself. Something like:</p> <pre><code>var wpfControl = new ...; wpfControl.Resources.Add(...); elementHost.Child = wpfControl; </code></pre> <p>In your question you mention that there are existing resource d...
How to put the content of a ByteBuffer into an OutputStream? <p>I need to put the contents of a <code>java.nio.ByteBuffer</code> into an <code>java.io.OutputStream</code>. (wish I had a <code>Channel</code> instead but I don't) What's the best way to do this?</p> <p>I can't use the ByteBuffer's <code>array()</code> me...
<p>Look at <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/channels/Channels.html#newChannel%28java.io.OutputStream%29">Channels.newChannel(OutputStream)</a>. It will give you a channel given an OutputStream. With the WritableByteChannel adapter you can provide the ByteBuffer which will write it to the Outpu...
HTTPS causes Joomla to revert back to old Domain when creating links <p>I have moved the website BradPPresents.com to BradP.com. <strong>URLS ARE NOT SAFE FOR WORK</strong></p> <p>The website links properly on HTTP but as soon as it uses HTTPS the links revert back to BradPPresents.com. </p> <p>I assumed this was a J...
<p>To others: Before your curiosity gets the best of you and you decide to check this guy's site, please be aware that may be not suitable for work at some places. Update: I don't have privilege to edit the URLs statement that was added to the question, so I'll just update here: The site is not an adult site in the...
Wrapping objects to extend/add functionality while working around isinstance <p>In Python, I've seen the recommendation to use holding or wrapping to extend the functionality of an object or class, rather than inheritance. In particular, I think that Alex Martelli spoke about this in his <a href="http://www.lecturefox...
<p>If the library code you depend on uses <code>isinstance</code> and relies on inheritance why not follow this route? If you cannot change the library then it is probably best to stay consistend with it.</p> <p>I also think that there are legitimate uses for <code>isinstance</code>, and with the introduction of <a hr...
Where can I find some websites with VB.NET tutorials? <p>I am looking for a website similar to W3Schools that teaches the basics for VB.NET 2008.</p> <p>If none exist I would just like some good tutorials to get me started. I did some basic VB.NET a couple of years ago but I need to refresh myself, any ideas? </p>
<p>You can find visual basic tutorials in MSDN: go to the <a href="http://msdn.microsoft.com/en-gb/vbasic/default.aspx" rel="nofollow">Visual Basic Developer Center</a> for a start.</p>
How can I enforce a constraint only if a column is not null in Postgresql? <p>I would like a solution to enforce a constraint only if a column is not null. I can't seem to find a way to do this in the documentation.</p> <pre><code>create table mytable( table_identifier_a INTEGER, table_identifier_b INTEGER, tabl...
<p>Ummm. Unique constraints don't prevent multiple NULL values.</p> <pre><code>CREATE TABLE mytable ( table_identifier_a INTEGER NULL, table_identifier_b INTEGER NOT NULL, table_value1 INTEGER NOT NULL, UNIQUE(table_identifier_a, table_identifier_b) ); </code></pre> <p>Note that ...
Suggestions for automating web application (work flow not testing) <p>A customer has a legacy web application which is used mainly to capture information. The application has no other interfaces available e.g. web services, API’s. </p> <p>Typical workflow:</p> <ul> <li>First form: Select “Action Type” of “P...
<p>You will want to do this <em>without</em> a browser, using HTTP POST requests. <strong>A scripting language such as Perl, Python etc. would be a good choice</strong> in terms of simplicity - in this case the actual code would probably take no more than 30-so lines.</p> <p>You would essentially have to:</p> <ol> <...
Python ORM that auto-generates/updates tables and uses SQLite? <p>I am doing some prototyping for a new desktop app i am writing in Python, and i want to use SQLite and an ORM to store data.</p> <p>My question is, are there any ORM libraries that support auto-generating/updating the database schema and work with SQLit...
<p><a href="http://www.sqlalchemy.org/">SQLAlchemy</a> is a great choice in the Python ORM space that supports SQLite.</p>
Why is $Id$ sometimes not expanded in SVN? <p>I'm working on a project in which we're actively using the <code>$Id$</code> string generated by subversion to write the version number in the documentation. For example, we parse this string</p> <pre><code>$Id: filename 999 2009-02-23 22:51:29Z author $ </code></pre> <p>...
<p>The svn:keywords property may not be properly set on that file. You need to set it to (at least) 'Id':</p> <pre><code>svn ps svn:keywords 'Id' filename.txt </code></pre>
Cannot get Adobe AIR's ApplicationUpdaterUI() to work <p>Here is my problem - I'm trying to write a self-updating application, but I keep getting an error saying that runtime.air.update.ApplicationUpdaterUI() does not return a constructor.</p> <p>Here's the relevant section of the code; there are other javascript file...
<p>Verify the path in that script tag for the SWF, I'm guessing you do not have the reference to the ApplicationUpdater_UI.swf correct. </p> <p>Air is basically complaining that it cannot find a runtime.air.update.ApplicationUpdaterUI() method to call anywhere, which likely means it can't find the SWF (or I suppose it...
Performance problems on iPhone using simple graphics <p>We're working on a couple simple games and we have some performance problems that we keep running into, and I was curious if it was a code issue or a "we're using the wrong objects" issue.</p> <p>Our games are basically simple ones that work as follows:</p> <p>W...
<p>There are definitely ways to speed this up. Manually redrawing the images every frame means you are redrawing textures you could be reusing. You could reuse them either by moving to OpenGL, or moving the images into a CALayer and then just repositioning the layer instead of redrawing the image.</p> <p>If you do not...
svn access to a https repository: username / password always being prompted for <p>I just moved my svn repository to a new server. Previously I was accessing my repository via <em>svn://oldserver/yyy/zzz</em> Now I want to access it via <em>https://newserver:8443/svn/yyy/zzz</em></p> <p>I used <strong>switch --relocat...
<p>I'm not really a SVN god, but I assume you got the checkout working? What happens if you just type</p> <pre><code>svn.exe update zzz </code></pre> <p>in the root directory of your project?</p>
Can Firebug set breakpoints in external JavaScript files? <p>Is there any way in <a href="http://www.getfirebug.com/" rel="nofollow">Firebug</a> to set a breakpoint in an external .js file that a page links to so that it can be stepped through?</p> <p>(I suspect I've found a bug in jQuery and I want to be able to step...
<p>Not sure if I understand the question, but I don't think Firebug treats external javascript any differently than internal one. Just go to the "script" tab, select the .js file in the drop down list and set your breakpoint.</p>
Skipping certain files/classes when using asdoc <p>For some reasons, <strong>asdoc</strong> seems to be only good at 'excluding' classes but not 'skipping', which means all the files will always be walked through and examine for errors.</p> <p>Is there a way to make <strong>asdoc</strong> really 'skip' some certain fi...
<p>We haven't found a way of having asdoc <em>skip</em> files, but we have got it working by only providing a whitelist of what files we do want parsed. You could easily write a script that would find all the *.as files and compare them to a 'deny' list and pass those all into asdoc.</p> <p>Newer versions of asdoc sup...
"Good" Database Record Comparison tool? <p>I am a system administrator for a company that supports a CRM CMS (Salesforce).</p> <p>I don't like the built-in functionality so I generally manage data through CSV/XLS files for uploading and downloading, because I can write better queries and the like. One of my tasks is u...
<p>The two db comparison tools I have used are xSQL and Redgate SQL Compare.</p> <p>I prefer redgate for its ease of use but it is pretty pricey. </p> <p>xSQL is a little complicated to get the hang of at first but is quite powerful, it also does a much better job of scripting schema and data than SQL server does. it...
How must I declare the regex for Perl's split? <p>I came across this Perl construct today:</p> <pre><code>@foo = split("\n", $bar); </code></pre> <p>That works well for splitting a large string into an array of lines for UNIX-type line endings, but leaves a trailing \r for Windows. So I changed it to:</p> <pre><code...
<p>The slashes are just the standard delimiters for a regular expression (you can use others), and they evaluate special characters and escape sequences just like double quotes.</p> <p><em>EDIT</em>: I shot too fast, as Manni explained in the comment. I'll try a longer explanation:</p> <p>Usually, matching regexes ...
Convert Collection to List <p>I am using <code>TreeBidiMap</code> from the <code>Apache Collections</code> library. I want to sort this on the values which are <code>doubles</code>.</p> <p>My method is to retrieve a <code>Collection</code> of the values using:<br> <code>Collection coll = themap.values();</code><br> Wh...
<pre><code>List list = new ArrayList(coll); Collections.sort(list); </code></pre> <p>As Erel Segal Halevi says below, if coll is already a list, you can skip step one. But that would depend on the internals of TreeBidiMap.</p> <pre><code>List list; if (coll instanceof List) list = (List)coll; else list = new Arr...
Avoiding dynamic_cast/RTTI <p>I was recently working on a piece of C++ code for a side project (the <a href="https://sourceforge.net/projects/cpp-markdown/"><code>cpp-markdown</code> library</a>, for the curious), and ran into a coding question that I'd like some opinions on.</p> <p><code>cpp-markdown</code> has a bas...
<p>#1 pollutes the class namespace and vtable for objects that don't need it. Ok when you have a handful of methods that will generally be implemented, but plain ugly when only needed for a single derived class.</p> <p>#2 is just <code>dynamic_cast&lt;&gt;</code> in a polka-dot dress and lipstick. Doesn't make client ...
Binary Trees in C <p>I'm trying to insert nodes into a tree in order. My function works fine... when there's only three nodes.</p> <p>I have this code:</p> <pre><code>typedef struct _Tnode Tnode; struct _Tnode { char* data; Tnode* left; Tnode* right; }; </code></pre> <p>Along with this:</p> <pre><code>...
<p>This would appear to just be a school project.</p> <p>Where to begin.</p> <p>1) You are clobbering left/right all the way down the tree. I'm not sure why you would expect them to be preserved since: a) You always write to these nodes. b) The only time you return an existing node is on a strcmp match.</p> <p>...
How to close the File after it is read from backward? <p>I asked a question about "How to read a text file reversely with iterator in C#" sometime ago. <a href="http://stackoverflow.com/questions/452902/how-to-read-a-text-file-reversely-with-iterator-in-c">Please see the link</a></p> <p>Jon Skeet was very kind to prov...
<p>It was just a very regrettable oversight.</p> <p>The answer is - as normal - to use <code>try</code>/<code>finally</code> or a <code>using</code> statement. That way the file will be closed even if an exception is thrown, and even if the caller doesn't iterate all the way back to the start of the file.</p> <p>Howe...
Oracle query to get book-name? <pre><code>table name:id col1:owner-name col2:book-id1 col3:book-id2 table name:book-name col1:id col2:name </code></pre> <p>Can anyone get me a query to get following result owner-name,book1-name,book2-name using above 2 table</p>
<pre><code>SELECT id.owner-name, b1.name "book1-name", b2.name "book2-name" FROM id LEFT JOIN book-name "b1" ON b1.id = id.book-id1 LEFT JOIN book-name "b2" ON b2.id = id.book-id2 </code></pre>
What exactly does this url mean? <p>I am using different analytics tags in one of our web applications. Most of them call a javascript code for tracking.</p> <p>Some tags have url of gif image with querystrings. </p> <p>Example : <a href="http://www.google-analytics.com/__utm.gif?utmwv=45.542" rel="nofollow">http://w...
<p>Basically, you write a script in your preferred language, and map that script to <em>yourtrackingscript.gif</em>. ..jpg, png even.</p> <p>Have done this in asp.net using a http handler.</p> <p>The script reads the querystring like any other dynamic page (aspnet, asp, php, anything really), then writes it to a db ...
Will HTML be replaced by any new technology? <p>I see various frameworks being launched that promise Rich Ui and better User experience as they call it. Silverlight, Flash, Yahoo's new framework etc etc.</p> <p>Does this mean that over a period of time these frameworks will replace the existing HTML, JAVASCRIPT CSS ba...
<p>HTML won't be replaced as a standard any time soon. It's too wide spread a technology, and the amount of re-education required among people working with webapps and websites to switch technology completely would be massive and very costly.</p> <p>HTML will however, like any other technology, evolve. Look at HTML to...
How to keep process from exiting when a pthread exits? <p>I am writing a server program in C wherein every time a client connects, I create a new pthread to handle the client's requests.</p> <p>When all of the threads exit, however, then my program exits, as though a call to exit() has been made. This is a problem - h...
<p>If you debug it in gdb you'll see that you're getting a SIGPIPE, which your program doesn't handle. You can either install a SIGPIPE handler or ignore SIGPIPE.</p> <p>The reason is that your thread is writing to a socket (pipe) that has been closed (by the client), which raises a SIGPIPE. You should check the retur...
adding classpath in linux <pre><code>export CLASSPATH=.;../somejar.jar;../mysql-connector-java-5.1.6-bin.jar java -Xmx500m folder.subfolder../dit1/some.xml cd .. </code></pre> <p>is the above statement for setting the classpath to already existing classpath in linux is correct or not</p>
<p>I don't like setting CLASSPATH. CLASSPATH is a global variable and as such it is evil: </p> <ul> <li>If you modify it in one script, suddenly some java programs will stop working. </li> <li>If you put there the libraries for all the things which you run, and it gets cluttered.</li> <li>You get conflicts if two diff...
New to Unit Testing <p>I would like to know how to implement unit testing in an existing (quite large) application using visual studio 2008 (.net 2.0).</p> <p>I understand that developing unit tests for the existing/legacy code is not realistic but I would like to have tests for code moving forward.</p> <p>I have fou...
<p>Simple approach:</p> <ul> <li>Pick one of unit test frameworks (Nunit, MbUnit, Xunit, VS unit test framework, ...)</li> <li>Add project for unit tests in your solution (for example UnitTests). </li> <li>Start writing tests.</li> </ul> <p>For easier organization, create at least one namespace for each project in so...
Can we run a C#/WPF application on Mac OS X? <p>I sell a C#/WPF application (targeting .net 3.0 at the moment) and people keep asking me for a Mac version.</p> <p>The application is a time tracking application with a good GUI, there isn't that much business logic in a time tracking application so most of the applicati...
<p>There's absolutely no way you can run full-fledged WPF app on Mac. I'm not even sure if this is possible in Parallels. The best thing you can do is to use Silverlight, which was previously named "WPF/E" and does run on Macintosh.</p>
checking for scrollbars <p>Is there a way to check for scrollbars? What I need is a way to see if the user has written too much text in an iframe (using punyMCE). If the user has gone beyond the allowed number of lines (which will cause scrollbars to appear), I want to tell the user that the maximum number of lines has...
<p>A simpler way would probably be to compare the clientHeight of the contents of the iframe with the outer height of the iframe. Something like this:</p> <pre><code>if (window.frames[0].innerHeight &lt; window.frames[0].document.documentElement.clientHeight) alert('too much!'); </code></pre> <p>(tested quickly w...
SharePoint development environment setup <p>i need to setup a development environment for writing Share Point Web Parts. What do I exactly need?</p> <p>My development machine is a Windows XP Prof. with Visual Studio 2008 Prof. If found <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=05E0DD12-8394-402...
<p>I highly recommend using a VM. SharePoint is big. It requires multiple servers and lots of services. Basically its guaranteed to slow down any workstation you install it on. Other benefits of using a VM to develop:</p> <ul> <li>Undo disks</li> <li>Moving your dev environment from workstation to workstation</li...
How do I stop 401 responses from TFS 2008 <p>Whenever a web request is made by Visual Studio to TFS, Fiddler will show a 401 Unauthorized error. Visual Studio will then try again with a proper Authorization Negotiate header in place with which TFS will respond with the proper data and a 200 status code.</p> <p>How ca...
<p>This is how the process of Windows Integrated Authentication (NTLM) works. NTLM is a connection based authentication mechanism and actually involves 3 calls to establish the authenticated session. </p> <p>The TFS API then goes to extra-ordinary lengths to make sure that this handshake is done in the most efficient...
Using MS Sync Framework to synchronize two SQL CE Dbs <p>I'm just working into the Microsoft Sync Framework. It looks quite easy to sync a local SQL CE 3.5 Database with a remote SQL Server 2008 using the SqlSyncAdapterBuilder and SqlServerChangeTracking.</p> <p>Unfortunately, syncing two SQL CE 3.5 Databases doesn't ...
<p><a href="http://msdn.microsoft.com/en-us/library/bb902854%28SQL.105%29.aspx">Sync Framework 2.0</a> allows synchronization between SQL Server Compact Edition databases.</p> <blockquote> <p>SqlCeSyncProvider is used to synchronize SQL Server Compact databases.</p> <p>This provider can be used to synchro...
Create XPathDocument from XmlElement <p>I'm using a webservice which returns an <code>XmlElement</code> object to my C# program. I would like to read information from the <code>XmlElement</code> using Xpath. What is the best way to create an <code>XPathDocument</code> from the <code>XmlElement</code>?</p>
<p>If you have an <code>XmlElement</code>, can you not just use <code>SelectNodes()</code> / <code>SelectSingleNode()</code>?</p> <p>Also, all <code>XmlNode</code>s are <code>IXPathNavigable</code>, allowing you to get a navigator.</p> <p>Finally, you can use <code>new XmlNodeReader(element)</code>, and use this to c...
How to use INNER JOIN in the scenario? <p>I have 2 tables:</p> <p>'Users' Table</p> <pre> id username ---- -------- 0001 user1 0002 user2 0003 user3 0004 user4 </pre> <p>'Friends' Table</p> <pre> user_id friend_id friend ------- --------- ------ 0001 ...
<pre><code>SELECT u.username FROM Friends f, Users u WHERE f.user_id = u.id AND f.friend = 1 AND f.friend_id = '0004' </code></pre>
What is a working copy and what does "switching" do for me in Tortoise SVN? <p>I have a software app and I've hit an important milestone, version 2.0.</p> <p>I decided I want to tag this version as "Version-2.0" so I have named this snapshot. I also created a "Version-2.0" branch in case I need to fix anything and mer...
<p>A working copy is the copy you have checked out to your working area. It doesn't matter if it is a branch or from the trunk. It's what you are working on.</p> <p>You can switch between branches (or more correctly copies) of the same parent with svn switch. This will basically say, what's different between the curre...
Dropdown list <p>I want people to choose from a dropdown list,and their choice takes them to a page they have chosen.</p>
<p>In aspx</p> <pre><code>&lt;asp:DropDown ID="MyDropDown" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RedirectUser"&gt; &lt;asp:ListItem Value="/MyPage.aspx" Text="MyPage"/&gt; &lt;/asp:DropDown&gt; </code></pre> <p>In code behind</p> <pre><code>protected void RedirectUser(object sender, EventArgs...
Control a service from another application in Vista <p>I'm wondering if it's possible to create a windows service in .NET and then create another windows.forms process that connects to the service and passes parameters, modifies and views its datastructures and connected database, etc.</p> <p>I believe that in Vista t...
<p>I'm not aware of a <code>ServiceController</code> limitation, but then: I rarely use Vista ;-p</p> <p>Rather than raw sockets... one option is to have the service act as a WCF host, via <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx" rel="nofollow"><code>ServiceHost</code></a>...
Need key code for Alt-Ctrl-Del <p>I need the key code for <kbd>Alt</kbd>+<kbd>Ctrl</kbd>+<kbd>Del</kbd> in c#, for example </p> <pre><code>const int KEYEVENTF_KEYUP = 0x2; const int KEYEVENTF_KEYDOWN = 0x0; keybd_event(0x11, 0, KEYEVENTF_KEYDOWN, 0); keybd_event(0x41, 0, KEYEVENTF_KEYDOWN, 0); keybd_event(0x11, ...
<p>You cannot capture <kbd>Alt</kbd>+<kbd>Ctrl</kbd>+<kbd>Del</kbd>. It's captured by the operating system and is <strong>very</strong> secure.</p> <p>Even programs like VMWare have to emulate it with <kbd>Alt</kbd>+<kbd>Ctrl</kbd>+<kbd>Ins</kbd> since Windows protects it so well, and for good reason. If you could sub...
Select COUNT(*) of subquery without running it twice <p>I've got a procedure to return a result set which is limited by page number and some other stuff. As an OUTPUT parameter I need to return a total amount of selected rows according to the parameters except the page number. So I have something like that:</p> <pre><...
<p>You can count the total rows as a separate column in your main query using COUNT(*). Like this:</p> <pre><code>WITH SelectedItems AS (SELECT Id, Row1, Row2, ROW_NUMBER() OVER (ORDER BY Row1) AS Position, COUNT(*) OVER () AS TotalRows FROM Items WHERE Row2 = @Row2) SELECT Id, Row1, Row2 FROM SelectedItems WHERE Po...
Static context in enum definition <p>The syntax sugar provided by Java's <code>enum</code> facility can sometimes be a little confusing. Consider this example, which does not compile:</p> <pre><code>public enum TestEnum { FOO("foo") { public void foo() { helper(); // &lt;- compiler error ...
<p>The error message is misleading, just make <code>helper</code> protected and it will work. </p> <pre><code>protected void helper(){ // can be called from subclasses (such as FOO) since it is not private } </code></pre>
The use of undefined variables in if-statements <p>This snippet results in a JavaScript runtime error: (<code>foo</code> is not defined)</p> <pre><code>if (foo) { // ... } </code></pre> <p>I have to define <code>foo</code> first, like so:</p> <pre><code>var foo = foo || null // or undefined, 0, etc. </code></pre...
<p>I sense you are asking because you are aware that javascript seems to allow undefined variables in some situations (ie no runtime errors) and not in others.</p> <p>The reasoning is as follows: javascript <em>always</em> throws an error on checking undefined variables, but <em>never</em> throws an error on checking ...
Do any functions fire when going "back" to a view with a UINavigation <p>I know its probably a really simple thing, but I need to reload some data if some changes have been made from a subview and then the master view is returned to.</p>
<p>Have a look at implementing</p> <pre><code>- (void)viewDidAppear:(BOOL)animated </code></pre> <p>or</p> <pre><code>- (void)viewWillAppear:(BOOL)animated </code></pre> <p>But note there can be a problem that needs to be taken care of for UINavigationControllers <a href="http://davidebenini.it/2009/01/03/viewwilla...
How can I create a temp file with a specific extension with .NET? <p>I need to generate a unique temporary file with a .csv extension.</p> <p>What I do right now is </p> <pre><code>string filename = System.IO.Path.GetTempFileName().Replace(".tmp", ".csv"); </code></pre> <p>However, this doesn't guarantee that my .cs...
<p>Guaranteed to be (statistically) unique:</p> <pre><code>string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".csv"; </code></pre> <p>(To quote from the wiki article on the probabilty of a collision:</p> <blockquote> <p>...one's annual risk of being hit by a meteorite is estimated to b...
How can I get started creating a Java web service? <p>I want to create a simple <code>hello world</code> java web service.</p> <p>What tools I need to get started?</p> <p>What do I need to know to get started deploying this in Tomcat?</p>
<p>There are plenty of <a href="http://www.google.com/search?q=tomcat%2Baxis%2Btutorial" rel="nofollow">Tomcat + axis tutorials</a>. For example, <a href="http://tomcat-configure.blogspot.com/2009/01/tomcat-axis-tutorial.html" rel="nofollow">this blog post</a> seems to do a reasonable job.</p>
SharePoint Webpart deserialize error <p>I am getting a random web part error, it works one refresh and then not the next:</p> <blockquote> <p><strong>Web Part Error</strong>: One of the properties of the web part has an incorrect format. Windows SharePoint services cannot deserialize the Web Part. Check the ...
<p>This could also be because of insufficient disk space on the server where SharePoint is hosted. <a href="http://www.sharepointblogs.com/vipul/archive/2006/09/25/webpart-error-due-to-space-crunch.aspx" rel="nofollow">http://www.sharepointblogs.com/vipul/archive/2006/09/25/webpart-error-due-to-space-crunch.aspx</a> Ch...
what is minimum flash player revision working with FLEX 3 <p>My page has currently this set up - what is minimum REVISION I can configure here:</p> <pre><code>// Major version of Flash required var requiredMajorVersion = 9; // Minor version of Flash required var requiredMinorVersion = 0; // Minor version of Flash requ...
<p>See <a href="http://www.adobe.com/products/flex/systemreqs/" rel="nofollow">this</a>. It looks like its best to have 9.0.124.0. Which means you will need to upgrade your Macbook flash player.</p>