input
stringlengths
51
42.3k
output
stringlengths
18
55k
What is the best way to retrieve distinct / unique values using SPQuery? <p>I have a list that looks like:</p> <pre><code>Movie Year ----- ---- Fight Club 1999 The Matrix 1999 Pulp Fiction 1994 </code></pre> <p>Using CAML and the SPQuery object I need to get a distinct list of items from t...
<p>Another way to do this is to use DataView.ToTable-Method - its first parameter is the one that makes the list distinct.</p> <pre><code> SPList movies = SPContext.Current.Web.Lists["Movies"]; SPQuery query = new SPQuery(); query.Query = "&lt;OrderBy&gt;&lt;FieldRef Name='Year' /&gt...
Simple database-based instance synchronization <p>I'm working on a service that runs in a java app server farm that needs to do some periodic jobs (say, once every 2 minutes). The service must interface to external entities, and it is necessary to synchronize the different instances so that only one of them works on t...
<p>I came up with the following implementation, but I'm not sure if it handles all corner cases (and I'm not entirely sure I'm using the BeanManagedTransaction correctly). Also, if you think this syncronization problem could be handled in a simpler way, point me to the right direction.</p> <pre><code>@Service(objectN...
How to sort columns in Excel programmatically using vb.net? <p>we are generating an Excel report and we need to sort the data programmatically before saving the file.</p> <p>Is it possible to sort a specific column of an Excel file programmatically using vb.net?</p> <p>As per your suggestion, in order to generate exc...
<p>Assuming you're using the interop assemblies this is how I do it:</p> <pre><code>Dim myWorkSheet As Excel.Worksheet = myWorkbook.Worksheets(aSheetName) myWorkSheet.Activate() Dim myRange As Excel.Range myRange = myWorkSheet.Range("A1", "L10") myRange.Select() myRange.Sort(Key1:=myRange.Range("D1"), _ ...
SQL query filtering <p>Using SQL Server 2005, I have a table where certain events are being logged, and I need to create a query that returns only very specific results. There's an example below:</p> <pre> <b>Log:</b> Log_ID | FB_ID | Date | Log_Name | Log_Type 7 | 4 | 2007/11/8 | Nina | Critical ...
<p>I guess that there is a better and more performant way, but this one seems to work:</p> <pre><code>SELECT * FROM log WHERE log_id IN ( SELECT MIN(log_id) FROM log WHERE ( SELECT COUNT(DISTINCT log_name) FROM log log2 WHERE log2.fb_id = log.fb_id ) = 1 ...
Empty HTML tags <p>I have a lot of empty span tags and so on in my code, due to CSS image replacement techniques. They trigger a HTML validation warning. Should I care?</p> <p>Thanks.</p>
<p>I agree with @Gumbo, but having lots of warnings that make no difference can hide the ones that you do need to pay attention to. If you can put something in the span that gets rid of the warning but doesn't break your UI, you should at least think about doing it.</p>
Out of memory error while parsing a specific excel file from a Perl Program <p>When the perl code is run the program generates some warnings and terminates. The output is as below:</p> <pre><code>D:\Perl\bin\search tool&gt;perl testa.pl UTF-16 surrogate 0xdb79 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm ...
<p>This question was answered on the Spreadsheet::ParseExcel Google Group <a href="http://groups.google.com/group/spreadsheet-parseexcel/msg/93a9da1f650eded6" rel="nofollow">here</a>.</p> <p>The problem is that the particular file is encrypted.</p> <p>John.</p>
string.Format() parameters <p>How many parameters can you pass to a string.Format() method?</p> <p>There must be some sort of theoretical or enforced limit on it. Is it based on the limits of the params[] type or the memory usage of the app that is using it or something else entirely?</p>
<p>Not as far as I know...</p> <p>well, the theoretical limit would be the int32 limit for the array, but you'd hit the string length limit long before that, I guess...</p> <p>Just don't go mad with it ;-p It may be better to write lots of small fragments to (for example) a file or response, than one huge hit.</p> <...
in jquery, match the first next element <p>I have a href tag, and next to it is a <b></b> tag. I want to put new text in between the bold tags.</p> <pre><code>&lt;a href=""&gt;&lt;/a&gt; &lt;b&gt;old text&lt;/b&gt; </code></pre> <p>So in my click handler, how can I get a reference to the text between the bold tag?</...
<p>Even though Magnar's answer has been marked as the accepted one, it doesn't actually answer the original question (necessarily). That's a problem when reaching this question from a search. Maybe the question needs to be reworded. Anyway, my point is that this will fail if there's another element in between 'a' and '...
c# using Array.ForEach Action Predicate with array of value type or string <p>Am I correct in thinking the following snippet does not work (the array items are not modified) <em>because</em> the array is of integer which is value type. </p> <pre><code>class Program { public static void Main() { int[] i...
<p>You are simply changing the local variable - not the item in the list. To do this, you want <code>ConvertAll</code>, which creates a new list/array:</p> <pre><code> int[] ints = new int[] { 1,2 }; int[] newArr = Array.ConvertAll&lt;int,int&gt;(ints, AddTen); </code></pre> <p>with:</p> <pre><code>static in...
Custom Image Handler: Caching Strategy <h1>The Scenario</h1> <p>I am building a custom CMS for a communications application. The users can upload images to the server and then later reference them in posts they write using markdown. Images are stored in a database and referenced with a url of the form <code>images/{...
<p>As you've said, Conditional GET it is the best option, as you only need to check one request header (If-None-Match or If-Modified-Since) and send back the corresponding status code (200 or 304) and a header (E-Tag or Last-Modified). Then the browser will deal with the image cache.</p> <p>Also, depending on your ser...
How may I scroll with vim into a big file? <p>I have a big file with thousands of lines of thousands of characters.</p> <p>I move the cursor to 3000th character.</p> <p>If I use <kbd>PageDown</kbd> or <kbd>Ctrl</kbd>+<kbd>D</kbd>, the file will scroll but the cursor will come back to the first no-space character.</p>...
<pre><code>CTRL-E - scroll down CTRL-Y - scroll up </code></pre> <p>100<code>&lt;CTRL-E&gt;</code> will scroll down 100 lines for example</p> <p>If you like using <kbd>PageUp</kbd>, <kbd>PageDown</kbd> or <kbd>Ctrl</kbd>+<kbd>D</kbd> etc. you can set the "nostartofline" option</p> <pre><code>:set nostartofline </cod...
When is the 'javascript:' prefix valid syntax? <p>I know that you can use a javascript: pseudo protocol for URLs in an <code>&lt;a&gt;</code> tag. However, I've noticed that Firefox and IE will both allow '<code>javascript:</code>' to precede javascript code within a <code>&lt;script&gt;</code> tag. Is this valid syn...
<p>Outside of the <code>href</code> attribute (where it is a protocol specifier), <em>name</em>: just creates <a href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Statements/Label">a label</a> (such as one might use with a <code>continue</code> or <code>break</code>).</p> <h3>See: <a href="http://st...
Need two div's to line up correctly <p><a href="http://img410.imageshack.us/img410/1425/picture2ye4.png" rel="nofollow">Here is a screenshot of how both div's lineup</a>.</p> <p>The left column is , the div that I want to line up to the right of it is </p> <p>And both those div's are within </p> <pre><code>.content-...
<p>Change the width of <em>.col-middle</em> to <em>80% or less</em> so both divs can fit inside their container.</p> <p>You could also make <em>.col-middle</em> float <em>right</em>.</p>
partial template specialization for dynamic dispatch <p>I am attempting to write a dynamic dispatcher for a function that's templated on integer values (not on types). While I could either write a code generator or use a big macro chain to create the dispatcher source, it seems that a templated solution would be more ...
<p>You're simply not calling the <code>f()</code> function in your recursive call, you're trying to "call the object":</p> <p>You write:</p> <pre><code>TestDispatcher2D&lt;...&gt; t; return t(m,n); </code></pre> <p>But you want:</p> <pre><code>TestDispatcher2D&lt;...&gt; t; return t.f(m,n); </code></pre>
Does "tell, don't ask" apply to user input validation? <p>I somehow must have overlooked the "tell, don't ask" OOP principle all these years because I just learned about it a couple days ago for the first time.</p> <p>But the context was a discussion about validation code that had been moved out of an ASP.NET web form...
<p>I thought it sounded like a load of "Best Practices" and "Design Methodologies" gone wrong, but now it kind of makes sense to me. Look at it this way:</p> <p>Imagine putting validation in the Business Object, but the "what do I do if validation fails' in the presentation layer. This would allow multiple different...
How many MySQL queries should I limit myself to on a page? PHP / MySQL <p>Okay, so I'm sure plenty of you have built crazy database intensive pages... </p> <p>I am building a page that I'd like to pull all sorts of unrelated database information from. Here are some sample different queries for this one page:</p> <u...
<p>As many as needed, but not more.</p> <p>Really: don't worry about optimization (right now). Build it first, measure performance second, and <strong>IFF</strong> there is a performance problem somewhere, then start with optimization.</p> <p>Otherwise, you risk spending a lot of time on optimizing something that doe...
What is a good naming convention for domain objects versus their relational tables? <p>I have seen this issue twice now and want to see what a best practice is for resolving this naming convention. Suppose I have an ORM (Linq to SQL in this case) and I map a table called User. Then I create my POCO called User also. ...
<p>I use to call the Linq2SQL objects DbUser and so on.<br /> This makes it very easy to scan through the code and see which is which, and since the L2S data objects are only accessible in the DataTier, the wierd naming is less of a problem.</p>
Classic ASP, ASP.NET, IFrames and response.redirect issue <p>A client has an asp page with an iframe. The Iframe loads an asp.net page inside the asp classic page. </p> <p>The ASP.NET page is responsible for connecting to a webservice, displaying some data, and then when the user clicks a button it does a response.red...
<p>It sounds like you need to return control to your parent window. You can do this through javascript:</p> <pre><code>function returnControl(returnPage). { parent.window.location.href = returnPage; } </code></pre>
Hide NSWindowToolbarButton <p>What do I have to do for hiding this <code>NSWindowToolbarButton</code> in windows with a <code>NSToolbar</code>?</p>
<p>There's a checkbox for this in the appearance section of the attributes tab of the inspector for a window in Interface Builder.</p>
ASP.NET 2.0 - DataGrid with tbody / thead <p>Is there a way to get the DataGrid control to render the tbody and thead HTML elements?</p>
<p>While I like the answer by "user186197", that blog post uses reflection, things might go wrong in non-full-trusted hosting environments. Here's what we use, no hacks:</p> <pre><code>public class THeadDataGrid : System.Web.UI.WebControls.DataGrid { protected override void OnPreRender(EventArgs e) { t...
In Java, how do I parse XML as a String instead of a file? <p>I have the following code: </p> <pre><code>DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile); </code></pre> <p>How can I get it to parse XML contained within a String instead of a file?</p>
<p>I have this function in my code base, this should work for you.</p> <pre><code>public static Document loadXMLFromString(String xml) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource is = new Input...
Is this the proper way of denying remote connections to jssh on Linux? <p>I don't know if jssh has any security built-in. While testing web apps, I would only like to be able to connect to jssh from localhost. I added the following lines to iptables :</p> <pre><code> iptables -A INPUT -p tcp -s 0/0 --dport 9997 -j LOG...
<p>Have you tested if the default configuration allows connections from outside localhost?</p> <p>AFAIK, by default it binds to 127.0.0.1 (only localhost), and not to 0.0.0.0 (all interfaces).</p>
SQL Server 2005 LENfunction oddity <p>The following code:</p> <pre><code>if (right(@eqlist,2) = ', ') set @eqlist = left(@eqlist,len(@eqlist)-2) </code></pre> <p>produces different results (with the same data) on my production server than on my development server.</p> <p>The problem is that the LEN function is 'su...
<p>Have you checked the value of ANSI_PADDING when your table(s) were created? Without full specifics on your issue I can't say for sure, but if you're going against a table with VARCHAR columns this could cause it to act differently.</p>
Requested registry access is not allowed <p>I'm writing a tweak utility that modifies some keys under <code>HKEY_CLASSES_ROOT</code>.</p> <p>All works fine under Windows XP and so on. But I'm getting error <code>Requested registry access is not allowed</code> under Windows 7. Vista and 2008 I guess too.</p> <p>How sh...
<p><code>app.manifest</code> should be like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001...
Inheriting aliases inside UNIX /usr/bin/script <p>The UNIX "/usr/bin/script" command will create a running transcript of your shell session (see "man script" for more info).</p> <p>However, when <em>inside</em> a script instance, it seems to forget the parent shell's env vars, aliases, etc.</p> <p>The following examp...
<p>An alias isn't an environment variable. You could source your <code>.profile</code> or where ever you set up the alias. Also take a look at the $SHELL environment variable.</p> <p>The <code>script</code> command isn't terribly complicated. It wouldn't be too difficult to replicate and make it work the way you ex...
retrieving variable from intermed table <p>I need to retrieve institution name by going through an intermediate table. My view gets all the values except this one or at least it is not displaying in the template. Can someone please help with either revising my view or template statement?</p> <p><a href="http://dpast...
<p>To debug these kinds of problems do the following.</p> <p>Run the view function's processing separate from any template or any other parts of Django.</p> <p>Either interactively or with a VERY simple script run your query. For example, use a simple script like this to explore your model and make sure your model r...
JNDI failing with NameNotFoundException <p>I'm writing regression tests for a in-house library (where the creators are looong gone) and I'm trying to validate the environment. A couple of the tests keep failing with that NameNotFoundException only when the jndi name is "complex".</p> <p>This is a stand alone app and ...
<p>I think you're getting mixed up with JNDI names.</p> <p>"QReply" is the JNDI name. You even say so:</p> <blockquote> <p>In file there is this entry: QReply/FactoryName=com.ibm.mq.jms.MQQueueFactory</p> </blockquote> <p>If the entry was: "jms/label/QReply" then your second test would work.</p>
Display a message in Visual Studio's output window when not debug mode? <p>In Java, you can use <code>System.out.println(message)</code> to print a message to the output window.</p> <p>What's the equivalent in Visual Studio ?</p> <p>I know when I'm in debug mode I can use this to see the message in the output window:...
<p>The results are not in the Output window but in the Test Results Detail (TestResult Pane at the bottom, right click on on Test Results and go to TestResultDetails).</p> <p>This works with Debug.WriteLine and Console.WriteLine.</p>
SMTP and Unicode/UTF-8 characters...? How do I send them? base64 everything? <p>Using SMTP, how do you send Unicode/UTF-8 e-mails? </p> <p>Am I expected to base64 encode the UTF-8 body and specify that in the MIME header or...? How about the headers? </p> <p>I'm sure there's a standard somewhere the describes this......
<p>Check out the <a href="http://tools.ietf.org/html/rfc2047">RFC 2047</a>.</p>
What advantages are there to developing a Win32 app in C++ over a .NET app in C#? <p>I learned windows programming using Visual C++, and the Win32 API. Nowadays, it seems most apps are being developed in .NET using C#. I understand that most of the time there isn't much performance difference between native code and ma...
<p>IMO the most important one for small downloadable applications is that native code does not need the .NET runtime. While broadband becomes more and more common not nearly everybody has it yet. </p> <p>Some people may be disappointed to see that your 2 MB application actually requires another 20MB of framework downl...
What is your opinion of Groovy? <p>For your projects, did you have a favorable experience with Groovy? How big was the project? Were there issues with the language? Did you consider Jython, JRuby or Clojure?</p>
<p><strong>I like</strong></p> <ol> <li>Closures</li> <li>The slurpers</li> <li>That there is no need of the typically redundant declaration <code>MyType x = new MyType()</code>, which can be reduced to simply <code>def x = MyType()</code>. However, the typing is moot in Groovy (and I don't like that).</li> <li>That y...
How is shared dll (GAC ) loaded to memory and used in comparison to private dll <p>I'd like to point out that I know how to add/remove assembles to/from GAC. What I am asking for is if someone could explain me how does it work from the technical point of view. What's the point in putting dll's there - from the point of...
<p>The point of putting things in the GAC is so that multiple applications (even from different vendors) can access the same assembly. There is then one location where it can be updated and all applications which can properly access that version can use it. You also know that all assemblies in the GAC are digitally s...
What methods/techniques/tools do you recommend for documenting systems and infrastructure (runbooks)? <h2>Background</h2> <p>I recently joined a small start-up after working at a large company.</p> <p>I'm not a professional system administrator, however, because of my programming and systems knowledge I am now the in...
<p>I've actually had good success with a Wiki. Use something where you can control logins easily — Mediawiki is okay, but requires some PHP hacking — and build some templates for processes, inventories, and so forth.</p> <h3>Update</h3> <p>Actually, I must have needed coffee. <a href="http://trac.edgewall.org/"...
How to enforce a "has a" relationship and protect the object that "is had" <p>Given the following code:</p> <pre><code>Class User{ Task m_Task; public function getTask("Do work") { return m_Task; } } Class Project{ Task m_Task; public function getTask("Do work") { return m_Task; } } Class Task { privat...
<p>It seems somewhat quixotic, but I suppose you write Task a constructor that requires a User as an argument and does some handshaking back and forth to link the User to the Task, requiring that the User does not already have a Task.</p>
How can I reference an encapsulated javascript function from another encapsulated function? <p>I'm new to object oriented javascript. I have a set up method that I want to a) check if an element is null and if so wait and call itself again and b) observe the click event of a button.</p> <pre><code>ErrorBox.prototype....
<p>Use closures to hold on to your execution context:</p> <pre><code>ErrorBox.prototype.setUpErrorBox = function(btnClientID) { var box = this; // object context reference if (btnClientID == null) { // use closure as event handler to maintain context setTimeout(function() { box.setUpErrorBox() }...
Best practices for multithreaded processing of database records <p>I have a single process that queries a table for records where <code>PROCESS_IND</code> = 'N', does some processing, and then updates the <code>PROCESS_IND</code> to 'Y'. </p> <p>I'd like to allow for multiple instances of this process to run, but don'...
<p>The pattern I'd use is as follows:</p> <ul> <li>Create columns "lockedby" and "locktime" which are a thread/process/machine ID and timestamp respectively (you'll need the machine ID when you split the processing between several machines)</li> <li><p>Each task would do a query such as:</p> <p>UPDATE taskstable SET ...
Fitting Flex Image in Canvas <p>How do I scale an Image in Flex to fit a Canvas? My code follows:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" width="100" height="100" verticalGap="0" borderStyle="solid" ...
<p>you need to make sure you have set</p> <pre><code>image.scaleContent = true; image.maintainAspectRatio = false; </code></pre> <p>That should scale the content to the size of the swf loader and distortin it so it fills the entire area of the Image component.</p> <p>Here's a quick version of it working</p> <pre><c...
Can optimizations affect the ability to debug a VC++ app using its PDB? <p>In order to be able to properly debug release builds a PDB file is needed. Can the PDB file become less usable when the compiler uses different kinds of optimizations (FPO, PGO, intrinsic functions, inlining etc.)? If so, is the effect of optimi...
<p>Yes, optimized code is less debuggable. Not only is some information missing, some information will be very misleading.</p> <p>The biggest issue in my opinion is local variables. The compiler may use the same stack address or register for multiple variables throughout a function. As other posters mentioned, some...
Where can I find a good NHibernate and ASP.NET MVC Reference Application <p>Where can I find a good NHibernate and ASP.NET MVC Reference Application? I downloaded S#arp and this seemed to be a lot more than I needed (IOC and CodeGen via T4). I might work my way up to this later, but I need something smaller at first.</...
<p>I would try to tackle them independently. </p> <p>Before Billy McCafferty wrote sharp-architecture he wrote, what I think is, a must read on <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx">codeproject</a> about best practices with NHibernate. Also, I have just discovered some <a ...
What is the quickest way from a concept to a site? <p>I've got a bunch of website ideas and I was wondering what is the quickest way to get from a pretty thorough concept definition (idea mind-maps, use-cases, architecture diagrams ) to a working website. The only point is to get to something that's functional, not wor...
<p>First, select a dynamic scripting language. Static types and compilation will slow development. PHP is a good choice since you can download a LAMP package like xampp and start immediately.</p> <p>Next, use a CMS if at all possible. If you require a flexible front end design, then choose a template focused CMS like ...
Oracle: What exactly do quotation marks around the table name do? <p>I thought that the quotation mark (") was simply a type of grouping marker but I'm debugging some NHibernate code and notice that while</p> <pre><code>SELECT * FROM site WHERE site_id = 3; </code></pre> <p>Works fine</p> <pre><code>SELECT * FROM "s...
<p>Putting double-quotes around an identifier in Oracle causes Oracle to treat the identifier as case sensitive rather than using the default of case-insensitivity. If you create a table (or a column) with double-quotes around the name, you must always refer to the identifier with double quotes and by correctly specif...
How can I resolve a "Provider load failure" for WMI requests? <p>I'm using WMI to collect system information. It works fine on every system I've tested it on, but I have one or two users that are reporting problems. The debug logs show the WMI code is throwing a "Provider load failure" exception. I haven't been able...
<p>One way to possibly track down the root cause of the issue is to use <a href="http://technet.microsoft.com/en-us/library/cc180684.aspx" rel="nofollow">WBEMTest</a> a tool that the MS Scripting Guys say is one of the easiest ways</p> <blockquote> <p>"To find the provider of a WMI class..."</p> </blockquote> <p>Th...
NHibernate Eager loading multi-level child objects <p>I have a hierarchy of objects, Order, Contact, Address:</p> <pre><code>public class Order { public virtual Contact BillingContact { get; set; } } public class Contact { public virtual Address Address { get; set; } } </code></pre> <p>I want to query an o...
<p>I believe you might need to add an alias to BillingContact to allow you access to it's Address.</p> <p>Something like:</p> <pre><code>var criteria = DetachedCriteria.For&lt;Order&gt;() .CreateAlias("BillingContact", "bc") .SetFetchMode("BillingContact", FetchMode.Eager) .SetFetchMode("bc.Address", FetchMode....
How to start with a PHP website? <p>For a school project I have to produce a website using PHP that allows user to generate there own article or comment on news or others articles. I was wondering how it is best to use the GET function to show the content in an include file and also use the get function for other inclu...
<p>Wheel has been invented, tested, rolled for a million miles: <a href="http://wordpress.org/" rel="nofollow"><strong>WordPress</strong></a></p>
What UNIX commands support coloured output? <p>I enjoy using UNIX/bash commands that support coloured output. Consequently, I have a few aliases defined which automatically enable coloured output of the commands that I know support this option. However, I'm sure there are hundreds of commands out there that support c...
<p>Why don't you try:</p> <pre><code>man -K color </code></pre> <p>That should search for the word color in all your man pages (content, not just headings).</p> <p>It asks, for each man page, whether you want to open and view the page:</p> <pre><code>$ man -K color /usr/share/man/mann/Widget.n.gz? [ynq] y /usr/shar...
Using GPS to measure area <p>Hey guys, I'm researching something for a friend of mine who's involved in road construction. He needs some sort of a device that he can use to measure distance or area between points. I have done some GPS programming in the past but for mobile devices and i wasn't too impressed with accura...
<p>You could use a mobile device that has GPS and the ability to run your custom software like the iphone, google phones, and probably a lot of other smart phones.</p>
svnsync: PROPFIND request failed <p>I'm desperately trying to backup my google code-repo but since I'm not too familiar with SVN, I can't get svnsync to work. I thought that backing up your repo to another repo or dumpfile was an easy task, but I'm wrong? I would really appreciate tips on how to do this..</p> <p>What ...
<p>I would raise this in a comment, but I don't have the points to comment yet. It looks like at least part of your problem is that your URLs may not be correct. The 301 is telling you that the resource you expect to find there is not actually there, so I'd start by checking that URL by doing an svn ls on it.</p>
Can I get && to work in Powershell? <p><code>&amp;&amp;</code> is notoriously hard to search for on google, but the best I've found is <a href="http://www.microsoft.com/technet/scriptcenter/webcasts/psweek/day4qanda.mspx">this article</a> which says to use <code>-and</code>.</p> <p>Unfortunately it doesn't give any mo...
<p>In CMD, '&amp;&amp;' means "execute command 1, and if it succeeds, execute command 2". I have used it for things like:</p> <pre><code>build &amp;&amp; run_tests </code></pre> <p>In PowerShell, the closest thing you can do is:</p> <pre><code>(build) -and (run_tests) </code></pre> <p>It has the same logic, but th...
A declarative workflow does not start automatically after you install Windows SharePoint Services 3.0 Service Pack 1 <p>That's the title of <a href="http://support.microsoft.com/kb/947284" rel="nofollow">kb947284</a> actually. Recently I was involved in a Sharepoint project. I run into this problem where <strong>my wor...
<p>From the KB:</p> <p>This behavior occurs because a security fix in Windows SharePoint Services 3.0 SP1 prevents declarative workflows from starting automatically under the system account. After you install Windows SharePoint Services 3.0 SP1, declarative workflows do not start automatically if the following conditi...
Reading an Excel file in PHP <p>I'm trying to read an Excel file (Office 2003). There is an Excel file that needs to be uploaded and its contents parsed.</p> <p>Via Google, I can only find answers to these related (and insufficient topics): generating Excel files, reading Excel XML files, reading Excel CSV files, or i...
<p>You have 2 choice as far as I know:</p> <ol> <li><a href="http://sourceforge.net/projects/phpexcelreader/">Spreadsheet_Excel_Reader</a>, which knows the Office 2003 binary format</li> <li><a href="http://www.codeplex.com/PHPExcel">PHPExcel</a>, which knows both Office 2003 as well as Excel 2007 (XML).</li> </ol> <...
JQuery - How to add a class to every last list item? <p>Got some code here that isn't working:</p> <pre><code>$("#sidebar ul li:last").each(function(){ $(this).addClass("last"); }); </code></pre> <p>Basically I have 3 lists and want to add a class (last) to each item appearing last in each unordered list.</p> ...
<p>Easy mistake to make. Try this:</p> <pre><code>$("#sidebar ul li:last-child").addClass("last"); </code></pre> <p>Basically :last doesn't quite do what you think it does. It only matches the very last in the document, not the last in each list. That's what :last-child is for.</p>
Why does Thread.Sleep(0) fix my problems, and how to avoid it? <p>I'm working on a client server application. At certain times, on certain machines, when there's more than 5 clients requesting data, it seems to reach a deadlock. If I step in to debug the problem, then the program appears to be processing. Simply set...
<p>Thread.Sleep(0) is a yield. I am guessing this rearranges the way you call to avoid some issues. I think if you released code with the yield and ran it on 1000 machines, you would get a lot of bug reports. I am guessing you need some type of lock/critical section to avoid your dead lock because some where your code ...
How can I check the memory usage of objects in iPython? <p>I am using iPython to run my code. I wonder if there is any module or command which would allow me to check the memory usage of an object. For instance:</p> <pre><code>In [1]: a = range(10000) In [2]: %memusage a Out[2]: 1MB </code></pre> <p>Something like <c...
<p>Unfortunately this is not possible, but there are a number of ways of approximating the answer:</p> <ol> <li><p>for very simple objects (e.g. ints, strings, floats, doubles) which are represented more or less as simple C-language types you can simply calculate the number of bytes as with <a href="http://stackoverfl...
How to read CGBitmapContextData? (on iPhone) <p>I'm working on obtaining bitmap data like ARGB from an image. </p> <p>a). I create a bitmapcontext for the image: </p> <pre><code>context = CGBitmapContextCreate(void * data, size_t width, size_t height, size_t bitsPerComponent, size_t bytesPerRow, CGColorSpaceRef color...
<p>The pointer can still point to the image data even if its type is void. I posted another related topic at: <a href="http://stackoverflow.com/questions/561663/how-to-pull-out-the-argb-component-from-bitmapcontext-on-iphone">http://stackoverflow.com/questions/561663/how-to-pull-out-the-argb-component-from-bitmapcontex...
Is there a way to simulate a click on an alert in JavaScript? <p>I have a page with an iframe whose source page is in a separate domain. From time to time, the source page generates an alert. When it does so, it stops what it is doing until the user clicks OK to the alert.</p> <p>What I would like to do is programmati...
<p>JavaScript is single-threaded, which means when you call a function, it blocks until it returns. When you call alert(), that passes control to the browser which decides how to handle it. It is not Javascript which is popping the UI dialog, it is the browser. alert() does not return until the browser receives the "OK...
HTML unordered list sucks in IE7 <p>I've created a HTML ordered list which looks fine in FF, but pretty awful in IE. My specific problems with the way IE displays the list are:</p> <ol> <li>List markers are missing</li> <li>Vertical spacing between list items is very uneven</li> </ol> <p>It seems the superscripts are...
<p>This is a known bug of IE5, IE6, and still in IE 7.</p> <p>IE 8 Beta 2 and the latest, IE 8 RC1, will display your web page correctly.</p> <p>But these are a list of list item bug before IE 8:</p> <p><a href="http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/" rel="nofollow">http://www.gtalbot.org/BrowserBugsSe...
How can I extract a subtree from my svn repository into a new one? <p>We have a subversion repository with one directory that is:</p> <ul> <li>not really in need of revision control beyond the capabilities of RCS</li> <li>not versioned in conjunction with anything else in the repository</li> <li>modified about 6x as o...
<p>You could use <em>svnadmin dump</em> and <em>svnadmin load</em> to create a new repository from the original one; then copy the directory that doesn't really fit into your scheme to a better location, then delete everything else. In the original repository you would simply delete the non-fitting directory. This keep...
Program to view what a webpage would look through a mobile phone <p>I know this might off subject but what's a good program let's me view what a website might look like on a iPhone or other mobile device which connects to the Internet. Dreamweaver cs3 might have this but I can't find it anyone know?</p>
<p>Use the iphone simulator (part of the iphone SDK) and go to the webpage you want to test using safari. </p> <p>Very simple except you will need a intel mac ( can be done on a ppc mac but installing the SDK requires some tricks on ppc and is not supported).</p>
In Sql Server 2005, is there a way to query the total disk space (physical hard drive(s)) available on the server? <p>I found this in googling, but I don't think it's the complete code?</p> <p><a href="http://www.dba-oracle.com/t_sql_server_2005_windows_script_display_disk_space_usage.htm" rel="nofollow">http://www.db...
<p>Does xp_fixeddrives do the trick? </p> <pre><code>EXEC master.dbo.xp_fixeddrives </code></pre>
Checking the value of a Lua stack item from C++ <p>how do I check the value of the top of the stack in Lua?</p> <p>I have the following C++ code:</p> <pre><code>if (luaL_loadfile(L, filename) == NULL) { return 0;// error.. } lua_pcall(L,0,0,0); // execute the current script.. lua_getglobal(L,"varia...
<p>The likely problem is that <a href="http://www.lua.org/manual/5.1/manual.html#luaL_loadfile" rel="nofollow"><code>luaL_loadfile()</code></a> is documented to return the same values as <a href="http://www.lua.org/manual/5.1/manual.html#lua_load" rel="nofollow"><code>lua_load()</code></a> or one additional error code....
How to figure out what got clicked? <p>In jquery, how can I figure out what object was clicked?</p> <p>Is there a way to alert(...) the type of tag? like if it was an <code>&lt;a href&gt;</code> or a <code>&lt;img&gt;</code> etc?</p>
<p>The object that was clicked is passed into the click handler as <code>this</code>. You can find out the type of element with <code>nodeName</code>. Like this:</p> <pre><code>function handle_click() { var clicked_element = this; alert(clicked_element.nodeName); } $("#mylink").click(handle_click); </code></pre>...
Difference between if () { } and if () : endif; <p>Are there any differences between...</p> <pre><code>if ($value) { } </code></pre> <p>...and...</p> <pre><code>if ($value): endif; </code></pre> <p>?</p>
<p>They are the same but the second one is great if you have MVC in your code and don't want to have a lot of echos in your code. For example, in my <code>.phtml</code> files (Zend Framework) I will write something like this:</p> <pre><code>&lt;?php if($this-&gt;value): ?&gt; Hello &lt;?php elseif($this-&gt;asd): ?&gt...
Reset checkboxes in datalist on click of button that is outside of datalist using c# <p>Reset checkboxes in datalist on click of button that is outside of datalist using c#</p>
<p>In the eventhandler for the buttons OnClick event you'd loop trough each item in the datalist and find the checkbox and reset it.</p>
Should I use a number or an email id to identify a user on website? <p>I have a web app where I register users based on their email id.</p> <p>From a design/ease of use/flexibility point of view, should I assign a unique number to each user or identify user based on emailid?</p> <p>Advantage of assigning unique numbe...
<p>The identity of your users should be unique and immutable. Choosing the email address as identity is not a good idea for several reasons:</p> <ul> <li>The email is one facet of the user's identity that can change at any point in time.</li> <li>You might decide to allow more than one emails.</li> <li>You might decid...
Can you store a variable inside a if-clause? <p>I'm kinda waiting for a 'no' answer on this question.</p> <p>I was interested if you can save a variable at the same time when you checking it in an if-clause. </p> <p>Let's say I have this code.</p> <pre><code>if(foo!=null){ if(foo.getBar()!=null){ Bar bar = foo...
<p>This is the closest you can get:</p> <pre><code>Bar bar; if(foo!=null &amp;&amp; (bar = foo.getBar())!=null){ System.out.println("Success: " + bar); } else { System.out.println("Failiure."); } </code></pre>
Subscription based software: Does it work? <p>A while back I worked with a software company that sold a specialized software product. Ever so often they would release a patch for free and a new version that would require an upgrade fee. This is typically how the software industry works.</p> <p>After some time the co...
<p>I used to work for a company which moved from product license to subscription based model. Here are some observations about that: </p> <ol> <li>Offer both product license and subscription models</li> <li>In product license: user buys 'n' number of seats for their use. </li> <li>In subscription models, customer <em>...
After moving a UITableView row, then selecting it, it only turns blue at the edges <p>I have a <code>UITableView</code> with reorderable rows and I'm using the standard <code>UITableViewCell.text</code> property to display text. When I tap Edit, move a row, tap Done, then tap the row, the built-in <code>UILabel</code>...
<p>This looks like a bug in UITableView's rendering, and you should file a Radar bug report on it. It's like the cells don't get refreshed properly after the move.</p> <p>One way to work around this for now is to not use the built-in label, but roll your own in the cell:</p> <pre><code>- (UITableViewCell *)tableView...
Split rows data to columns <p>I have a table, that has a simple structure:</p> <blockquote> <p>user_id, month, balance, balance_type</p> </blockquote> <p>I want to display selected balance types per month for each user that is:</p> <blockquote> <p>user_id, month, balance_1, balance_2, balance_3, balance_...</p> ...
<p>If this is a one time requirement, I can suggest a hack. Use multiple self joins on user_id and month (you will need as many joins as there are balance types). </p> <pre><code>select a.user_id, a.month, a.balance balance_1, b.balance balance_2, c.balance balance_3... from mytable a, mytable b, mytable c.... where ...
Anybody tried mosso CloudFiles with Google AppEngine? <p>I'm wondering if anybody tried to integrate mosso CloudFiles with an application running on Google AppEngine (mosso does not provide testing sandbox so I cann't check for myself without registering)? Looking at the code it seems that this will not work due to htt...
<p>It appears to implement a simple RESTful API, so there's no reason you couldn't use it from App Engine. Previously, you'd have had to write your own library to do so, using App Engine's urlfetch API, but with the release of SDK 1.1.9, you can now use urllib and httplib instead.</p>
How to get a TextBlock to right-align? <p>How do I get the TextBlock in my status bar below to align to the right?</p> <p>I've told it to:</p> <ul> <li>HorizontalAlignment="Right"</li> <li>TextAlignment="Right"</li> </ul> <p>but the text is still sitting unobediently on the left. What else do I have to say?</p> <pr...
<p>I've had a play with your code and managed to make it look "right" (no pun intended) by using a StatusBarItem rather than a TextBlock:</p> <pre><code>&lt;StatusBar Width="Auto" Height="25" Background="#888" DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" &gt; &lt;StatusBarItem Foreground="#fff" ...
Embedding: mono vs lua <p>I am interested in hearing about peoples experience with embedding mono (open source implementation of .NET) in a C/C++ application. How is it to distribute such an application and what are the dependencies? I have tested on OS X and mono comes as a huge framework (hundreds of MB). Do users of...
<p>You should probably also take a look at Mono's <a href="http://www.mono-project.com/Small_footprint">Small Footprint</a> page that describes how you can embed a smaller runtime. Heck, they do it themselves with <a href="http://www.mono-project.com/Moonlight">Moonlight</a>.</p> <p>I hope that helps.</p>
Splitting string into pair of characters in Ruby <p>I have a string (e.g. "AABBCCDDEEFF") and want to split this into an array with each element containing two characters - ["AA", "BB", "CC", "DD", "EE", "FF"].</p>
<p>Try the String object's <a href="http://www.ruby-doc.org/core/classes/String.html#M000827">scan</a> method:</p> <pre><code>&gt;&gt; foo = "AABBCCDDEEFF" =&gt; "AABBCCDDEEFF" &gt;&gt; foo.scan(/../) =&gt; ["AA", "BB", "CC", "DD", "EE", "FF"] </code></pre>
Xml vs. Database for application configuration <p>My application configuration is very hierarchical and fits nicely into a single XML. Soon (YAGNI, Yeh) parts of this information will be consumed by other applications remotely, which calls for a database.</p> <p>So, I went into designing DB tables and mapping them bac...
<p>We had very good experience with storing the config in a database for long running applications (like web sites and services). Advantages:</p> <ul> <li>You can edit the config remotely and securely (user/password)</li> <li>It is simple for the application to pick up changes (<code>select max(lmod) from config</code...
Easiest way to fetch SSL page via a proxy in Java <p>I would like to fetch a SSL page in Java. The problem is, that I have to authenticate against a http proxy.</p> <p>So I want a simple way to fetch this page. I tried the Apache Commons httpclient, but it's too much overhead for my problem.</p> <p>I tried this piece...
<p>You need to set a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Authenticator.html" rel="nofollow">java.net.Authenticator</a> before you open your connection:</p> <pre><code>... public static void main(String[] args) throws Exception { // Set the username and password in a manner which doesn't leav...
How do I use p4merge from Xcode? <p>I would like to use the p4merge tool from Xcode in an SVN setup. Asking for trouble?</p>
<p>Found the solution here: <a href="http://wiki.changesapp.com/index.php/Application_Integration#XCode_2.5_.26_3" rel="nofollow">http://wiki.changesapp.com/index.php/Application_Integration#XCode_2.5_.26_3</a></p> <ol> <li>Go to the "SCM" section in XCode's preferences.</li> <li>Select the "Options" tab.</li> <li>Sel...
ASP.NET 2.0 Membership: ValidateUser not locking out the user? <p>I am using the default SQLMembershipProvider in my ASP.NET 2.0 website, and expect the Membership.ValidateUser to lock-out the user after entering a number of wrong passwords (5, in my case) but ValidateUser doesn't seem to be caring about keeping count ...
<p>what is the PasswordAttemptWindow and MaxInvalidPasswordAttempts set to? and is these configuration settings set in the correct web.config? (the one actual in use by the test environment)</p>
Convert HTML to PDF in .NET <p>I want to generate a PDF by passing HTML contents to a function. I have made use of iTextSharp for this but it does not perform well when it encounters tables and the layout just gets messy.</p> <p>Is there a better way?</p>
<p>Try <a href="http://wkhtmltopdf.org/">wkhtmtopdf</a>. It is the best tool I have found so far.</p> <p>For .NET, you may use this <a href="https://github.com/codaxy/wkhtmltopdf">small library</a> to easily invoke wkhtmtopdf command line utility.</p>
Creating a sub site in SharePoint takes a very long time <p>I am working in a MOSS 2007 project and have customized many parts of it. There is a problem in the production server where it takes a very long time (more than 15 minutes, sometimes fails due to timeouts) to create a sub site (even with the built-in site temp...
<p>Yes, its normal OOB if you haven't turned the Second Stage Recycle bin off or set a site quota. If a site quota has not been set then the growth of the Second Stage Recycle bin is not limited...</p> <p>the second stage recycle bin is by default limited to 50% size of the site quota, in other words if you have a sit...
How to get MessageBox.Show() to pop up in the middle of my WPF application? <p>I have a 700w x 300h WPF applciation and can drag it anywhere on my large screen.</p> <p>When my application executes:</p> <pre><code>MessageBox.Show("Sorry, this function is not yet implemented."); </code></pre> <p>the mesage box appears...
<p>Here's a version of the MessageBoxEx helper class posted in the other thread that uses WPF style message boxes (Note that you still need to reference System.Drawing):</p> <pre><code>using System; using System.Text; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Interop; using Syste...
Code Freeze when you aren't going to be finished <p>I am working on a project that has been running for a long period of time and we're coming up on a final release of the product.</p> <p>Current testing efforts have discovered there are about thirty defects left in the system, however we don't have time to fix all of...
<p>It's a balancing act. </p> <p>On one hand it's nice to have a code freeze period, but on the other, it's in nobody's interest for you to ship a product with critical issues large enough to make your customers walk away.</p> <p>If the issues are serious enough, no code freeze would stop me fixing them if it were my...
SSRS Microsoft Reporting: Conditional grouping <p>Is it possible to make a group and sort conditional? If so, is it possible to somehow do this based on the value of a textbox item?</p> <p>I thought I could just set the Expression of the group and sort to something like <code>=IIF(ReportItems!TheTextBox.Value = 0, 0, ...
<p><strong>edit</strong></p> <blockquote> <p>It is a sub-report, so I can't use report parameters. </p> </blockquote> <p>you can. see <a href="http://msdn.microsoft.com/en-us/library/ms160348.aspx" rel="nofollow">How to: Add a Subreport and Parameters (Reporting Services)</a><br /> <strong>/edit</strong></p> <p...
What is the difference between NOT(x > y) and (x < y) in an SQL query? <p>What is the difference between the following query:</p> <pre><code>SELECT * FROM employee WHERE NOT(start_date &gt; '01-JAN-1970'); </code></pre> <p>and this query:</p> <pre><code>SELECT * FROM employee WHERE start_date &lt; '01-JAN-1970'; <...
<p>In <code>MySQL</code> and <code>PostgreSQL</code></p> <pre><code>SELECT * FROM employee WHERE not(start_date &gt; '01-JAN-1970') </code></pre> <p>will not use an <code>INDEX</code> on <code>start_date</code> if any, their optimizers are not smart enough.</p> <p>Otherwise, if you correct the condition not be not s...
How to temporarily disable the log in SQL2000/2005? <p>Is there a way to stop the log file from growing (or at least from growing as much) in SQL2000/2005?</p> <p>I am running a very extensive process with loads of inserts and the log is going through the roof.</p> <p><strong>EDIT</strong>: please note I am talking a...
<p>You can't disable the log, but you could perform your inserts in batches and backup/truncate the log in between batches.</p> <p>If the data originates from outside your database you could also consider using <a href="http://msdn.microsoft.com/en-us/library/aa174646.aspx" rel="nofollow">BCP</a>.</p>
Preserve datalist data on load event in c# <p>I have datalist containing radio buttons and check boxes. If I select some of them and then redirect to another aspx page. when I come to previous page the radio buttons and check boxes in datalist must be selected. I have selected data in session variable. How to do this u...
<p>Using the ItemDataBound event I would retrieve the radio button and compare it's value to your Session variable</p> <p>something like this:</p> <pre><code>protected void MyDataList_ItemDataBound(object sender, DataListItemEventArgs e) { RadioButton myRadioButton = e.Items.FindControl("myRadioButton") as RadioB...
Javascript - form select element open url in new window and submit form <p><strong>UPDATED</strong> - please read further details below original question</p> <p>I have a select form element with various urls, that I want to open in a new window when selected - to do this I have the following code in the element's onch...
<p>Here ya go</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { $("#selectElement").change(function() { if ($(this).val()) { window.open($(this).val(), '_blank'); $("#formElement").submit(); } }); // just to be sure ...
Porting a .NET 3.5 application to a portable device <p>I have written a server/client application using sockets in C# for .NET 3.5. I'm interested in porting the client part to some kind of mobile device and am pondering the best way. The client is actually an underlying library and a GUI depending heavily on touch int...
<p>I'd go for option 2 then. It wont take you too long (hopefully) to port the libraries over to the Compact Framework, and providing it's just sockets, etc, you're dealing with then I'm sure the CF will handle it fine.</p> <p><strong>EDIT:</strong> The only problems you'll have with option 2 is if you use any .Net fu...
can my programs access more than 4GB of memory? <p>if I run python on a 64bit machine with a 64bit operating system, will my programs be able to access the full range of memory? I.e. Could I build a list with 10billion entries, assuming I had enough RAM? If not, are there other programming languages that would allow th...
<p>You'll need to be sure that Python has been built as a 64 bit application. For example, on Win64 you'll be able to run the 32bit build of Python.exe but it won't get the benefits of the 64 bit environment as Windows will run it in a 32bit sandbox.</p>
sql query to find customers who order too frequently? <p>My database isn't actually customers and orders, it's customers and prescriptions for their eye tests (just in case anyone was wondering why I'd want my customers to make orders less frequently!)</p> <p>I have a database for a chain of opticians, the prescriptio...
<p>Something like this</p> <pre><code>select p1.branch, p1.patient from prescription p1, prescription p2 where p1.patient=p2.patient and p1.dateoftest &gt; p2.dateoftest and datediff('day', p2.dateoftest, p1.dateoftest) &lt; 90; </code></pre> <p>should do... you might want to add</p> <pre><code>and p1.dateoftest &gt...
Using jep.invoke() method <p>I need to call a function from a python script and pass in parameters into it. I have a test python script which I can call and run from java using Jepp - this then adds the person. </p> <p>Eg Test.py</p> <pre><code>import Finding from Finding import * f = Finding() f.addFinding("John", ...
<p>Easier way to run python code in java is to use <a href="http://www.jython.org/" rel="nofollow">jython</a>.</p> <p><strong>EDIT:</strong> Found an <a href="http://wiki.python.org/jython/JythonMonthly/Articles/September2006/1" rel="nofollow">article with examples</a> in the jython website.</p>
"BigInt" in C? <p>What is the easiest way to handle huge numbers in C? I need to store values in the Area 1000^900... </p> <p>Does anybody know of an easy way to do that? Any help would really be appreciated!</p>
<p>Use <a href="http://gmplib.org/" rel="nofollow">libgmp</a>:</p> <blockquote> <p>GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. There is no practical limit to the precision except the ones implied by the available memory in the ...
Private working set size dependent on application name <p>A colleague has been trying to reduce the memory footprint of a 32 bit app running on vista 64 and has noticed some weird behaviour in the reported size of the private working set.</p> <p>He made some changes and recompiled the app. Then he ran the app and load...
<p>This usually happens during full moons.</p> <p>Did he remember to sacrifice a chicken to Ba'al-ze-Bool, the god of memory?</p>
Casting NSString to unsigned char * <p>I'm trying to use a function that has the following signature to sign a HTTP request:</p> <pre><code>extern void hmac_sha1(const unsigned char *inText, int inTextLength, unsigned char* inKey, const unsigned int inKeyLength, unsigned char *outDigest); </code></pre> <p>And this is...
<p>It looks like the problem is not with the casting, but with <code>outDigest</code>. The fifth argument to <code>hmac_sha1</code> should point to an already allocated buffer of size 20 bytes (I think).</p> <p>If you change the line that says</p> <pre><code>unsigned char *outDigest; </code></pre> <p>to say</p> <pr...
Overloading, strings, and default parameters <p>Refactoring legacy code, I came across this function (pseudocode):</p> <pre><code>int getMessage( char * buffer, int size = 300 ); </code></pre> <p>Gee, look at that buffer just waiting to overflow. So I came up with a function using std::string, and thought it would be...
<p>It works as expected on my GCC 4.3.2, maybe you misspelled the name of the overload? There's no conversion from std::string to char*, so the compiler shouldn't have any problems choosing the correct overload.</p> <pre><code>$ cat test.cpp #include &lt;string&gt; #include &lt;stdio.h&gt; int getMessage( char * buff...
(Deep) copying an array using jQuery <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object">What is the most efficient way to clone a JavaScript object?</a> </p> </blockquote> <p>I need to copy an (...
<p>Since Array.slice() does not do deep copying, it is not suitable for multidimensional arrays:</p> <pre><code>var a =[[1], [2], [3]]; var b = a.slice(); b.shift().shift(); // a is now [[], [2], [3]] </code></pre> <p>Note that although I've used <code>shift().shift()</code> above, the point is just that <em><code>b...
Generate a number of ranges for a random set of values <p>Given a set of random numeric values in a database, how do I generate a limited list of ranges where each range contains at least one value? The ranges should not overlap and ideally have a similar amount of values in them. Ideally their boundaries should also b...
<p>In <code>MS SQL 2005+</code>:</p> <pre><code>SELECT range, (MIN(getprev) + MIN(value)) / 2 as range_start, (MAX(getnext) + MAX(value)) / 2 AS range_end, COUNT(*) as range_values FROM ( SELECT value, NTILE(4) OVER (ORDER BY value ) AS range, ( SELECT TOP 1 value FROM values li ...
ASP.NET MVC - Form Submission, Retrieve Database ID, and Redirect <p>I currently learning ASP.NET MVC . I wondered if it is possible when a form is submitted to the get the id of the new record and then redirect to a new page with the new record id?</p> <p>The information is entered into the database correctly, but Iâ...
<p>How are you accessing the database? If you are using an ORM (such as NHibernate or LINQ to SQL) then the object should have it's ID property updated after you insert it into the database.</p> <p>If you are hand rolling the SQL then you need to do a select in the same statement as the insert of:</p> <pre><code>inse...
XPath Node element indexing based on attribute <p>I am trying to build an Infopath form which populates fields with data back from a Sharepoint list. I set up a drop-down list box who's values get populated from a Sharepoint data source. That part works fine. Now I want other string fields to get automatically populate...
<p>I think I figured it out.</p> <pre><code>xdXDocument:GetDOM("Base Printers")/dfs:myFields/dfs:dataFields /dfs:Base_Printers[@Printer = current()]/@PNP_String </code></pre> <p>For some strange reason, it works when you use:</p> <pre><code>@Printer = current() </code></pre> <p>But not when you use:</p> <pre><code...
Difference between JOIN and INNER JOIN <p>Both these joins will give me the same results:</p> <pre><code>SELECT * FROM table JOIN otherTable ON table.ID = otherTable.FK </code></pre> <p>vs</p> <pre><code>SELECT * FROM table INNER JOIN otherTable ON table.ID = otherTable.FK </code></pre> <p>Is there any difference b...
<p>They are functionally equivalent, but <code>INNER JOIN</code> can be a bit clearer to read, especially if the query has other join types (i.e. <code>LEFT</code> or <code>RIGHT</code> or <code>CROSS</code>) included in it.</p>
Are there cross-platform precompiled header frameworks/methods in C++? <p>I'm wondering what others have experienced implementing cross-platform (linux and windows) precompiled headers in C++. I'm thinking of what Visual Studio lets you do with stdafx.h files that can drastically improve compile times for large amounts...
<p><code>gcc</code> will automatically precompile headers if you pass a header file instead of an implementation file. Simply add the <code>-x</code> switch if it tries to produce object code. GCC will always look for the <code>.gch</code> file before the header, so it's simple enough to use. <a href="http://gcc.gnu.or...
Why could VirtualBox not find a registered machine named Windows_7?n <p>I'm trying to change TCP/UDP of a virtual machine using VBoxManage setextradata.</p> <p>Whenever I type the command:</p> <pre>sudo VBoxManage setextradata Windows_7 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestEmule_TCP/Protocol" TCP</pre> <p...
<p>It fails because you are using sudo. VirtualBox is designed to be run by any user (in the <code>vboxusers</code> group), and sudo runs the command as the root user whose VirtualBox configuration is empty.</p> <p>You can check that by typing:</p> <pre><code>sudo VBoxManage -nologo list vms # Should print only a new...