instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>What is a good way to remove the code from display pages when developing with PHP. Often the pages I work on need to be editted by an outside person. This person is often confused by lots of blocks of PHP, and also likes to break my code.</p> <p>I've tried moving blocks of code out into functions, so now there are ...
<p>You don't need a "system" to do templating. You can do it on your own by keeping presentation &amp; logic separate. This way the designer can screw up the display, but not the logic behind it.</p> <p>Here's a simple example:</p> <pre><code>&lt;?php $people = array('derek','joel','jeff'); $people[0] = 'martin'; //...
<p>There's a lot that can be said on this topic but a very basic starting point would be to move as much code as possible out into separate files and then use include statements.</p>
5,703
<p>Looking for a software solution to to store large files (>50MB - 1.5GB), distributed across multiple servers. We have looked at MogileFS, however, given existing software demands, need to have an NFS interface. Would prefer open source, however, open to all options.</p>
<p>If you have only a small number of servers, you could try <a href="http://samba.anu.edu.au/rsync/" rel="nofollow noreferrer">rsync</a>. Couple it with SSH for some security.</p>
<p>did you look at Hadoop DFS? it's much more then distributed file system but should be good for very big files.</p>
18,867
<p>I need to save a user's login information in encrypted form for this application I'm building, but I'm not sure of the best place to save the file. I don't want to save it into the program application folder as I want it per user.</p> <p>So what is the best folder (or way) to save it into?</p> <p>Edit: Using C++.<...
<p>Seems like C:\Documents and Settings\%username%\Local Settings\Application Data may be the appropriate place according to <a href="http://en.wikipedia.org/wiki/Special_Folders" rel="nofollow noreferrer">Wikipedia</a>. The article says this location is used for "User-specific and computer-specific application setting...
<p>are you using .NET? how about <a href="http://msdn.microsoft.com/en-us/library/3ak841sy(VS.80).aspx" rel="nofollow noreferrer">IsolatedStorage</a>? That way you wouldn't have to worry about the directory location, it'll just be there...</p>
17,764
<p>In a drop down list, I need to add spaces in front of the options in the list. I am trying</p> <pre><code>&lt;select&gt; &lt;option&gt;&amp;#32;&amp;#32;Sample&lt;/option&gt; &lt;/select&gt; </code></pre> <p>for adding two spaces but it displays no spaces. How can I add spaces before option texts?</p>
<p>Isn't <code>&amp;#160</code> the entity for space?</p> <pre><code>&lt;select&gt; &lt;option&gt;&amp;#160;option 1&lt;/option&gt; &lt;option&gt; option 2&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Works for me...</p> <h3>EDIT:</h3> <p>Just checked this out, there <em>may</em> be compatibility issues with this...
<p>I tried several of these examples, but the only thing that worked was using javascript, much like dabobert's, but not jQuery, just plain old vanilla javascript and spaces:</p> <pre><code>for(var x = 0; x &lt; dd.options.length; x++) { item = dd.options[x]; //if a line that needs indenting item.text = ' ...
4,534
<p>I want to select nodes for which a specific attribute does not exist. I've tried the Not() function, but it doesn't work. Is there a way for this?</p> <p>Example: The following Xpath query:</p> <pre><code>group/msg[not(@owner)] </code></pre> <p>Should retrieve the first node but not the 2nd one. However, both Ske...
<p>In some old and not very standard XPath engine I had to use <code>string-length(@attr)=0</code> for the same reason.</p>
<p>Works for me when testing with <a href="http://sourceforge.net/projects/xpe" rel="nofollow noreferrer" title="XPath Explorer">XPath Explorer</a> (based on <a href="http://jaxen.org/" rel="nofollow noreferrer" title="Jaxen">Jaxen</a> library).<br> So I guess it is indeed depending on the XPath implementation.</p>
47,373
<p>I'm using Delphi 6, and I want a database bound list box with multiselect. I found three types of List boxes: <code>TListBox</code>, <code>TDBListBox</code> and <code>TDBLookupListBox</code>. </p> <p>As far as I can understand, <code>TListbox</code> is not bound to database. <code>TDBListBox</code> and <code>TDBL...
<p>The problem with databinding components is that they rely on a datasource and a datasource has only a single cursor. That is probably the reason why.</p> <p>By the way, do you need to change the data? Else you could fill a normal listbox from a dataset. Or even use an invisible data listbox and copy the contents to...
<p>In a TDbLookupListBox you have the option to bind two different things to data; first you can bind the list to a dataset (ListSource/ListField/KeyField), second you can bind the selected item to a field in another dataset (DataSource, DataField). There is nothing conceptually wrong with wanting to bind the list of i...
30,328
<p>I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars.</p> <p>Does anyone know if I can pull up to date exchange rates off the net somewhere in an ea...
<p>You can get currency conversions in a simple format from yahoo:</p> <p>For example, to convert from GBP to EUR: <code>http://download.finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&amp;f=sl1d1t1ba&amp;e=.csv</code></p>
<p>coinnill.com has a sort-of web-service.</p> <blockquote> <p><a href="http://coinmill.com/rss/AUD_USD.xml" rel="nofollow noreferrer">http://coinmill.com/rss/AUD_USD.xml</a></p> </blockquote> <p>will give you the AUD --> USD rate for example. You'll just need to parse the XML that comes back.</p>
21,989
<p>Resharper, RefactorPro, etc?</p>
<p>I have tried using Resharper for some while and also CodeRush with Refactor later on. </p> <p>I have stayed with CodeRush/Refactor. There is one major difference - the discoverability of the commands. Their learning videos are quite nice and show you a lot.</p> <p>Most importantly Coderush has one key/shortcut for...
<p>I think ReSharper is great. I've been using it for 3 years now and I just love it more and more.</p>
6,970
<p>Is it possible to access JSTL's forEach variable via code from within the loop?</p> <pre><code>&lt;c:forEach items="${elements}" var="element"&gt; &lt;% element.someMethod(); %&gt; &lt;/c:forEach&gt; </code></pre>
<p>Well, I believe "element" is stored in the page context.</p> <pre><code>&lt;c:forEach items="${elements}" var="element"&gt; &lt;% ((Element) pageContext.getAttribute("elements")).someMethod(); %&gt; &lt;/c:forEach&gt; </code></pre>
<p>Edit following the correction of the example:</p> <p>Yes, it is possible to access the <code>var</code> inside the <code>c:forEach</code> </p> <p>Here's an example:</p> <pre><code>&lt;c:forEach items="${elements}" var="element"&gt; ${((Element)element).someMethod()} &lt;/c:forEach&gt; </code></pre> <p>See <a...
43,458
<p>I have a file with n lines. (n above 100 millions)</p> <p>I want to output a file with only 1 of 10 lines, I can't split the file in ten part and keep only one part, as it must be a little more random. later I have to do a statistical analysis I can't afford to create a strong bias in the data).</p> <p>I was think...
<p>Ok, I think I've cracked it:</p> <pre><code>findstr/N . path-to-log-file | findstr ^[0-9]*0: </code></pre> <p>(use findstr to add the line number to the beginning of the line, then again to print only lines with a line number ending in zero)</p> <p>So you'll get one line in 10, but with the linenumber and colon p...
<p>Paul has a really good answer. By adding the redirection operator you can have the data written to a file.</p> <pre><code>findstr /n . yourLogFile.txt | findstr ^[0-9]*0: &gt; numberedFile.txt for /f "tokens=1,2* delims=:" %i in (numberedFile.txt) do echo %j &gt; smallFile.txt del numberedFile.txt </code></pre> <p...
42,440
<p>Has anyone experienced memcached limitations in terms of:</p> <ul> <li><h1>of objects in cache store - is there a point where it loses performance?</h1></li> <li>Amount of allocated memory - what are the basic numbers to work with?</li> </ul>
<p>I can give you some metrics for our environment. We run memcached for Win32 on 12 boxes (as cache for a very database heavy ASP.NET web site). These boxes each have their own other responsibilities; we just spread the memcached nodes across all machines with memory to spare. Each node had max 512MB allocated by memc...
<p>I can't vouch for the accuracy of this claim, but at a linux/developer meetup a few months ago an engineer talked about how his company scaled memcache back to using 2GB chunks, 3-4 per memcache box. They found that throughput was fine, but with very large memcache daemons that they were getting 4% more misses. He...
46,634
<p>I am running both maven inside the m2eclipse plugin, windows command line and my cygwin command line.</p> <p>cygwin's bash shell dumps artifacts into the cygwin /home/me/.m2 directory</p> <p>but m2eclipse &amp; windows shell (on vista) uses /Users/me/Documents/.m2</p> <p>Is it possible to tell the mvn command to ...
<p>Sure, several ways. The most typical is to specify this in your settings.xml file:</p> <ul> <li><a href="http://maven.apache.org/settings.html" rel="noreferrer">http://maven.apache.org/settings.html</a></li> </ul> <blockquote> <pre><code>&lt;settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w...
<p>Sure, several ways. The most typical is to specify this in your settings.xml file:</p> <ul> <li><a href="http://maven.apache.org/settings.html" rel="noreferrer">http://maven.apache.org/settings.html</a></li> </ul> <blockquote> <pre><code>&lt;settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w...
25,424
<p>I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java.</p> <p>If I have <em>x</em> items which I want to display in chunks of <em>y</em> per page, how many pages will be needed?</p>
<p>Found an elegant solution:</p> <pre><code>int pageCount = (records + recordsPerPage - 1) / recordsPerPage; </code></pre> <p>Source: <a href="http://www.cs.nott.ac.uk/~rcb/G51MPC/slides/NumberLogic.pdf" rel="noreferrer">Number Conversion, Roland Backhouse, 2001</a></p>
<p>You'll want to do floating point division, and then use the ceiling function, to round up the value to the next integer.</p>
3,854
<p>At my work we are running a group of tests that consist of about 3,000 separate test cases. Previously we were running this entire test suite on one machine, which took about 24-72 hours to complete the entire test run. We now have created our own system for grouping and distributing the tests among about three sepa...
<p>I've seen some people having a play with <a href="http://216.93.179.140:8080/wiki/display/GG15UG/Distributed+JUnit+Overview" rel="nofollow noreferrer">distributed JUnit</a>. I can't particularly vouch for how effective it is, but the other teams I've seen seemed to think it was straight forward enough. Hope that hel...
<p>Our build people use Mozilla Tinderbox. It seems to have some hooks for distributed testing. I'm sorry not to know the details but I thought I would at least pass on the pointer to you.</p> <p>It's also nice coz you can find out immediately when a build breaks, and what checkin might have been the culprit.</p> <...
2,968
<p>I'm about to put my head thru this sliding glass door. I can't figure out how to execute the following code in VB.NET to save my life. </p> <pre><code>private static void InitStructureMap() { ObjectFactory.Initialize(x =&gt; { ...
<p>At the moment, it's simply not possible. The current version of VB does not support multiline (or statement) lambdas. Each lambda can only comprise one single expression. The next version of VB will fix that (there simply wasn't enough time in the last release).</p> <p>In the meantime, you'll have to make do with a...
<p>That's awesome, for whatever reason though, it doesn't compile. Ugh.</p> <p>Here's what it came up with though:</p> <pre><code>Private Shared Sub InitStructureMap() ObjectFactory.Initialize(Function (ByVal x As IInitializationExpression) x.AddRegistry(New DataAccessRegistry) x.AddRegistry(New CoreRegistry...
47,880
<p>I have trouble comparing 2 double in Excel VBA</p> <p>suppose that I have the following code</p> <pre><code>Dim a as double Dim b as double a = 0.15 b = 0.01 </code></pre> <p>After a few manipulations on b, b is now equal to 0.6</p> <p>however the imprecision related to the double data type gives me headache bec...
<p>You can't compare floating point values for equality. See this article on "<a href="http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/" rel="noreferrer">Comparing floating point numbers</a>" for a discussion of how to handle the intrinsic error.</p> <p>It isn't as simple as c...
<p>Try to use Single values if possible. Conversion to Double values generates random errors.</p> <pre><code>Public Sub Test() Dim D01 As Double Dim D02 As Double Dim S01 As Single Dim S02 As Single S01 = 45.678 / 12 S02 = 45.678 D01 = S01 D02 = S02 Debug.Print S01 * 12 Debug.Print S02 Debug.Print D01 * 12 Debug.Print...
29,142
<p>I'm experimenting with the Tiny MCE editor. We also use jQuery, and I noticed that the standard Tiny MCE install includes a file called <code>tiny_mce_jquery.js</code>. Can anyone enlighten me as to what that's for? Oddly, I can't find anything about it online. Should I reference it in addition to the standard Tiny ...
<p>You should use the 'struts-and-springs' control in IB to set your base view to be full-justified. Then it will auto-resize. Once you do this, you can just use the view.bounds property to access its visible area.</p>
<p>You should use Ben Gottlieb's solution but in terms of calculating the visible area of a view named "<code>view</code>", you could probably use:</p> <pre><code>CGRect viewBoundsInWindow = [[[UIApplication sharedApplication] keyWindow] convertRect:view.layer.visibleRect fromView:view]; </code></pre>
42,663
<p>I am receiving a message from a commercial program stating that the "LogMessage" stored procedure is not found. There does not appear to be a stored procedure called LogMessage in the associated MS SQLServer 2000 database. What can I do to track down the missing procedure, other than calling the company?</p>
<p>The reason you couldn't find it is because it's not there. Unless you have the original proc, you're going to have to call the company.</p> <p>Granted, you could take a stab at creating the proc, yourself. But why bother when somebody already has the original proc?</p> <p>Is this a fresh install of the commercia...
<p>LogMessage seems pretty self-explanatory. You could probably take a stab at creating one yourself just to see what happens, if you can't easily get the real thing.</p> <p>Create a new table called LoggedMessages and just insert to the table when the proc is called. Then see what pops in.</p> <p>Kind of hacky, bu...
9,972
<p>I have heard/read the term but don't quite understand what it means.</p> <p>When should I use this technique and how would I use it? Can anyone provide a good code sample?</p>
<p>The visitor pattern is a way of doing double-dispatch in an object-oriented way.</p> <p>It's useful for when you want to choose which method to use for a given argument based on its type at runtime rather than compile time.</p> <p>Double dispatch is a special case of <strong>multiple dispatch</strong>. </p> <p>Wh...
<p>Full listing of working code</p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Linq; namespace TestConsoleApp { internal class Program { public static void Main(string[] args) { const int x = 5; var dispatch = new DoubleDispatch(); ...
6,415
<p>I am in the process of researching/comparing CXF and Spring-WS for web services? I need to function both as a provider and a consumer of WS. In a nutshell, I have been told that Spring-WS is more configurable, but CXF is easier to get up and running. This question is subjective, but will help direct me in my researc...
<p>About Apache CXF:</p> <ul> <li>CXF supports several standards including SOAP, the WSI Basic Profile, WSDL, WS-Addressing, WS-Policy, WS-ReliableMessaging, WS-Security, WS-SecurityPolicy, and WS-SecureConversation. </li> <li>Apache CXF offers both contract-last (starting with Java) and Contract-first (starting with ...
<p>Please take a look at a related post at : <a href="http://justcompiled.blogspot.com/2010/09/building-web-service-with-spring-ws.html" rel="nofollow">Building a web service with Spring-WS</a></p>
37,991
<p>I'm developing a web app with java servlet, I hope to get the user ip info by calling <code>request.getRemoteAddr()</code> from inside <code>processRequest(HttpServletRequest request,HttpServletResponse response)</code>.</p> <p>But it returns a wrong IP. Since I'm not very knowledgeable about this area, I don't kn...
<p>What IP address is it displaying? My guess is there's some proxy or something changing things. (For instance, that script page displayed my ADSL router's IP address - not the one inside my LAN - for obvious reasons.)</p> <p>EDIT: Now that you've shown that the IP address you're seeing is 127.0.0.1 the answer is fai...
<p>You're running your test server on your local computer and connecting to it on <a href="http://localhost/" rel="nofollow noreferrer">http://localhost/</a>. Since you're connecting on the local interface, the source of the connection is also localhost, aka 127.0.0.1.</p>
32,905
<p>I have a utility (grep) that gives me a list of filenames and a line numbers. After I have determined that devenv is the correct program to open a file, I would like to ensure that it is opened at the indicated line number. In emacs, this would be:</p> <pre><code>emacs +140 filename.c </code></pre> <p>I have found...
<p>With VS2008 <strong>SP1</strong>, you can use the following command line to open a file at a specific line in an existing instance :</p> <pre><code>devenv /edit FILE_PATH /command "edit.goto FILE_LINE" </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/xee0c8y7%28VS.80%29.aspx" rel="noreferrer">Sour...
<p>I was about to ask this question because when you get the "yellow screen of death" when debugging a web application, you want to quickly go to the file and line that it gives you in the stacktrace e.g:</p> <pre><code>[ContractException: Precondition failed: session != null] System.Diagnostics.Contracts.__Contrac...
45,599
<p>All my prints come out about 1 mm too short in the Z dimension. So for example a 20 mm cube comes out 19 mm high. A 10 mm cube comes out 9 mm high. The X and Y dimensions are fine. There's a little bit of visible elephant's foot at the bottom, so I assume whatever is happening is in the first couple of layers. The p...
<p>Do you have any “slop” on the right side (non motor) of the gantry?</p> <p>I’ve noticed that my gantry will settle on the right side and lag behind the motor driven - ever so slightly - when it starts to drive up. It will, after that first lag, move fine for the rest of the time. Z axis travel seems barely affected ...
<p>I have the exact same issue on my Ender 3 V2, perfect bed level using a dial gauge, perfect first layer test prints (printing 9 squares all 1 layer high).</p> <p>I can only get rid of it two ways:</p> <ol> <li>Using a Raft as you have said (annoying).</li> <li>Adjusting the Z-height Just exactly as the 1st layer fin...
1,701
<p>How would you attach a propertychanged callback to a property that is inherited? Like such:</p> <pre><code>class A { DependencyProperty prop; } class B : A { //... prop.AddListener(PropertyChangeCallback); } </code></pre>
<p>(edited to remove recommendation to use DependencyPropertyDescriptor, which is not available in Silverlight)</p> <p><a href="http://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/" rel="nofollow noreferrer">PropertyDescriptor AddValueChanged Alternative</a></p>
<p>Have you tried a two way data binding between the two dependency properties?</p>
3,344
<p>jQuery selectors are wonderful, but I sometimes I find myself typing them over and over, and it gets a little annoying.</p> <pre><code> $('#mybutton').click(function() { $('#message-box').doSomething(); $('#message-box').doSomethingElse(); $('#message-box').attr('something', 'something'); }); </code></...
<p>You should chain them:</p> <pre><code>$('#mybutton').click(function() { $('#message-box').doSomething().doSomethingElse().attr('something', 'something'); }); </code></pre> <p>If you need to do something over and over again and the functions don't return the jQuery object saving them in a var is faster.</p>
<p>Actually the question is much more complex.</p> <ol> <li><p>Chaining is not always possible, because selector strings or cached jQuery selector instances might be stored in new function() properties, accessed by various prototype functions, not the single piece of code.</p></li> <li><p>You may chain both selector s...
42,655
<p>I find my self having a repeater control which is being databound to an xml document. My client is now requesting that the Textbox's which are being repeater can be either a Textbox or a Checkbox.</p> <p>I cannot seem to find an easyway to essentially do the following:</p> <pre><code>if ((System.Xml.XmlNode)e.Item...
<p>What about something similar to this in your markup in each the textbox and checkbox controls?</p> <blockquote> <pre><code>Visible=&lt;%= Eval("type").tostring() == "text") %&gt; </code></pre> </blockquote>
<p>If there is needed to add controls based on data then there can be used this approach:</p> <pre><code>&lt;asp:Repeater ID=&quot;ItemsRepeater&quot; runat=&quot;server&quot; OnItemDataBound=&quot;ItemRepeater_ItemDataBound&quot;&gt; &lt;itemtemplate&gt; &lt;div&gt; &lt;asp:PlaceHolder ID=&quot...
15,590
<p>In java, there's three levels of access:</p> <ul> <li>Public - Open to the world</li> <li>Private - Open only to the class </li> <li>Protected - Open only to the class and its subclasses (inheritance).</li> </ul> <p>So why does the java compiler allow this to happen?</p> <p>TestBlah.java:</p> <pre><code>public c...
<p>Actually it should be:</p> <blockquote> <p>Open only to the <a href="http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html" rel="noreferrer"><strong>classes on the same package</strong></a> the class and its subclasses (inheritance)</p> </blockquote> <p>That's why</p>
<p>You're able to call <code>b.getMessage()</code> because <code>b</code> is of type <code>Bloo</code>, which extends <code>Blah</code>, and <code>getMessage()</code> is protected. Protected, as you mentioned, allows subclasses to access the method.</p> <p>You've got the following errors, though:</p> <ul> <li>Callin...
43,148
<p>SQL Server 2005/2008 Express edition has the limitation of 4 GB per database. As far as I known the database engine considers data only, thus excluding log files, unused space, and index size.</p> <p>Getting the length of the MDF file should not give the correct database size in terms of SQL Server limitation. My q...
<p>sp_spaceused</p>
<p><strong><em>Common Query To Check Database Size in SQL Server that supports both Azure and On-Premises-</em></strong></p> <p><strong>Method 1 – Using ‘sys.database_files’ System View</strong></p> <pre><code>SELECT DB_NAME() AS [database_name], CONCAT(CAST(SUM( CAST( (size * 8.0/1024) AS DECIMAL(15,...
21,249
<p>My solution includes these two projects:</p> <ul> <li>MyNamespace.Web.UI</li> <li>MyNamespace.Web.Core</li> </ul> <p>UI references Core, and Core references Foobar.dll, which exists nowhere except my library. When I build from Visual Studio 2008 Foobar.dll is in the UI project's Bin folder as expected. I have ma...
<p>You likely have the option in VS to "Copy Local" on, which is implicitly, well, copying it locally before the build. You'll need to emulate that in NAnt. </p> <p>Similar to why you can just do a "Publish" for a web project from Visual Studio, but for the command line you have to both build and then copy out the out...
<p>In some things that I've worked on, I've resorted to using NAnt's <a href="http://nant.sourceforge.net/release/latest/help/tasks/copy.html" rel="nofollow noreferrer">copy task</a> to copy the DLL into the bin directory so that the project will build. I don't know if that's necessarily best practice, but it works.</p...
33,994
<p>I've read <a href="http://www.xs4all.nl/~hipster/lib/scheme/gauche/define-syntax-primer.txt" rel="noreferrer">JRM's Syntax-rules Primer</a> for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syn...
<p>To answer your second question: <code>syntax-case</code> is the other form that goes inside <code>define-syntax</code>. Kent Dybvig is the primary proponent of <code>syntax-case</code>, and <a href="http://www.cs.uml.edu/~giam/91.531/Textbooks/RKDybvig.pdf" rel="noreferrer">he has a tutorial on using it [PDF].</a></...
<p>The list of resources at <a href="https://web.archive.org/web/20150321052219/http://schemecookbook.org/Cookbook/GettingStartedMacros" rel="nofollow noreferrer">The Scheme Cookbook</a> is a great place to start. If you prefer papers, then don't hessitate to visit <a href="https://web.archive.org/web/20160306064729/ht...
15,948
<p>I'll regularly get an extract from a DB/2 database with dates and timestaps formatted like this:</p> <pre><code>2002-01-15-00.00.00.000000 2008-01-05-12.36.05.190000 9999-12-31-24.00.00.000000 </code></pre> <p>Is there an easier way to convert this into the Excel date format than decomposing with substrings?</p> ...
<p>It's not clear if you talk about formula functions or VBA functions.</p> <h2>Formula functions</h2> <p>Don't use the DateValue function, which expects a string; use the Date function, which expects numeric Year, Month, Day:</p> <pre><code>=DATE(INT(LEFT(A1,4)),INT(MID(A1,6,2)),INT(MID(A1,9,2))) </code></pre> <p>...
<p>I'm sure you could cook something up with Regex's if you really cared to. It wouldn't be any 'better' though, probably worse. </p> <p>If you'll forgive a bit of C# (I havn't touched VB in years, so I don't know the function calls anymore) you could also do:</p> <pre><code>DB2string = "2002-01-15-00.00.00.000000"; ...
20,071
<p>What is the XPath expression that I would use to get the string following 'HarryPotter:' for each book.</p> <p>ie. Given this XML:</p> <pre><code>&lt;bookstore&gt; &lt;book&gt; HarryPotter:Chamber of Secrets &lt;/book&gt; &lt;book&gt; HarryPotter:Prisoners in Azkabahn &lt;/book&gt; &lt;/bookstore&gt; </code>...
<p>In XPath 2.0 this can be produced by a single XPath expression:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><code>/*/*/substring-after(., 'HarryPotter:')</code></strong></p> <p>Here we are using the very powerful feature of XPath 2.0 that at the end of a path of location steps we can put a function and this...
<p>Xpath:</p> <pre><code>substring-after(//book, 'HarryPotter:') </code></pre> <p>I'm totally new in this area, but for me, it works ...!</p>
43,191
<p>I've used both and I've found MySql to have several frustrating bugs, limited support for: IDE integration, profiling, integration services, reporting, and even lack of a decent manager. Total cost of ownership of MSSQL Server is touted to be less than MySQL too (.net environment), but maintaining an open mind could...
<p>I've used MySQL in the past and I'm using MSSQL lately but I can't remember anything that MySQL has and MSSQL can't do. </p> <p>I think the most killer feature of MySQL it's the simplicity. For some projects you just don't need all the power you can have with a huge system like MSSQL. I have an UNIX heritage and fi...
<p>MySQL probably has a lower TCO, since administration and configuration is more simple and straightforward than the Spaghetti GUI that MS SQL makes you do most of the configuration through, having to dig through hundreds of obscure properties dialogs to accomplish even basic administration tasks.</p> <p>There is one...
28,185
<p>A few years ago client Java was unsuitable for web development because a remarkable part of web users did not have Java installed. ( I don't remember exact numbers, more than 10%). </p> <p>Now I see the Google Analytics stats for a big site and it tells that >98% of users have Java installed.</p> <p>Is these stats...
<p>When I wrote my diploma project, I had to choose between Flash and Java Applets. Here are some pros and cons: </p> <p>Java Applets: </p> <ul> <li>[plus] you program in Java, which is mature and stable</li> <li>[plus] you can use the Java GUI frameworks that pack a lot of punch</li> <li>[minus] the first time the u...
<p>Not an exact answer, as it would be very opinionated, just sharing my experience... </p> <p>In a recent project, where we were building a WAI compliant site, we were asked to avoid flash objects as accessiblity was a major issue. Applets on a different note don't go very well with most web developers ;). One reason...
37,304
<p>In PHP you can access characters of strings in a few different ways, one of which is substr(). You can also access the Nth character in a string with curly or square braces, like so:</p> <pre><code>$string = 'hello'; echo $string{0}; // h echo $string[0]; // h </code></pre> <p>My question is, is there a benefit ...
<p>use <code>$string[0]</code>, the other method (braces) has been removed in PHP 8.0.</p> <p>For <a href="https://www.php.net/manual/en/language.types.string.php" rel="nofollow noreferrer">strings</a>:</p> <blockquote> <p>Accessing characters within string literals using the {} syntax has been deprecated in PHP 7.4. T...
<p>Yes, there's no difference. This language quirk has some history...</p> <p>Originally, the curly brace syntax was intended to replace the square bracket syntax which was going to be deprecated:</p> <p><a href="http://web.archive.org/web/20010614144731/http://www.php.net/manual/en/language.types.string.php#language...
43,470
<pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; div { border:1px solid #000; min-width: 50%; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt;This is some text. &lt;/div&gt; &lt;/body&gt; &lt;/html&g...
<p>If you provide <code>absolute</code> positioning to the element, it will be <code>50%</code> in Firefox. However, IE doesn't like the <code>min-width</code> or <code>min-height</code> attributes, so you will have to define width as <code>50%</code> also for it to work in IE.</p>
<p>You may want to try an IE specific style-sheet and include and expression like:</p> <pre><code>print("width:expression(document.body.clientWidth &lt; 1024? "50%" : "100%");"); </code></pre> <p>This will change the width setting based on the width of the browser window at load time. I personally like to use px as t...
24,132
<p>I don't need to validate that the IP address is reachable or anything like that. I just want to validate that the string is in dotted-quad (xxx.xxx.xxx.xxx) IPv4 format, where xxx is between 0 and 255.</p>
<p>You probably want the <a href="http://man7.org/linux/man-pages/man3/inet_pton.3.html" rel="nofollow noreferrer">inet_pton</a>, which returns -1 for invalid AF argument, 0 for invalid address, and +1 for valid IP address. It supports both the IPv4 and future IPv6 addresses. If you still need to write your own IP addr...
<pre><code>void validate_ip_address(const std::string&amp; s) { const std::string number_0_255 = "((([0-9])|([1-9][0-9])|(1[0-9][0-9]|2[0-4][0-9]|25[0-5])){1})"; const std::string dot = "(\\.){1}"; static const boost::regex e(number_0_255 + dot + number_0_255 + dot + number_0_255 + dot + number_0_255); ...
41,124
<p>Like many projects, we deploy to many environments, QA, UA, Developer trunks, etc..</p> <p>What is the best way to store sensitive configuration parameters in SVN? Or, should you not and just maintain a smaller unversioned file with credentials in it on the server?</p> <p>Mainly, we do not want to expose productio...
<p>I'd rather provide configuration examples than real config files. In my project there is <code>setup.default.php</code> file in root directory that every user need to copy as <code>setup.php</code> and amend to match local environment. Additionally, to prevent checking in back customised setup files there is a rule ...
<p>I would not store configuration information in the repository at all. That way you don't have to worry about SVN trying to update the config when you update your source. </p>
18,013
<p>Today at work we came across the following code (some of you might recognize it):</p> <pre><code>#define GET_VAL( val, type ) \ { \ ASSERT( ( pIP + sizeof(type) ) &lt;= pMethodEnd ); \ val = ( *((type *&amp;)(pIP))++ ); \ } <...
<p>The inverse square root implementation in Quake 3:</p> <pre><code>float InvSqrt (float x){ float xhalf = 0.5f*x; int i = *(int*)&amp;x; i = 0x5f3759df - (i&gt;&gt;1); x = *(float*)&amp;i; x = x*(1.5f - xhalf*x*x); return x; } </code></pre> <p><strong>Update:</strong> <a href="http://www.lom...
<p>Binary shift confuses me all the time. An example from the <code>java.util.concurrent.ConcurrentHashMap</code> package:</p> <pre><code>return ((h &lt;&lt; 7) - h + (h &gt;&gt;&gt; 9) + (h &gt;&gt;&gt; 17)) </code></pre>
21,485
<p>I'm trying to create a c++ library for use on windows/MSVC.</p> <p>My problem is that it seems that in order to link properly, I need to distribute a bunch of different versions, linked against different versions of MSVC's c++ runtimes - single and multi-threaded, debug and release, different compiler versions, var...
<p>You want static linking, as a general answer.</p> <p>Quick note on Chris' answer (don't want to de-boost cause it's mostly good, but...):</p> <p>DO NOT link to msvcrt.dll (the unversioned one); this is the OS-specific version DLL, and if you link to it, your app probably will not work on other versions of Windows....
<p>You don't need to use a custom allocator if you are using C++, and you wrap all allocations around <code>std::tr1::shared_ptr</code> (where you can specify a deallocation function). This ensures that even when clients release the last reference to the shared pointer, it's still code in your library (or your library'...
23,061
<p>Is it possible to make efficient queries that use the complete regular expression feature set.</p> <p>If not Microsoft really should consider that feature.</p>
<p>For SQL Server 2000 (and any other 32 bit edition of SQL Server), there is <a href="http://www.codeproject.com/KB/database/xp_pcre.aspx" rel="nofollow noreferrer">xp_pcre</a>, which introduces Perl compatible regular expressions as a set of extended stored procedures. I've used it, it works.</p> <p>The more recent ...
<p>I think we can see from the new types in SQL Server 2008 (hierarchyid, geo-spatial) that if Microsoft do add this it will come in the form of a SQL CLR Assembly</p> <p>If you are able to install Assemblies into your database you could roll your own by creating a new Database\SQL Server project in Visual Studio - th...
33,610
<p>Is it possible to have multiple view of the same display object? (e.g. same-computer multi-player game using split screen)</p> <p>The sample code that failed to work follows:</p> <pre><code> var content: Sprite = new Sprite(); var v1: Sprite = new Sprite(); var v2: Sprite = new Sprite(); with(conte...
<p>The easiest way to do this is to have a bitmap that's updated with the original display object's contents, something like:</p> <pre> var bitmap:Bitmap = new Bitmap(new BitmapData(1,1)); addChild(bitmap); addEventListener(Event.ENTER_FRAME,enterFrameHandler); function enterFrameHandler(event:Event):void { bitm...
<p>If you put render to a bitmap inside of sprite, then you can capture mouse clicks.</p> <p>mike</p>
23,172
<p>I have following string</p> <pre><code>String str = "replace :) :) with some other string"; </code></pre> <p>And I want to replace first occurance of <code>:)</code> with some other string</p> <p>And I used <code>str.replaceFirst(":)","hi");</code></p> <p>it gives following exception</p> <blockquote> <p>"Unma...
<p>The <code>replaceFirst</code> method takes a regular expression as its first parameter. Since <code>)</code> is a special character in regular expressions, you must quote it. Try:</p> <pre><code>str.replaceFirst(":\\)", "hi"); </code></pre> <p>The double backslashes are needed because the double-quoted string also...
<p><a href="http://commons.apache.org/" rel="nofollow noreferrer">Apache Jakarta Commons</a> are often the solution for this class of problems. In this case, I would have a look at <a href="http://commons.apache.org/lang/" rel="nofollow noreferrer">commons-lang</a>, espacially <a href="http://commons.apache.org/lang/ap...
38,167
<p>I am trying to write a unit test for an action method which calls the <code>Controller.RedirectToReferrer()</code> method, but am getting a "No referrer available" message.</p> <p>How can I isolate and mock this method?</p>
<p>Have you thought about creating a <a href="http://xunitpatterns.com/Test%20Double.html" rel="nofollow noreferrer">test double</a>?</p>
<p>In <em>my</em> version of the trunk I'm working against, r5299, I had to do this to mock out RedirectToReferrer. I think it's been changed in recent commits, I'm not sure.</p> <pre><code>[TestFixture] public class LoginControllerTests : GenericBaseControllerTest&lt;LoginController&gt; { private string referrer...
8,737
<p>Is there something like <a href="http://effbot.org/zone/python-getattr.htm" rel="noreferrer">Python's getattr()</a> in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.</p>
<p>There is also <a href="http://msdn.microsoft.com/en-us/library/66btctbe.aspx" rel="noreferrer">Type.InvokeMember</a>.</p> <pre><code>public static class ReflectionExt { public static object GetAttr(this object obj, string name) { Type type = obj.GetType(); BindingFlags flags = BindingFlags.I...
<p>There's the System.Reflection.PropertyInfo class that can be created using object.GetType().GetProperties(). That can be used to probe an object's properties using strings. (Similar methods exist for object methods, fields, etc.)</p> <p>I don't think that will help you accomplish your goals though. You should proba...
16,697
<p>My bash script doesn't work the way I want it to:</p> <pre><code>#!/bin/bash total="0" count="0" #FILE="$1" This is the easier way for FILE in $* do # Start processing all processable files while read line do if [[ "$line" =~ ^Total ]]; then tmp=$(echo $line | cut -d':' -f2)...
<p>It looks like you are trying to add up the totals from the lines labelled 'Total:' in the files provided. It is always a good idea to state what you're trying to do - as well as how you're trying to do it (see <a href="http://www.catb.org/~esr/faqs/smart-questions.html" rel="nofollow noreferrer">How to Ask Question...
<p>If you define a function, it'll receive the argument as $1. Why is $1 more valuable to you than $FILE, though?</p> <pre><code>#!/bin/sh process() { echo "doing something with $1" } for i in "$@" # Note use of "$@" to not break on filenames with whitespace do process "$i" done </code></pre>
42,359
<p>I have embedded a Python interpreter in a C program. Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e.g., ISO 8859-1, Windows-1252, or UTF-8). How do I decode the contents of this char array into a Python string?</p> ...
<p>PyString_Decode does this:</p> <pre><code>PyObject *PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) { PyObject *v, *str; str = PyString_FromStringAndSize(s, size); if (str == NULL) return NULL; v = PyString_AsDe...
<p>You don't want to decode the string into a Unicode representation, you just want to treat it as an array of bytes, right?</p> <p>Just use <code>PyString_FromString</code>:</p> <pre><code>char *cstring; PyObject *pystring = PyString_FromString(cstring); </code></pre> <p>That's all. Now you have a Python <code>str...
26,259
<p>What are the most common memory optimizations in csharp, dotnet 2.0. Wanted to see if there common things that people may not be doing by default in winform app</p>
<ul> <li>use structs for small wrapper objects to avoid heap fragmentation</li> <li>think carefully about object lifetimes, especially for large objects so they do not end up on the LOH unless you intend them to</li> <li>think about allocations inside of a loop</li> <li>make sure dynamically sized array will be of reas...
<p>Sealing as much classes as possible should also help. AFAIK this is one trick that SmartAssembly uses to reduce memory consumption.</p>
8,560
<p>I did some googling to try to answer this question but even after that I'm not quite clear about something. Is it possible to create a console app from VB6? </p> <p>I've got a VB6 app that doesn't put up a window. I always assumed that it was a console app. However, I want to be able to use the Windows API SetC...
<p>Yes. It's also possible to create totally headless applications (which I've done a few times in the past). <a href="http://www.tek-tips.com/faqs.cfm?fid=5647" rel="noreferrer">This link</a> gives an example with a code snippet.</p>
<p>See this <a href="http://visualbasic.about.com/od/learnvb6/l/bldykvb6dosa.htm" rel="nofollow noreferrer">article</a>. </p> <p>Or you could rewrite the VB6 app as a VBScript program.</p>
36,490
<p>Is there a way to get notification of date change in c#?</p> <p>I have a requirement where I have to do something when the system date is changed.</p> <p>I found that SystemsEvent.TimeChanged is an event you can hook into, however it is only fired only when user has changed the time.</p>
<p>Would this be better handled by having a scheduled task/cron job that runs at midnight?</p>
<p>Your app could run a loop that sleeps for a minute, then checks the date. If it's different than last time, run your logic.</p> <p>But I agree that this scenario would be better handled with a scheduled task.</p>
48,665
<p>Visual Studio gives many navigation hotkeys: <kbd>F8</kbd> for next item in current panel (search results, errors ...), <kbd>Control</kbd>+<kbd>K</kbd>, <kbd>N</kbd> for bookmarks, <kbd>Alt</kbd>+<kbd>-</kbd> for going back and more.</p> <p>There is one hotkey that I can't find, and I can't even find the menu-comma...
<p>I wrote 2 macros to gain it: <code>PreviousStackFrame</code> and <code>NextStackFrame</code> and assigned shortcuts to</p> <pre><code>Function StackFrameIndex(ByRef aFrames As EnvDTE.StackFrames, ByRef aFrame As EnvDTE.StackFrame) As Long For StackFrameIndex = 1 To aFrames.Count If aFrames.Item(StackFra...
<p>Look in <strong>Tools->Options->Environment->Keyboard</strong>. Enter "stack" or "frame" and related menus will appear. It seems that there's no next and previous call-stack frame.</p>
28,393
<p>I have a struts-based webapp, and I would like the default "welcome" page to be an action. The only solutions I have found to this seem to be variations on making the welcome page a JSP that contains a redirect to the action. For example, in <code>web.xml</code>:</p> <pre><code>&lt;welcome-file-list&gt; &lt;wel...
<p>Personally, I'd keep the same setup you have now, but change the redirect for a forward. That avoids sending a header back to the client and having them make another request.</p> <p>So, in particular, I'd replace the </p> <pre><code>&lt;% response.sendRedirect("/myproject/MyAction.action"); %&gt; </code></pre>...
<p>This works as well reducing the need of a new servlet or jsp</p> <pre><code>&lt;welcome-file-list&gt; &lt;welcome-file&gt;/MyAction.action&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; </code></pre>
6,045
<p>I am trying to create a custom control that a "gridview" like control but specifcally for business objects that implement certain custom interfaces. </p> <p>In doing this I have come across the following problem.</p> <p>I have a control that I have disabled viewstate on (and I don't want to re-enable it) and it ha...
<p>You cannot enable viewstate on a control which is within another control that has viewstate disabled.</p> <p>Your only option is to enable it for the outer control, and then turn it off for all of the controls within it, except for the control you need viewstate.</p> <p>EnableViewState property on any container wi...
<p>If you're happy putting data into the ViewState manually (instead of letting ASP.NET preserve the state of your control for you), You could put items directly into the ViewState of the page, rather than the ViewState of your control.</p> <p>I.e. instead of saying:</p> <pre><code>this.ViewState["someKey"] = someVal...
21,132
<p>Has anybody been successful in integrating the Enterprise Library v4.0 with SharePoint WSS 3.0? I created a very simple .ASPX page. It's only purpose will to be to connect to an Oracle database and display some values in a DropDownList. But right now, all it does is displays Hello World. I've added the necessary...
<p>I'm not sure about the Enterprise Library, but to get a more meaningful error message from SharePoint than the super informative "Unknown Error" message go modify a couple things in web.config:</p> <ol> <li>In <code>&lt;SharePoint&gt;&lt;SafeMode&gt;</code> set the CallStack property = "true"</li> <li>In <code>&lt;...
<p>Are you able to debug and see where the failure is occurring in your code? Is it occurring on an Enterprise Library related call? If so I would capture the exception that is being thrown and evaluate the message that it provides using; try {} catch (Exception ex) {}.</p> <p>One thing I have seen with Enterprise L...
22,455
<p>I'm working on a gadget a bit like a jewelry box. I want the lid on a hinge. Are 3d printed hinges robust enough for daily use long term? Perhaps with a metal pin?</p> <p>I want to incorporate the hinge into the design but my thinking is that it would be a waste of time if the hinge will break as I'd need to reprint...
<p>You can make a print-in-place hinge as a horizontal cone with a 45-degree angle. The opposing face will be a similar conical hole with a 0.25 mm gap between the faces (or whatever your printer's tolerance needs to be).</p> <p>The strength of this (as in the other answers) depends on the diameter of the hinge. The ...
<p>Maker's Muse has <a href="https://www.youtube.com/watch?v=7JhjhgjchfM" rel="nofollow noreferrer">a video</a> on how to design hinged objects for printing. It's quite old and might be outdated with regard to materials, slicer functionality, etc. but I think it provides a good background on the topic and a source of i...
2,119
<p>I am writing a console program in C#.</p> <p>Is there a way I can use a Console.Clear() to only clear certain things on the console screen?</p> <p>Here's my issue:</p> <p>I have a logo (I put it on screen using Console.WriteLine()) and a 2d array which I want to keep constant and clear everything below it. </p>
<p>You could use a custom method to clear parts of the screen...</p> <pre><code>static void Clear(int x, int y, int width, int height) { int curTop = Console.CursorTop; int curLeft = Console.CursorLeft; for (; height &gt; 0;) { Console.SetCursorPosition(x, y + --height); Console.Write(n...
<p>Can you not clear and then re-write the logo and array? The console is not designed to be used as you describe.</p>
49,498
<p>I'm having some doubts on how to set up my SVN stuff. </p> <p>First my situation: Programmer working alone on most stuff, outside access not needed (yet).</p> <p>I want:<ul> <li>A speedy SVN, preferably free. <li>Private <li>Backup friendly <li>Somewhat hassle free <li>A lot of storage. </ul> I don't want:<ul...
<p>I would have a look at <a href="http://visualsvn.com/server/" rel="nofollow noreferrer">VisualSVN Server</a>. It installs easily on Windows and addresses all your concerns.</p>
<p>Hmm, my bet would be to install it on your machine, on an external hard disk drive. You will sacrifice a bit of the speed, but you'll have the storage (it has it's own HDD) and the back-up friendliness.</p>
38,168
<p>I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform...
<pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main(void) { char * ptr; long parsed = strtol("11110111", &amp; ptr, 2); printf("%lX\n", parsed); return EXIT_SUCCESS; } </code></pre> <p>For larger numbers, there as a <code>long long</code> version, <code>strtoll</code>.</p>
<pre><code>#include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;string&gt; using namespace std; string getBinaryString(int value, unsigned int length, bool reverse) { string output = string(length, '0'); if (!reverse) { for (unsigned int i = 0; i &lt; length; i++) { if ((value &...
14,344
<p>I need to compress portions of our application's network traffic for performance. I presume this means I need to stay away from some of the newer algorithms like bzip2, which I think I have heard is slower.</p>
<p>You can use <a href="https://docs.oracle.com/javase/8/docs/api/java/util/zip/Deflater.html" rel="nofollow noreferrer">Deflater</a>/<a href="http://docs.oracle.com/javase/7/docs/api/java/util/zip/Inflater.html" rel="nofollow noreferrer">Inflater</a> which is built into the JDK. There are also GZIPInputStream and GZI...
<p>If the network traffic is going over HTTP, most of the various web servers/servlet containers support for negotiated zipping, e.g., mod_deflate for Apache.</p>
15,454
<p>I have a method to return a group of objects as a generic list which I then bind to a Repeater. I want to implement paging on the repeater using the PagedDataSource class but I'm not sure that this is possible as it doesn't seem to work.</p> <p>Will I have to change the return type of my method or is it possible to...
<p>I've just modified some of my code to use a generic list and seems to have worked fine, hope this helps:</p> <p>Note that this entire method can be called with or without a page number to automatically set the page, it also builds a paging control inside of a panel calling PagingPanel.</p> <p>The line that sets th...
<ol> <li>Set your PagedDataSource's datasource to your list</li> <li>Setup the paging variables of your PagedDataSource to whatever you require</li> <li>Set your repeater's datasource to the pageddatasource object itself</li> <li>Bind the repeater</li> <li>Job done</li> </ol>
38,668
<p>is there a quick way to sort the items of a select element? Or I have to resort to writing javascript?</p> <p>Please any ideas.</p> <pre><code>&lt;select size="4" name="lstALL" multiple="multiple" id="lstALL" tabindex="12" style="font-size:XX-Small;height:95%;width:100%;"&gt; &lt;option value="0"&gt; XXX&lt;/optio...
<p>This will do the trick. Just pass it your select element a la: <code>document.getElementById('lstALL')</code> when you need your list sorted.</p> <pre><code>function sortSelect(selElem) { var tmpAry = new Array(); for (var i=0;i&lt;selElem.options.length;i++) { tmpAry[i] = new Array(); tmpA...
<p>Not quite as pretty as the JQuery example by Marco but with prototype (i may be missing a more elegant solution) it would be:</p> <pre><code>function sort_select(select) { var options = $A(select.options).sortBy(function(o) { return o.innerHTML }); select.innerHTML = ""; options.each(function(o) { select.inse...
35,109
<p>What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!</p>
<p>I am using the <code>pre-revprop-change</code> hook that allows me to actually go back and edit comments and such information after the commit has been performed. This is very useful if there is missing/erroneous information in the commit comments.</p> <p>Here I post a <code>pre-revprop-change.bat</code> batch file...
<p>The most common one I think is to allow people to change revision comments after comitting. </p> <p>You need to enable the 'pre-revprop-change' hook script to allow that. The example provided, if enabled allows editing only the comment property and only be the original comitter. Great for correcting typos.</p>
2,797
<p>I am developing a CMS where the clients will need to upload files larger than 2mb - up to 10mb at least. I have changed the details in the php.ini file and I cannot see anywhere else that the problem might be. Any help?</p> <p>Cheers</p>
<p>Here's what I recommend changing (assuming Apache &amp; PHP):</p> <p>I've found this works well for up to about 30mb attachments</p> <h2>PHP Settings</h2> <ul> <li>max<code>_execution</code>_time = 120</li> <li>max<code>_input</code>_time = 120</li> <li>memory_limit = 30M</li> <li>post<code>_max</code>_size = 30M</l...
<p>As long as you have restarted your web service (ie apache) then the changes should take effect, however if you are developing for anyone other then yourself then instead of changing the php.ini I would add this to the upload script:</p> <pre><code>ini_set('upload_max_filesize', '10M'); </code></pre> <p>as some p...
24,023
<p>I would like to have the authentication and registration parts of my website encrypted (for obvious reason). This site is currently and older site which some friends and I started in middle school and still use today. I may or may not register it to be a Non-Profit Organization in the near future, but either way, ...
<p>The SSL certificate solves two purposes: encryption of traffic <em>(for RSA key exchange, at least)</em> and verification of trust. As you know, you can encrypt traffic with <em>(or without, if we're talking SSL 3.0 or TLS)</em> any self-signed certificate. But trust is accomplished through a chain of certificates. ...
<p>If that van around the corner is capable of hijacking your internet connection already, you've got worse problems than self-signed certificates.</p> <p>Banks should use client certificates for authentication. That would make it impossible for that van to do anything.... since it doesn't have the banks private key...
37,351
<p>I'm working in a team environment where each developer works from their local desktop and deploys to a virtual machine that they own on the network. What I'm trying to do is set up the Visual Studio solution so that when they build the solution each projects deployment is handled in the post-build event to that dev...
<p>A slightly different question that I looked for here: "How do you pass an object to a tag file?"</p> <p>Answer: Use the "type" attribute of the attribute directive:</p> <pre><code>&lt;%@ attribute name="field" required="true" type="com.mycompany.MyClass" %&gt; </code></pre> <p>The typ...
<p>Use expression language:</p> <pre> &lt;wf:my-tag obj="${myObject}" /&gt; </pre>
10,124
<p>What is the best way to extract RSS/ATOM URLs from HTML LINK tags? I know regex is not the best way to do this, so I'm wondering what alternatives I have. Surely some kind of horrible string munging using .Contains after loading the HTML into a string is not optimal either. Anyone got a decent strategy for this?</p>...
<p>I recommend that you use username/password combos for website accounts, and API keys for any web services. Here are the advantages of this technique:</p> <ol> <li>By linking API keys to an account, you could have many API keys for the same user. Perhaps this could be used for many remote web servers that consume th...
<p>The github approach is bootstrapping on top of existing git practices, however it's not a bad idea since presumably each user will have their own private key to match a published public one in the central authority. Since key-agent's already furnish a means of safe authentication this seems like a very safe approac...
44,020
<p>Is there a way to separate a C# class into a header that contains the class definition and then an actual .cs file that contains the implementation? I suppose one can do this by creating an interface, but that doesn't seem right. I just want a file where I can just see the class design, and not all the detail. It...
<p>That's a wrong approach. C# isn't C++. <strong>Forget about header files</strong>.</p> <p>If you want the class summary, just open the <strong>Object Browser</strong> in Visual Studio. It will give you the signature of all the methods within your classes.</p>
<p>Isn't this what the IDE is for?</p> <p>EDIT: Otherwise inferfaces and abstract classes is the way to go.</p>
13,717
<p>I had a discussion with a colleague at work, it was about SQL queries and sorting. He has the opinion that you should let the server do any sorting before returning the rows to the client. I on the other hand thinks that the server is probably busy enough as it is, and it must be better for performance to let the cl...
<p>In general, you should let the database do the sorting; if it doesn't have the resources to handle this effectively, you need to upgrade your database server.</p> <p>First off, the database may already have indexes on the fields you want so it may be trivial for it to retrieve data in sorted order. Secondly, the c...
<p>Situations vary, and measuring performance is important.</p> <p>Sometimes it's obvious - if you have a big dataset and you're interested in a small range of the sorted list (e.g. paging in a UI app) - sorting on the server saves the data transfer.</p> <p>But often you have one DB and several clients, and the DB ma...
42,319
<p>I've searched around for a while today, but I haven't been able to come up with an AutoComplete TextBox code sample for Silverlight 2 Beta 2. The most promising reference was found on <a href="http://www.nikhilk.net/Silverlight-AutoComplete.aspx/" rel="nofollow noreferrer">nikhilk.net</a> but the online demo doesn'...
<p>You may want to take a look at my blog: <a href="http://weblogs.manas.com.ar/ary/2008/09/26/autocomplete-in-silverlight/" rel="nofollow noreferrer">http://weblogs.manas.com.ar/ary/2008/09/26/autocomplete-in-silverlight/</a></p> <p>You simply write in your XAML:</p> <pre><code>manas:Autocomplete.Suggest="DoSuggest"...
<p>There is also another good example here:</p> <p><a href="http://silvermail.com.au" rel="nofollow noreferrer">http://silvermail.com.au</a></p> <p>This is a Silverlight based mail client that looks a little like Outlook. When I go to send mail and start typing in the "To" text box, an auto-complete pops up and popu...
16,596
<p>I'm thinking of forming a <a href="http://www.catb.org/~esr/jargon/html/H/hacker.html" rel="nofollow noreferrer">Hacker</a>s Club at work. My idea is that we would meet monthly and at each meeting one member would present an interesting hack he had created. (The hacks presented wouldn't necessarily have to be soft...
<p>We do this at the office. I call it 'Developer Fight Club'</p> <p>Usually do challenges of varying difficulty and compete against one another.</p> <p>At the end of it, we go over our solutions, do code-reviews and discussions, and then use either benchmark results or other people as the deciding factor for who win...
<p>If there are women in your 'hacker' group, consider the advice given in the <a href="http://www.tldp.org/HOWTO/Encourage-Women-Linux-HOWTO/" rel="nofollow noreferrer">Howto Encourage Women in Linux</a>. Especially the 'meeting places and times' section.</p>
37,040
<p>Is there a way to "align" columns in a data repeater control? </p> <p>I.E currently it looks like this:</p> <pre><code>user1 - colA colB colC colD colE user2 - colD colE </code></pre> <p>I want it to look like:</p> <pre><code> user1 -colA -colB -colC -colD -colE user1 -colD -colE </...
<p>If you have access to how many columns are mising in the repeat, then just the following as the table tag. I you don't have access to this, can you post the source for your data repeater and what DataSource you're going against?</p> <pre><code>&lt;td colspan='&lt;%# MissingCount(Contatiner.DataItem) %&gt;'&gt; </c...
<p></p> <pre><code> &lt;tr class="RadGridItem"&gt; &lt;td width="100"&gt; &lt;asp:Label ID="lblFullName" runat="server" Text ='&lt;%# DataBinder.Eval(Container.DataItem, "FullName") %&gt;' ToolTip='&lt;%# "Current Grade: " + DataBinder.Eval(Container.DataItem,"Cu...
12,773
<p>I find Google's <a href="http://labs.google.com/inquotes/" rel="nofollow noreferrer">In Quotes</a> a really nifty application, and as a CS guy, I have to understand how it works. How do you think it turns news articles into a list of quotes attributed to specific persons? Sure, there are some mistakes, but their alg...
<p>It's simple, it checks for the words, but there can be anything in between them, as long as they're still in order. "Hello world!" would become the regex /hello [ .]* world/</p>
<p>I do not have any paper but some idea. Google take quotes from a set of person. Easy for them with Google News and other media access.</p> <p>They have an other set of subject. Google match subject set with the set of person (both set are finite). The last set is all quote,</p> <p>If you notice, the subject contai...
29,293
<p>I've been working on a program to read a dbf file, mess around with the data, and save it back to dbf. The problem that I am having is specifically to do with the writing portion.</p> <pre><code> private const string constring = "Driver={Microsoft dBASE Driver (*.dbf)};" + "Sou...
<p>For people coming here in the future: I wrote this today and it works well. The filename is without the extension (.dbf). The path (used for connection) is the directory path only (no file). You can add your datatable to a dataset and pass it in. Also, some of my datatypes are foxpro data types and may not be compat...
<p>What kind of dbf file are you working with? (There are several, e.g. dBase, FoxPro etc that are not 100% compatible.) I have gotten this to work with the Microsoft Visual FoxPro OleDB Provider from C#, you might give that a shot instead of using the dBase ODBC driver.</p>
41,776
<p>Would using WSDualHttpBinding for duplex callbacks work in real-world scenarios? Say, I have a .NET application that uses a random port, would the service be able to resolve the client's base addresses and port for callbacks?</p>
<p>A complete answer to your question depends on the "real-world scenario" being either an Intranet or an Internet scenario. Although WSDualHttpBinding works in both scenarios there are specifics to be aware of:</p> <p><strong>Intranet</strong></p> <p>WSDualHttpBinding will work with your .NET application using a pr...
<p>If it's an application behind a firewall, theoretically yes. It depends on what you mean by "real world"; if by that you mean "high performance" perhaps NetTcpBinding is a better appraoch.</p>
8,435
<p>I would like to know if there is a way to disable automatic loading of child records in nHibernate ( for one:many relationships ).</p> <p>We can easily switch off lazy loading on properties but what I want is to disable any kind of automatic loading ( lazy and non lazy both ). I only want to load data via query ( i...
<p>Given your request, you could simply not map from Department to Employees, nor have an Employees property on your department. This would mean you <em>always</em> have to make a database hit to find the employees of a database.</p> <p><em>Aplogies if these code examples don't work out of the box, I'm not near a comp...
<p>You can have the lazy attribute on the collection. In your example, Department has n employees, if lazy is enabled, the employees will not be loaded by default when you load a department : <a href="http://www.nhforge.org/doc/nh/en/#collections-lazy" rel="nofollow noreferrer" title="documentation on lazy">http://www....
26,760
<p>At my job we make &amp; sell websites. Usually we install our .NET C# based site on a customer's server and maintain and support it remotely. However, every once in a while, for bigger development works and just to make things simpler (and faster!), we will copy the site to a local server.</p> <p>This is great, but ...
<p>I'd look at either <a href="http://www.selenic.com/mercurial/wiki/" rel="nofollow noreferrer">Mercurial</a> or <a href="http://bazaar-vcs.org/" rel="nofollow noreferrer">Bazaar</a>. I'm told Git also works on windows, but I suspect the windows port is still a second class port at best.</p> <p>You'll probably need t...
<p>Maybe not exactly what you request but checkout <a href="http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp" rel="nofollow noreferrer">DeltaCopy</a> which is a windows version of <a href="http://en.wikipedia.org/wiki/Rsync" rel="nofollow noreferrer">rsync</a>. You can also read about another rsync solution <a href="...
4,972
<p>In WPF:</p> <p>Can someone please explain the relationship between DependencyProperty and Databinding?</p> <p>I have a property in my code behind I want to be the source of my databinding. When does a DependencyProperty (or does it) come into play if I want to bind this object to textboxes on the XAML.</p>
<p>The target in a binding must always be a <code>DependencyProperty</code>, but any property (even plain properties) can be the source.</p> <p>The problem with plain properties is that the binding will only pick up the value once and it won't change after that because change notification is missing from the plain sou...
<h2><em>What is the DependencyProperty?</em></h2> <p>The <strong>DependencyProperty</strong> class is one of the most important design bases hidden deep in the .Net Framework WPF.</p> <p>This class is protected by <code>sealed</code> from the .NET Framework. This property differs from the one-dimensional general proper...
19,246
<p>So I am following this guide: <a href="http://technotes.1000lines.net/?p=23" rel="noreferrer">http://technotes.1000lines.net/?p=23</a> and I am going through the steps. I have a VPN (slicehost.com) with Debian Etch, serving a website (static so far) with nginx. I used wget to download FastCGI and I did the usual mak...
<p>The webserver needs a Unix domain socket to connect to the FastCGI application, but the socket can't be created. Most likely the directory you want it to be in doesn't exist (because they are automatically created when you do a <code>bind</code>).</p>
<p>I'm gonna try and "water down" fastcgi-wrapper.pl, so it can be used with <a href="http://redmine.lighttpd.net/projects/spawn-fcgi/Blockquote" rel="nofollow noreferrer">spawn-fcgi</a>.</p> <p>I use two of those sockets allready:</p> <pre><code>spawn-fcgi -C 3 -u www-data -s /var/run/php-fcgi.sock -P /var/run/php-f...
48,308
<p>How can I force the input's onchange script to run <em>before</em> the RangeValidator's script? </p> <p>I want to prevent a failed validation when the user enters a dollar sign or comma.</p> <pre><code>function cleanUp(str) { re = /^\$|,/g; return str.replace(re, ""); // remove "$" and "," } &lt;input ty...
<p>Have you tried using a CustomerValidator control and combined the functionality of the JS cleanup methods and the RangeValidator method.</p>
<p>There is a way to do this by registering the script; however why not use a Regular Expression Validator to make sure the input is proper?</p> <p>Also, the Range validator executes on the fields onBlur js event, not on change.</p>
46,155
<p>I'm using <b>Struts 2</b>.</p> <p>I'd like to return from an Action to the page which invoked it.</p> <p>Say I'm in page <strong>x.jsp</strong>, I invoke Visual action to change CSS preferences in the session; I want to return to <strong>x.jsp</strong> rather than to a fixed page (i.e. <strong>home.jsp</strong>)<b...
<p>You can use a dynamic result in struts.xml. For instance:</p> <pre><code>&lt;action name="Visual" class="it.___.web.actions.VisualizationAction"&gt; &lt;result name="next"&gt;${next}&lt;/result&gt; &lt;/action&gt; </code></pre> <p>Then in your action, you create a field called next. So to invoke the acti...
<p>I prefer the way when you navigating users by particular actions. </p> <p><a href="http://domain.com/myAction.action" rel="nofollow noreferrer">http://domain.com/myAction.action</a></p> <p>You could use some parameter as indicator, that you want to change current design: i.e.</p> <p><a href="http://domain.com/myA...
6,730
<p>I am aware that Javascript WYSIWYG editors use the inbuilt editor mode of the browser to function, but that comes up with various problems and issues.</p> <p>Can an editor be built from scratch in JS, something like what Buzzword people have done with flash/flex? I came across <a href="http://manishjethani.com/blog...
<p>It depends what you mean by "from scratch". <a href="http://docs.google.com/" rel="nofollow noreferrer">Google Docs</a> provides a pretty good text editor in JS. Is that what you mean ?</p>
<p>Of course you can do it and it is not very difficult. But before reinventing the wheel please take a look at all the existing ones. Many of them are really very well written and open source.</p>
48,896
<p>I need to store the timezone an email was sent from. Which is the best way to extract it from the email's 'Date:' header (an RFC822 date)? And what is the recommended format to store it in the database (I'm using hibernate)?</p>
<p>Probably easiest to parse with JodaTime as it supports ISO8601 see <a href="http://johannburkard.de/blog/programming/java/date-time-parsing-formatting-joda-time.html" rel="nofollow noreferrer">Date and Time Parsing and Formatting in Java with Joda Time</a>.</p> <pre><code>DateTimeFormatter parser2 = ISODateTimeForm...
<p>Extract the data from the header using some sort of substring or regular expression. Parse the date with a SimpleDateFormatter to create a Date object.</p>
13,358
<p>I'm researching this for a project and I'm wondering what other people are doing to prevent stale CSS and JavaScript files from being served with each new release. I don't want to append a timestamp or something similar which may prevent caching on every request. </p> <p>I'm working with the Spring 2.5 MVC framewor...
<p>I add a parameter to the request with the revision number, something like:</p> <pre><code>&lt;script type="text/javascript" src="/path/to/script.js?ver=456"&gt;&lt;/script&gt; </code></pre> <p>The 'ver' parameter is updated automatically with each build (read from file, which the build updates). This makes sure th...
<p>If you get the "modified time" of the file as a timestamp it will be cached until the file is modified. Just use a helper function (or whatever it is called in other frameworks) to add script/css/image tags that get the timestamp from the file. On a unix like system (wich most survers are) you could simply <code>tou...
46,488
<p>I have a web application that comprises the following:</p> <ul> <li>A web project (with a web.config file containing a connection string - but no data access code in the web project)</li> <li>A data access project that uses LINQ-SQL classes to provide entities to the web project UI (this project has a settings file...
<p>I've never had a problem with the <em>Data Access Layer</em> (DAL) being able to use the connection strings from my <code>web.config</code> file. Usually I just copy the connection strings section from the DAL and paste it into the <code>web.config</code>. I'm using the DBML designer to create the data context.</p...
<p>How about defining a ConnectionFactory object, that takes an enum as a parameter and returns a fully-formed connection object?</p>
29,260
<p>I'm building an app in Ruby on Rails, and I'm including 3 of my models (and their migration scripts) to show what I'm trying to do, and what isn't working. Here's the rundown: I have users in my application that belong to teams, and each team can have multiple coaches. I want to be able to pull a list of the coach...
<p>You can't do a has_many :through twice in a row. It'll tell you that its an invalid association. If you don't want to add finder_sql like above, you can add a method that mimics what you're trying to do.</p> <pre><code> def coaches self.teams.collect do |team| team.coaches end.flatten.uniq end </...
<p>While I love to write SQL, I don't think it's the ideal solution in this instance. Here's what I ended up doing in the User model:</p> <pre><code> def coaches self.teams.collect do |team| team.coaches end.flatten.uniq end def canCoach(coachee) u = User.find(coachee) coaches = u.coaches...
24,231
<p>I've written a simple Flash player for a Shoutcast stream. At first it seemed to work reliably, however about 5% of the time users experience slow playback where the stream plays at roughly half of normal speed.</p> <p>All files being streamed are MP3, encoded at 128kbps/44.1kHz, the same settings as used in the Sh...
<p>This is a flash player bug unfortunately. It seems like the only reliable solution is to roll it back to AS2.</p> <p><a href="https://bugs.adobe.com/jira/browse/FP-173" rel="nofollow noreferrer">https://bugs.adobe.com/jira/browse/FP-173</a></p>
<p>I believe that the slow playing is caused by audio drivers problems. Can you give a link to the player?</p>
11,696
<p>I want to take html, including the text and images and turn it into one image containing everything. Is there a free way to do it?</p> <p>This is using .net 3.5.</p> <h3>See also:</h3> <p><a href="https://stackoverflow.com/questions/119116/server-generated-web-screenshots">Server Generated web screenshots?</a><br /...
<p>You might check out <a href="http://www.codeproject.com/KB/graphics/IECapture.aspx" rel="nofollow noreferrer">this project</a> or <a href="http://www.developerfusion.co.uk/show/4712/" rel="nofollow noreferrer">this page</a>.</p> <p>Hope that helps.</p>
<p>Here's some code that I posted on my blog a few weeks ago that does this:</p> <p><a href="http://pietschsoft.com/post.aspx?id=2a628f30-fe83-4e44-a34b-f31be76d1b4f" rel="nofollow noreferrer">C#: Generate WebPage Thumbnail Screenshot Image</a></p> <p>I'll also post the code for it below:</p> <pre><code>public Bitma...
17,709
<p>I am looking to use Cocoon for a couple of sites I am creating. I will make heavy use of xml, xsl and conversion to html, pdf and excel on the sites. I am attracted to coccon as it implements these functions quite well.</p> <p>I guess I am just wondering if anyone has used it and like it, or if they found it was ...
<p>Cocoon is a very powerful framework. But it's not easy to understand all aspects of it. (see Ulysses answer). Once you have understood the basic concepts though there is hardly anything comparable in the XML space.</p> <p>It has been integrated with so many things that you really need to strip it down to what you r...
<p>Just had a quick look for alternatives you could look at:</p> <ul> <li><a href="http://wiki.apache.org/cocoon/CocoonCompared" rel="nofollow noreferrer">Cocoon Comparison</a></li> <li><a href="http://wiki.apache.org/cocoon/WorkflowImplementationComparison" rel="nofollow noreferrer">Workflow comparisons</a></li> <li>...
23,025
<p>There are some HTML based games (ie bootleggers.us) that have a simple login form and after that your entire game experience revolves around submitting various forms and reading information from the website itself.</p> <p>My Question is, <strong>what is the best way to go about writing a bot / automate the html-bas...
<p>You could use Watin: <a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">http://watin.sourceforge.net/</a></p>
<p>No, you're pretty much going to have to "screen scrape" every page. You might consider writing most this in JavaScript instead of C#. Depending on the HTML of the game site, this could be more or less difficult depending on whether they provide good id attributes on the page elements, etc...</p>
13,047
<p>I have two threads in an Android application, one is the view thread, and the other is the worker thread. What I want to do is, sleep the worker thread until the view thread terminates the handling of the onDraw method.</p> <p>How i can do this? is there any wait for the signal or something?</p>
<p>Share a java.lang.Object between the two threads, whose sole purpose is to tell the worker thread when it can continue its work. Whenever the worker thread reaches a point where it should sleep, it does this:</p> <pre><code>stick.wait(); </code></pre> <p>When the view thread finishes its onDraw work, it calls thi...
<p>If you want a higher-level concurreny API (with things like Barriers), you could try the backport of the java 5 concurrency API, which works on java 1.3 and above, and may work on Android. The likes of Object.wait/notify will work, but they can be a bit terse.</p> <p><a href="http://backport-jsr166.sourceforge.net...
14,805
<p>I'm writing an application using Qt4.</p> <p>I need to download a very short text file from a given http address.</p> <p>The file is short and is needed for my app to be able to continue, so I would like to make sure the download is blocking (or will timeout after a few seconds if the file in not found/not availab...
<p>Instead of using a thread you can just go into a loop which calls <code>processEvents</code>:</p> <pre><code>while (notFinished) { qApp-&gt;processEvents(QEventLoop::WaitForMore | QEventLoop::ExcludeUserInput); } </code></pre> <p>Where <code>notFinished</code> is a flag which can be set from the <code>onRequest...
<p>How about giving the GUI some amount of time to wait on the thread and then give up.</p> <p>Something like:</p> <pre><code>JSHttpGetterThread* pGetter = new JSHttpGetterThread(this); pGetter-&gt;start(); pGetter-&gt;wait(10000); //give the thread 10 seconds to download </code></pre> <p>Or...</p> <p>Why does the...
31,209
<p>How do I calculate distance between two GPS coordinates (using latitude and longitude)?</p>
<p><a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="noreferrer">Calculate the distance between two coordinates by latitude and longitude</a>, including a Javascript implementation.</p> <p><em>West</em> and <em>South</em> locations are negative. Remember minutes and seconds are out of 60 so S31 30' i...
<p>I think a version of the algorithm in <strong>R</strong> is still missing:</p> <pre><code>gpsdistance&lt;-function(lat1,lon1,lat2,lon2){ # internal function to change deg to rad degreesToRadians&lt;- function (degrees) { return (degrees * pi / 180) } R&lt;-6371e3 #radius of Earth in meters phi1&lt;-degreesToRa...
47,759
<p>I have a strange encounter when creating a GridView using <code>SELECT..WHERE..&lt;field&gt; IN (value1, val2...)</code>.</p> <p>In the "Configure datasource" tab, if i hard code the values <code>SELECT .... WHERE field1 in ('AAA', 'BBB', 'CCC')</code>, the system works well.</p> <p>However, if I define a new para...
<p>This works. Not sure how efficient it is though.</p> <pre><code>CREATE PROCEDURE [dbo].[get_bars_in_foo] @bars varchar(255) AS BEGIN DECLARE @query AS varchar(MAX) SET @query = 'SELECT * FROM [foo] WHERE bar IN (' + @bars + ')' exec(@query) END -- exec [get_bars_in_foo] '1,2,3,4' </code></pre>
<p>If you go to using a stored procedure, you can use <a href="http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/232/pageid/119.aspx" rel="nofollow noreferrer">this method</a>, which I discussed in regards to how to do it in SQL.</p>
44,553
<p>How can I bring my WPF application to the front of the desktop? So far I've tried:</p> <pre><code>SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);...
<pre><code>myWindow.Activate(); </code></pre> <p><em>Attempts to bring the window to the foreground and activates it.</em></p> <p>That should do the trick, unless I misunderstood and you want Always on Top behavior. In that case you want:</p> <pre><code>myWindow.TopMost = true; </code></pre>
<p>I built an extension method to make for easy reuse.</p> <pre><code>using System.Windows.Forms; namespace YourNamespace{ public static class WindowsFormExtensions { public static void PutOnTop(this Form form) { form.Show(); form.Activate(); }// END ...
32,144
<p>Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite text editor UltraEdit32.</p> <p>Is there any way I can implement MVC without the use of VS?</p>
<p>There is nothing VS specific with the MVC framework - it is just a bunch of DLLs that you can use. The wizards in VS just build you a quick-start framework.</p> <p>ASP.NET MVC is "bin-deployable" - there is nothing too clever to set up on the server either - just point the wildcard ISAPI filter to ASP.NET</p>
<p>For small to mid size mvc project <a href="http://www.microsoft.com/web/webmatrix/" rel="nofollow">WebMatrix</a> is not bad at all. Also for simple changes to the projects I often use SublimeText.</p>
2,434
<p>I was asked for a comprehensive breakdown on space used within a specific database. I know I can use <em>sys.dm_db_partition_stats</em> in SQL Server 2005 to figure out how much space each <em>table</em> in a database is using, but is there any way to determine the individual and total size of the <em>stored proced...
<pre><code>;WITH ROUTINES AS ( -- CANNOT use INFORMATION_SCHEMA.ROUTINES because of 4000 character limit SELECT o.type_desc AS ROUTINE_TYPE ,o.[name] AS ROUTINE_NAME ,m.definition AS ROUTINE_DEFINITION FROM sys.sql_modules AS m INNER JOIN sys.objects AS o ON m.object_id =...
<p>A slightly better way than counting the characters, is to use information schema.routines. You could sum the length of each Routine Definition as (Note each routine definition will max out at 4,000 characters, see below for a method that doesn't have this restriction):</p> <pre> select Sum(Len(Routine_Definition))...
27,030
<p>Let's say I have some pointers called:</p> <pre><code>char * pChar; int * pInt; </code></pre> <p>I know they both simply hold memory addresses that point to some other location, and that the types declare how big the memory location is pointed to by the particular pointer. So for example, a char might be the size ...
<p>"++" is just another name for X = X + 1;</p> <p>For pointers it doesn't matter if you increment by 1 or by N. Anyway, sizeof(type)*N is used. In the case of 1 it will be just sizeof(type).</p> <p>So, when you increment by 2 (your second case):<br> for char is 2*sizeof(char)=2*1=2 bytes,<br> for int will be 2*sizeo...
<p>I would have said that the point of pointer types in <strong>C++</strong> is to account for vtable offsets.</p>
49,855
<p>I was trying to figure out how to implement method_missing in C# 4, based on all of 2 blog posts floating around on IDynamicObject. </p> <p>What I want to do is have a Business Logic Layer that has a Repository, and if the method is missing from the Business Logic Layer, just call the Repository and pass through it...
<p>I believe you need to return a new MetaObject with the returned value as a constant expression.</p> <p>That's certainly what happens on <a href="http://www.codeproject.com/KB/cs/moemeka.aspx?display=Print" rel="nofollow noreferrer">this CodeProject page</a>. Worth a try :)</p>
<blockquote> <p>but if I try to access a property on myCustomer, is just hangs</p> </blockquote> <p>Can you set a breakpoint on the line after service.GetByID(1)? See what you've really got back from that call. Otherwise it's hard to tell what exactly happened.</p>
35,878
<p>This is related to a chapter from <a href="https://rads.stackoverflow.com/amzn/click/com/0596510047" rel="noreferrer" rel="nofollow noreferrer">beautiful code</a>. And in that chapter I read about the nested <code>if</code>s.</p> <p>The author was talking about deeply nested <code>if</code>s as originator of bugs a...
<p>Well, not directly an answer to your question since you specifically ask about switch/case statements, but here is a similar question.</p> <p><a href="https://stackoverflow.com/questions/268132/invert-if-statement-to-reduce-nesting">Invert “if” statement to reduce nesting</a></p> <p>This talks about replacing nest...
<p>Another example some languages allow is this</p> <pre><code> switch true{ case i==0 //action break case j==2 //action break case i&gt;j //action break } </code></pre>
43,729
<p>I am wondering how to naturally sort a DataView... I really need help on this. I found articles out there that can do lists with IComparable, but I need to sort the numbers in my dataview.</p> <p>They are currently alpha sorted because they are numbers with 'commas' in them. Please help me out.</p> <p>I would l...
<p>I often like to add a "SortOrder" column to results that I want to sort in a way other than is provided by the data. I usually use an integer and just add it when I am getting the data.</p> <p>I don't show this column and only use it for the purposes of establishing the order.</p> <p>I'm not sure if this is what ...
<p>See these related questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/89987/how-to-naturally-sort-a-dataview-with-something-like-icomparable">How to Naturally Sort a DataView with something like IComparable</a></li> <li><a href="https://stackoverflow.com/questions/91766/how-do-i-sort-an-aspnet-data...
12,409