input
stringlengths
51
42.3k
output
stringlengths
18
55k
Is there a way to raise the backlight on an Android device through the official API? <p>What I've read seems to indicate that the only way to do it is to use unofficial APIs that are being locked down in Cupcake (1.5). Is this true?</p>
<p>It looks like the answer is "not until cupcake". </p> <p>From <a href="http://android-developers.blogspot.com/2009/04/future-proofing-your-apps.html" rel="nofollow">Android Developers Blog: Future-Proofing Your Apps</a>:</p> <blockquote> <p>Technique to Avoid, #1: Using Internal APIs</p> <p>Even though we'v...
SQLite - pre allocating database size <p>Is there a way to pre allocate my SQLite database to a certain size? Currently I'm adding and deleting a number of records and would like to avoid this over head at create time. </p>
<p>The fastest way to do this is with the zero_blob function:</p> <p><strong>Example:</strong> </p> <p>Y:> <strong>sqlite3 large.sqlite</strong><br> SQLite version 3.7.4<br> Enter ".help" for instructions<br> Enter SQL statements terminated with a ";"<br> sqlite> <strong>create table large (a)</strong>;<br> sqlite> ...
What is the Best way to deserialize a null-terminated string in .NET? <p>I am reading a message from my network connection which is serialized as a series of null-terminated strings (and other binary data)</p> <p>I could read a char at a time using a BinaryReader, until I find a NULL.</p> <p>Is there a more efficient...
<p>I think reading byte by byte is a reasonable option, but I would use a <a href="http://msdn.microsoft.com/en-us/library/system.io.bufferedstream.aspx" rel="nofollow">BufferedStream</a> to minimize IO on the underlying stream.</p>
How can I access request headers that don't appear in $_SERVER? <p>I am attempting to create a REST API in PHP and I'd like to implement an authentication scheme similar to Amazon's S3 approach. This involves setting a custom 'Authorization' header in the request.</p> <p>I had thought I would be able to access the hea...
<p>You'll need to do some <code>mod_rewrite</code> wizardry to get your headers past the CGI barrier, like so:</p> <pre><code>RewriteEngine on RewriteRule .? - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] &lt;?php $auth = $_SERVER['HTTP_AUTHORIZATION']; ?&gt; </code></pre> <p>Note that if you're using <code>mod_...
Large ResultSet on postgresql query <p>I'm running a query against a table in a postgresql database. The database is on a remote machine. The table has around 30 sub-tables using postgresql <a href="http://www.postgresql.org/docs/8.3/interactive/ddl-partitioning.html" rel="nofollow">partitioning capability</a>.</p> <p...
<p>I'm betting that there's not a single client of your app that needs 1.8M rows all at the same time. You should think of a sensible way to chunk the results into smaller pieces and give users the chance to iterate through them.</p> <p>That's what Google does. When you do a search there might be millions of hits, b...
Is there an advantage to using parse_str for optional function parameters vs an array? <p>I happened to be making some changes to a WordPress blog and noticed that they use <code>parse_str</code> (<a href="http://php.net/parse%5Fstr" rel="nofollow">http://php.net/parse_str</a>) for parsing and setting their optional p...
<p>No. That seems like a ridiculous way to pass functional parameter arguments. I could understand it if you needed to recreate $_GET or $_POST variables or something along those lines, but for parameters to a function? That's code smell right there.</p> <p>They should be using an array, and then utilizing <a href=...
Any real world experience with H2 database? <p>Has anybody out there got any real world experience with the <a href="http://www.h2database.com/html/main.html">H2 database</a>? I'm interested in:</p> <ul> <li>performance</li> <li>stability</li> <li>bugs</li> </ul>
<p>We use H2 as the storage engine for a very large RCP/Eclipse-based design tool. The tool itself has been in use for over 2 years now on some data-heavy projects so we've stressed H2 pretty thoroughly. </p> <p>We did a fairly in-depth analysis of other Java embeddable db engines and chose H2. Overall I think we'r...
generic class and generic methods <pre><code>class test &lt;T&gt; where T : class { public void Write&lt;T&gt;() { Console.Write(typeof(T).FullName); } } </code></pre> <p>In the above class, it is possible to pass in a string for the class (<code>test&lt;string&gt; Test = new test&lt;string&gt;</co...
<p>As it was originally written no you cannot. In order to use different types at different points in the class, you must have multiple generic parameters. It is possible to define a different one at the method level and get your sample to work</p> <pre><code>class Test&lt;T&gt; where T : class { public void Write...
Problem with flash in a webbrowser in a winform <p>I have the oddest problem (but aren't all programming problems odd?). I have a winform that contains a webbrowser object that opens a website that has flash on it. This winform is running on a touchscreen computer (I can't find the brand or model number).</p> <p>Her...
<p>We had a similar error and the only solution was to ensure that at least service pack 1 for .NET 2.0 was installed on the client machine.</p>
Disable auto correction of iPhone text field <p>When I try to edit texts in my iPhone application (<code>UITextfield</code>), it auto-corrects my input. </p> <p>Could you let me know how can I disable this?</p>
<pre><code>UITextField* f = [[UITextField alloc] init]; f.autocorrectionType = UITextAutocorrectionTypeNo; </code></pre>
How do you set the default font for Tk widgets <p>I have a Tcl/Tk app that generates many forms and would like to be able to configure the default widget fonts from a central location without having to configure each widget with the <code>-font</code> switch.</p> <pre><code>#!&lt;path&gt;/wish button .hello -text "Hel...
<p>Try adding,</p> <pre><code>font create myDefaultFont -family Helvetica -size 20 option add *font myDefaultFont </code></pre> <p>to the top of your script. <a href="http://www.tclscripting.com/articles/jun06/article1.html">(link to article on fonts)</a></p>
windows apps <p>Hello am new to c++ from php. Although i am not an absolute newbie, meaning i have programmed large db driven apps using oop php and sql, i would like to know what the general process of creating stand alone windows applications using c++ is as far as patters, APIs compilations etc...</p> <p>EDITED: A...
<p>I think you should really pick up a copy of <a href="http://www.charlespetzold.com/pw5/" rel="nofollow">Programming Windows 5th Edition</a> by Charles Petzold to help you with a lot of this background information. </p>
a JOIN query edited so that a field that has unique values <p>I have a JOIN query that pulls the last 6 "topic" records (the records with the highest topic_ids that are have a topic_status of 0, i.e. it's not spam):</p> <pre><code>SELECT topic_title, topic_slug, meta_value, topic_poster FROM `folio_topics` as Topics I...
<p>According to <a href="http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html" rel="nofollow">this</a> article you may use a Group By to accomplish what you are trying. Try this</p> <pre><code>SELECT topic_title, topic_slug, meta_value, topic_poster FROM `folio_topics` as Topics INNER JOIN `folio_topicmet...
How can I prevent these redundant namespaces from an XSLT stylesheet? <p>When using an XSLT stylesheet to transform an XML file which contains embedded XHTML (using namespaces) into pure XHTML, I'm left with redundant namespace definitions on the elements which were originally XHTML. Simple test case:</p> <p>XML:</p>...
<p>Instead of <code>xsl:copy-of</code> use an identity transformation templates and remove the namespace prefix from XHTML elements.</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:fbb="urn:foo:bar:baz" xmlns:xsl="http://www.w3....
Is it ok for entities to access repositories? <p>I've just started working with DDD, so maybe this is a silly question...</p> <p>Is it ok for an entity to access a repository (via some IRepository interface) to get a value at runtime? For example, I want to enforce a "default" selection for a property:</p> <pre><cod...
<p>it's not a horrible violation of DDD it's a horrible violation of... well... it's just plain horrible (i say this tongue in cheek) :).</p> <p>First off, your entity becomes dependent on having a repository... that's not ideal. Ideally you'd want to have your repository create the Person and then assign it everythin...
Flagging an email before sending using any class of System.net.mail namespace <p>Is it possible to "Flag an email" for followup using SMTPClient/MailMessage classes in .NET?</p>
<p>It's my understanding that the flag is not part of the POP/MIME/SMTP specs and is simply a sorting feature offered by many applications. You can set the importance high, normal and low.</p> <pre><code>MailMessage msg = new MailMessage { Priority = MailPriority.High, Subject = "High priority message." }; </c...
passing session id via url <p>I'm trying to get my script to use url session id instead of cookies. The following page is not picking up the variable in the url as the session id. I must be missing something.</p> <p>First page <a href="http://www.website.com/start.php" rel="nofollow">http://www.website.com/start.php</...
<p>It looks like you just need to call <a href="http://www.php.net/manual/en/function.session-start.php" rel="nofollow">session_start()</a> on the second page.</p> <p>From the docs:</p> <blockquote> <p>session_start() creates a session or resumes the current one based on the current session id that's being passed v...
How can I use bash (grep/sed/etc) to grab a section of a logfile between 2 timestamps? <p>I have a set of mail logs: mail.log mail.log.0 mail.log.1.gz mail.log.2.gz</p> <p>each of these files contain chronologically sorted lines that begin with timestamps like:</p> <p><strong>May 3 13:21:12 ...</strong></p> <p>How ...
<p>Convert your min/max dates into "seconds since epoch",</p> <pre><code>MIN=`date --date="$1" +%s` MAX=`date --date="$2" +%s` </code></pre> <p>Convert the first <code>n</code> words in each log line to the same,</p> <pre><code>L_DATE=`echo $LINE | awk '{print $1 $2 ... $n}'` L_DATE=`date --date="$L_DATE" +%s` </cod...
C# - Need Suggestions on Improving a Section of Code <p>I have a function that receives three different "people" objects and generates a new "compatibility" object based on the combined values in the "people" objects.</p> <p>However, about 1/3 of the time the three "people" objects that it receives as input are the sa...
<p>I think you're looking at things in a much too complex manner. Take the 3 PersonID values and sort them,so that they're always in the same order, no matter which order they were passed in. Then set a value in a hashtable using the three PersonIDs as the key, separated with a hyphen or some other character that won't...
Using SubclassDlgItem to change control types <p>I have a C++ MFC app with a dialog where I want to change the type of the control dynamically based on the selection in a combo box. The dialog resource starts off with a plain old edit control which I then call SubclassDlgItem on to change to a custom control type.</p>...
<p>You can create a set of all possible controls in the same area of the parent window and show only the relevant one and hide all the others. When the user causes the control change you hide the active control and show the new relevant. This should look smoother.</p>
Tracing registry operations in C# <p>I have a problem. I need to trace all read/write operations to the registry made by various different programs.</p> <p>I need to do this tracing from within a C# program.</p> <p>Can I do this, or is it impossible?</p>
<p>Answer is you can.... :) </p> <p>Sysinternals has developed a utility called <a href="http://technet.microsoft.com/en-au/sysinternals/bb896652.aspx" rel="nofollow">Regmon</a> that does this thing. Then there is no reason to become this "Impossible"</p> <p>But definitely some time will be needed to understand the p...
Is there an accepted best-practice on making asynchronous HTTP requests in Android? <p>I've seen any number of examples and they all seem to solve this problem differently. Basically I just want the simplest way to make the request that won't lock the main thread and is cancelable.</p> <p>It also doesn't help that we ...
<p>The Android 1.5 SDK introduced a new class, <a href="http://developer.android.com/reference/android/os/AsyncTask.html">AsyncTask</a> designed to make running tasks on a background thread and communicating a result to the UI thread a little simpler. An example given in the <a href="http://android-developers.blogspot....
Flex/AS3: why I failed to listen ready event of module <p>follow are code snippet</p> <pre><code> var depTree:IModuleInfo=ModuleManager.getModule('modules/depTree.swf'); if(!depTree.loaded){ depTree.addEventListener(ModuleEvent.ERROR, onModuleError); depTree.addEventListener(ModuleEvent.PROGRESS,onModule...
<p>Its an SDK bug move to 3.4</p>
Is HTML::StripScripts still safe for removing modern exploits? <p>I need a way in Perl to strip naughty things, such as XSS, image interjection, and the works.</p> <p>I found <a href="http://search.cpan.org/dist/HTML-StripScripts" rel="nofollow">HTML::StripScripts</a> but it hasn't updated in close to two years, and I...
<p>XSS is a vast topic and exploits come up every other day. </p> <p>Just removing scripts will not make your code/site safe.</p> <p>It is better to not try to strip (Blacklisting) certain things. It is safer to white list html/special characters you will allow on your site. i.e <code>&lt;b&gt;, &lt;i&gt;</code></p> ...
problems with mysql for ruby on rails <p>ah...it is not easy to get started ruby on rails to me..</p> <p>I am trying to use mysql for ruby on rails development.</p> <p>When I execute "gem install mysql", I get following error.</p> <p>error: while generating documentation for mysql-2.8.3-x86-mswin32...message: unhand...
<p>If you are on windows and want to avoid mysql issues, just use v 2.1.2, just before they removed the mysql connector and put it into the mysql gem. It's better like that, but I ran into MANY issues installing this on the Windows XP machine at my work.</p>
NHibernate Mapping File Help <p>NHibernate noob here. Looking for advice on how to map the following common scenario:</p> <p><strong>[Store]</strong><br /> id pk<br /> Name</p> <p><strong>[StockItem]</strong><br /> id pk<br /> Name</p> <p><strong>[StockItemStore]</strong><br /> id pk<br /> StockItemId fk<br /> Store...
<p>I would strongly recommend reading up on nHibernate. Here's a very good starting point:</p> <p><a href="https://web.archive.org/web/20110227204838/http://blogs.hibernatingrhinos.com/nhibernate/Default.aspx" rel="nofollow">The nHibernate FAQ</a></p> <p>I would also recommend that you do the mappings by hand the fir...
ASP.NET MVC: Using LINQ to XML to render (X)HTML <p>There has been a lot of discussions on <em>View-engines</em> for ASP.NET MVC and some criticisms against the inline "tag-soup" with for-loops and thing like it.</p> <p>The alternative or complement has been to use HTML-helpers, which are just inline method-calls.</p>...
<p>This is a great idea! The only problem I see with it is the use of C#. ;) VB.NET has much better support for producing XML via it's XML literals feature.</p> <p>The code you list in your question could be written like this in VB.NET. (With the addition of the text <em>"This is a link"</em> as your example didn't co...
How do I get textual contents from BLOB in Oracle SQL <p>I am trying to see from an SQL console what is inside an Oracle BLOB.</p> <p>I know it contains a somewhat large body of text and I want to just see the text, but the following query only indicates that there is a BLOB in that field:</p> <pre><code>select BLOB_...
<p>First of all, you may want to store text in CLOB/NCLOB columns instead of BLOB, which is designed for binary data (your query would work with a CLOB, by the way).</p> <p>The following query will let you see the first 32767 characters (at most) of the text inside the blob, provided all the character sets are compati...
How to know if my winform is on top of other windows in c#? <p>I need to know if a specific window in my application is on top of all the other windows (including other applications). I tried the <code>TopLevel</code> property but it tells if it is Toplevel within my application only, I would need to know related to ot...
<p>Maybe this will help from MSDN <a href="http://msdn.microsoft.com/en-us/library/ms633514.aspx" rel="nofollow">GetTopWindow</a></p>
How to add user-defined function too parameters? <p>Query gives me some error:</p> <p>Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'from'. Msg 156, Level 15, State 1, Line 9 Incorrect syntax near the keyword 'group'. </p> <pre><code>select Count(Page) as VisitingCount, dbo.fn_GetActivityLogsAr...
<p>You missed a parentheses</p> <pre><code>select Count(Page) as VisitingCount, dbo.fn_GetActivityLogsArranger(CONVERT(VARCHAR(5),Date, 108)**)** as [Time] from scr_SecuristLog where Date between '2009-04-30' and '2009-05-02' and [user] in(select USERNAME from scr_CustomerAuthorities wh...
How to performance tune when you have heavy concurrency on an Oracle table <p>On an Oracle 10g table which has heavy read/write we occassionally get a huge spike in concurrency quoting "latch library cache" using all the CPU.</p> <p>What approaches can we take to lessen the load within the database. We've seen stuff ...
<p>"latch library cache" isn't related to whether I/O is high on a given table. It means you are waiting on a latch for the cache of parsed SQL statements; so most likely when you see these spikes there are an unusual number of hard parses occurring.</p> <p>The most common reason for this is that you are not using bi...
PHP/regex: How to get the string value of HTML tag? <p>I need help on regex or <a href="http://php.net/preg_match"><code>preg_match</code></a> because I am not that experienced yet with regards to those so here is my problem.</p> <p>I need to get the value "get me" but I think my function has an error. The number of h...
<pre><code>&lt;?php function getTextBetweenTags($string, $tagname) { $pattern = "/&lt;$tagname ?.*&gt;(.*)&lt;\/$tagname&gt;/"; preg_match($pattern, $string, $matches); return $matches[1]; } $str = '&lt;textformat leading="2"&gt;&lt;p align="left"&gt;&lt;font size="10"&gt;get me&lt;/font&gt;&lt;/p&gt;&lt;/...
usage of virtual keyword with a class declaration <p>I was asked in an interview that what is the usage of virtual keyword with a class declaration in C++ and I answered that virtual keyword cannot be used with a class declaration in C++. The interviewer said that it is possible and asked me to test it later. </p> <p>...
<p><strong>virtual</strong> can be used when deriving from another class:</p> <pre><code>class Foo : public virtual Bar { } </code></pre> <p>This is used to avoid having multiple versions of the same base class when using multiple inheritance. <a href="http://en.wikipedia.org/wiki/Virtual%5Finheritance">Wikipedia</a>...
How to migrate from my WAMP environment to using MSSQL? <p>I have on my local PC installed WAMP environment (using WampServer OS). Now I would need to change one script from working with MySQL to MSSQL. I have no idea at all how to proceed, where to download MSSQL, how to install it and how to connect with PHP? Thank y...
<ul> <li>Download mssql express <a href="http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx" rel="nofollow">http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx</a></li> <li>Familiarize yourself with one of the great database abstraction layers, for example PDO <a href="http://www.php.net/pdo" rel="nofoll...
Why doesn't this C# code compile? <pre><code>double? test = true ? null : 1.0; </code></pre> <p>In my book, this is the same as</p> <pre><code>if (true) { test = null; } else { test = 1.0; } </code></pre> <p>But the first line gives this compiler error:</p> <blockquote> <p>Type of conditional expression canno...
<pre><code>double? test = true ? null : (double?) 1.0; </code></pre>
How can I add maven dependencies to the flex build path in Flex Builder 3? <p>We're using maven to build a flex project using <a href="https://docs.sonatype.org/display/FLEXMOJOS/Home">flex-mojo's</a>, which is great. The problem is I can't add the swc dependencies specified in the pom to the flex build path. As far ...
<p>Flex-mojos now supports doing this using the <a href="http://www.sonatype.com/books/maven-book/reference/flex-dev-sect-flexbuilder.html" rel="nofollow"><code>flexmojos:flexbuilder</code></a> goal. It's not perfect for nested projects but seems to work well in all other cases.</p>
What are Microsoft's public symbol servers useful for? <p>Until now I've always used the ASP.NET MVC framework source for debugging ASP.NET MVC. On my laptop I just tried a different approach, namely bringing up the "Modules" window in VS while I am debugging and right-clicking System.Web.Mvc, then select "Load Symbols...
<p>They make stack traces work properly for native DLLs - without symbols, your stack traces often only go as far as the nearest Windows DLL and then stop. With symbols, they continue through the Winodws DLLs. You can see the function names, but not the source code (obviously).</p> <p>Debugging a native Windows prog...
Suggest a progression path from struts1 → (struts2, spring) <p>After having read and used <code>Struts1</code> (made a web application using <code>Struts/Hibernate</code> last semester), I want to step forward in learning a better <code>MVC framework</code>. I have been wondering if it would be more prudent to learn ...
<p>I would suggest not treating the two as mutually exclusive. Struts2 competes with Spring MVC, but Struts2 uses Spring's injection container and AOP capabilities (Spring core and AOP).</p> <p>Struts2 and Spring MVC are both working to achieve the same results: a clean MVC web framework. Deciding between the two wi...
How to build a query string for a URL in C#? <p>A common task when calling web resources from a code is building a query string to including all the necessary parameters. While by all means no rocket science, there are some nifty details you need to take care of like, appending an <code>&amp;</code> if not the first pa...
<p>You can create a new writeable instance of <code>HttpValueCollection</code> by calling <code>System.Web.HttpUtility.ParseQueryString(string.Empty)</code>, and then use it as any <code>NameValueCollection</code>. Once you have added the values you want, you can call <code>ToString</code> on the collection to get a qu...
ToString() for a class property? <p>Supposing I have a class "Item", which has three member variables: string name, decimal quantity and string unit. I have got public get/set properties on all three.</p> <p>Sometimes, I want to display quantity as text along with correct unit, eg. 10m or 100 feet. </p> <p>My questio...
<p>What you can do is to make a new (readonly) property returning a formatted version:</p> <pre><code>public string QuantityAsString { get { return string.Format("{0} {1}", this.Quantity, this.Unit); } } </code></pre>
Implement a faster svn cat with SvnClient <p>I'm looking for a faster way to retrieve files from SVN than svn cat in .NET.</p> <p>Currently I'm running a svn cat process for each revision, but it's extremely slow.</p> <p>Then I've tried with SvnClient:</p> <pre><code> Stream st = Console.OpenStandardOutput(); ...
<p>You can use the FileVersions command to do this. This fetches one complete file, and all other files using the differences between each revision in a single connection. This should give a nice performance boost.</p> <pre><code>public void WriteRevisions(SvnTarget target, SvnRevision from, SvnRevision to) { usin...
MQJE018: Protocol error - unexpected segment type received <p>Calling all MQ Gurus,</p> <p>I have a box under my desk which we use to replicate our production environment which is:</p> <p>WebSphere 6.1 Fedora Linux MQ 6.0</p> <p>Whenever one of our applications tries to send a message to a MQ queue we get the follow...
<p>OK, finally managed to get around this error. It was nothing to do with the MQ install its self. I knew it was some kind of network issue so I changed the host name settings within websphere from the hostname to the ip of the box and everything worked fine.</p> <p>Note, I made the host name changes on the queues an...
C# program always crash when creating Windows Media Encoder object <p>I am using Windows Vista x86 + VSTS 2008. When creating new Windows Media Encoder object using statement</p> <p>WMEncoder encoder = new WMEncoder();</p> <p>My program always crash in VSTS 2008. Here is the screen snapshot. Any ideas what is wrong?<...
<p>It looks like the problem may be in Windows Media Encoder: <a href="http://support.microsoft.com/kb/929182" rel="nofollow">http://support.microsoft.com/kb/929182</a></p> <p>You might just have to update WME for this to work. As a test, you might try this on XP to see if it works - if so, it's likely the WME version...
Handling combat effects in game development <p>I'm trying to nut out a highlevel tech spec for a game I'm tinkering with as a personal project. It's a turn based adventure game that's probably closest to <a href="http://en.wikipedia.org/wiki/Archon%5F%28computer%5Fgame%29">Archon</a> in terms of what I'm trying to do. ...
<p>What you're calling 'special effects' used to be called 'modifiers' but nowadays go by the term popular in MMOs as 'buffs'. Handling these is as easy or as difficult as you want it to be, given that you get to choose how much versatility you want to be able to bestow at each stage.</p> <p>Fundamentally though, each...
Getting today's date in java - I've tried the regular ways <p>I need today's date - and zero anything else (" 05/06/08 00:00:00 ")</p> <p>I've tried </p> <pre><code>Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR, 0); Date date1 = calendar.getTime(); System...
<p>I use this:</p> <pre><code>public static Date startOfDay(Date date) { Calendar dCal = Calendar.getInstance(); dCal.setTime(date); dCal.set(Calendar.HOUR_OF_DAY, 0); dCal.set(Calendar.MINUTE, 0); dCal.set(Calendar.SECOND, 0); dCal.set(Calendar.MILLISECOND, 0); return dCal.getTime(); } </code><...
Multi culture web sites <p>How can I create a website using Tamil Font instead of English?</p>
<p>You should be able to use Tamil by creating a site that uses UTF-8 as an encoding. Here's a web site that explains how:</p> <p><a href="http://tlt.its.psu.edu/suggestions/international/bylanguage/tamilchart.html" rel="nofollow">http://tlt.its.psu.edu/suggestions/international/bylanguage/tamilchart.html</a></p>
Should we go open-source? <p>Recently, we've release first stable version of our API access for developers(main features of main product).</p> <p>Our API now has about 4 features with their own signatures, response types and so on.</p> <p>To increase its popularity we want to release <b>Wrapper Class</b> for this fun...
<p>I thoroughly recommend releasing the code to the community; additionally I think it'd be a good idea to release it using a public repo. Even if you don't have many users contributing (though I suspect you are probably underestimating that), the fact that you've released the code will be a draw for many developers. <...
How to display key values in toolbar which is on keyboard <p>Hi to all I am developing one application. In that I have toolbar on keyboard. But I want that when I press keys, the key values should be displayed in toolbar textfield. So if anyone knows kindly reply.</p>
<p>Have you added a UITextField to your NIB or view? That is the best way to get a keyboard displayed and enter text. You can then retrieve the text using UITextView's text property.</p>
C++ new[] into base class pointer crash on array access <p>When I allocate a single object, this code works fine. When I try to add array syntax, it segfaults. Why is this? My goal here is to hide from the outside world the fact that class c is using b objects internally. I have posted the program to <a href="http:...
<p>Creating an array of 10 <code>b</code>'s with <code>new</code> and then assigning its address to an <code>a*</code> is just asking for trouble.</p> <p><strong>Do not treat arrays polymorphically.</strong></p> <p>For more information see <a href="https://www.securecoding.cert.org/confluence/display/cplusplus/ARR39-...
How to dump a table to a text file in SQL server? in sql Server 2005 <p>How to export a table to a text file?</p> <p>I need to get the INSERT script (structure and data) for an already existing table.</p>
<p>In SQL2k, try to read about bulk copy, the command should be <strong>bcp</strong> i think</p> <p>examples from MS help file has something like ...</p> <p>Exporting data from table to text file</p> <pre><code>bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout Authors.txt -c -Sservername ...
SharePoint 2007 Calendar - Remove Time <p>Does anyone know how to remove the time from a SharePoint 2007 Calendar month view?</p> <p>I could do this using some jQuery but would like to know if it is possible via configuration?</p> <p>Cheers</p>
<p>Try <a href="http://www.dlocc.com/sharepoint-main-menu/customization-category/63-sharepoint-calendars-remove-the-time-for-calendar-items.html" rel="nofollow">this article</a> on customizing the SharePoint 2007 calendar view.</p>
Pad Rows in BizTalk Flat File Schema <p>I'm trying to create a BizTalk Schema that looks something like the below (ignore the spaces between the lines- they're only there for clarity.): <br/> " <br/> x Rows will be inserted <br/> Column1^Column2^Column3^Column4^Column5<br/> Data1a^Data2a^Data3a^Data4a^Data5a<br/> Data1...
<p>Okay... I found an answer: Feel free to chime in if you find/have a better one.</p> <p>Set the blank row to a Field of Type xs:string.<br/> Set the Header row to a single record (defining the fields all as strings).<br/> Define the repeating record.</p> <p>I'm still open to further suggestions if anyone has a bet...
Calling constructor from other constructor in same class <p>I have a class with 2 constructors:</p> <pre><code>public class Lens { public Lens(string parameter1) { //blabla } public Lens(string parameter1, string parameter2) { // want to call constructor with 1 param here.. } } ...
<p>Append <code>:this(reqd params)</code> at the end of the ctor to do <strong>'constructor chaining'</strong></p> <pre><code>public Test( bool a, int b, string c ) : this( a, b ) { this.m_C = c; } public Test( bool a, int b, float d ) : this( a, b ) { this.m_D = d; } private Test( bool a, int b ) { ...
Different result with * and explicit field list? <p>I was exploring <a href="http://stackoverflow.com/questions/829514/prevent-recursive-cte-visiting-nodes-multiple-times">another question</a>, when I hit this behaviour in Sql Server 2005. This query would exhaust the maximum recursion:</p> <pre><code>with foo(parent...
<p><strong>Edit</strong></p> <p>I think I know what's going on and is a great example of why to avoid select * in the first place.</p> <p>You defined your table with childId first then parentId, but the CTE Foo expects parentId then childId,</p> <p>So essentially when you say select #bar.* your saying select childId...
Binary Data vs Character Data confusion <p>Ok, so I have a function that takes the path to an image file and is supposed to return the binary data as a string. The caller then inserts the returned string into the inner text of an XML element. </p> <p>Is this correct?:</p> <pre><code>string dataAsString = ""; using (S...
<p>What you are asking for doesn't really make sense. You can't read binary data into a string.</p> <p>You can easily read the data into a byte array without using a <code>BinaryReader</code>:</p> <pre><code>byte[] data = File.ReadAllBytes(mergedFile); </code></pre> <p>If you want to put the data in an XML document,...
How do I resolve multiple linq queries in one operation without using a base query? <p>I have 14 LINQ queries to resolve in one method. None of them have a base query that I could hang them from as subqueries and then store the results as properties of an anonymous type instance.</p> <p>Rather than making 14 separate ...
<p>You're still making 14 seperate call's to the database through each of your sub queries, your just doing it at a single instance when your data object is called.</p> <p>Edit:</p> <p>The MARS error occurs when you have multiple open data readers for a connection. By default with SQl 2005 this is turned off. in yo...
Adding a field to an existing Django model <p>I have a little website with a few users and I'd like to add a field to one of my models (and hence tables.) The problem is that <code>syncdb</code> of course won't touch the existing models and I'm trying to figure out how to add this field to the model/table without havi...
<p>There's no built-in way to do this. However there are a number of third-party projects that will do it for you. The two leading ones are called <a href="http://south.aeracode.org/">South</a> and <a href="http://code.google.com/p/django-evolution/">django-evolution</a>, although there are various others as well (incl...
Why doesn't SourceSafe respect the "Open this database next time..." option? <p>Using Visual SourceSafe's "Open SourceSafe Database..." command, there is an option at the bottom of the dialog to "Open this database next time I run Visual SourceSafe."</p> <p>Typically, when checking this box the most recent opened VSS ...
<p>An environment variable had been set to force that particular database.</p> <p>When SSDIR is set, the VSS dialog option is ignored.</p> <p>Clearing the SSDIR variable fixed the issue.</p>
Memory management when using macruby and Objective-C <p>i have a <code>macruby</code> application that leaks <em>gigs</em> of memory. Ruby is for the logic stuff and accesses some Objective-C classes of mine, to access functions like Accessibility-API and making some screenshots and process them via CIImage.</p> <p><s...
<p>In your code, </p> <pre><code>resultCode = AXUIElementCopyAttributeValue( element, attribute, (CFTypeRef *)&amp;temp ); </code></pre> <p>temp is never released.</p> <p>You should add:</p> <pre><code>CFMakeCollectable(temp) </code></pre> <p>MacRuby apps run in GC mode by default but your CF/Obj-C memory manageme...
How can I implement a circular scrolling mechanism? <p>I'm having some images from which the user should choose one. Now I don't want to just offer an flat scrolling area with a boring grid. Instead, I'd like to show up a wheel that contains those images. At the top would be a marker indicating the selection. Something...
<p>If you're talking about capturing gestures then here is <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html#//apple_ref/doc/uid/TP40007072-CH9-SW14" rel="nofollow">the example they give in the docs</a>.</p> <p>Though I could ha...
Best practices for developing customized B2B Java software? <p>I'm working on Java-based server software that needs to be customized for a few, but large customers. A separate instance of the server runs for each customer.</p> <p>Each customer has sufficiently differing requirements such that different business logics...
<p>You should seriously consider if there's a <a href="http://en.wikipedia.org/wiki/Domain-specific%5Fprogramming%5Flanguage" rel="nofollow">domain-specific language</a> to be had there.</p> <p>DSL's have been a big thing in Ruby, but there's certainly no reason you can't do one in Java, or build a collection of class...
Reading HTTP Header in ActionScript2 <p>In AS2, I need to get a URL. In the header of the HTTP response, a cookie is set. Is it possible to read the header of the HTTP response and get the cookie's data?</p>
<p>This is a bit tricky. What you might have to do, is use a serverside script to get the HTTP request header, then call that script from flash.</p>
Tailor the Publish feature in VisualStudio to use specific paths for individual files <p>Is there a way to tailor the Publish feature of VisualStudio (I'm using VS 2008) so that different files go to different directories. I'm developing a web application which is used within a CMS (Immediacy) and the folder structure...
<p>Unfortunately this is not possible.</p>
Issue with WPF Focus <p>I have code that handles the LostFocus event of my controls. It validates the value and in some cases will enable a subsequent control. For instance, there might be a ComboBox that allows a user to select a country. The subsequent ComboBox allows the user to select a state. IF the currently ...
<p>I'm guessing what is happening is it determines the control to tab to before the LostFocus event fires, thereby skipping the State combo box since it is disabled. Here's the information for <a href="http://msdn.microsoft.com/en-us/library/aa969768.aspx" rel="nofollow">how focus works in WPF</a>. What you will want t...
$.ajax not returning data <p>I am trying to POST data back to the server and get a dataset back. What I am getting back instead is the HTML for the whole page <em>AND</em> it is not kicking off the Action in my Controller. And yes - JQuery is still confusing to me.</p> <p>The code I currently have is:</p> <pre><cod...
<p>The solution may be pretty simple.</p> <p>You're using <code>path:</code> where it should have <code>url:</code></p> <p>Source: <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options" rel="nofollow">jQuery.ajax options list</a></p>
Python Iterator Help + lxml <p>I have this script-</p> <pre><code>import lxml from lxml.cssselect import CSSSelector from lxml.etree import fromstring from lxml.html import parse website = parse('http://example.com').getroot() selector = website.cssselect('.name') for i in range(0,18): print selector[i].te...
<p>The CSSSelector.cssselect() method returns an iterable, so you can just do:</p> <pre><code>for element in selector: print element.text_content() </code></pre>
Shared Authentication, Membership & Roles across DNN and ASP.net applications <p>Here's my situation. I have a DotNetNuke application. I want to link to an existing ASP.net website from within the DNN website, and have decided to use DNN's IFrame for that. </p> <p>The existing ASP.net application uses Forms Authen...
<p>I don't know if what you're talking about is possible within DNN. We're on DNN 4.0 and they do some weird things with the ASP.NET membership tables which may cause trouble.</p> <p>What I can tell you is an alternative way (assuming you have control over the ASP.NET application). There is a project called <a href=...
DNS two domains one server <p>Greetings All, Long time reader first time poster. I work for a small school district. We are our own SOA so we can pretty much do what we want. </p> <p>In the state of Washington all educational institutions are given a name like <em>myschools.wednet.edu</em>. I've recently purchased a...
<p>To do this, you'll have multiple DNS record entries (A-Recs) pointing to the same IP Address. You may also need to tweak IIS (or your web server software) to accept requests coming from both domains. </p> <p>So...in your DNS manager (e.g. in Register.com or whereever you manage your domains) change the A-Rec to po...
Problem caching Model instances on a constant in Rails <p>I am using Single-Table Inheritance (STI) on one of my models for a Rails App and I am having problems storing model objects on a constant. I have isolated the problem into a sample project and submitted it to GitHub: <a href="http://github.com/fcoury/rails-sti-...
<p>My first idea would be that Rails frees up (invalidates) all model objects after serving a request. So <code>class: Music - class obj_id: 13067420</code> becomes unusable in the 2nd request. I'd suggest having a look at the ActiveRecord source code and finding out who invalidates model objects.</p> <p>Also this rai...
Is there a difference between id,date or date,id index in sql server <p>I'm creating an index in sql server 2005 and the discussion with a coworker is if it makes a difference between index key columns being id and date vs date then id.</p> <p>Is there a fundamental difference in the way the index would be created in ...
<p>Yes, definitely. Does anyone ever query the table for JUST date or JUST id? An index of date,id can be used to look up just date, but not just id, and vice-versa</p> <p>Using date,id:</p> <pre><code>Jan 1 4 Jan 1 7 Jan 2 6 Jan 2 9 Jan 2 33 Jan 3 23 Jan 4 1 </code></pre> <...
Putting XML Data into the Windows Event Log <p>How can I write XML data into the Windows Event Log?</p> <p>I have noticed that there is a way to insert XML into the windows event log (and not by just stuffing it into the description). The effect is that you get just your description message in the <code>General</code>...
<p>Unless I am mistaken, in order to write xml to the Crimson/Vista event log you will have create and register a manifest that will give you the appropriate channels and events. Then you have to compile the manifest using the <a href="http://blogs.msdn.com/windowssdk/archive/2009/02/03/released-windows-sdk-for-window...
Optional parameters when calling an XSL template <p>Is there way to call an XSL template with optional parameters?</p> <p>For example:</p> <pre><code>&lt;xsl:call-template name="test"&gt; &lt;xsl:with-param name="foo" select="'fooValue'" /&gt; &lt;xsl:with-param name="bar" select="'barValue'" /&gt; &lt;/xsl:call-...
<p>You're using the <code>xsl:param</code> syntax wrong.</p> <p>Do this instead:</p> <pre><code>&lt;xsl:template name="foo"&gt; &lt;xsl:param name="foo" /&gt; &lt;xsl:param name="bar" /&gt; &lt;xsl:param name="baz" select="DEFAULT_VALUE" /&gt; ...possibly more params... &lt;/xsl:template&gt; </code></pre> <p...
How do I remove a custom toolbar from an Excel workbook? <p>I'm using Excel 2007, and I have an Excel workbook with a custom toolbar attached. Every time I open the workbook, the toolbar appears on the ribbon under "Add-ins". I can right-click on the toolbar and choose Delete Custom Toolbar and that removes it. But whe...
<p>I realize this is an old question, but I just found an easy solution not mentioned on here that will be of use to future viewers:</p> <ol> <li>Change the file's extension to ".zip"</li> <li>Open the archive</li> <li>Delete the <code>Attachedtoolbars.bin</code> file from the archive</li> <li>Close the archive</li> <...
How to enter long SQL text sample data with Visual Studio? <p>The Server Explorer built into Visual Studio is a nice way to connect to your database, view existing data, and edit data. Very useful for entering sample data into a database for testing and development purposes.</p> <p>However, what if you have a "text" ...
<p>I don't think it's possible. Management Studio display multi-lines text as one string.</p>
Crystal Report: Centering reports within report viewer control <p>Looking for a way to center a report within the .NET Crystal Reports viewer control when the containing form is maximized.</p>
<p>I thought it centers the report by default? I put the crv onto a form and set the dock to fill. In fact, I don't know how to get it to not center the report.</p>
IE8 issue: div breaks line even though its floated <p>This looks like IE8 issue. I have two divs that are side by side because I float one of them to left. However, if the content inside of right div gets too big for the window, the right div breaks line and goes under left div. How do I make both divs stay on same lev...
<p>Add float: left to the right_div as well.</p> <p>If it is anything similar to the examples shown by <a href="http://matthewjamestaylor.com/blog/perfect-2-column-left-menu.htm" rel="nofollow">Matthew James Taylor</a> and his <a href="http://matthewjamestaylor.com/blog/perfect-2-column-left-menu.htm" rel="nofollow">P...
VC2008 compiler errors opening sbr files (C2418 C1903 C2471) <p>EDIT: See my answer below for the hotfix.</p> <p>ORIGINAL QUESTION:</p> <p>In setting up for our boat-programming adventure I have to set up source control and fix project files for a team to use them. (the project was previously only being worked on b...
<p><strong>Title: You may receive a "PRJ0008" or "C2471" or "C1083" or "D8022" or "LNK1103" or similar error message when you try to build a solution in Visual C++</strong></p> <p><strong>Symptoms:</strong></p> <ul> <li>D8022 : Cannot open 'RSP00000215921192.rsp'</li> <li>PRJ0008 : Could not delete file 'vc90.idb'.</...
How to get "GET" request parameters in JavaScript? <p>How to get "GET" variables from request in JavaScript?</p> <p>Does jQuery or YUI! have this feature built-in?</p>
<p>All data is available under</p> <pre><code>window.location.search </code></pre> <p>you have to parse the string, eg.</p> <pre><code>function get(name){ if(name=(new RegExp('[?&amp;]'+encodeURIComponent(name)+'=([^&amp;]*)')).exec(location.search)) return decodeURIComponent(name[1]); } </code></pre> <p>j...
Is it possible to use Java webstart execute .exe or dll? <p>I know java webstart is running under a secure sandbox. Is it possible to include a .dll/.exe in the jar (or have the webstart download it to the local machine) and then execute it (using Runtime.exec or process,etc)</p> <p>Please Advise. Any suggestion/comme...
<p>Yes. You have to wrap the <code>.dll</code> in a <code>.jar</code> file, and reference it in your <code>.jnlp</code> file using <code>&lt;nativelib&gt;</code></p> <p>See <a href="http://www.velocityreviews.com/forums/t126704-java-webstart-and-jni.html">here</a> for a more detailed description.</p> <p>If you want t...
Controlling the ID of a custom action item in SharePoint <p>I have added a custom action to the CustomList type. For testing purposes I would like to exercise my new custom action using our testing harness. Unfortunately, I don't know how I can generate an ID for my custom menu item!</p> <p>Here is an example (XPath e...
<p>If it's just for testing you probably don't want to be digging into SharePoint internals to get control over the id. You should be testing for the presence of an item labeled "Delete Item", not for one with a particular id.</p>
How can I set the scrolling position of an UIScrollView? <p>I've seen the setContentOffset:animated: method. Is that going to scroll to a specific position, or what does that "offset" mean?</p>
<p>Yes. From the <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instm/UIScrollView/setContentOffset%3aanimated%3a">Apple documentation</a>:</p> <p><code>setContentOffset:animated:</code> Sets the offset from the content view...
SQL Server, where clauses comparisons with different types & default casting behaviour <p>Right... this one had me baffled for a while today so maybe one of you SQL Server bright sparks can shed some light on this behaviour.</p> <p>We have a table <code>Phones</code>. In it, the phone numbers are stored as nvarchars a...
<p>Data type precedence is well defined - <a href="http://msdn.microsoft.com/en-us/library/ms190309.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms190309.aspx</a></p> <p>Edit - to clarify, it is not that sql always converts the column type to the param type. It just follows the type precedence in the l...
Reading data from UTF-8 text file and tokenize <p>I'm trying to read UTF-8 from a text file and do some tokenization, but I'm having issues with the encoding:</p> <pre><code>try { fis = new FileInputStream(fName); } catch (FileNotFoundException ex) { //... } DataInputStream myInput = new DataInputStream(fis);...
<p>Let me quote the Javadoc for this method.</p> <p>DataInputStream.readLine()</p> <blockquote> <p>Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStrea...
KeyedCollection with enum key type will not index by int <p>I have classes</p> <pre><code>public class FooKeyedCollection : KeyedCollection&lt;FooType,Foo&gt; { } public enum FooType { FooType1, FooType2, FooType3 } public Foo { public FooType Type { get; set; } public string Value { get; set; } } </c...
<p>You might consider using the "new" keyword here:</p> <pre><code>public new Foo this[int index] { get { IList&lt;Foo&gt; self = this; return self[index]; } set { (IList&lt;Foo&gt;)[index] = value; } } </code></pre> <p>This will allow you to index by integer value. Using the enum...
What pitfalls to expect from generation of classes from database tables using Reflection.Emit and xsd files? <p>I am playing with class generation ( one class for a table - inheritance etc. not to be considered for now ... ). So I copied shamelessly from <a href="http://codebetter.com/blogs/david.hayden/archive/2006/02...
<p>You get all the problems of using a (relational)database-driven oo design:</p> <ul> <li>not enough abstraction, no inheritance and no building of ADTs;</li> <li>classes with too many responsibilities;</li> <li>behaviour in the wrong places;</li> <li>no usable way to handle time aspects.</li> </ul> <p>I prefer work...
What is the current state of XSLT 2.0 availability within .NET <p>The latest I can find from the web and blogosphere indicate that Microsoft's XML team would be <a href="http://blogs.msdn.com/xmlteam/archive/2007/01/29/xslt-2-0.aspx" rel="nofollow" title="from Microsoft XML Team blog">supporting XSLT 2.0 (now that it w...
<p>It is not supported by Microsoft and there hasn't been any anouncement I'm aware of. Where did you hear about that?</p> <h3>UPDATE (after you added the link to the XML Team Blog):</h3> <p>It seems that Microsoft changed their strategy according to <a href="http://blogs.msdn.com/xmlteam/archive/2007/11/16/chris-lov...
C# TabControl TabPage Change <p>How do I change the tabpage being displayed in my tabcontrol programmatically?</p>
<p>Either by tabControl1.SelectedIndex which is an integer or if you have a reference to a particular tab, tabControl1.SelectedTab.</p> <p>If you wanted the first one selected:</p> <pre><code>tabControl1.SelectedIndex = 0; </code></pre>
input hidden and updatePanel (a story of ASP.NET AJAX) <p>How can update a input hidden inside an UpdatePanel on an AsyncPostBack?</p> <p>The user click a button outside the panel. The method associated with click event update the value of the input (it has runat="server" property).</p> <p>I can't update the value of...
<p>Because its a postback, you might have to perform a check in the post back event and perform the update. If not, you might have to override an earlier event. See <a href="http://msdn.microsoft.com/en-us/library/dct97kc3.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dct97kc3.aspx</a></p>
VBA Trim() function truncating text oddly! <p>I'm trying to trim extraneous white space at the end of a memo field in MS Access. I've tried doing it a number of ways:</p> <p>1) an update query with the field being updated to Trim([fieldname]). For some reason, that doesn't do anything. The whitespace is still there...
<p>According to this <a href="http://office.microsoft.com/en-us/access/HP051875211033.aspx" rel="nofollow">article</a>:</p> <blockquote> <p>Both Text and Memo data types store only the characters entered in a field; space characters for unused positions in the field aren't stored.</p> </blockquote> <p>As hypoxide s...
class() vs. type() in Ruby <p>What's the difference between the class and type methods in Ruby? I've noticed that type works to find the type of some classes but not others.</p>
<p>The key difference is that <code>Object#type</code> is deprecated. From the RDoc for Object#type:</p> <blockquote> <p>Deprecated synonym for Object#class.</p> </blockquote> <p>Here's why you should use <code>Object#class</code>:</p> <blockquote> <p>Returns the class of obj, now preferred over Object#type, ...
Check several different example inputs in a single test? <p>Let's say I want to write a function that validates an email address with a regex. I write a little test to check my function and write the actual function. Make it pass.</p> <p>However, I can come up with a bunch of different ways to test the same function (...
<p>Most testing frameworks now support some sort of data based testing to let you run the same test on multiple data sets.</p> <p>See the <a href="http://www.nunit.org/index.php?p=values&amp;r=2.5">ValuesAttribute</a> in NUnit.</p> <p>xUnit.net, MBUnit and others have similar methods.</p>
ModelForms in Django where the underlying model depends on another model (via OneToOneField) <p>I have two models in my Django application, for the purposes of storing search parameters used for some homology search programs:</p> <pre><code># models.py class Search(models.Model): """A class to represent search run...
<p>This is a case where I would use inheritance to take care of this:</p> <pre><code># models.py class Search(models.Model): """A class to represent search runs.""" ... class FastaRun(Search): # one-to-one field has been removed .... </code></pre> <p>Now, instantiating a <code>FastaRun</code> is by d...
There are spatial data features for MS Sql Server 2005? <p>I wonder if there is any optimization I can do to achieve faster SELECTs for spatial data without moving to SQL SERVER 2008. There is for SQL Server 2005, natively or through plugins, any of the features below?</p> <ol> <li>Spatial field types</li> <li>Spatial...
<p>There are some GIS features available through <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=MsSqlSpatial" rel="nofollow">http://www.codeplex.com/Wiki/View.aspx?ProjectName=MsSqlSpatial</a> but as far as I know SQL 2008 is the way to go</p>
Is my Unit Test Sufficient? <p>I am looking at the Unit Tests I wrote for an email service (using SMTP) and I am wondering if one test in particular is sufficient. Here is a snippet of my email service:</p> <pre><code>[PluginFamily("EmailService")] public interface IEmailService { Boolean SendEmail( string toAddr...
<p>Improve your <a href="http://en.wikipedia.org/wiki/Code%5Fcoverage" rel="nofollow">code coverage</a> (all of the types)</p>
Search for motif in protein sequence? <p>I have written the following script to search for a motif(substring) in a protein sequences(strings). I am beginner and writing this has been tough for me. I have two questions regarding the same: <strong>1. Errors: The following script has few errors. I have been at it for quit...
<ol> <li><p>First of all, the keyword is <code>elsif</code>, second of all you don't need it. You can compress the code in the <code>get_file_data</code> loop to: </p> <pre><code>next if $line =~ /^\s*$|^&gt;/; $sequence .= $line; </code></pre> <p>As long as you're going to use regular expressions -- unless too unwi...
How should unit tests set up data sources when not running in an application server? <p>Thank you all for your help. A number of you posted (as I should have expected) answers indicating my whole approach was wrong, or that low-level code should never have to know whether or not it is running in a container. I would t...
<p>The whole concept is back to front. Lower level code should not be doing this sort of testing. If you need a different implementation pass it down at a relevant point.</p>
SQL Server: Retrieve auto-incremented ID inside a stored procedure? <p>My database has a parent table with an auto-incrementing primary key identity 'ID', and a normal 'TIMESTAMP column'. I have child tables with a foreign key that refer to the parent 'ID' column. </p> <p>I want to write a stored procedure that insert...
<p>You can retrieve it from SCOPE_IDENITY(). For example:</p> <pre><code>declare @myid int INSERT INTO table (field) VALUES ('value') SELECT @myid = SCOPE_IDENTITY() </code></pre>
Should a database table always have primary keys? <p>Should I always have a primary key in my database tables?</p> <p>Let's take the SO tagging. You can see the tag in any revision, its likely to be in a tag_rev table with the postID and revision number. Would I need a PK for that?</p> <p>Also since it is in a rev ta...
<p>A <strong>table</strong> should have a primary key so that you could identify each row uniquely with it.</p> <p>Technically, you <strong>can</strong> have tables without a primary key, but you'll be breaking good database design rules.</p>
Generate BitmapSource from UIElement <p>I am attempting to generate a <code>BitmapFrame</code> that is based on a <code>UIElement</code>. Here is my function:</p> <pre><code>private BitmapFrame RenderToBitmap2() { RenderTargetBitmap renderBitmap = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32); ...
<p>Take a look at this for an alternate way to create a <code>BitmapSource</code> from a <code>UIElement</code>:</p> <p><a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/fb84fbcb-fe36-45a7-bc1a-0dd0d0bb9fdb/" rel="nofollow">MSDN Thread</a></p> <p>I have also been trying to get the VisualBrush to work ...
Using IN clause in a native sql query <p>We are trying to dynamically generate an IN clause for a native sql query to return a JPA entity. Hibernate is our JPA provider. Our code looks something like this.</p> <pre><code>@NamedQuery( name="fooQuery", queryString="select f from Foo f where f.status in (?1)" )...
<p>JPA supports named list parameters, in your case:</p> <pre><code>@NamedQuery( name="fooQuery", queryString="select f from Foo f where f.status in (?1)" ) Query q = entityManager.createNamedQuery("fooQuery"); List&lt;String&gt; listParameter = new ArrayList&lt;&gt;(); listParameter.add("NEW"); listParamet...