instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Does anyone know if IE6 ever misrenders pages with hidden <code>divs</code>? We currently have several <code>divs</code> which we display in the same space on the page, only showing one at a time and hiding all others.</p> <p>The problem is that the hidden <code>divs</code> components (specifically option menus) so...
<p>One hack you could use is to move your div outside the screen:</p> <pre><code>MyDiv.style.left = "-1000px"; </code></pre> <p>And then put it back on its original position when you want to show it.</p>
<p>One hack you could use is to move your div outside the screen:</p> <pre><code>MyDiv.style.left = "-1000px"; </code></pre> <p>And then put it back on its original position when you want to show it.</p>
16,023
<p>Suppose I have a design like this:</p> <p>Object GUI has two objects: object aManager and object bManager, which don't ever talk to each other.</p> <p>Both aManager and bManager have object cManager as an attribute (or rather a pointer to cManager). So when aManager modifies its cManager, it's affecting bManager's...
<p>I'm going to interpret this as simply as possible, if I'm not answering your question, I apologize.</p> <p>When you really get the answer to this question, it's your first step to really thinking Object Orientedly.</p> <p>In OO, when two objects both "has a" 'nother object, it's perfectly acceptable for both to re...
<p>You can use the Factory pattern to request a reference to cManager by both aManager and bManager as needed.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms954600.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms954600.aspx</a></p>
11,960
<p>I'm using the Scriptaculous library to slap an appealing UI on an application which helps an enduser build lists. Let's say its for pizza creation.</p> <p>To fill out an order, you drag a size of pizza from the pizza palette into the orders droppable. Once it is put in there, it gets replaced with a new div which...
<p>It turns out, after a few days of banging my heads into various walls, that Scriptaculous will happily nest things by default.</p> <p>The issue is when your call to <code>draggable_element</code> looks like this</p> <pre><code>&lt;% draggable_element blah blah blah blah blah blah blah%&gt; </code></pre> <p>instea...
<p>Try this, I think it's close to what you're trying to do. I'm using a sortable for the list on the left. You may not need to.</p> <pre><code>&lt;table border="1" cellpadding="5"&gt; &lt;tr&gt; &lt;td valign="top"&gt; &lt;ul id='fList' style='border:1px solid #c0c0c0'&gt; &lt;li class='fruit'...
22,540
<p>In some applications (notably Visual Studio 2008, Windows Explorer, Internet Explorer) all of the menus open to the left of the cursor. In other apps (Firefox, ACDSee) they open to the right. Then there's Foxit Reader, where the ones in the menu bar open to the left and the context menu opens to the right.</p> <p>T...
<p>In the Control Panel go to "Tablet PC Settings" in the "Mobile PC" category and, in the General Tab, select "Left-handed" to make the menus appear on the right side.</p>
<p>They all open to the right for me. Have you got your internationalization settings set for a right to left language somehow?</p>
32,140
<p>Is it possible to use the <a href="https://login.live.com/login.srf?wa=wsignin1.0&amp;rpsnv=10&amp;ct=1221809452&amp;rver=5.5.4177.0&amp;wp=MCLBI&amp;wlcxt=msdn%24msdn%24msdn&amp;wreply=http:%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fsystem.windows.forms.openfiledialog.aspx&amp;id=254354&amp;lc=1033" rel="noreferr...
<p>This is the solution I have been looking for, this article provides code and describes how to create a dialog that meets my needs.</p> <p><a href="http://www.codeproject.com/KB/dialog/FileDialogs.aspx" rel="noreferrer">CodeProject: Full Implementation of IShellBrowser</a></p>
<p>In my experience in .NET, I would have to say no, sorry for the negative and short answer, but I really don't think there is</p>
12,554
<p>In C++, on Linux, how can I write a function to return a temporary filename that I can then open for writing?</p> <p>The filename should be as unique as possible, so that another process using the same function won't get the same name.</p>
<p>Use one of the standard library "mktemp" functions: mktemp/mkstemp/mkstemps/mkdtemp.</p> <p>Edit: plain mktemp can be insecure - mkstemp is preferred.</p>
<p>You should simply check if the file you're trying to write to already exists. This is a locking problem. Files also have owners so if you're doing it right the wrong process will not be able to write to it.</p>
19,347
<p>I am trying to merge several XML files in a single XDocument object.</p> <p>Merge does not exist in XDocument object. I miss this.</p> <p>Has anyone already implemented a Merge extension method for XDocument, or something similar ?</p>
<p>I tried a bit myself :</p> <pre><code>var MyDoc = XDocument.Load("File1.xml"); MyDoc.Root.Add(XDocument.Load("File2.xml").Root.Elements()); </code></pre> <p>I dont know whether it is good or bad, but it works fine to me :-)</p>
<p>As a workaround, you could use a XSL file to merge the XML files and then transform it to a XDocument object.</p>
35,441
<p>How do I get a status report of all files currently being uploaded via HTTP form based file upload on an Apache Server?</p>
<p>I don't believe you can do this with Apache itself. The upload looks like nothing more than a POST as far as Apache cares. There are modules and other servers that do special processing to uploads so you may have some luck there. It would probably be easier to keep track of it in your application.</p>
<p>Check out <a href="http://swfupload.org/" rel="nofollow noreferrer">SWFUpload</a>, its uses Flash (in a nice way) to assist with managing multiple uploads.</p> <p>There are events you can monitor for how many files of a set have been uploaded.</p>
26,636
<p>On a particular Debian server, iostat (and similar) report an unexpectedly high volume (in bytes) of disk writes going on. I am having trouble working out which process is doing these writes.</p> <p>Two interesting points:</p> <ol> <li><p>Tried turning off system services one at a time to no avail. Disk activity...
<p>iotop is good (great, actually). </p> <p>If you have a kernel from before 2.6.20, you can't use most of these tools.</p> <p>Instead, you can try the following (which should work for almost any 2.6 kernel IIRC):</p> <pre> sudo -s dmesg -c /etc/init.d/klogd stop echo 1 > /proc/sys/vm/block_dump rm /tmp/disklog ...
<p>You could try to use <a href="http://sourceware.org/systemtap/" rel="nofollow noreferrer">SystemTap</a> , it has a lot of examples , and if I'm not mistaken , it shows how to do this sort of thing .</p>
31,030
<p>I created a simple .NET windows application in Visual Studio 2005 and on just entering the main form load event my threads window is as in the following image:</p> <p><a href="http://img519.imageshack.us/my.php?image=threadshh4.jpg" rel="nofollow noreferrer">http://img519.imageshack.us/my.php?image=threadshh4.jpg</...
<p>1) They're threads that are part of the managed framework.</p> <p>2) It monitors for system events that you can register event handlers for, such as when you change your display settings and such.</p> <p>3) Because they're part of the framework rather than your application code, so the source location isn't known ...
<p>Remember that there is a one to many relationship between unmanaged thread and managed threads.</p> <p>There is a way to move SystemEvents notifier into your thread:</p> <pre><code>public static class ThreadingHelper_NativeMethods { [DllImport("user32.dll")] public static extern bool IsGUIThread(bool bConver...
29,195
<p>I am using a Session Parameter on an ObjectDataSource. It works fine on the local development machine but I get this error after copying the website to the production server:</p> <p>Type 'System.Web.UI.WebControls.SessionParameter' does not have a public property named 'DbType'.</p>
<p>I found the answer but I don't know why it does this. </p> <p>I just removed the DBType property and it worked fine.</p>
<p>Travis' answer gave me a clue, but perhaps it could be stated better thusly:</p> <p>Somehow, in copying the website to the production server, a number of the parameter objects (Specifically, those with type GUID) had the "Type"="Guid" element changed to "DBType"="Guid". </p> <p>e.g parameter should be: </p> <p></...
22,282
<p>I have a RadioButtonList on my page that is populated via Data Binding</p> <pre><code>&lt;asp:RadioButtonList ID="rb" runat="server"&gt; &lt;/asp:RadioButtonList&gt; &lt;asp:Button Text="Submit" OnClick="submit" runat="server" /&gt; </code></pre> <p>How do I get the value of the radio button that the user selected...
<p>The ASPX code will look something like this: </p> <pre><code> &lt;asp:RadioButtonList ID="rblist1" runat="server"&gt; &lt;asp:ListItem Text ="Item1" Value="1" /&gt; &lt;asp:ListItem Text ="Item2" Value="2" /&gt; &lt;asp:ListItem Text ="Item3" Value="3" /&gt; &lt;asp:ListItem Text ="Item4" Value="4"...
<p><code>radiobuttonlist.selected &lt;value&gt;</code> to process with your code.</p>
49,595
<p>I discovered that you can start your variable name with a '@' character in C#. In my C# project I was using a web service (I added a web reference to my project) that was written in Java. One of the interface objects defined in the WSDL had a member variable with the name "params". Obviously this is a reserved word...
<p>Straight from the <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/" rel="noreferrer">C# Language Specification</a>, <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#identifiers" rel="noreferrer">Ide...
<p>If we use a keyword as the name for an identifier, we get a compiler error “identifier expected, ‘Identifier Name’ is a keyword” To overcome this error, prefix the identifier with “@”. Such identifiers are verbatim identifiers. The character @ is not actually part of the identifier, so the identifier might be seen i...
11,726
<p>We let users create ad-hoc queries in our website. We would like to have the user select their criteria, then click submit and have the results streamed automatically to Excel. I have the application populating a DataTable, then using the datatable to create a tab delimited string. The problem is getting that to ...
<p>Change the page's file type to excel, and only stream the HTML necessary to build a table to the page. code from <a href="http://www.eggheadcafe.com/tutorials/aspnet/6e1ae1a8-8285-4b2a-a89b-fafc7668a782/aspnet-download-as-wor.aspx" rel="noreferrer">here</a> </p> <pre><code>//for demo purpose, lets create a small da...
<p>I'd recommend using a <a href="http://www.aspcode.net/Creating-an-ASHX-handler-in-ASPNET.aspx" rel="nofollow noreferrer">filehandler (.ashx)</a> The only issue is creating the excel file from the DataTable. There are a lot of third party products that will do this for you (e.g. Infragistics provides a component that...
17,945
<p>This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts appear. This could be...
<p>If you do decide to roll your own C# application to do this, it is very straightforward in the current version of the .NET Framework.</p> <p>Look for the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.aspx" rel="nofollow noreferrer">System.ServiceModel.Syndication</a> namespace. T...
<p>This should be fairly easy with any language...all you would need to do is read the feed xml into a DOM structure (nearly all languauges including C# have a DomDocument class)</p> <p>You should then be able to simply loop through the item nodes in reverse order...</p> <p>see: <a href="http://msdn.microsoft.com/en-...
16,504
<p>I have been trying to use the Perl utility/module &quot;prove&quot; as a test harness for some unit tests. The unit tests are a little more &quot;system&quot; than &quot;unit&quot; as I need to fork off some background processes as part of the test, Using the following...</p> <pre><code>sub SpinupMonitor{ my $bas...
<p><p>Note that you don't test whether <code>fork()</code> failed. You need to make sure <code>$pid</code> is <a href="http://perldoc.perl.org/functions/defined.html" rel="nofollow noreferrer">defined</a> before assuming that "false" means "child." <p>Because your <code>$cmd</code> contains shell metacharacters (space...
<p><p>Note that you don't test whether <code>fork()</code> failed. You need to make sure <code>$pid</code> is <a href="http://perldoc.perl.org/functions/defined.html" rel="nofollow noreferrer">defined</a> before assuming that "false" means "child." <p>Because your <code>$cmd</code> contains shell metacharacters (space...
22,196
<p>My application uses an event tap to capture keyboard events, and I'd like to know which device (i.e. which keyboard) each event comes from. Is there an sort of device-identifying information along with the CGEvent that a tap gets? I've looked at NSEvent's methods, and the various CGEventField keys, but none of them ...
<p>You might want to take a look at DDHidLib, Dave Dribin's excellent framework to work with USB HID devices independently.</p> <p><a href="http://www.dribin.org/dave/blog/archives/2007/03/19/ddhidlib_10/" rel="nofollow noreferrer">http://www.dribin.org/dave/blog/archives/2007/03/19/ddhidlib_10</a></p> <p>(not just a...
<p>DDHidLib is neat, and in fact I rewrote parts of it for Delicious Library 2 for Leopard's newer HID APIs, and submitted the changes back to the original author -- if you write him you can get the Leopard-only sample code.</p> <p>Unfortunately, the new Leopard HID APIs have the ability to peak at keyboard events as ...
27,040
<p>I am relatively new to matchers. I am toying around with <a href="http://code.google.com/p/hamcrest/" rel="noreferrer">hamcrest</a> in combination with JUnit and I kinda like it.</p> <p>Is there a way, to state that one of multiple choices is correct?</p> <p>Something like</p> <pre><code>assertThat( result, is( e...
<pre><code>assertThat(result, anyOf(equalTo(1), equalTo(2), equalTo(3))) </code></pre> <p>From <a href="http://hamcrest.org/JavaHamcrest/tutorial#logical" rel="noreferrer">Hamcrest tutorial</a>:</p> <blockquote> <p><code>anyOf</code> - matches if any matchers match, short circuits (like Java ||)</p> </blockquote> <p>Se...
<p>marcos is right, but you have a couple other options as well. First of all, there <em>is</em> an either/or:</p> <pre><code>assertThat(result, either(is(1)).or(is(2))); </code></pre> <p>but if you have more than two items it would probably get unwieldy. Plus, the typechecker gets weird on stuff like that sometimes....
18,427
<p>I'm trying to create a jqgrid, but the table is empty. The table renders, but the data doesn't show.</p> <p>The data I'm getting back from the php call is:</p> <pre><code>{ "page":"1", "total":1, "records":"10", "rows":[ {"id":"2:1","cell":["1","image","Chief Scout","Highest Award test","0"]}, {"id":"2:2","cell":...
<p>I got it to work!</p> <p>The <strong>dataType</strong> field should be <strong>datatype</strong>. It's case sensitive.</p>
<p>I don't think your ID is the correct type, I think it should be an int.</p> <p>For the given json you really don't need the jsonreader settings. What you have listed is the defaults anyway, plus you don't have a subgrid in your json.</p> <p>Try this:</p> <pre><code>{ "page":"1", "total":1, "records":"10", "rows"...
32,412
<p>I am running Visual Studio Team Edition 2008. <br /> <br /> <br /> When I create a new website, I get a new file I've never seen before: <em>vwd.webinfo</em>.</p> <p>The contents of this file is as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;VisualWebDeveloper&gt; &lt;!-- Visual St...
<p>It is created because you are using a file system web site. Read more about it here: <a href="http://msdn.microsoft.com/en-us/library/e5x4xz73.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/e5x4xz73.aspx</a></p> <p>What do you mean with "bloat" ? Can you please paste the bloat?</p>
<p>Looks like that file is part of the File System Web Projects based on <a href="http://msdn.microsoft.com/en-us/library/e5x4xz73.aspx" rel="nofollow noreferrer">this MSDN page</a>. It seems they moved some features out of the project file and into that file (makes sense because the project file isn't in file system p...
22,975
<p>In C#, I am using a library that defines an enum. I would like to allow consumers of my code (in a different assembly) to pass in an enum value as a parameter to one of my functions without having to reference the underlying library themselves.</p> <p>Is there a way for me to expose the library's enumeration to my...
<p>You could define your own enum with the values you want to support, expose that to your consumers, and simply convert it to the library's enum before you call into it. Since enums are just numbers behind the scenes, it's easy to convert one enum's values to another's.</p>
<p>I realy don't know, which rational reason is doing this ( combination of "consumer call method from type in my assembly" and "consumer doesn't have my assembly as reference" ), but there are 2 ways.</p> <p>The first ( recommended ): You should split your assembly into two. One with enum type definition and the seco...
27,848
<p>Without running this code, identify which <code>Foo</code> method will be called:</p> <pre><code>class A { public void Foo( int n ) { Console.WriteLine( "A::Foo" ); } } class B : A { /* note that A::Foo and B::Foo are not related at all */ public void Foo( double n ) { Console.WriteLi...
<p>I really wouldn't use this as an interview question. I know the answer and the reasoning behind it, but something like this should come up so rarely that it shouldn't be a problem. Knowing the answer really doesn't show much about a candidate's ability to code.</p> <p>Note that you'll get the same behaviour even if...
<p>Try a similar sample given below:</p> <pre><code>class Program { class P {} class Q : P {} class A { public void Fee(Q q) { Console.WriteLine("A::Fee"); } } class B : A { public void Fee(P p) { Console.WriteL...
18,620
<p>When extending classes, I find it very descriptive to use the <code>base</code> (<code>MyBase</code> in VB) keyword when accessing methods in the base-class. And the <code>this</code> (<code>Me</code> in VB) keyword when accessing functions in the class extending the base-class. That goes for a "flat" structure with...
<p>Have a look at StyleCop.</p> <p><a href="http://code.msdn.microsoft.com/sourceanalysis" rel="nofollow noreferrer">http://code.msdn.microsoft.com/sourceanalysis</a></p> <p>There are some rules in there that should do what you want. You can configure it to show any style violations as warnings or errors.</p>
<p>You may also want to check out <a href="http://www.ssw.com.au/ssw/CodeAuditor/" rel="nofollow noreferrer">SSW's code auditor</a></p> <p>Unfortunately there is no way that I'm aware of to enforce this in the compiler.</p>
21,760
<p>This question is more security related than programming related, sorry if it shouldn't be here.</p> <p>I'm currently developing a web application and I'm curious as to why most websites don't mind displaying their exact server configuration in HTTP headers, like versions of Apache and PHP, with complete "mod_perl, ...
<p>I think you usually see those headers because the systems send them <strong><em>by default</em></strong>. </p> <p>I routinely remove them as they provide no real value and could, as you suggested reveal information about the server.</p>
<p>Running <code>nmap -O -sV</code> against an IP will give you the OS and service versions with a fairly high degree of accuracy. The only extra info you're giving away by having your server advertise that information is which modules you have loaded.</p>
44,063
<p>How do I tell the Vim editor about my include files path so that it can auto complete the function names when I press <kbd>CTRL</kbd>+<kbd>N</kbd>?</p> <p>For example, I have a C program like below:</p> <pre><code>#include&lt;stdio.h&gt; int main() { sca // here I press control+N, it does not complete to scanf...
<p>In your <code>.vimrc</code>, add the paths to your <code>.vimrc</code>:</p> <pre><code>set path+=/usr/include/** set path+=/my_include_dir/include set path+=/my_include_dir/srclib/apr/** set path+=/my_other_include_dir/srclib/apr-util/** ** means all sub-directories. * means all contained directories . means all...
<p>Vim might also know the path already, if the files are in a standard location. &lt;C-n&gt; uses the 'complete' option and the flag <code>i</code> scans included files. To add <code>i</code> to 'complete':</p> <p><code>set complete+=i</code></p> <p>you can also get a tags file from the symbols you want completed, ...
39,700
<p>What is the best way to authorize all users to one single page in a asp.net website.</p> <p>For except the login page and one other page, I deny all users from viewing pages in the website. </p> <p>How do you make this page accessible to all users?</p>
<p>I've been using forms authentication and creating the necessary GenericIdentity and CustomPrincipal objects that allows me to leverage the User.IsInRole type functions you typically only get with Windows authentication.</p> <p>That way in my web.config file, I can do stuff like...</p> <pre><code>&lt;location path=...
<p>I created a base "page" class that handles that sort of thing. All my pages can then be decorated with the RequiresLogin attribute if a login is required to view them. If the attribute is not present, the page is accessible to all.</p> <p>Example:</p> <pre><code>&lt;RequiresLogin()&gt; _ &lt;RequiresPermission("p...
3,905
<p>What is the most elegant way of bubble-sorting in F#?</p> <p><strong>UPDATE</strong></p> <p>As pointed out in one of the answers, bubble sorting isn't efficient in a functional language to begin with. A humourously-cynical commenter also pointed out that bubble sorting is only appropriate when the list is small an...
<p>using bubble sort in a functional language isn't very efficient, because the implementation has to reverse the list many times (and this can't be really implemented very efficiently for immutable lists).</p> <p>Anyway, the example from Erlang can be rewritten to F# like this:</p> <pre><code>let sort l = let rec...
<p>F# is an impure language. Don't be puritanical about purity. Here is a simpler and more elegant impure bubblesort in F#:</p> <pre><code>let rec sort (a: int []) = let mutable fin = true for i in 0..a.Length-2 do if a.[i] &gt; a.[i+1] then let t = a.[i] a.[i] &lt;- a.[i+1] a.[i+1] &lt;- t ...
35,258
<p>DDD states that you should only ever access entities through their aggregate root. So say for instance that you have an aggregate root X which potentially has a <em>lot</em> of child Y entities. Now, for some scenario, you only really care about a subset of these Y entities at a time (maybe you're displaying them in...
<p>I consider an aggregate root with a <em>lot</em> of child entities to be a code smell, or a DDD smell if you will. :-) Generally I look at two options.</p> <ol> <li>Split your aggregate into many smaller aggregates. This means that my original design was not optimal and I need to identify some new entities.</li> ...
<p>You are allowed since the code will compile anyway, but if you're going for a pure DDD design you should not have incomplete instances of objects.</p> <p>You should look into LazyLoading if you're afraid to load a huge object of which you will only use a small portion of its child entities.</p> <p>LazyLoading dela...
4,469
<p>Given an array of type <code>Element[]</code>:</p> <pre><code>Element[] array = {new Element(1), new Element(2), new Element(3)}; </code></pre> <p>How do I convert this array into an object of type <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ArrayList.html" rel="noreferrer"><code>...
<pre><code>new ArrayList&lt;&gt;(Arrays.asList(array)); </code></pre>
<p>Use below code</p> <pre><code>Element[] array = {new Element(1), new Element(2), new Element(3)}; ArrayList&lt;Element&gt; list = (ArrayList) Arrays.asList(array); </code></pre>
19,100
<p>I'm doing a fair bit of work in Ruby recently, and using</p> <pre><code> ruby script/console </code></pre> <p>Is absolutely critical. However, I'm really disappointed with the default Windows console in Vista, especially in that there's a really annoying bug where moving the cursor back when at the bottom of the s...
<p>I use <a href="http://sourceforge.net/projects/console/" rel="nofollow noreferrer">Console2</a>.</p> <p>I like the tabbed interface and that copy works properly if text breaks at the end of a line.</p>
<p><a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" rel="nofollow noreferrer">Powershell</a></p> <blockquote> <p>Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and i...
6,246
<p>I am new to .net and would like to know whether .net has the java equivalent of AtomicInteger, ConcurrentLinkedQueue, etc?</p> <p>I did a bit of search and couldnt come up with anything.</p> <p>The lock free algorithms need some sort of a CAS instruction, which is provided through the undocumented Unsafe class in ...
<p>In .NET there is the Interlocked class, with static methods Interlocked.Increment() and Interlocked.Decrement().</p> <p>See <a href="http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx</a>.</p> <p>You ...
<p>For info, it is likely (<a href="http://blogs.msdn.com/pfxteam/archive/2008/10/31/9026988.aspx" rel="nofollow noreferrer">here</a>) that .NET 4.0 will inherit the CCR/TPL from <a href="http://blogs.msdn.com/somasegar/archive/2007/11/29/parallel-extensions-to-the-net-fx-ctp.aspx" rel="nofollow noreferrer">Parallel Ex...
42,416
<p>I heard on a recent podcast (Polymorphic) that it is possible to cache a user control as opposed to the entire page. </p> <p>I think my header control which displays static content and my footer control could benefit from being cached. </p> <p>How can I go about caching just those controls?</p>
<p>Take a look <a href="https://web.archive.org/web/20081207012138/http://asp.dotnetheaven.com/aspnet/doc/caching/fragment.aspx" rel="nofollow noreferrer">here</a><br> You can use <code>VaryByParam</code> and <code>VaryByControl</code> in the output cache.</p>
<p>I think you can specify OutputCache in the control's markup file like you'd do on an ASPX page. And it'd get properly cached automatically.</p> <p>Just read up on OutputCache page directive on MSDN and get the parameters right and it should do what you want it to.</p> <p>It's been a long time since I write classic...
6,649
<p>How do I grab the controls inside of a UserControl tag?</p> <p>So if this is on a Page:</p> <pre><code>&lt;ME:NewControl ID="tblCustomList" runat="server"&gt; // ... these controls will be used in my UserControl.aspx &lt;/ME:NewControl&gt; </code></pre> <p>How do I access those controls in my UserControl?</p> <p...
<p>Turns out I just needed something like this:</p> <pre><code>public TableRow DTHeader { get; set; } protected override void OnInit(EventArgs e) { tblCollection.Rows.Add(DTHeader); base.OnInit(e); } </code></pre> <p>And then use this on my Page:</p> <pre><code>&lt;ME:NewControl ID="tblCustomList" runat="se...
<p>I am not sure if I understand the question 100%.</p> <p>However if you a custom control called Row you can add a collection to the main table user control.</p> <p>You can do this with a generic list. This should give you the ability to add them like a normal aspx control. </p> <p>I don't have a code sample here...
44,363
<p>I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL D...
<p>SQLAlchemy is more full-featured and powerful (uses the DataMapper pattern). Django ORM has a cleaner syntax and is easier to write for (ActiveRecord pattern). I don't know about performance differences.</p> <p>SQLAlchemy also has a <a href="http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/declarative/index.h...
<p>I'd check out <a href="http://www.sqlalchemy.org/" rel="nofollow noreferrer">SQLAlchemy</a> </p> <p>It's really easy to use and the models you work with aren't bad at all. <strike>Django uses SQLAlchemy for it's ORM</strike> but using it by itself lets you use it's full power.</p> <p>Here's a small example on crea...
7,687
<p>I have noticed that GhostDoc hasn't been updated in a long while. So I am curious if there is a plug-in for Resharper or CodeRush that will accomplish the same thing? Or even if this type of functionality is built in to one of the tools that would be great too. </p>
<p>Latest version of GhostDoc specifically works with VS 2008. Not sure what you mean that it hasn't been updated in a long while. As far as I'm concerned, GhostDoc is the best in-code XML commenter available. It is customizable, has great language and grammar support. And it just works.</p> <p>Is there something ...
<p>GhostDoc is working just fine, so I guess there is no need to be updated (unless some new features will be added). Also, it does not conflict with Resharper in any way (for me, at least).</p> <p><strong>Edit:</strong> Since everybody seems to happily use GhostDoc (based on my Google search), I doubt anyone will rei...
37,537
<p>In my main page (call it <code>index.aspx</code>) I call </p> <pre><code>&lt;%Html.RenderPartial("_PowerSearch", ViewData.Model);%&gt; </code></pre> <p>Here the <code>viewdata.model != null</code> When I arrive at my partial:</p> <pre><code>&lt;%=ViewData.Model%&gt; </code></pre> <p>Says <code>viewdata.model ==...
<p>Have you tried just passing in ViewData instead of ViewData.Model? This is an abridged version what I use in my helpers (shamelessly stolen from the Storefront series):</p> <pre><code> /// &lt;summary&gt; /// Renders a LoggingWeb user control. /// &lt;/summary&gt; /// &lt;param name="helper"&gt;Helpe...
<p>This is untested:</p> <pre><code>&lt;%=Html.RenderPartial("_ColorList.ascx", new ViewDataDictionary(ViewData.Model.Colors));%&gt; </code></pre> <p>Your control view is expecting view data specific to it in this case. If your control wants a property on the model called Colors then perhaps:</p> <pre><code>&lt;%=Ht...
28,389
<p>How do I get a platform-dependent newline in Java? I can’t use <code>"\n"</code> everywhere.</p>
<p>In addition to the line.separator property, if you are using java 1.5 or later and the <strong>String.format</strong> (or other <strong>formatting</strong> methods) you can use <code>%n</code> as in</p> <pre><code>Calendar c = ...; String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY%n", c); //Note `%n` at...
<p>Avoid appending strings using String + String etc, use StringBuilder instead.</p> <pre><code>String separator = System.getProperty( "line.separator" ); StringBuilder lines = new StringBuilder( line1 ); lines.append( separator ); lines.append( line2 ); lines.append( separator ); String result = lines.toString( ); </...
25,496
<p>I have been working at converting game files into 3d files that can be printed, but many of the models have very thin or walls. I was wondering if there was a way to increase the thickness of the walls using meshmixer or meshlab.</p>
<p>Only today, I learned of a solution for this sort of objective, but it uses Fusion 360 rather than Meshmixer or Meshlab. As your question does not include that program, I'll toss the Meshmixer method.</p> <p>This image is of the model prior to modification:</p> <p><a href="https://i.stack.imgur.com/XsIS5.jpg" rel...
<p>Only today, I learned of a solution for this sort of objective, but it uses Fusion 360 rather than Meshmixer or Meshlab. As your question does not include that program, I'll toss the Meshmixer method.</p> <p>This image is of the model prior to modification:</p> <p><a href="https://i.stack.imgur.com/XsIS5.jpg" rel...
756
<p>We are currently using the ExtJS tree view in an application - a requirement has arisen requiring a user to select multiple nodes (which the tree view supports currently through a pluggable selection model) - but you can not then drag the multiple selections to another part of the tree.</p> <p>Does anyone know of a...
<p>Check out this post in the ExtJS forum that details how you can enable multi-select in a Javascript tree.</p> <p><a href="http://extjs.com/forum/showthread.php?t=28115" rel="nofollow noreferrer">http://extjs.com/forum/showthread.php?t=28115</a></p>
<p>Ha i just asked the exact same question in their forum... want to acheive the goal without using the Custom User-Extension tough.</p> <p><a href="http://www.extjs.com/forum/showthread.php?97463-3.2.0-Treepanel-MultiSelectionModel-and-Dragdrop&amp;p=459962" rel="nofollow noreferrer">http://www.extjs.com/forum/showth...
6,926
<p>Let's say I have an array, and I know I'm going to be doing a lot of "Does the array contain X?" checks. The efficient way to do this is to turn that array into a hash, where the keys are the array's elements, and then you can just say <pre>if($hash{X}) { ... }</pre></p> <p>Is there an easy way to do this array-to-...
<pre><code>%hash = map { $_ =&gt; 1 } @array; </code></pre> <p>It's not as short as the "@hash{@array} = ..." solutions, but those ones require the hash and array to already be defined somewhere else, whereas this one can take an anonymous array and return an anonymous hash.</p> <p>What this does is take each element...
<p>You might also want to check out <a href="http://search.cpan.org/~gsar/Tie-IxHash-1.21/lib/Tie/IxHash.pm" rel="nofollow noreferrer">Tie::IxHash</a>, which implements ordered associative arrays. That would allow you to do both types of lookups (hash and index) on one copy of your data.</p>
12,132
<p>I have a standalone Java app that has some licensing code that I want to secure, i.e., prevent users from changing my software to circumvent the licensing. What is the best way to do this? </p> <p>I've looked at obfuscation, but that entails all sorts of problems: reflection, serialization, messed-up stack traces...
<p>Sorry, if your users are savy enough to tamper with your class files, they will remove the signature checking features first thing. I agree with obfuscation, but shouldn't a good obfuscator keep some dictionary to convert an obfuscated stack-trace for you?</p> <p>This discussion is really old, and really really com...
<p>You can seal the jar. Pls. see the below links for details</p> <p>-- <a href="http://java.sun.com/docs/books/tutorial/deployment/jar/sealman.html" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/deployment/jar/sealman.html</a></p> <p>java.sun.com/developer/JDCTechTips/2001/tt0130.html</p>
30,290
<p>Specifically, when you create an interface/implementor pair, and there is no overriding organizational concern (such as the interface should go in a different assembly ie, as recommended by the s# architecture) do you have a default way of organizing them in your namespace/naming scheme?</p> <p>This is obviously a ...
<p>The answer depends on your intentions.</p> <ul> <li>If you intend the consumer of your namespaces to use the interfaces over the concrete implementations, I would recommend having your interfaces in the top-level namespace with the implementations in a child namespace</li> <li>If the consumer is to use both, have t...
<p>I HATE when I find interfaces and implementations in the same namespace/assembly. Please don't do that, if the project evolves, it's a pain in the ass to refactor.</p> <p>When I reference an interface, I want to implement it, not to get all its implementations.</p> <p>What might me be admissible is to put the inte...
17,669
<p>What software does everyone use to monitor hardware? I know about nagios and cacti, but does anyone use any other software?</p>
<p><a href="http://www.solarwinds.com/products/ipmonitor/" rel="nofollow noreferrer">SolarWinds IPMonitor</a> is pretty useful. A bit like cacti or nagios, but more pleasing to the eye. Windows only, and not free (not even as in "free beer"), though. ;-)</p>
<p>I have used both <a href="http://mon.wiki.kernel.org/index.php/Main_Page" rel="nofollow noreferrer">mon</a> and <a href="http://mon.wiki.kernel.org/index.php/Main_Page" rel="nofollow noreferrer">munin</a>. I like munin because of its simplicity and flexibility.</p>
34,822
<ul> <li>Any personal experience in overcoming web application performance hurdles? </li> <li>Any recommended strategies for improving the performance of a data-driven web application? </li> </ul> <p>My development team works on a web application (JSP reports, HTML, JavaScript) that uses an Oracle database (PL/SQL). T...
<p>While my answer may not contain any concrete steps to help this is always where I start.</p> <p>First thing I would do is try to throw away all of your assumptions about what the trouble is and take steps to install metrics everywhere you can. Let the metrics guide you rather than your intuition. I've chased many...
<p>As Webjedi says, metrics are your friend.</p> <p>Also look at your stack and see where there are opportunities for caching - then employ mercilessly wherever possible!</p>
4,274
<p>How do I get the difference in days between 2 dates in SQLite? I have already tried something like this:</p> <pre><code>SELECT Date('now') - DateCreated FROM Payment </code></pre> <p>It returns 0 every time.</p>
<pre><code> SELECT julianday('now') - julianday(DateCreated) FROM Payment; </code></pre>
<p>In my case, I have to calculate the difference in minutes and <code>julianday()</code> does not give an accurate value. Instead, I use <code>strftime()</code>:</p> <p><code>SELECT (strftime('%s', [UserEnd]) - strftime('%s', [UserStart])) / 60</code></p> <p>Both dates are converted to unixtime (seconds), then subtr...
36,897
<p>I currently have an asp.net website hosted on two web servers that sit behind a Cisco load balancer. The two web servers reference a single MSSQL database server.</p> <p>Since this database server is a single point of failure, I'm adding an additional MSSQL server for backup. I would like to setup my web.config f...
<p>What you want is called "failover", where if one database fails your queries are automatically redirected to the other. This is acheived at the database level, not the application. There are a lot of walkthroughs etc for setting up failover clusters: here's one for <a href="http://www.microsoft.com/technet/prodtec...
<p>Its a bit more complex than that. Does your webpage write to the databases? Or just read?</p> <p>If they write, then you'll have to worry about keeping the 2 databases synchronized, probably using mirroring or log shipping. </p> <p>But what you are (in essense) talking about doing is setting up a SQL cluster. </p>...
29,857
<p>I'm using an older version of ASP.NET AJAX due to runtime limitations, Placing a ASP.NET Validator inside of an update panel does not work. Is there a trick to make these work, or do I need to use the ValidatorCallOut control that comes with the AJAX toolkit?</p>
<p>I suspect you are running the original release (RTM) of .NET 2.0.</p> <p>Until early 2007 validator controls were not compatible with UpdatePanels. This was resolved with the SP1 of the .NET Framework.</p> <p>The source of the problem is that UpdatePanel can detect markup changes in your page, but it has no way to...
<p>If for what ever reason you are unable to use the udpated version of the ASP.NET validator controls is actually very easy to validate a validation group yourself, all you need to do is call </p> <pre><code>Page_ClientValidate("validationGroupName"); </code></pre> <p>Then you can use the PageRequestManager execute ...
5,281
<p>I'm just learning to work with partial classes in VB.NET and VS2008. Specifically, I'm trying to extend a LINQ to SQL class that was automatically created by SqlMetal. </p> <p>The automatically generated class looks like this:</p> <pre><code>Partial Public Class DataContext Inherits System.Data.Linq.DataContex...
<p>Unless VB.NET generates different stuff in its LINQ to SQL files from C# the classes of the DB tables aren't within the DataContext class, just beside it.</p> <p>So you have the class <strong>MyNamespace.DataContext.Concession</strong> when the other half of the partial class is realy <strong>MyNamespace.Concession...
<p>(This related to VB.NET - might be differences with C# projects) </p> <p>I put my entities in their own namespace by configuring the Linq-to-SQL model property. </p> <p>e.g. MyCo.MyProj.Business.Entities</p> <p>I then add non-Linq business entities in there too, so they are all in the same namespace.</p> <p>Howe...
29,342
<p>I have the following code:</p> <pre><code>info = new System.Diagnostics.ProcessStartInfo(&quot;TheProgram.exe&quot;, String.Join(&quot; &quot;, args)); info.CreateNoWindow = true; info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; info.RedirectStandardOutput = true; info.UseShellExecute = false; System...
<p>The problem is that if you redirect <code>StandardOutput</code> and/or <code>StandardError</code> the internal buffer can become full. Whatever order you use, there can be a problem:</p> <ul> <li>If you wait for the process to exit before reading <code>StandardOutput</code> the process can block trying to write to ...
<p>This post maybe outdated but i found out the main cause why it usually hang is due to stack overflow for the redirectStandardoutput or if you have redirectStandarderror.</p> <p>As the output data or the error data is large, it will cause a hang time as it is still processing for indefinite duration.</p> <p>so to r...
16,884
<p>I am writing an internal application where we let users to do a few different types of queries. </p> <p>The application allows users to search a database by either of the following keys:</p> <ul> <li>employeeId</li> <li>name (first or last)</li> <li>companyId</li> <li>status (workingFullTime, sickLeave, maternityL...
<p>When it comes to PHP the one reason I choose XML over JSON is because even in PHP 5 there is no officially supported API for traversal. You can encode, and you can decode, and that is it. There is no validation, no efficient way to traverse key/value pairs, and all-in-all, very little support for it. Don't get me wr...
<p>Regarding the performance of file_get_contents() versus cURL, I believe that cURL will be slightly faster. For your application you could run some quick benchmarks to compare the two approaches.</p> <p>More importantly, I would prefer cURL because file_get_contents() will not work in PHP environments which have a h...
32,357
<p>I have a Creality Ender 3. I've unscrewed the coupler from the drive assembly, but can't get it loose from the tube. The hot end coupler came free easily.</p> <p>I compress the rubber gasket, but it stays tight.</p> <p>Are these manufactured to be replaced every time? My new Bowden tube didn't come with a new coup...
<p>After depressing the retaining ring, try pushing the Bowden tube further in to the coupler. This should disengage the internal sprung clip, and allow removal of the Bowden tube.</p> <p>Good quality pneumatic couplings should allow many insertion and removal cycles, although the couplings that Creality use have a rep...
<p>After depressing the retaining ring, try pushing the Bowden tube further in to the coupler. This should disengage the internal sprung clip, and allow removal of the Bowden tube.</p> <p>Good quality pneumatic couplings should allow many insertion and removal cycles, although the couplings that Creality use have a rep...
2,004
<p>We have a function which a single thread calls into (we name this the main thread). Within the body of the function we spawn multiple worker threads to do CPU intensive work, wait for all threads to finish, then return the result on the main thread.</p> <p>The result is that the caller can use the function naively,...
<p>C++11 introduced the <code>exception_ptr</code> type that allows to transport exceptions between threads:</p> <pre><code>#include&lt;iostream&gt; #include&lt;thread&gt; #include&lt;exception&gt; #include&lt;stdexcept&gt; static std::exception_ptr teptr = nullptr; void f() { try { std::this_thread:...
<p>You will need to do a generic catch for all exceptions in the worker (including non-std exceptions, like access violations), and send a message from the worker thread (i suppose you have some kind of messaging in place?) to the controlling thread, containing a live pointer to the exception, and rethrow there by crea...
28,855
<p>Note that this function does not have a "{" and "}" body. Just a try/catch block:</p> <pre><code>void func( void ) try { ... } catch(...) { ... } </code></pre> <p>Is this intentionally part of C++, or is this a g++ extension?</p> <p>Is there any purpose to this other than bypass 1 level of {}?</p> <p>I'...
<p>Yes, it is standard. Function try blocks, as they're called, aren't that much use for regular functions, but for constructors, they allow you to catch exceptions thrown in the initialiser list.</p> <p>Note that, in the constructor case, the exception will always be rethrown at the end of any catch blocks.</p>
<p>Yes, it is standard. Function try blocks, as they're called, aren't that much use for regular functions, but for constructors, they allow you to catch exceptions thrown in the initialiser list.</p> <p>Note that, in the constructor case, the exception will always be rethrown at the end of any catch blocks.</p>
43,567
<p>I noticed a new web service today called a <a href="http://www.deadmansswitch.net/" rel="nofollow noreferrer">Dead man's switch</a>, which dispatches email in the event that you don't respond to periodic "pings" that prove you're still alive. But it occurred to me that I might outlive the person or organization that...
<p>You can't make a service robust in this way - if the bank account is a single point of failure then when (not if) it fails, you lose. A bank account can't exist without a legal entity to own it, but that's just a detail here - other failures are that Amazon might pull SC2, or raise the price, or make an incompatible...
<p>I think you've been watching too many sci-fi movies. Why do I have the feeling you're the kind of guy who will bring about humanity's demise by letting loose the robots with deadly AI...</p> <p>Interesting thought though. I like it. :)</p>
11,810
<p>I want to copy all of the columns of a row, but not have to specify every column. I am aware of the syntax at <a href="http://dev.mysql.com/doc/refman/5.1/en/insert-select.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.1/en/insert-select.html</a> but I see no way to ignore a column.</p> <p>For my example,...
<p>If your <code>id</code> or primary key column is an <code>auto_increment</code> you can use a temp table:</p> <pre><code>CREATE TEMPORARY TABLE temp_table AS SELECT * FROM source_table WHERE id='7'; UPDATE temp_table SET id='100' WHERE id='7'; INSERT INTO source_table SELECT * FROM temp_table; DROP TEMPORARY TAB...
<p>I'm assuming that since you want to omit the primary key that it is an <code>auto_increment</code> column and you want MySQL to autogenerate the next value in the sequence.</p> <p>Given that, assuming that you do not need to do bulk inserts via the insert into ... select from method, the following will work for sin...
28,468
<p>Is there a good ruby gem for a WYSIWYG editor that will easily work with a rails app?</p>
<p>Though it's certainly not a direct answer, in the past I've found I prefer to use RedCloth (or a Markdown parser if you don't enjoy Textile) and use a simple textarea with an AJAXy preview. Generally speaking, WYSIWYG editors have a long history of creating redundant tags and similar, leading to potentially broken p...
<p>I'm really loving CKeditor gem. It's much, much more elegant than TinyMCE, especially if you deal with raw HTML. CKeditor displays on page--TinyMCE gives a popup. CKeditor allows access to things like all headings right out of the box, too. TinyMCE requires hacking.</p> <p>RedCloth's inability to support ALL HT...
4,420
<p>So I'm a newbie to TDD, and I successfully created a nice little sample app using the MVP pattern. The major problem to my current solution is that its blocking the UI thread, So I was trying to setup the Presenter to use the SynchronizationContext.Current, but when I run my tests the SynchronizationContext.Current...
<p>I've run into similar problems with ASP.NET MVC where it is the HttpContext that is missing. One thing you can do is provide an alternate constructor that allows you to inject a mock SynchronizationContext or expose a public setter that does the same thing. If you can't change the SynchronizationContext internally...
<p>You have to much app-logic in your presenter. I would hide contexts and threads inside a concrete model and test the functionality alone.</p>
47,079
<p>I have unmanaged C++ calling a managed delegate via the function pointer provided by Marshal::GetFunctionPointerForDelegate. This delegate has the potential to throw an exception. I need to be able to properly handle this exception in my unmanaged C++ to ensure things like pointer cleanup, and potentially rethrow ...
<p>Catching from managed code with</p> <pre><code>try { throw gcnew InvalidOperationException(); } catch(InvalidOperationException^ e) { // Process e throw; } </code></pre> <p>And an</p> <pre><code>[assembly:RuntimeCompatibility(WrapNonExceptionThrows = true)]; </code></pre> <p>on your assembly catches manage...
<p>I was told...{the vector can't show if variables a&amp;b weren't declared in the scope process. After a bit of digging figured out that the loop hole was as follows--- weibull_distribution> unmanaged_code
22,149
<p>Acetone is banned in my country, and I cannot get it.</p> <p>What substitute could I use?</p>
<p>The answer really depends on what you are using it for. Is it for dissolving ABS? A <a href="https://www.google.com/search?q=accetone%20substitute" rel="nofollow noreferrer">quick google search</a> should show you what you want.</p> <p>The thread, <a href="https://www.researchgate.net/post/Could_you_recommend_me_a_...
<p>I have used DCM (dichloromethane, or ethylene dichloride) to dissolve ABS (or cold-weld/glue parts together).</p> <p>From <a href="https://en.wikipedia.org/wiki/Acrylonitrile_butadiene_styrene" rel="nofollow noreferrer">ABS wikipedia page</a>: </p> <blockquote> <p><strong>ABS polymers</strong> are resistant to a...
605
<p>I've made some unit tests (in test class). The tutorial I've read said that I should make a TestSuite for the unittests.</p> <p>Odd is that when I'm running the unit test directly (selecting the test class - Run as jUnit test) everything is working fine, altough when I'm trying the same thing with the test suite th...
<p>I'm not experienced in ant - so I'm not using it for testing it right now.</p> <p>Searching the internet it seems like I'm mixing up the old jUnit 3.8 and jUnit 4.0 behavior. Trying now a way to use the "new behavior"</p> <p>edited:<br> now it works:</p> <p>AllTest changed to: </p> <pre><code>import org.junit.r...
<p>For sure, it won't work since you're not telling the test suite what are your test classes.</p> <p>But I'm wondering why you're not using the "classical way" for building Test suites, which is ant using jUnit's ant tasks.</p>
23,080
<p>I'm using Delphi and need to get the current Windows DNS server IP address so I can do a lookup. What function should I call to find it? The only solution I have right now does an ipconfig/all to get it, which is horrible.</p>
<p>Found a nice one using the function GetNetworkParams().Seems to work quite good. You can find it here: <a href="http://www.swissdelphicenter.ch/torry/showcode.php?id=2452" rel="nofollow noreferrer">http://www.swissdelphicenter.ch/torry/showcode.php?id=2452</a></p>
<p>See <em><a href="http://msdn.microsoft.com/en-us/library/aa365968(VS.85).aspx" rel="nofollow noreferrer">GetNetowrkParams</a></em> method (Platform SDK: IP Helper)</p>
8,748
<p>let's say we have a c++ class like:</p> <pre><code>class MyClass { void processArray( &lt;an array of 255 integers&gt; ) { int i ; for (i=0;i&lt;255;i++) { // do something with values in the array } } } </code></pre> <p>and one instance of the class like: </p> <pre><code>MyCl...
<p><code>i</code> is allocated on the stack. Since each thread has its own separate stack, each thread gets its own copy of <code>i</code>.</p>
<p>Since i is a local variable it is stored on the thread's own private stack. Hence, you do not need to protect i with a critical section.</p>
17,358
<p>I have a Java maven project which includes XSLT transformations. I load the stylesheet as follows:</p> <pre><code>TransformerFactory tFactory = TransformerFactory.newInstance(); DocumentBuilderFactory dFactory = DocumentBuilderFactory .newInstance(); dFactory.setNamespaceAware(true); DocumentBuil...
<p>Solved my problem using a URIResolver.</p> <pre><code>class MyURIResolver implements URIResolver { @Override public Source resolve(String href, String base) throws TransformerException { try { ClassLoader cl = this.getClass().getClassLoader(); java.io.InputStream in = cl.getResourceAsStream("xsl/" + href)...
<p>I had a problem similar to this once with relative paths in the XSLT. </p> <p>If you can, try to put absolute paths in the XSLT - that should resolve the error.</p> <p>An absolute path probably isn't preferable for the final version of the XSLT, but it should get you past the maven problem. Perhaps you can have tw...
32,303
<p>I'm not sure if it's my system, although I haven't done anything unusual with it, but I've started noticing incorrectly rendered characters popping up in web pages, text-files, <a href="http://ejohn.org/blog/html5-doctype/" rel="nofollow noreferrer">like this</a>:</p> <p><a href="http://www.kbssource.com/strange-ch...
<p>It appears that for this particular author, the text was edited in some editor that assumed it wasn't UTF8, and then re-wrote it out in UTF8. I'm basing this off the fact that if I tell my browser to interpret the page as different common encodings, none make it display correctly. This tells me that some conversion ...
<p>I'm fairly positive it's nothing you can do. I've seen this on the front page of digg alot recently. It more than likely has to do with a character being encoded improperly. Not necessarily a factor of the font, just a mistake made somewhere in translation.</p>
2,754
<p>I just learned something interesting. The add method for the javascript select object in IE 6 takes only one parameter. It throws an error when you pass it two parameters which I believe is the <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html" rel="noreferrer">standard</a>, even as <a ...
<p>Adding a new Option type works at least IE6 and up</p> <pre><code>function addOption(selectID, display, value) { var obj = document.getElementById(selectID); obj.options[obj.options.length] = new Option(display, value); } </code></pre> <p>Additionally tested in Firefox 2, 3, Opera 8, 9.5, and Safari 4 successf...
<p>As I remember, IE4 accepts creation of an option element and appending it, but perhaps I don't recall it coorrectly !-)</p>
37,270
<p>I'm probably asking for the world, but is there any Windows-based software for easily managing lots of tasks/projects and all the associated documents (spreadsheets, Word documents, other files) that can be quickly navigated/searched. </p> <p>I deal with probably 10-20 active projects and tasks, some lasting only a...
<p>I've had this same problem.</p> <p>I believe the answer hasn't yet been invented (if I had the time, I'd write it myself and make millions).</p> <p>Essentially we need to steal GMail's idea of 'labels' and use it to completely replace windows explorer for management of digital resources.</p> <p>The idea would be ...
<p>Yes, Microsoft Team Foundation Server does all of this (it ties in with and uses SharePoint web sites), of course it will cost you a bit. :-)</p> <p>Add Project Server into the mix and you have Microsoft Project capabilities published to share point viewable sites as well.</p>
20,827
<p>Someone on here recently recommended BWToolkit, and it really impressed me, so I started googling for more IB plug-ins. I've found a couple on random blogs, but haven't been able to find any kind of repository/aggregator for them. Anyone know where I can find more of these?</p> <p>Thanks. </p>
<p>I just created <a href="http://cocoadev.com/index.pl?InterfaceBuilderPlugins" rel="nofollow noreferrer">a page on CocoaDev to list them</a> [edit: question originally just said “Interface Builder plug-ins”, did not mention Cocoa frameworks], with the two I know of listed.</p>
<p>Well that's a good start. I guess that wiki page is the de-facto repository, for now. Seems like there's not much out there.</p>
46,810
<p>I'm trying to get CellID using AT commands, but I dont get any response from the modem, mine code looks like below, I send AT+CCED command, but never get any response.</p> <pre><code>HANDLE hCom; char * xpos; char rsltstr[5]; DWORD returnValue; DWORD LAC; DWORD CellId; int bufpos; DCB dcb; COMMTIMEOUTS to; DWORD nW...
<p>First of all, try <strong>L"COM9:"</strong> for the first parameter of CreateFile.</p> <p>Check out this page: <a href="http://msdn.microsoft.com/en-us/library/aa930218.aspx" rel="nofollow noreferrer">Device File Names</a></p>
<p>I don't know anything about using the AT commands to get the cell id but you can use the RIL interface to get the cell id. It may be simpler than using the AT commands (unless you are trying to get it remotely?)</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms890075.aspx" rel="nofollow noreferrer">http:/...
32,809
<p>We use memcache basically as an after thought to just cache query results.</p> <p>Invalidation is a nightmare due to the way it was implemented. We since learned some techniques with memcache thru reading the mailing list, for example the trick to allow group invalidation of a bunch of keys. For those who know it...
<p>One point to remember with object caching is that it's just that - a cache of objects/complex structures. A lot of people make the mistake of hitting their caches for straightforward, efficient queries, which incurs the overhead of a cache check/miss, when the database would have obtained the result far faster.</p> ...
<p>mysqlnd_qc, which inserts memcaching at the database query results return level, auto caches result sets from mysql. It is FANTASTIC and automatic.</p>
41,766
<p>I am trying to improve the performance of the threaded application with real-time deadlines. It is running on Windows Mobile and written in C / C++. I have a suspicion that high frequency of thread switching might be causing tangible overhead, but can neither prove it or disprove it. As everybody knows, lack of proo...
<p>While you said you don't want to write a test application, I did this for a previous test on an ARM9 Linux platform to find out what the overhead is. It was just two threads that would boost::thread::yield() (or, you know) and increment some variable, and after a minute or so (without other running processes, at lea...
<p>I don't know but do you have the usual performance counters in windows mobile? You could look at things like context switches/sec. I don't know if there is one that specifically measures context switch time though.</p>
39,172
<p>Is there guide out there that will help me, A .Net developer whose been using Visual studio for some time, get to grips with Eclipse?</p> <p>Even just a quick guide to eclipse.</p> <p>Has anyone else made the transition, and if so how did you cope. Any Tips?</p>
<p>Not sure if it will help you, but Eric Sink ran a nice four part series some time ago on his move from VS to Eclipse: </p> <p><a href="http://www.ericsink.com/entries/java_eclipse_1.html" rel="nofollow noreferrer">From C# to Java - Part 1</a></p> <p><a href="http://www.ericsink.com/entries/java_eclipse_2.html" rel...
<p>There is a DZone Refcardz <a href="http://refcardz.dzone.com/refcardz/getting-started-eclipse" rel="nofollow noreferrer">Getting Started with Eclipse</a> (free registration required)</p>
21,421
<p>Looking for a way to drive a Compact Framework app running on a CE device. All we basically need is to be able to write little scripts that press buttons and click on things. Anyone know of such a tool or it best to just hack one up ourselves?</p>
<p>Unfortunately there are no nice, unified tools (that I've found anyway) for testing CF apps. No one provides mocking, since the CF CLR is missing things like Emit, making the taks difficult for a small market.</p> <p>Microsoft provides unit test capabilities in Studio and Team Foundation Server for smart device ap...
<p>Slightly off topic, but we (www.orbiz.biz, if it's still alive) did a kind of a port of NUnit, so we had a runner on the device, and executed the CF code on the device and ran tests. </p> <p>Works quite well - I dont think it was a big change from the original one, so the newer NUnit's might work with the newer CF....
14,856
<p>I've got mssql 2005 running on my personal computer with a database I'd like to run some python scripts on. I'm looking for a way to do some really simple access on the data. I'd like to run some select statements, process the data and maybe have python save a text file with the results.</p> <p>Unfortunately, even ...
<p>I use <a href="http://www.sqlalchemy.org/" rel="noreferrer">SQL Alchemy</a> with cPython (I don't know if it'll work with IronPython though). It'll be pretty familiar to you if you've used Hibernate/nHibernate. If that's a bit too verbose for you, you can use <a href="http://elixir.ematia.de/trac/wiki" rel="norefe...
<p>If you are want the quick and dirty way with CPython (also works for 3.X python):</p> <p>Install PYWIN32 after you install python <a href="http://sourceforge.net/projects/pywin32/files/pywin32/" rel="nofollow">http://sourceforge.net/projects/pywin32/files/pywin32/</a></p> <p>Import the following library: import od...
36,948
<p>Here is the X-axis of the P3Steel:</p> <p><a href="https://i.stack.imgur.com/xuYOq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xuYOq.jpg" alt="X-axis arm of P3Steel" /></a></p> <p>The X-axis idler end of a P3Steel printer, employs an 8 mm diameter rod for the axle on which a 608zz bearing is m...
<p>You could look up a <a href="https://www.pivotpins.com/products/bc-clevis-pins-with-grooves.html" rel="nofollow noreferrer">Clevis pin</a> with one groove.<br> You could look up a <a href="http://technifast.co.uk/clevis-pins" rel="nofollow noreferrer">Clevis pin</a> with a hole for a split pin.<br> Perhaps a <a href...
<p>Oh fascinating. It took me a while to figure out what exactly that is. It is a smooth rod used as the idler for the X belt. </p> <p>What I would do is get a bearing / wheel. Take a thicker screw, nut and washer. Put the idler / bearing / wheel into the slot, then fit the screw / nut. Should work without any issue!<...
477
<p>So, I've started to create some Ruby unit tests that use <a href="http://selenium-rc.openqa.org/" rel="nofollow noreferrer">Selenium RC</a> to test my web app directly in the browser. I'm using the <a href="http://github.com/ph7/selenium-client/tree/master" rel="nofollow noreferrer">Selenum-Client</a> for ruby. I'...
<p>Did you try <a href="http://selenium-grid.openqa.org/how_it_works.html" rel="nofollow noreferrer">Selenium Grid</a>? I think it creates pretty good summary report which shows details you need. I may be wrong, as I didn't use it for quite a while.</p>
<p><em>Disclaimer: Not a selenium expert.</em></p> <p>Do you just want to know which browser failed, or do you want to run the test across all browsers and then report the total failures when it's done?</p> <p>The former is pretty simple if you store the drivers by hash in your setup. (I'm sure there's a fancy-pants ...
26,236
<h3>TL;DR</h3> <p>I need a complete list of fasteners (bolts, nuts and washers) for the <em>Sintron Kossel</em>.</p> <hr /> <p>Has anyone bought this kit, and knows the answer, or knows where this is documented?</p> <p>A complete list would be great, but in particular, I need the dimensions (M2.5/3/4/5? and length) and...
<p>After examining the guide (<a href="https://gr33nonline.files.wordpress.com/2017/05/kossel-mini-instrution-by-sintron-technology_v2.pdf" rel="nofollow noreferrer">Kossel mini instrution by sintron technology_v2</a>) and the printed parts kit, I came up with an 99.9% complete parts list. The lists relating to the eff...
<p>I found two lists for the Kossel mini (the documents you referenced are for a mini, so that is what I am assuming you got). One as a <a href="https://docs.google.com/spreadsheets/d/1s_ekMab3iavE6ohXIHZImjlCRGyXr9UWbBqC8XOGF_M/pub?output=html" rel="nofollow noreferrer">Google Doc</a> and one as an <a href="http://ww...
615
<p>As the title states, I'd be interested to find a safe feature-based (that is, without using navigator.appName or navigator.appVersion) way to detect Google Chrome.</p> <p>By feature-based I mean, for example:</p> <pre><code>if(window.ActiveXObject) { // internet explorer! } </code></pre> <p><strong>Edit:</str...
<pre><code>isChrome = function() { return Boolean(window.chrome); } </code></pre>
<p>isIE: !!(!window.addEventListener &amp;&amp; window.ActiveXObject),</p> <p>isIE6: typeof document.createElement('DIV').style.maxHeight == "undefined",</p> <p>isIE7: !!(!window.addEventListener &amp;&amp; window.XMLHttpRequest &amp;&amp; !document.querySelectorAll),</p> <p>isIE8: !!(!window.addEventListener &amp;&...
10,666
<p>I have two queries saved on my SQL Server 2005 and I would like to have them running at certain intervals, e.g. every 24 hours. Is there a way to automate these queries and schedule them via SQL Server Management Studio?</p>
<p>You need to use the SQL Server Agent, installed as part of SQL Server. This is the background service that's responsible for running scheduled maintenance and backup tasks.</p> <p>Expand the SQL Server Agent node in SQL Server Management Studio, you should see a tree node called "Jobs"</p> <p>Right-clicking this w...
<p>Create a job with a step in which you execute your queries; the job can be scheduled at your needs.</p>
22,590
<p>Does any of you have a clue how to alter the contents of <code>Security.framework/TrustStore.sqlite3</code>. It seems as if the iPhone uses it to store trusted CA certificates. I really want my iPod touch to trust my custom certificate. Beside that, does anyone of you know an app (win32) to edit sqlite3 database fi...
<p>I can imagine that someone else will encounter this problem, therefore I'd like to answer how it works (Apple won't like to see that):</p> <p>1st) The iPhoneOS trusts every CA certificate stored in /System/Library/Frameworks/Security.framework/TrustStore.sqlite3</p> <p>2nd) Some fields in that database contain dat...
<p>Since iOS 11 the TrustStore is located at: <code>/System/Library/Security/Certificates.bundle</code> instead of the usual location: <code>/System/Library/Frameworks/Security.framework</code></p>
45,249
<p>I have normally hand written xml like this:</p> <pre><code>&lt;tag&gt;&lt;?= $value ?&gt;&lt;/tag&gt; </code></pre> <p>Having found tools such as simpleXML, should I be using those instead? What's the advantage of doing it using a tool like that?</p>
<p>Good XML tools will ensure that the resulting XML file properly validates against the DTD you are using.</p> <p>Good XML tools also save a bunch of repetitive typing of tags.</p>
<p>Always use a tool of some kind. XML can be very complex, I know that the PHP guys are used to working with hackey little stuff, but its a huge code smell in the .NET world if someone doesn't use System.XML for creating XML.</p>
16,891
<h3>Background:</h3> <p>Some time ago, I built a system for recording and categorizing application crashes for one of our internal programs. At the time, I used a combination of frequency and aggregated lost time (the time between the program launch and the crash) for prioritizing types of crashes. It worked reasonably...
<p>I've not seen any studies, but a reasonable heuristic would be something like :</p> <p>( Time since last application save when crash occurred + Time to restart application ) * Average hourly rate of application operator.</p> <p>The estimation gets more complex if the crashes have some impact on external customers ...
<p>It depends...</p> <p>In terms of cost, the <em>only</em> thing that matters is the <strong>business impact</strong> of the crash, so it rather depends on the type of application.</p> <p>For may applications, it may not be possible to determine business impact. For others, there may be meaninful measures.</p> <p>D...
7,933
<p>Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.</p> <p>The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point...
<p>First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.</p> <p><strong>Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)</strong></p> <p>Of course, there are many, but the most popular tha...
<p>You don't need to <em>compile</em> python for Mac/Windows/Linux. It is an interpreted language, so you simply need to have the Python interpreter installed on the system of your choice (it is available for all three platforms).</p> <p>As for a GUI library that works cross platform, Python's <a href="http://www.tcl...
2,508
<p>I have the following code that I need to add an additonal object to after the results have been retrieved from the databse. Any Ideas on how I might to this ?</p> <pre><code> public IEnumerable&lt;ProdPriceDisplay&gt; GetShopProductsPrices() { //ProdPriceDisplay ProdPrice = new ProdPriceDisplay(); var Pr...
<p>Use <a href="http://msdn.microsoft.com/en-us/library/bb302894.aspx" rel="nofollow noreferrer"><code>Enumerable.Concat</code></a>:</p> <pre><code>public IEnumerable&lt;ProdPriceDisplay&gt; GetShopProductsPrices() { var products = from shop in db.SHOPs select new ProdPriceDisplay ...
<p>That could be a solution;</p> <pre><code>var productsAsList = Products.ToList(); productsAsList.Add(new ProdPriceDisplay { ProdPrice = "some additional text"; }); return productsAsList; // As your return type is IEnumarable, that won't be a problem; </code></pre>
38,178
<p>VStudio ASP.NET gives the following message: </p> <pre><code>Attribute 'bgcolor' is considered outdated. A newer construct is recommended. </code></pre> <p>What is the recommended construct?</p> <p><code>bgcolor</code> is within a <code>&lt;td&gt;</code> element.<br> Another related message is : </p> <pre><cod...
<p><a href="http://webdesign.about.com/od/intermediatetutorials/a/aa080502a.htm" rel="noreferrer"><code>BGColor</code></a> was deprecated in the W3C HTML 4.0 Specification.</p> <p>Newer Web sites and web applications use CSS (Cascading Style Sheets) to render the same thing, as follows:</p> <pre><code> body { bac...
<p>The newer replacement is cascading style sheets (CSS). Any attributes or elements that control the visual appearance of an HTML document are deprecated. Visual styles should be specified using CSS.</p>
47,199
<p>I am using in the first part of my program</p> <p><code>On Error GoTo start</code></p> <p>Suppose in my second part I am again using</p> <p><code>On Error Resume Next</code></p> <p>This second error trap will not get activated as the first one will still be active. Is there any way to de-activate the first error han...
<p><code>On error goto 0</code> give hand to visual basic for error treatment (in general message box)</p> <p><code>On error goto label</code> will redirect your code to <em><strong>label:</strong></em></p> <p><code>On error resume next</code> will ignore the error and continue</p> <p><code>Resume next</code> redirect ...
<p>try </p> <pre><code>On Error Goto 0 </code></pre> <p>For further help look here: <a href="http://msdn.microsoft.com/en-us/library/bb258159.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb258159.aspx</a></p>
42,863
<p>So I have an application that is based heavily on the QT API which using the QPlugin system. It's fairly simple to use, you define a class which inherit from an Interface and when the plugin is loaded you get an instance of that class. In the end it'll boil down to a <code>dlopen</code>/<code>dlsym</code> or <code>L...
<p>Create a set of interfaces for the main interaction objects that will be exposed by your application and build them in a lib/dll of their own and implement those interfaces on classes in your application as appropriate. The library should also include a plugin interface with perhaps just an "initialize" method that...
<p>Create a registry object that is passed to the plugin in the initialization function that contains a dictionary of exposed components. Then allow the plugin to request a pointer to components by string name or other identifier from this registry. It sacrifices compile-time type safety for a stable interface.</p> <p...
45,767
<p>For all major browsers (except IE), the JavaScript <code>onload</code> event doesn’t fire when the page loads as a result of a back button operation — it only fires when the page is first loaded.</p> <p>Can someone point me at some sample cross-browser code (Firefox, Opera, Safari, IE, …) that solves this problem? ...
<p>Guys, I found that JQuery has only one effect: the page is reloaded when the back button is pressed. This has nothing to do with "<strong>ready</strong>".</p> <p>How does this work? Well, JQuery adds an <strong>onunload</strong> event listener.</p> <pre><code>// http://code.jquery.com/jquery-latest.js jQuery(windo...
<p>OK, I tried this and it works in Firefox 3, Safari 3.1.1, and IE7 but <strong>not</strong> in Opera 9.52.<br> If you use the example shown below (based on palehorse's example), you get an alert box pop-up when the page first loads. But if you then go to another URL, and then hit the Back button to go back to this p...
19,140
<p>Is there a htop/top on Linux where I get to sort processes by network usage?</p>
<p>Also <a href="http://ex-parrot.com/~pdw/iftop/" rel="noreferrer">iftop</a>:</p> <blockquote> <h3>display bandwidth usage on an interface</h3> <p>iftop does for network usage what top(1) does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by p...
<p>Another option you could try is <a href="https://web.archive.org/web/20170701124232/http://linuxcommand.org/man_pages/iptstate8.html" rel="nofollow noreferrer">iptstate</a>.</p>
48,038
<p>IOKit and the DiskArbitration framework can tell me a lot of things about mounted volumes on a mac, but they don't seem to be able to differentiate between HFS+ and HFS Standard volumes. </p> <p>The IOKit/DA keys <code>Content</code>, <code>DAVolumeKind</code> and <code>DAMediaContent</code> are always Apple_HFS an...
<p>There are two ways to do this:</p> <ol> <li>Use <code>getattrlist()</code> to retrieve the <code>ATTR_VOL_SIGNATURE</code> attribute for the mount path of the volume. </li> <li>Use the Carbon call FSGetVolumeInfo() and look in the <code>signature</code> field of the returned struct.</li> </ol> <p>The signature of...
<p>The other problem you can run into should you ever try your hand at reading partition maps directly is that, historically, HFS+ volumes were nested inside HFS wrappers. This was done so that anyone trying to use an HFS+ disk with an older OS would see a single file on the drive explaining where all the rest of their...
23,651
<p>What is an NP-complete problem? Why is it such an important topic in computer science?</p>
<p><strong>NP</strong> stands for <strong><em>Non-deterministic</em> Polynomial</strong> time.</p> <p>This means that the problem can be solved in Polynomial time using a Non-deterministic Turing machine (like a regular Turing machine but also including a non-deterministic "choice" function). Basically, a solution has...
<p>NP-complete problems are a set of problems to each of which any other NP-problem can be reduced in polynomial time, and whose solution may still be verified in polynomial time. That is, any NP problem can be transformed into any of the NP-complete problems. – Informally, an NP-complete problem is an NP problem that ...
25,889
<p>In the Google C++ Style Guide, there's a section on <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Operator_Overloading" rel="noreferrer">Operator Overloading</a> that has a curious statement:</p> <blockquote> <p>Overloading also has surprising ramifications. For instance, you can't f...
<p>5.3.1 of the Standard has "The address of an object of incomplete type can be taken, but if the complete type of that object is a class type that declares operator&amp;() as a member function, then the behavior is undefined (and no diagnostic is required)."</p> <p>I didn't know this either, but as another poster ha...
<p><b>Edited to account for comments:</b></p> <p><s>This is a guess, but one of the main reasons to forward declare is to be able to declare pointers to that class. The compiler has to make assumptions about the class before having the definition - for example, the size of pointers. </p> <p>Is it possible to change...
21,270
<p>i have never used LINQ in any of my projects , i have always used ado.net /OR tool in my Business App projects , so i want to know What are the benefits of LINQ ? why and when anybody should use LINQ ?</p>
<p>Just to clarify there are differences between the concept of <strong>LINQ</strong> and <strong>LINQ to SQL</strong>.</p> <p>LINQ is a query <em>syntax</em>, not a language or an O/RM. You can build an O/RM on top of the syntax provided by LINQ.</p> <p>Since I gather that your question is really <em>When to use LIN...
<p>LINQ-to-SQL functions well as a light-weight ORM via the DMBL designer. It has built-in language support and makes it pretty easy to access your entities using standard access patterns. I use it in all of my new projects and find that it is a significant improvement for me in simplicity and testability. There is ...
44,109
<p>I am trying the following code:</p> <pre><code>&lt;?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = "SELECT * FROM Auctions"; $result = mysql_query($query); while($r...
<p>You haven't selected a database - use <a href="http://www.php.net/mysql_select_db" rel="nofollow noreferrer"><code>mysql_select_db()</code></a></p> <p>That would be something like:</p> <pre><code>&lt;?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' ...
<p>Are you getting anything returned? If no results are found, mysql_query returns FALSE.</p> <p>Check that before running fetch_array.</p>
31,583
<p>Do you write one test per function/method, with multiple checks in the test, or a test for each check?</p>
<p>One test per check and super descriptive names, per instance:</p> <pre><code>@Test public void userCannotVoteDownWhenScoreIsLessThanOneHundred() { ... } </code></pre> <p>Both only one assertion and using good names gives me a better report when a test fails. They scream to me: "You broke THAT rule!".</p>
<p>A testcase per check. If you name the method appropriately, it can provide valuable hint towards the problem when one of these tests cause a regression failure.</p>
13,568
<p>I've got this date time string:</p> <pre><code>post["date"] = "2007-07-18 10:03:19" </code></pre> <p>I'd like to extract just "2007-07-18" as a date. I've seen some reference to <code>strptime</code> but I'm not sure how to use it. How can I extract the date from this string?</p>
<p>The other two answers are fine, but if you actually want the date for something else, you can use the <code>datetime</code> module:</p> <pre><code>from datetime import datetime d = datetime.strptime('2007-07-18 10:03:19', '%Y-%m-%d %H:%M:%S') day_string = d.strftime('%Y-%m-%d') </code></pre> <p>It might be overkil...
<pre><code>import dateutil.parser a = "2007-07-18 10:03:19" d = dateutil.parser.parse(b).date() </code></pre> <p>Your Output will be like this **</p> <blockquote> <p>datetime.date(2007, 07, 18)</p> </blockquote> <p>**</p>
38,691
<p>What frameworks exist to unit test Objective-C code? I would like a framework that integrates nicely with Apple Xcode.</p>
<p>Xcode includes XCTest, which is similar to <a href="http://www.sente.ch/software/ocunit/" rel="noreferrer">OCUnit</a>, an Objective-C unit testing framework, and has full support for running XCTest-based unit tests as part of your project's build process. Xcode's unit testing support is described in the <a href="ht...
<p>I hope u can use 'SenTestKit', from which u can test each and every method. </p>
5,320
<p>At work I'm using Perl 5.8.0 on Windows.</p> <p>When I first put Perl on, I went to CPAN, downloaded all the sources, made a few changes (in the .MAK file(?) to support threads, or things like that), and did <code>nmake</code> / <code>nmake test</code> / <code>nmake install</code>. Then, bit by bit, I've downloaded...
<p>As others noted, start by installing the new perl in a separate place. I have several perls installed, each completely separate from all of the others.</p> <p>To do that, you'll have to configure and compile the sources yourself. When you run <code>configure</code>, you'll get a chance to specify the installer. I g...
<p>Why don't you use ActivePerl and its "ppm" tool to (re)install modules?</p> <p><img src="https://i.stack.imgur.com/5OzUa.png" alt="alt text"></p>
14,311
<p>We'd like to start our bug numbers to something other than 1 for a new Bugzilla installation. Is there a way to do this?</p>
<p>I'm not sure about Bugzilla's backend, but if it uses a SQL database, you should be able to find the table that controls the bug ID number and set the autoincrement value to something else. That is, if Bugzilla uses autoincrement.</p> <p>But I don't have a copy of Bugzilla to provide more info.</p>
<p>I believe it's an autoincrement value in the "bugs" table. </p> <p>In order to force this to start at a predefined value, </p> <p>in MYSQL, you'll need to ... </p> <ul> <li>switch off autoincrement on this field. </li> <li>insert a record with a bug_id set to your starting point. </li> <li>switch the autoincreme...
31,096
<p>I'm having a problem with the WPF Tab View control that I was hoping someone here might be able to help me with.</p> <p>I want my tab view control to use rounded corners for the tab headers, because I think rounded tabs look better.</p> <p>To do this I modified the default control template for the tab by using the...
<p>There is no way to make rounded tab corners without creating a custom template for TabItem. Doing the "Edit Copy" in blend I believe creates default template based on the current theme of windows you have (I may be wrong however. I beleive that wehn you do a controltemplate dump it get's the current control template...
<p>Add a simple style control to your window in Blend. This will add the SimpleStyles.xaml, including one for the tab control.</p> <p>Take a look at the Family.Show and how they do the black and silver themes.</p> <p>Between these two you should have a good example of how to customize the tab control and handle diff...
40,046
<p>I have a page where a few textboxes cannot be empty before clicking a Save button. </p> <pre><code>&lt;TextBox... &lt;TextBox.Text&gt; &lt;Binding Path ="LastName" UpdateSourceTrigger="PropertyChanged"&gt; &lt;Binding.ValidationRules&gt; ...
<p>Here is the complete sample what you need.</p> <p><a href="http://codeblitz.wordpress.com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/" rel="noreferrer">http://codeblitz.wordpress.com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/</a></p> <p><a href="https://skydrive.live.com/?cid=2c6600f1c1d...
<p>This website has the code you're looking for: <a href="https://www.wpfsharp.com/2012/02/03/how-to-disable-a-button-on-textbox-validationerrors-in-wpf/" rel="nofollow noreferrer">https://www.wpfsharp.com/2012/02/03/how-to-disable-a-button-on-textbox-validationerrors-in-wpf/</a></p> <p>For posterity the button code s...
28,598