input
stringlengths
51
42.3k
output
stringlengths
18
55k
Clojure Vector of Refs <p>What's the simplest way to create a vector of distinct refs?</p> <p>Using <code>(repeat 5 (ref nil))</code> will return a list, but they will all reference the same ref:</p> <pre><code>user=&gt; (repeat 5 (ref nil)) (#&lt;Ref@16ef71: nil&gt; #&lt;Ref@16ef71: nil&gt; #&lt;Ref@16ef71: nil&gt; ...
<pre><code>user&gt; (doc repeatedly) ------------------------- clojure.core/repeatedly ([f]) Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it nil user&gt; (take 5 (repeatedly #(ref nil))) (#&lt;Ref@1f10a67: nil&gt; #&lt;Ref@1e2161d: nil&gt; #&lt;Ref@1a...
Workload Distribution / Parallel Execution in JAVA <p>Dear All, I have a situation here where I need to distribute work over to multiple JAVA processes running in different JVMs, probably different machines.</p> <p>Lets say I have a table with records 1 to 1000. I am looking for work to be collected and distributed ...
<p>Might want to look into <a href="http://en.wikipedia.org/wiki/MapReduce" rel="nofollow">MapReduce</a> and <a href="http://hadoop.apache.org/core/docs/current/mapred%5Ftutorial.html" rel="nofollow">Hadoop</a></p>
How much space is alloted to application storage on the iPhone? <p>Does anyone know what subset of the iPhone's overall storage capacity is reserved for applications and application data? I am not talking about RAM, but rather disk space. I remember reading that only a portion of the iPhone's capacity was used for appl...
<p>It depends on the model, of course - you have 8, 16 and 32 GB variations. My 16GB iPhone 3G would have around 14GB of free space, while my 32GB iPhone 3GS has around 28GB of free space. This free space is not limited to either applications, music, videos or podcasts - it is shared. As long as there is still free spa...
Serialize an image in XAML using XamlWriter <p>I'm using XamlWriter to serialize a group of WPF objects. One of these objects is an Image control whose Source is set to a file on disk. </p> <p>When the XamlWriter serializes the objects, it sets the source image to an Uri that points to the file on the filesystem. Is t...
<p>From MSDN:<br> <a href="https://msdn.microsoft.com/library/ms754193(v=vs.100).aspx" rel="nofollow">Serialization Limitations of XamlWriter.Save</a> </p> <p>"Images are also serialized as object references to images as they exist in the project, rather than as original source references, losing whatever filename or...
XML file interpretation and manipulations <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;root&gt; &lt;MyData&gt; &lt;MyField&gt;SomeValueHere1&lt;/MyField&gt; &lt;MyComplexData&gt; &lt;MyComplexDataField1 property="1"&gt;&lt;/MyComplexDataField1&gt; &lt;MyComplexDataField2 someproper...
<p>This is the .NET 2.0 way of doing things - using a XmlDocument from System.Xml.</p> <pre><code>XmlDocument xdoc = new XmlDocument(); xdoc.Load('(your file name)'); XmlNodeList myDataList = xdoc.SelectNodes('//MyData'); foreach(XmlNode dataNode in myDataList) { // do whatever oyu need to do with your myData nod...
Superfish problem, "Object does not support this property or method" <p>I'm getting an "Object does not support this property or method" error on the following line...</p> <pre><code>$("ul.sf-menu").superfish({ pathClass: 'current-subs' }); </code></pre> <p>My understanding is that superfish.js should ha...
<p>Figured it out.</p> <p>I had imported jQuery twice as follows:</p> <pre><code>&lt;script src="../js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../js/superfish.js" type="text/javascript"&gt;&lt;/script&gt; ... &lt;!-- Didn't notice this one --&gt; &lt;script src="../js/jquery-1...
C: Using memset function <p>This is the code that I want to try to write:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;malloc.h&gt; int main(int argc, char *argv[]) { float arry[3] = {0}; memset(arry, (int) 10.0, 3*sizeof(flo...
<p><a href="http://www.cplusplus.com/reference/clibrary/cstring/memset/">Memset</a> takes a int, but casts it to an unsigned char, and then fills each byte of float (sizeof(float) is probably 4) with that bit pattern. If this is c++, prefer <a href="http://www.cplusplus.com/reference/algorithm/fill/">fill</a> instead:<...
Is there a Database Diagram programes more powerful than that with MS SQL Server? <p>As i described,</p> <p>I want program give me more helpful diagram for example :</p> <p>MS SQL Server Diagram didn't give you a good design for relations so if you <strong>have many relations in the same table</strong> then the diagr...
<p>Try MS Visio. I think that will fit your bill. A better alternate would be ERWIN.</p> <p>Raj</p>
What's the simplest, quickest way to pause/play Windows Media Player? <p>I'm just trying to get a quick way to play and pause Windows Media Player remotely. After reading several questions here on SO, I realized that most people were talking about C#, Java, COM, ActiveX... which seem a bit overkill for my project. Is t...
<p>You need this:</p> <p><a href="https://github.com/pywinauto/pywinauto" rel="nofollow">https://github.com/pywinauto/pywinauto</a></p> <p>..............</p>
Trouble passing ViewModel to Partial View <p><strong>My ViewModel class (ItemViewModel.cs) looks like this:</strong></p> <p>public class ItemViewModel {</p> <pre><code>public ItemViewModel(xxx.Product product) { this.product = product; } private readonly xxx.xxx.Product product; private readonly Pers pers; priva...
<p>This could be because your partial view file needs this line above your html:</p> <pre><code>&lt;%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage&lt;xxx.ViewModels.**ItemViewModel**&gt;" %&gt; </code></pre> <p>So this is how your partial view should look:</p> <pre><code>&lt;%@ Page Language="C#" Inherits="...
Using Generic Types in Window.Resources <p>I am trying to use Generic Types in Windows.Resources section in XAML code. To attach the notification for a collection of objects my generic collection inherits from ObservableCollection as shown below: </p> <pre><code>public class PresentationModalCollection&lt;T&gt; : Obse...
<p>Mike Hillberg has some <a href="http://blogs.msdn.com/mikehillberg/archive/2006/10/06/LimitedGenericsSupportInXaml.aspx" rel="nofollow">extensions</a> that can help out with it and work pretty well. I agree that creating a CustomerCollection and collection type for each type you wanted to wrap would be overbearing....
Redirect domain.com/folder to folder.domain.com permanently <blockquote> <p><strong>Possible Duplicates</strong><br /> <a href="http://stackoverflow.com/questions/597390/how-can-i-use-mod-rewrite-to-redirect-a-folder-path-to-a-subdomain-but-without-a">how can I use mod rewrite to redirect a folder to a subdomain .....
<p>you would use this line in your main .htaccess for a simple folder 301 "Moved/Permanent" Redirect</p> <pre><code>Redirect 301 /subdomain http://subdomain.example.com </code></pre> <p><a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#Redirect" rel="nofollow">Source</a></p>
why everything gone with display:block? <p>This is OK:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;tabs&lt;/title&gt; &lt;style&gt; li { display:inline; margin:0 90px; background:#777777 none repeat scroll 0 0; } li a { padding:6px 12px; color:#FFFFFF; text-decoration:none; font...
<p>Your code disappears because you have block elements (with line breaks and height and width) inside an inline element (no line breaks and no height or width). </p> <p>It may help to review the w3 page on the <a href="http://www.w3.org/TR/CSS2/visuren.html#box-gen" rel="nofollow">visual formatting model</a>.</p> <p...
XSL:T Benchmarking <p>How would you approach benchmarking the following XSL:T process. </p> <p>Testing environment: a Linux server running apache, php, and mysql that is only visible behind our network: (It is not outward facing, so It cannot be remotely accessed).</p> <p>Note: I have considered using AB(Apache Bench...
<p>In general, adding some steps should increase processing time. I suppose the solution "PHP that generates XMTML" will be faster than the other alternatives.</p> <p>Therefore, to answer your question, I would consider what may increase your productivity: Is it easier to generate a simple XML stream from PHP, proces...
Delete foreign keys in sybase 12.5 <p>I have two tables:</p> <pre><code>CREATE TABLE dbo.country ( cntry_id VARCHAR(2) NOT NULL, name VARCHAR(50) NOT NULL, CONSTRAINT pk_country PRIMARY KEY (cntry_id) CREATE TABLE dbo.city ( city_id VARCHAR(3) NOT NULL, name VARCHAR(50) NOT NULL, cntry_id VAR...
<pre><code>ALTER TABLE dbo.city DELETE FOREIGN KEY [enternameoftheforeignkeyhere] </code></pre> <p>Otherwise I don't know what could be the reason. The number of the error message means he couldn't delete it from syskeys. But he found the two tables alright and your are the owner of the tables too.</p> <p><hr /></p> ...
wx.Panel scales to fit entire parent Frame despite giving it a size <p>Hi I am newbie to wxpython I am trying to have a Frame and within that a small panel area which I am coloring blue. However no matter what I do the wx.Panel using the size attribute , the single panel snaps to the size of its parent frame. If I add...
<p>By default, wx.Frame has a sizer that expands its child to fill the frame. Create your own sizer, add the panel to it (without specifying expand flags) and set that as the frame's sizer.</p> <pre><code>import wx app = wx.PySimpleApp() frame = wx.Frame(None, -1, 'Test') sizer = wx.BoxSizer(wx.VERTICAL) panel = wx.P...
Wildcard search for LINQ <p>I would like to know if it is possible to do a wildcard search using LINQ.</p> <p>I see LINQ has Contains, StartsWith, EndsWith, etc.</p> <p>What if I want something like %Test if%it work%, how do I do it?</p> <p>Regards</p>
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.sqlclient.sqlmethods.like.aspx">SqlMethods.Like()</a>.</p> <p>An example of the usage:</p> <pre><code>var results = from u in users where SqlMethods.Like(u.FirstName, "%John%") select u; </code></pre>
Trim blank newlines from string in Ruby <p>I have a string of four blank lines which all up makes eight lines in total in the following:</p> <pre><code>str = "aaa\n\n\nbbb\n\nccc\ddd\n" </code></pre> <p>I want to return this all in one line. The output should be like this on a single line:</p> <pre><code>aaabbbccc...
<p>The Ruby (and slightly less Perl-ish) way:</p> <pre><code>new_str = str.delete "\n" </code></pre> <p>...or if you want to do it in-place:</p> <pre><code>str.delete! "\n" </code></pre>
Is there a way to utilize the Mac Laptops' touchpad pinch gestures on Flex? <p>I have written a Google Maps-based application in Flex. Currently you can use the mouse wheel to zoom in and out the map. Is it possible on Mac laptops to use the pinch gesture to zoom?</p>
<p>Not without some hacking. There's <a href="http://github.com/whenders0n/multiclutch/tree/master" rel="nofollow">MultiCluch</a>, which is an InputManager that lets you assign gestures to keyboard shortcuts, which might be a starting point.</p> <p>In any case, you're in for some pain, because there's (currently) no <...
Writing to one db while reading from another using DevExpress XPO <p>Does anyone have any experience with working with DevExpress' XPO in an environment where the DB is replicated? From my <a href="http://stackoverflow.com/questions/1034538/backend-db-setup-for-an-app-with-geographically-diverse-users">previous questio...
<p><b>EDIT: </b> since you don't like the first approach.</p> <p>here are some master-master replication links in case you haven't seen them.<br /> <a href="http://forums.mysql.com/read.php?144,235807,235807" rel="nofollow">http://forums.mysql.com/read.php?144,235807,235807</a><br /> <a href="http://code.google.com/p/...
After a Plone 2.5x to Plone 3.x migration, how do I correct the kss_generic_macros problem? <p>I get the error below on several views. Which seems identical to what is described here in this <a href="http://plone.org/support/forums/general#nabble-td336363" rel="nofollow" title="kss_generic_macros problem">other kss_gen...
<p>Log into the ZMI then go to the portal_skins tool. Now click on the "properties" tab. The "Plone Default" skin should look something like this:</p> <pre><code>custom cmfeditions_views CMFEditions ChangeSet kupu_plone kupu kupu_tests archetypes archetypes_kss mimetypes_icons plone_kss ATContentTypes ATReferenceBro...
Why are generics completely disabled when you ignore a parameter type? <p>As a followup to <a href="http://stackoverflow.com/questions/1039658/why-is-code-that-returns-a-genericized-map-generating-a-compiler-warning-when-ass">this question</a>, first the background</p> <p>Given a class with this declaration:</p> <pre...
<p>I don't quite know the rationale for this, but this behavior is specified in the <a href="http://java.sun.com/docs/books/jls/third%5Fedition/html/typesValues.html#4.8" rel="nofollow">Java Language Specification JLS S4.8</a>:</p> <blockquote> <p>The superclasses (respectively, superinterfaces) of a raw type are th...
Doxygen \xrefitem doesn't seem to work <p>I'm trying to use xrefitem to create a "Related Page", but it doesn't seem to be working, nor inline. Here is an example:</p> <pre><code>/// \xrefitem makeup "Makeup" "This is made up" ok so it is /// \xrefitem makeup2 "Makeup2" "This is made up2" Ok it #ismade"up" </code></p...
<p>Two quick thoughts:</p> <p>First, does this work for you? (Splitting it up so the text is on a second line...)</p> <p>/// \xrefitem makeup "Makeup" "This is made up" /// ok so it is</p> <p>Also, your second example has a number in the tag - is that arbirtrary? I actually had problems with \addtogroup when some...
background attribute in CSS <pre><code>background:#777777 none repeat scroll 0 0; </code></pre> <p>the 5 attributes it includes are background-color,background-image,background-repeat,background-attachment and background-position.</p> <p>My question is:</p> <p>Are background-repeat,background-attachment and backgrou...
<p>yes. They have no meaning without that.</p>
add item to right-click menu in Excel chart <p>How to add item to right-click menu in Excel chart using VBA? Excel is 2007. Chart is standalone sheet.</p>
<p>This is pretty late, but I thought it's important for anyone else trying to do this.</p> <p>In Excel 2007 and 2010, you cannot alter the context menus for charts and shapes. There are no errors, but the modifications just are not applied. Microsoft knows about this, at least the smart guys in the product group, but...
SAS Proc SQL Database Table Insert <p>Using SAS's Proc SQL, is there a way to insert records from a SAS Dataset into a table in the open SQL Server connection? Something like this (which doesn't work):</p> <pre><code>proc sql exec; connect to sqlservr as DataSrc (server=my-db-srvr database=SasProcSqlTest); crea...
<p>To my knowledge, using pass through SQL constrains you to the database server. The SAS documentantion says that you should preferrably create a library reference to the database and then treat the database tables just like SAS tables. In your case this means just normal proc sql. This should work at least in the lat...
In Delphi IDE, how to quickly determine the location of an open non-project-related file? <p>This is probably a question that has an easy/simple/obvious answer, but I've found myself asking it many, many times, and never able to answer it:</p> <p>When I Ctrl-click a class name, Delphi loads up the unit that defines it...
<p>Erika's got a good answer. Here's an even better one: You can have Delphi open the Windows folder and highlight the file for you. Here's how to set it up:</p> <p>Tools menu -> Configure Tools -> Add</p> <pre><code>Title: Explore Program: Explorer.exe Working dir: &lt;leave blank&gt; Parameters: /select, $EDNAME...
Creating a Powerpoint with Graphs from Access <p>I am trying to programmatically create a PowerPoint from graphs in Access. Ideally, when the graphs move over to PowerPoint they will become static pictures and not graphs still linked to the access data.</p> <p>I have tried procedures such as:</p> <pre><code> Private ...
<p>Ok, I found a way to do it. I am still interested if anyone has a more elegant way, but for anyone else dealing with a similar problem:</p> <pre><code>Private Sub Command1_click() 'Note: Sample only, in real code this should probably have something to save the 'PPT file and then close the powerpoint application...
Creating controls in a non-UI thread <p>I have a sort of plug-in model in which various complex user controls are stored in DLLs and loaded and instantiated at run time using </p> <pre><code>Activator.CreateInstanceFrom(dllpath, classname). </code></pre> <p>Since I'm loading quite a few of these I wanted to do it in ...
<p>Is fine to load the DLLs and create the control objects in the background, but the control has to be added to the form in the main thread and all user interaction as well as any programmatic change of control properties (after it was created) has to occur in the main thread. There is simply no way around this, as yo...
How do I convert RTF to PDF from my PHP web page using OpenOffice? <p>My OS is Windows XP, and I'm using IIS 5.1 and PHP 5.2.9. I'm trying to call a PHP script from my PHP page in order to convert an RTF doc to a PDF, using OpenOffice. The script works just fine when I call it directly from the command line, but I'm...
<p>Yay!!!! With the help of a super-duper brainiac here at work, I now have a solution that actually WORKS! Forget all the code I posted earlier, I'm not using any of it anymore. If anyone else needs to convert word docs to PDF from PHP on IIS here's what will work:</p> <p>1) Install OpenOffice, of course</p> <p>2...
.NET - vs EJB <p>What is the comparable technology of EJB (Enterprise Java Beans) in .net?</p>
<h3>Definition of terms is important</h3> <p>When doing comparisons, the definition of terms is important. EJB is a component model. It defines persistence, transaction, remoting, activation and security capabilities (and maybe others) for components that operate within the container. </p> <p>You can look at compa...
Why would you check for Assigned(self) in object methods? <p>I am looking at some code (Delphi 7) with following check is at the top of every method call for a specific object:</p> <pre><code>if not Assigned(self) then raise Exception.CreateRes(@sAbstractError); { Real code for this method} </code></pre> <p>I gu...
<p>A clear error complaining about a nil pointer is better than an access violation that doesn't say how it happened.</p>
How can I run unit tests for just the source files which have changed? <p>Is there a way I can get ant to run the unit tests just for the java classes it builds? For example, if MyClass.java is out of date, ant will build MyClass.class. After that I want it to also run MyClassTest and MyClassTestSuite if they exist. ...
<p>I would not recommend this approach, There is a good chance of missing errors introduced by side effects.</p>
Possible to do xsl transform on dynamically generated xml? <p>Let's say I have an empty XML file like so:</p> <pre><code>&lt;root&gt;&lt;/root&gt; </code></pre> <p>And I want to add an element to root during an XSL transformation like so:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1...
<p>There are three essential elements to running a multi-pass transform.</p> <ul> <li><code>&lt;xsl:import&gt;</code></li> <li><code>&lt;xsl:apply-imports&gt;</code></li> <li><code>node-set()</code> extension function</li> </ul> <p>The example passes an XML document through two transforms serially. That is, it passes...
How to use SIFR or Facelift with ASP.net? <p>Has anyone used SIFR or Facelift (FLIR) with ASP.net? I noticed that all the scripts included with FLIR are all PHP pages. I looked around but it looks like there isn't a good solution for image replacement for ASP.net.</p>
<p>sIFR is a client-side technique that leverages Javascript and Flash, so is pretty much independent of which server-side language you use. For some examples of how to implement it, see <a href="http://wiki.novemberborn.net/sifr3/How%2Bto%2Buse" rel="nofollow">How to use</a>.</p>
Reference-type conversion operators: asking for trouble? <p>When I compile the following code using <code>g++</code></p> <pre><code>class A {}; void foo(A&amp;) {} int main() { foo(A()); return 0; } </code></pre> <p>I get the following error messages:</p> <pre><code>&gt; g++ test.cpp -o test test.cpp: In ...
<p>It isn't that an address can't be taken (the compiler could always order it shoved on the stack, which it does with ref-to-const), it's a question of programmers intent. With an interface that takes a A&amp;, it is saying "I will modify what is in this parameter so you can read after the function call". If you pass ...
How do I return an interface from a WCF Service? <p>Lets say I have some interfaces:</p> <pre><code>public interface IFoo { IBar DoesStuff(); } public interface IBar { string Thingo { get; } } </code></pre> <p>I'm consuming this code throughout my code base. The IFoo process needs to be moved onto a different sys...
<p>IBar needs to be concrete and a DataContract. WCF isn't about distributed objects, but rather a way to transfer data and have services work on that data. You can't return an object in WCF that has behavior.</p>
iPhone: Weird space at the top of UINavigationController <p>I'm having a strange problem with adding a UINavigationController to my iPhone application. I add the controller as follows:</p> <pre><code>myViewController *viewController = [[myViewController alloc] initWithNibName:@"myView" bundle:nil]; myNavigationViewCo...
<p>What does the line</p> <pre><code>UIView *finalView = myeNavigationViewController.view; </code></pre> <p>add to the code? It's redundant as you can add the view directly without assigning it to a UIView first - plus it's incorrect as it references the myNavigationController and not navigationController..<br /> I t...
How to handle onclick event in a listview button? <p>If I have listview control with a button in the item template, how do I handle the onclick events for each of the buttons that ends up getting generated in the listview?</p>
<p>You can use <strong>CommandArgument</strong> property of the button control to specify which button clicked.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemcommand.aspx" rel="nofollow">This example</a> shows how to get values from command argument within listview cont...
Calling C++ function from C# <p>I have a the following C++ function</p> <pre><code>void FillAndReturnString(char ** someString) { char sourceString[] = "test"; *someString = new char[5]; memcpy(*someString, sourceString, 5); } </code></pre> <p>It is declared as </p> <pre><code>extern "C" { __declspec(dll...
<p>With <a href="http://msdn.microsoft.com/en-us/library/aa288468%28VS.71%29.aspx" rel="nofollow">P/Invoke</a>.</p>
echo printing variables on single line <p>I have two variables:</p> <pre><code>export portNumber=8888^M export loginIP_BASE=10.1.172.2^M </code></pre> <p>I'm trying to print them both on a single line separated by a colon ':'. It should look like "10.1.172.2:8888"</p> <pre><code>echo -n 'Login IP:' echo -n $loginIP_...
<p>In Windows a tipical new line is \r\n (in *nix systems is just \n).</p> <p><strong>\r</strong> is carriage return.</p> <p><strong>\n</strong> is new line.</p> <p><strong>^M</strong> is <strong>\r</strong>, so after writing $loginIP_BASE you are at position 0 of the actual line.</p> <p>If you want to remove all t...
how to enable innodb in Noinstall Zip Archive MySQL version <p>I want to enable innodb in MySQL. I am using Noinstall Zip Archive with the following command to install it: mysqld-nt --install.</p> <p>I tried adding the --innodb at the end but seems it doesn't work. I have enabled all commented out partial related to i...
<p>Don't use the <strong>mysqld-nt</strong> executable use the <strong>mysqld</strong> executable. If I remember correctly mysqld-nt hasn't innodb support compiled in.</p>
DB Schema Organization <p>I'm currently in the planning phase of building a scheduling web app (for volunteer staffing of events), and I've got a question for those with more experience.</p> <p>Background: There's a calendar of events, and any user at any time can register for any of the events. At a later time, but ...
<p>This seems good, although you might want to consider combining your User - Event association tables into one, and having a column on that table that indicates the purpose of the association, i.e. Event, Staff, or Alt. This would effectively obviate the need for the duplication you describe in the UserEvent tables, ...
How do I get triple click to work in Visual Studio's Text Editor <p>Go into Notepad, Internet Explorer or most other applications that display or edit text. Triple click on some text. Windows will select the entire paragraph under the cursor.</p> <p>This doesn't work in Visual Studio 2005.</p> <p>How do I get triple ...
<p>I wrote an extension for this for Visual Studio 2010 that you can <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/2bbdc70c-32f7-4b69-8cff-d8190cae0cc7" rel="nofollow">download from the VS Gallery</a> or directly from the extension manager in Visual Studio, by searching for "triple click" or my name.</p>...
Representing a tree structure out of a db <p>I've read about various ways of representing hierarchical structure within a relational database like Adjacency List.</p> <p>I have decided to try a straight-forward way like a table (oversimplified) done like this: <code>id | name | parent</code> where parent is an inner r...
<p>Ironically, the hardest part of this problem can be getting a constrained set of records from the database that satisfy a particular path predicate. Unless you're using a database that provides hierarchical query support (like Oracle's CONNECT BY), this can get quite complicated. Check out <a href="http://stackoverf...
How to Implement an OpenGL Zoom Extents Function <p>I have an OpenGL application which implements navigation functions such as Orbit, Walk, Pan, Rotate, etc. for navigating a 3D environment. All this works flawlessly and is fairly straighforward to set up using <em>gluPerspective</em> and <em>gluLookAt</em>.</p> <pre...
<p>Actually it can be done much 'easier'.</p> <p>What you need to do is a projection of your model to a plane. Then, determine the highest and lowest points (top y, bottom y, leftmost x, rightmost x), and finally determine how much scaling you need to fit this rectangle in the rectangle you'd actually need.</p> <p>Th...
how to get around lack of 'add' button in ABPeoplePickerNavigationController? <p>My app needs to associate instances of a custom class with contact records in the iPhone's AddressBook. Everything's all well and good when I present the <strong>ABPeoplePickerNavigationController</strong> and allow the user to pick an <em...
<p>You can create a UIBarButton and add it to the UINavigationBar of the ABPeoplePickerNavigationController like so.</p> <pre><code> peoplePicker.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPerson...
How to move an element in a list in Haskell? <p>I'm reading through <a href="http://learnyouahaskell.com/input-and-output" rel="nofollow" title="Learn You a Haskell for Great Good!">Learn You a Haskell</a> and reached a spot where I'm trying to move an element in a list to the head. I've come up with what I think is t...
<p>I would do it this way:</p> <pre><code>move n as = head ts : (hs ++ tail ts) where (hs, ts) = splitAt n as </code></pre> <p><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:splitAt"><code>splitAt</code></a> splits a list at the given position, it returns the two parts that are crea...
How to design for JPA in a non-Java EE web server (e.g. Tomcat) <p>Considering there is no @PersistenceContext available to inject the EntityManager, plus you need to manually manage Transactions, what is the best way to design such an application?</p> <p>For the EntityManagerFactory/EntityManager, as far as I can see...
<p>I wouldn't do all that. Why try to recreate the whole JPA spec yourself? You just need to be able to use JPA without a container. </p> <p>Spring can help you with this. Try it.</p>
Apache RewriteRule not working without Page # specified <p>I have a rewrite rule set up in my .htaccess file:</p> <pre><code>RewriteRule ^Crocodile-Style/([0-9]+)/?$ products/display.php?folder=crocodile-style&amp;page=$1 [L,NC] </code></pre> <p><a href="http://test.bradp.com/drupal/Crocodile-Style/1" rel="nofollow">...
<p>It's probably easiest to implement this with two rules:</p> <pre><code>RewriteRule ^Crocodile-Style/?$ products/display.php?folder=crocodile-style [L,NC] RewriteRule ^Crocodile-Style/([0-9]+)/?$ products/display.php?folder=crocodile-style&amp;page=$1 [L,NC] </code></pre>
What is Windows 7's Fault Tolerant Heap? <p>I'd like some technical information on how it works, and how I can disable or enumerate the Fault Tolerant Heap shims that are associated with processes that crash frequently. Is there a heuristic of some sort that Windows 7 uses to decide when to apply an FTH shim?</p>
<p>Fault Tolerant Heap is a layer over the heap that defends against common heap errors, such as heap overruns, double frees, and so on. To my knowledge, there is only one FTH shim - not multiple for each mitigation. <a href="http://msdn.microsoft.com/en-us/library/dd744764%28VS.85%29.aspx">http://msdn.microsoft.com...
Context-sensitive string splitting, preserving delimiters <p>I have a string of the form "foo-bar-1.23-4", and I need to split at the first hypen followed by a numeral, such that the result is ['foo-bar', '1.23-4']. I've tried the following:</p> <pre><code>&gt;&gt;&gt; re.split('-\d', 'foo-bar-1.23-4', 1) ['foo-bar', ...
<p>You were very close, try this:</p> <pre><code>re.split('-(?=\d)', 'foo-bar-1.23-4', 1) </code></pre> <p>I am using <a href="http://www.regular-expressions.info/lookaround.html" rel="nofollow">positive lookahead</a> to accomplish this - basically I am matching a dash that is immediately followed by a numeric charac...
Can't figure out the jQuery selector <p>So Basically I am trying to keep the top level categories image of a down arrow turned on while hovering over the submenu's elements. I want to do this through jQuery on a hover function however I cannot for the life of me get a selector to target the sub menu items.</p> <p>Here...
<p>I think the fact that the images are added on the fly interferes with them being found by jQuery. Unless you bound the events with <code>live()</code> I think they get missed.</p> <p>That said, here's how I got it to work.</p> <pre><code>$(document).ready(function(){ var downArrow = '/Test/images/DownArrow....
What's the most efficient way to erase duplicates and sort a vector? <p>I need to take a C++ vector with potentially a lot of elements, erase duplicates, and sort it.</p> <p>I currently have the below code, but it doesn't work.</p> <pre><code>vec.erase( std::unique(vec.begin(), vec.end()), vec.end()); std...
<p>I agree with <a href="http://stackoverflow.com/questions/1041620/most-efficient-way-to-erase-duplicates-and-sort-a-c-vector/1041874#1041874">R. Pate</a> and <a href="http://stackoverflow.com/questions/1041620/most-efficient-way-to-erase-duplicates-and-sort-a-c-vector/1041700#1041700">Todd Gardner</a>; a <a href="htt...
Doxygen - Objective-C - Document Private Class functions Private <p>In doxygen, I can create objective-c categories inside my implementation file to hide interfaces that shouldn't be accessed publicly. However, doxygen still documents the category as the members being "public". Even by adding the \protected or \private...
<p>Have you tried <code>\internal</code> in code, coupled with <code>INTERNAL_DOCS = NO</code> in Doxyfile?</p> <p>Another way to put some part of the code out of doxygen scope is to use <code>\cond</code> and <code>\endcond</code> commands.</p>
Is it possible to make Eclipse's code-folding gutter black? <p>Is there a way (I'll settle for a hack) to make the code-folding gutter in Eclipse render with a black background? I'm clinging to TextMate as my main editor but would really like to go back to Eclipse for code completion, but I'm stuck with this ugly crap:...
<p>After you change the background color of the editor, disable then re-enable code folding and click apply this seems to fix the color problem however keeps that ugly white line separator.</p>
How can I determine if my TextBlock text is being trimmed? <p>The following textblock wraps and trims as expected. The elipsis "..." is displayed when the text is trimmed.</p> <pre><code>&lt;TextBlock MaxWidth="60" MaxHeight="60" Text="This is some long text which I would like to wrap." TextWrapping...
<p>Because the link in Alek's answer is down, I found a <a href="http://web.archive.org/web/20130316081653/http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/">cached copy of the link</a> from the wayback machine. You can not download the code linked in the article, so here is a pre-asse...
yuicompressor error, not sure what is wrong? <p>Very confused here, trying out the yuicompressor on a simple javascript file.</p> <p>My js file looks like:</p> <pre><code>function splitText(text) { return text.split('-')[1]; } </code></pre> <p>The error is:</p> <p>[INFO] Using charset Cp1252</p> <p>[Error] 1:2...
<p>Your encoding of the actual file YUICompressor is acting on is the issue. Open the file in notepad++ and change to ANSI &amp; it should work.</p> <p>[<a href="http://extjs.com/forum/showthread.php?t=27732" rel="nofollow">http://extjs.com/forum/showthread.php?t=27732</a>][1]</p>
Automatically Wrap a Controller Around a Service in ASP.NET MVC <p>The question title might not be clear but what I want to do is something like this:</p> <p>This is how I layer out my app</p> <blockquote> <p>App.Domain App.Services App.Web</p> </blockquote> <p>What I want is, if I request something like <code...
<p>It's sounds like you're trying to make a <a href="http://ajaxpatterns.org/RESTful%5FService" rel="nofollow">RESTful service</a>. </p> <p>Using a RESTful service, the <code>/api/OrderProcessor/GetAllOrders</code> URI would return your JSON objects. </p> <p>If that's the case, I would use WCF instead of ASP.NET MV...
iPhone: Can I get an image picker to have the documents folder as its source <p>It looks like I cant create an album for my picture producing app in the photo library... so what I was going to do is save the images to the documents folder for my app, which I think should be easy enough. The issue though is that the im...
<p>the image picker that apple provides only gives you access to pictures saved in the camera roll. It also gives you the functionality to take a new picture if you are on an iphone. If you save pictures in your app's local storage directory, then you need to build your own mechanism for viewing these photos. You ma...
Get unique System ID with Flex <p>Is there a way to get a unique machine-specific system ID in a Flex application running in a browser, so that is can be used for example to determine if the machine is properly licensed to run the application?</p>
<p>I can't think of any way to do this based off the users machine or OS. The whole point of browser applications is to have them able to run anywhere, any time via a browser. To my knowledge Flash provides no information that could reasonable be converted into a unique machine ID for licensing purposes, not even the M...
Using scanf() in C++ programs is faster than using cin? <p>I don't know if this is true, but when I was reading FAQ on one of the problem providing sites, I found something, that poke my attention:</p> <blockquote> <p>Check your input/output methods. In C++, using cin and cout is too slow. Use these, and you will gu...
<p>Here's a quick test of a simple case: a program to read a list of numbers from standard input and XOR all of the numbers.</p> <p><strong>iostream version:</strong></p> <pre><code>#include &lt;iostream&gt; int main(int argc, char **argv) { int parity = 0; int x; while (std::cin &gt;&gt; x) parity ^= x;...
Reading Google Gears blobs with JavaScript <p>Does anybody know how to read google gears blob objects within the browser? I'm using gwt on top of gears, but I'm looking for any kind of solutions. The application needs to work fully offline so I can't post the files and process them server side. My files are simple text...
<p>I wrote a very simple class to do this you can check it out here: <a href="http://procbits.com/2009/07/29/read-file-contents-blobs-in-gwt-and-gears/" rel="nofollow">http://procbits.com/2009/07/29/read-file-contents-blobs-in-gwt-and-gears/</a></p> <p>It's very simple to use. Either call the method "readAllText" or y...
NGen and Gacutil best practices <p>This is my first post, so please forgive me if this isn't written well.</p> <p>I've been working on a WinForms application which has about 5 referenced assemblies - written by us, and about 8 referenced assemblies by third parties (we wont be hoping to update them in the future unles...
<p>Main idea to improve startup time is to use delayed initialization whenever possible. Do not instantiate things that unnecessary immediately after startup. Use <a href="http://www.bluebytesoftware.com/blog/CommentView,guid,a2787ef6-ade6-4818-846a-2b2fd8bb752b.aspx" rel="nofollow">lazy init</a> pattern. It is also po...
How can I write a Visual Studio macro to perform an Extract Class refactoring? <p><strong>I'm trying to build a macro for Visual Studio 2008 that behaves thusly:</strong> (Extract Class Macro)</p> <p>I highlight some text in the currently open document and call the Macro (using a keybinding or whatever).</p> <p>The m...
<p>I just made a macro to do this today and found your question while seeing whether others had done it - although its a couple of years late as an answer goes here is one :)</p> <p>Updated Feb 2012 - The macro project can now be found here: <a href="http://plisky.net/main/macros/documentation" rel="nofollow">http://p...
Best way to add a new column with an initial (but not default) value? <p>I need to add a new column to a MS SQL 2005 database with an initial value. However, I do NOT want to automatically create a default constraint on this column. At the point in time that I add the column the default/initial value is correct, but ...
<p>I'd <code>ALTER TABLE tbl ADD col INTEGER CONSTRAINT tempname DEFAULT 1</code> first,, and drop the <em>explicitly named</em> constraint after (presumably within a transaction).</p>
Is there a Subversion user's guide to Git? <p>I am a new user in Git world. I used to use Subversion (using TortoiseSVN) and it is pretty easy. I would like to try Git but i got confused by the terms. Is there any documentation/guides that can explain me how to use Git?</p> <p>For example, in Subversion I use checkout...
<p>Here are two good guides:</p> <ul> <li><a href="http://git.or.cz/course/svn.html">Git - SVN Crash Course</a></li> <li><a href="http://www.gnome.org/~newren/eg/git-for-svn-users.html">(Easy) Git for SVN users</a></li> </ul>
a simple django jquery location question <p>I'm setting up a django project for the first time and I want to use jQuery. Is the idea that I just create a media folder, stick jquery in it and then point MEDIA_ROOT to it? Any suggestions for a good standard location for the media folder?</p>
<p>The <a href="http://docs.djangoproject.com/en/dev/howto/static-files/" rel="nofollow">how to serve static files</a> section in the Django documentation should help you get started. I tend to keep all static files for all my Django projects under <code>static</code> directory at the root of the project. I usually cre...
Parse MIME messages <p>For my new project which has email module.i need to show all the email information on web.when i m making a call to server i m getting the base64 encoded mime data. after applying base64 decoding technique i m getting the mime data as follows:</p> <p>/<strong>*****************</strong>Mime data ...
<p><a href="http://github.com/Vagabond/gen%5Fsmtp/tree/master" rel="nofollow">gen_smtp</a> and <a href="http://hg.opensource.lshift.net/erlang-smtp/" rel="nofollow">erlang_smtp</a> contain code for parsing mime messages.</p>
Problem Compiling in VS 2005 after installing microsoft platform SDK for Windows Server 2003 SP1 <p>As the title suggests I'm having a problem compiling MFC based applications, this problem started immediately after installing the windows server 2003 platform SDK and now even when I try to compile a new MFC project I g...
<p>Did you make sure to #include windows.h before zmouse.h</p>
Ajax performance: ASP.Net MVC vs Webforms <p>I just switch my website over to MVC from Webforms and I am using ajax very heavily. MVC seems to be slower but I haven't set up anything to record benchmarks.</p> <p>Does anyone know which is faster for ajax handling and why it's faster?</p>
<p>You shouldn't see any difference from one framework to the next. They are essentially the same with an exception of less things going on in the execution pipeline of the MVC framework, less stored (no state tracking), etc. How are you doing ajax in your site? Are you using partials? Full views? Rendering json o...
How to write a lightweight executable like uTorrent <blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/1021210/programming-slim-c-programs-like-utorrent-for-windows">Programming slim C++ programs (like uTorrent) for Windows</a> </p> </blockquote> <p><a href="htt...
<p>my contribution to your opinion:</p> <p>no crazy tactics in the beginning at least: <a href="http://en.wikipedia.org/wiki/Optimization%5F%28computer%5Fscience%29" rel="nofollow">"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."</a></p> <p>and l...
How do I make my urls work with mod_rewite? <p>Hey everyone, I'm having rewite issues.</p> <p><a href="http://test.bradp.com/drupal/Crocodile-Style/1" rel="nofollow">http://test.bradp.com/drupal/Crocodile-Style/1</a> works OK.</p> <p><a href="http://test.bradp.com/drupal/Crocodile-Style/" rel="nofollow">http://test.b...
<p>You're using the + modfier (1 or more) instead of the * modifier (0 or more).</p> <p>Instead, you should use:</p> <pre><code>RewriteRule ^Crocodile-Style/([0-9]*)/?$ products/display.php?folder=crocodile-style&amp;page=$1 [L,NC] </code></pre>
git releases management <p>I couldn't find anything what is the "right" approach to manage the releases using git. Say, I have master, release-1, release-2 and release-3 branches. Release 1 is already released and I do only bugfixing and released versions tagging on it. Release 2 is going to be released soon and I deve...
<p>See the following posts on Junio C Hamano (git maintainer) blog:</p> <ul> <li><a href="http://gitster.livejournal.com/25801.html">Completing a merge</a></li> <li><a href="http://gitster.livejournal.com/26540.html">Never merging back</a> (about branches forked with intention of not merging back)</li> <li><a href="ht...
How to update assmebly version info with new build and revision during build? <p>I have to update the build number in assembly version of assemblyinfo.cs file. I have written a custom tasks which updates all the assmeblyinfo.cs under a solution before starting build. But when i change this file and try to build then so...
<p>There's a good <a href="http://nantcontrib.sourceforge.net/" rel="nofollow">NAntContrib</a> task called <a href="http://nantcontrib.sourceforge.net/help/tasks/version.html" rel="nofollow">Version</a> that should do what you're looking for</p>
C# windows mobile skins or fancy controls <p>I am developing an application for a window mobile 6 using Visual Studio C# 2008 SP1.</p> <p>However, the design of the application is very plain using the standard windows controls.</p> <p>The application I am making is a phone that will be installed on WM6, so I am looki...
<p>Take a look at <a href="http://www.codeplex.com/site/search?TagName=windows%20mobile" rel="nofollow">CodePlex</a></p>
How to copy multiple files from server to local hard disk in one http request using C++? <p>How do you copy a group of files from server machine to local hard disk through a C++ web application in one request? This is kind of downloading bulk files to your local machine from a server. I guess in Java you could do this ...
<p>Say you have a Java servlet / ISAPI extension that accepts requests of the form</p> <p><a href="http://server:port/fileserver?f=FILE1&amp;f=FILE2&amp;.....&amp;f=FILEN" rel="nofollow">http://server:port/fileserver?f=FILE1&amp;f=FILE2&amp;.....&amp;f=FILEN</a></p> <p>On receipt of such a request, the server side co...
is there any way to acess swf embeded in html page from air application? [my air application loads the html page via html loader] <p>is there any way to acess swf embeded in html page from air application? [my air application loads the html page via html loader]</p>
<p>Did you write the swf? You would use flash.external.ExternalInterface to interact via JavaScript with the swf.</p>
How to do a NVL (or DECODE or CASE) statement within an Informix SE SQL query? <p>IBM is very clear on his Informix Standard Engine, it doesn't support neither CASE nor DECODE. "Please upgrade to a new version" : <a href="http://www-01.ibm.com/support/docview.wss?rs=632&amp;context=SSGU5Y&amp;dc=DB560&amp;dc=DB520&amp;...
<pre><code>CREATE PROCEDURE NVL(a CHAR(32), b CHAR(32) DEFAULT NULL, c CHAR(32) DEFAULT NULL, d CHAR(32) DEFAULT NULL, e CHAR(32) DEFAULT NULL, f CHAR(32) DEFAULT NULL, ...
Best way to store "views" of an topic <p>I use this code to update views of an topic.</p> <pre><code>UPDATE topics SET views = views + 1 WHERE id = $id </code></pre> <p>Problem is that users likes spam to F5 to get ridiculous amounts of views.</p> <p>How should I do to get unique hits? Make a new table where I sto...
<p>I would create a separate table for storing this information. You can then capture a larger amount of data and not require updating the table that is likely to be read the most.</p> <p>You would always use INSERT INTO tblTopicViews...</p> <p>And you would want to capture as much information as you can, IP address,...
Design tips for StoreKit in iPhone OS 3.0? <p>I am going to implement StoreKit in an iPhone application and wanted to know if there is any experience out there already that could point out any pitfalls or traps in using StoreKit?</p> <p>I know the API is new - but there is some premium content in my app that I would l...
<p>Things to think about when implementing StoreKit:</p> <ol> <li><p>When you call <code>[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];</code> sometimes you get the <code>(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue </code> callback before (and sometimes <em>long</em> b...
SQL counts performance (sql 2000) <p>I've seen in the post called something like "a small change you've done that has increased the performance of your application" a comment about changing from:</p> <pre><code>SELECT U.userid,groups_in=( SELECT COUNT(*) FROM usersgroup WHERE userid=U.userid) FROM tbl_u...
<p>The SQL Server optimiser seems to get better and better with each new version, service pack and hotfix. I can't count the number of times I have seen it execute [horrible convoluted mess] using the same efficient plan as [simple elegant equivalent].</p> <p>Look to your table and index design for efficiency savings ...
Example of a parallel acceleration anomaly <p>What is an example of a parallel acceleration anomaly? ie. A task that when run over p processors, results in a speedup greater than p.</p>
<p>Consider a matrix algorithm that for the purposes of parallelization is modified in such a way that every computing node is assigned a region of the matrix and only operates on this region.</p> <p>If with one node the region doesn't fit into cache (because it's the whole matrix) and with multiple nodes it starts fi...
Call click event of a button form another website <p>I am explaing with a exmple what I am trying to do.</p> <p>Suppose there is a site abc.com and i am working for site xyz.com</p> <p>in a aspx page of xyz.com i want to have the results of a aspx page of www.abc.com/somepage.aspx conatins a textbox , a combobox a o...
<p>What you are suggesting is XSS. This is usually undesired. Basically, you are looking for ways to bypass the <a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="nofollow">same origin policy</a>. A lot of browsers will block whatever you are doing. Imagine if there was an online poll on abc.com I wanted to...
Redirecting to another form in windows application c# <p>I am using the below function to Close existing form and opening new form. I am getting the below error when the code tries to close the existing form</p> <p>Error :</p> <p>{System.InvalidOperationException: Cross-thread operation not valid: Control 'Screensave...
<p>I would guess that <code>MyContext.curMain</code> refers to a form that was created on another thread than the one that you are currently executing on when trying to close it (the call <code>StartThread();</code> and the exception message indicates that there is some threading going on). All attempts to execute any ...
Retrieving a pixel alpha value for a UIImage <p>I am currently trying to obtain the alpha value of a pixel in a UIImageView. I have obtained the CGImage from [UIImageView image] and created a RGBA byte array from this. Alpha is premultiplied.</p> <pre><code>CGImageRef image = uiImage.CGImage; NSUInteger width = CGImag...
<p>If all you want is the alpha value of a single point, all you need is an alpha-only single-point buffer. I believe this should suffice:</p> <pre><code>// assume im is a UIImage, point is the CGPoint to test CGImageRef cgim = im.CGImage; unsigned char pixel[1] = {0}; CGContextRef context = CGBitmapContextCreate(pixe...
How to use in_array() for caseless? <p>It's a big array, so i won't to strtolower every value.</p>
<p>Use <a href="http://de2.php.net/manual/en/function.preg-grep.php" rel="nofollow"><code>preg_grep</code></a> with the case insensitivity flag “<code>i</code>”:</p> <pre><code>$result = preg_grep('/pattern/i', $array); </code></pre>
Django unit testing with date/time-based objects <p>Suppose I have the following <code>Event</code> model:</p> <pre><code>from django.db import models import datetime class Event(models.Model): date_start = models.DateField() date_end = models.DateField() def is_over(self): return datetime.date.t...
<p><strong>EDIT</strong>: Since my answer is the accepted answer here I'm updating it to let everyone know a better way has been created in the meantime, the freezegun library: <a href="https://pypi.python.org/pypi/freezegun" rel="nofollow">https://pypi.python.org/pypi/freezegun</a>. I use this in all my projects when ...
writing directly to std::string internal buffers <p>I was looking for a way to stuff some data into a string across a DLL boundary. Because we use different compilers, all our dll interfaces are simple char*.</p> <p>Is there a correct way to pass a pointer into the dll function such that it is able to fill the string...
<p>I'm not sure the standard guarantees that the data in a <code>std::string</code> is stored as a <code>char*</code>. The most portable way I can think of is to use a <code>std::vector</code>, which is guaranteed to store its data in a continuous chunk of memory:</p> <pre><code>std::vector&lt;char&gt; buffer(100); Fu...
Is there a quick way to create random development data for a Rails application? <p>I'd like to write a Rake task that will load some development data for my app so I can see what the design looks like in the browser with some data populated in there. I've tried hacking together something using ActiveRecord and the Fake...
<p>Take a look at this screencast by railscasts.com: <a href="http://railscasts.com/episodes/126-populating-a-database" rel="nofollow">http://railscasts.com/episodes/126-populating-a-database</a>.</p>
Performance of nested yield in a tree <p>I've got a tree-like structure. Each element in this structure should be able to return a Enumerable of all elements it is root to. Let's call this method <code>IEnumerable&lt;Foo&gt; GetAll()</code>. So if we have</p> <pre><code> A &lt;-- topmost root / \ B C...
<p>You can improve performance if you unroll recurse to stack, so you will have only one iterator:</p> <pre><code>public IEnumerable&lt;Foo&gt; GetAll() { Stack&lt;Foo&gt; FooStack = new Stack&lt;Foo&gt;(); FooStack.Push(this); while (FooStack.Count &gt; 0) { Foo Result = FooStack.Pop(); ...
DataSet: Enumerator and FindById do not return equal DataRow <p>Today's problem in my code is kind of strange, and I could not reproduce it yet. I'm working with a typed dataset (created with the designer) and I'm looping over all rows in a datatable.</p> <p>Sometimes (!), when finding via primary key, the returned ro...
<p>WHat's the type of you primary key? the DataSet has a subtle bug for comparing Guids (and possibly other values). The Guid error only has to do with certain Guid values and usually works well.</p> <p>note: When I say have a bug, I mean I know that a bug report has been accepted but I don't know if it's been fix as ...
Selecting an element that has a specific class and ID <p>I tried this and it worked in all browsers (IE, FF, Chrome, Opera and Safari):</p> <p>.classname#id</p> <p>Still, I can't find this mentioned anywhere on w3c.org, can you point me to where this is mentioned? I mean if this is supported by all those browsers the...
<p>You can chain CSS selectors, it's just like using H1.title where you chain a type selector (H1) and a class selector (.title). See <a href="http://www.w3.org/TR/css3-selectors/#selector-syntax" rel="nofollow">http://www.w3.org/TR/css3-selectors/#selector-syntax</a></p>
How do you calculate the height of a triangle given only the hypotenuse and the ratio of the other two sides? <p>There are two sorts of TV: Traditional ones that have an aspect ratio of 4:3 and wide screen ones that are 16:9. I am trying to write a function that given the diagonal of a 16:9 TV gives the diagonal of a 4...
<p>Having diagonal and ratio is enough :-).</p> <p>Let d be the diagonal, r the ratio: r=w/h.</p> <p>Then d²=w²+h².</p> <p>It follows r²h²+h²=d². That gives you</p> <p>h²= d² /( r²+1) which you can solve :-).</p>
List of WMIEvent classes <p>Recently I have been learning about WMI and WQL. I found out the list of Win32 classes (from MSDN) that I can query for but I am not able to find out the list of event classes (should be the subset of the list of Win32 classes isn't it ?) Does any one have a list or some kind of cheat sheet ...
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661-8da4-55bbc145c30e&amp;displaylang=en" rel="nofollow">WMI Code Creator</a> is a great tool for learning WMI that, among other things, lets you explore WMI event classes on the local or remote computer and generate code for receiving ...
How can I include the output of a Perl script into a PHP page? <p>We've been asked to support some rather old Perl forms on a new site, as we're using a PHP based CMS we need to include the Perl scripts into our new CMS.</p> <p>I've tried a bit of shell_exec but that's disabled. Has anyone got any ideas?</p>
<h2>Perl extension </h2> <p>There is a Perl extension available for PHP.</p> <p>An article from the Zend developer zone details it <a href="http://devzone.zend.com/article/1712">here</a>.</p> <p>The extension allows you to:</p> <ul> <li>load and execute Perl files</li> <li>evaluate Perl code</li> <li>access Perl va...
How Can I get Text Inside an Element with Children using jQuery <p>I have text stored in a variable which contains several span tags.<br /> I want to get all the contents inside every span at once. How can I do that with jQuery or javascript?</p> <pre><code>&lt;htmlText&gt; Researchthe university has been given a ...
<p><strong>Update:</strong> This solution has been updated following additional questions in the comments:</p> <p>Just grab the .text() property of the parent selector.</p> <pre><code>var myWords = "&lt;span&gt;I&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;like&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;...
SQL ranking solution <p>I am implementing ranking solution for one of my tables to optimize read queries to get rid of expensive queries which use COUNT(*), LIMIT and OFFSET clause. My problem is that I don't know why position calculation are incorrect. Please look at my example to reproduce problem.</p> <pre><code>CR...
<p>You're using too much magic, and trying to use a SQL statement like a conventional loop-based programming language. You need to think of SQL as a <em>declarative language</em>. The rows are evaluated on their own, not relative to which row was evaluated previously. </p> <p>(There are some cases when you can caus...
How do I convert a wav file to mp3 format using sox? <p>When I run sox directly from the command line as ;</p> <pre><code>sox -r 8000 -c 1 &lt;wavfilename&gt; &lt;mp3filename&gt; </code></pre> <p>I get the following error message:</p> <blockquote> <p>sox: Unknown output file format for '747a.mp3': File type 'mp...
<p>You'll need to install an appropriate MP3 encoder, e.g. <a href="http://lame.sourceforge.net/download.php">LAME</a>, or recompile Sox with liblame support.</p> <p>This is independent of your Perl programming :)</p>
Photos and Database <p>I am working on a website, where user can upload photos of product they want to advertise. I am saving photos in a folder on the web. In the table where I keep reference of photos, there is a key field photoid which is Identity field(primary key). </p> <p>My repository has following methods</p> ...
<p>Second approach is definitely more efficient; other option could be to create a unique in your application layer(you can use guids ) and then use this as key DB record and same as file name.</p>