input
stringlengths
51
42.3k
output
stringlengths
18
55k
Identifying characteristics of certain categories network traffic (originating from load balancer or port based NAT) <p>I'm using a sniffer (such as Wireshark) to monitor network traffic.</p> <p>I have no prior knowledge of the network topology. My purpose is to identify IPs as load balancers or NAT entry points.</p> ...
<p>If there is no layer-3 (router) device between your point-of-capture and the balancer/firewall devices are layer-3, you could use the source-MAC to detect where the packets came from.</p> <p>Actually, a lot depends on how the network appears from where you capture the packets.</p> <ul> <li>Are the load-balancers o...
Loading message <p>Searching for a js script, which will show some <strong>message</strong> (something like "Loading, please wait") <strong>until the page loads all images</strong>.</p> <p>Important - <strong>it mustn't use any js framework</strong> (jquery, mootools, etc), must be an ordinary js script.</p> <p>Messa...
<p>Yeah an old-school question! This goes back to those days when we used to preload images...</p> <p>Anyway, here's some code. The magic is the "complete" property on the document.images collection (Image objects).</p> <pre><code>// setup a timer, adjust the 200 to some other milliseconds if desired var _timer = se...
Imprecise numbers with microtime and floating point addition in PHP <p>I'm having a terrible time convincing myself what I've done here is a good idea. The specific section I find objectionable is:</p> <pre><code>return ((float)($now+$sec).'.'.$mic); </code></pre> <p>In order to preserve the floating point precision,...
<p>Why don't you use <a href="http://de.php.net/manual/en/function.microtime.php" rel="nofollow"><code>microtime(true)</code></a> which simply returns a microsecond timestamp as <code>float</code>? The parameter <code>[bool] $get_as_float</code> was added in PHP 5.0.0.</p> <p><strong>Regarding the comment about the "l...
Can you build an iPhone app which has 2.1 as it's target SDK, but uses 3.0 features? <p>I noticed that IM+ came out today and lists it's minimum requirements (in iTunes) as OS 2.2 or later, but they support 3.0 features like push.</p> <p>Is it possible to build an app (eg: one binary) for firmware 2.1 that has feature...
<p>I guess this has been <a href="http://stackoverflow.com/questions/986589/how-do-you-optionally-use-iphone-os-3-0-features-in-a-2-0-compatible-app">answered before</a>.</p>
Simultaneous Java and Scala development within the same project <p>I want to leverage the Scala's Actor Framework while I develop the user interface in the familiar Swing way.</p> <p>Is it possible to have a mixed Java - Scala project in Eclipse, NetBeans or any other IDE?</p>
<p>The "official" Scala plugin for Eclipse allows you to add the "scala nature" to any project, alongside the java nature. This allows you to mix and match however you'd wish.</p> <p>I was playing with scala for the first time last night, using the Eclipse IDE, and it works very well.</p> <p><hr /></p> <p>Also, I ju...
CruiseControlException when connecting to source control <p>I'm getting an exception from Cruise Control about not being able to connect to the server. However, if I force a build it works just fine. I've also tried using the repo-browser to connect to the server without any problems so I know that the server is up and...
<p>I finally got it working again and this is what I've done.</p> <ul> <li>Set maxSourceControlRetries to 10 in my CCNET-config </li> <li>Set sourceControlErrorHandling to ReportOnEveryRetryAmount in my CCNET-config</li> <li>Switched to the latest version of CollabNet client</li> </ul> <p>As it turns out, CCNET swall...
Returning a table type from a PL?SQL function called via JDBC? <p>I've got the following function that I wish to call:</p> <pre><code>CREATE OR REPLACE PACKAGE utils AS TYPE item_list IS TABLE of items.item_id%TYPE; FUNCTION getParentsForItem(p_item_id IN items.items_id%TYPE) RETURN item_list; END utils; </code></p...
<p>After some Google searching, I found <a href="http://www.mail-archive.com/orion-interest@orionserver.com/msg15883.html" rel="nofollow">this example</a>. It makes use of methods exclusive to the Oracle JDBC driver, namely:</p> <ul> <li><a href="http://www710.univ-lyon1.fr/~ecoquery//files/oracle-jdbc/javadoc/oracle/...
Wait for jQuery show() to finish before continuing function? <p>I can't make my div visible with the jquery show() until my function is over! It actually works in IE/FF but not in Chrome. How can I make sure my element is visible before continuing with my function?</p> <p>Here's my code:</p> <pre><code>function doOpe...
<p>Add a callback to show:</p> <pre><code>$("#progressbar_area").show(speed, function() {}); </code></pre> <p>The callback function will be called when the animation is complete.</p>
form validation in django <p>In which file or form should validation code be written ?</p>
<p>In the file where you define the form class.</p> <p>You might want to read the <a href="http://docs.djangoproject.com/en/dev/ref/forms/validation/" rel="nofollow">documentation</a> on form validation. There's a decent example on that page of validation <a href="http://docs.djangoproject.com/en/dev/ref/forms/validat...
Code Layout for getters and setters <p>I am writing a class that has lots of getters and setters and was wondering on what people thought about the following:</p> <p>The normal way is to code like the following:</p> <pre><code>public function setChangeSort($changeSort) { self::$changeSort = $changeSort; } public...
<p>One-line conditional blocks are fine if they're consistent, obvious and intuitive, although I'd encourage spacing them carefully so it's immediately obvious that they are functions rather than some single line of code!</p>
C# enum in interface/base class? <p>i have problem with enum</p> <p>I need make a enum in base class or interface (but empty one)</p> <pre><code>class Base { public enum Test; // ??? } </code></pre> <p>and after make diffrent enums in some parent classes</p> <pre><code>class Parent1 { public enum Test {A,...
<p>There is no such thing as an abstract enum (that can have different implementations in subclasses) - but generics may be an option:</p> <pre><code>class Base&lt;T&gt; where T : struct { private T value; public void Foo(T value) { this.value = value; } } class Parent1 : Base&lt;Parent1.Enum1&gt; ...
ADOQuery, trigger and requery bug <p>I have an ADOQuery that inserts a record to SQL Server 2005 table that has trigger inserting data to another table. I use following code to refresh the query and avoid <code>Row cannot be located for updating</code> (There are PKs on each table, UpdateCriteria property are set, Curs...
<p>I am not familiar with ADOQuery but as you are saying that you are getting an ID of the table affected by trigger while expecting to get ID of the original table perhaps it is a matter of using equivalent function to SQL "scope_identity" See <a href="http://stackoverflow.com/questions/42648/best-way-to-get-identity-...
how to prevent search engine to index only one part of my page <p>what is the best way to do it ?</p> <p>put it in iframe .</p> <p>set this section after load with javascript ?</p> <p>thanks</p>
<p>This is relevant to Yahoo: </p> <p><a href="http://searchengineland.com/yahoo-supports-new-robots-nocontent-tag-to-block-indexing-within-a-page-11120" rel="nofollow">http://searchengineland.com/yahoo-supports-new-robots-nocontent-tag-to-block-indexing-within-a-page-11120</a></p> <p>Loading content by Javascript wo...
User Input filtering in PHP <p>Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT_QUOTES) to process user's posts and comments. </p> <p>Now, i want some certain ht...
<p><strong>solution a)</strong><br /> use strip_tags insted of htmlspecialchars, and whitelist the needed tags.<br /> <strong>better solution b)</strong><br /> Use bbcodes, and give aliases to the wanted tags, e.g: [b]bold[/b]</p>
moving around uploaded files in PHP <p>I need to resize an uploaded image. The class that resizes needs to get the location of the image to be worked with. It returns the image in a variable.</p> <p>However, when I try to get the path to the image, I get from <code>$_FILES['profile_upload']['tmp_name']</code> the foll...
<p>You should complete the whole file upload setup with something similar and then the variable $_FILES['uploadedfile']['name'] will also contain the original file name:</p> <pre><code>$target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES[...
Implementing complex inheritance in C++ <p>I have the following existing classes:</p> <pre><code>class Gaussian { public: virtual Vector get_mean() = 0; virtual Matrix get_covariance() = 0; virtual double calculate_likelihood(Vector &amp;data) = 0; }; class Diagonal_Gaussian : public Gaussian { public: virtua...
<p>Looks good, I think this is a pretty classic implementation of the Adapter pattern. Just don't forget to declare a virtual destructor for your Gaussian class. As for the disadvantages. </p> <ol> <li>The way Java class library deal with the dummy method problem is to create a dummy class that provides empty implemen...
How do I handle drag-and-drop in the designer? <p>I've created a control, <code>DataGridViewContainer</code>, that fakes partial-line scrolling in a <code>DataGridView</code> - basically it's a panel and a scrollbar and a few event handlers. I'd like to be able to use <code>DataGridViewContainer</code> at design time,...
<p>If you want to be able to drag a datagridview (or any other object in fact), your usercontrol needs to be configured to act as a container,</p> <p><a href="http://support.microsoft.com/kb/813450" rel="nofollow">A simple example a control acting as a container</a></p> <p>Alternatively, and what I would reccomend, i...
Entity Framework references not loading automatically <p>In the ADO.Net Entity Framework, I have an object which has 4 references to other objects. For some reason, when I query those references, two of them load automatically (as expected), and two of them always return null.</p> <p>Bizarrely enough, when I <em>manua...
<p>Using ADO.NET Entities, you need to specify what entities you want to load automatically with <code>Include</code>, as in</p> <pre><code>Dim entity = (From e in db.Entities.Include("SubEntity")) </code></pre>
Should one steer clear of adding yet another field to a larger MySQL table? <p>I have a MySQL-InnoDB table with 350,000+ rows, containing a couple of things like id, otherId, shortTitle and so on. Now I'm in need of a Bool/ Bit field for perhaps a couple of hundreds or thousands of those rows. Should I just add that bo...
<p>Adding a field can indeed hamper performance a little, since your table row grow larger, but it's hardly a problem for a <code>BIT</code> field.</p> <p>Most probably, you will have exactly same row count per page, which means having no performance decrease at all.</p> <p>On the other hand, using an extra <code>JOI...
How is a rounded rect view with transparency done on iphone? <p>A lot of apps pop up a transparent view with rounded corners and an activityIndicator when running a time consuming operation.</p> <p>How is this rounding done and is it possible to do it just using Interface Builder (as there are lots of places I'd like ...
<p>As of iPhone SDK 3.0, you can simply use the layer's <code>cornerRadius</code> property. E.g.:</p> <pre><code>view.layer.cornerRadius = 10.0; </code></pre> <p>Along the same lines, you can change the view's border color and width:</p> <pre><code>view.layer.borderColor = [[UIColor grayColor] CGColor]; view.layer.b...
400.0 - Bad Request with MSXML2::IXMLHTTPRequestPtr <p>I'm trying to access an xml file over http. The address is similar to:</p> <pre><code>http://localhost/app/config/file.xml </code></pre> <p>When pasting this in a browser the xml is displayed as expected. In my software I am using:</p> <pre><code>MSXML2::IXMLHTT...
<p>According to this Microsoft knowledge base article you may be experiencing some kind of packet corruption:</p> <blockquote> <p><a href="http://support.microsoft.com/kb/247249" rel="nofollow">Error Message: HTTP/1.1 Error 400 - Bad Request (KB247249)</a></p> </blockquote> <p>Just out of interest, do you experienc...
Siverlight Grid XAML script issue <p>Here is my Siverlight Grid script, I want Media Element mediaPlayer to occupy left half of the whole Grid space, and want Media Element cameraPlayer to occupy right half of the whole Grid space. But my following code does not work quite well (I have set related Grid column/row value...
<p>You need to define your column definitions on your grid.</p> <pre><code>&lt;Grid x:Name="LayoutRoot2" Margin="0" Background="#FF0D0A0A" Cursor="Hand" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="specify width" /...
How to return a collection of strings from C# to C++ via COM interop <p>I hav created a com componet for some Display method in C# it returns a String List</p> <p>as shown below. In v++ i hav used std::lst to catch the return value from Disp() but it </p> <p>gives compiler error that Disp is not a member of class. I ...
<p>This just isn't going to work, even if you fix the typos. COM interop doesn't have a standard mapping from <code>List&lt;T&gt;</code> to something in COM, and it certainly won't map it to <code>std::list</code>. Generics aren't allowed to appear in COM interfaces.</p> <p><strong>UPDATE</strong></p> <p>I tried usin...
Bing architecture and how it works underneath? <p>Could someone please explain how Bing.com works underneath and what is it's architecture?</p> <ol> <li>Implementation (languages used)</li> <li>Brief description of algorithm approach</li> <li>Hardware it runs on</li> <li>Approaches for scalability</li> </ol>
<p>That isn't the type of stuff anybody here can tell you. Even if an employee working on the Bing project were here, there would most certainly be ND's preventing them from discussing it. That being said, if you want to study large-scale search engines, there's a slew of papers available via <a href="http://www.google...
.NET: How to change the value in a DataTable <p>In ADO.NET i'm using <strong><a href="http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdatareader.getschematable.aspx" rel="nofollow">GetSchemaTable</a></strong> to return the schema table for a results set. </p> <pre><code>DataTable schema = rdr.GetSchemaT...
<p>I might be completely off here, but can't you just set the ReadOnly property of the column to false? Like:</p> <pre><code>schema.Columns["ProviderType"].ReadOnly = false; </code></pre> <p>Afterwards you might get a columntype problem as you're trying to put a string value into a integer column. But this should get...
The .NET 'Type' class alternative in Delphi <p>I want to write in Delphi (2009 - so I have generic dictionary class) something similar to that C# code:</p> <pre><code>Dictionary&lt;Type, Object&gt; d = new Dictionary&lt;Type, Object&gt;(); d.Add(typeof(ISomeInterface), new SomeImplementation()); object myObject = d[ty...
<p>For interfaces, you'll want to use a PTypeInfo pointer, which is returned by the compiler magic function TypeInfo. PTypeInfo is declared in the TypInfo unit.</p> <pre><code>type TInterfaceDictionary = TObjectDictionary&lt;PTypeInfo, TObject&gt;; var d: TInterfaceDictionary; myObject: TSomeImplementation; beg...
Saving a file with Javascript in S60v3 mobile browser <p>I'm busy experimenting with <a href="http://tiddlywiki.com/" rel="nofollow">TiddlyWiki</a> and trying to get it to run on my Nokia E51, which uses S60v3. The browser is <a href="http://opensource.nokia.com/projects/S60browser/" rel="nofollow">based on webkit</a>,...
<p>I skimmed through the source of TiddlyWiki. For its file operations it is using the <a href="http://jquery.tiddlywiki.org/twFile.html" rel="nofollow">jQuery.twFile plugin</a> which in turn uses a custom Java applet on Webkit-based browsers. The S60 browser does not support java applets so I'm afraid you're out of lu...
parallel port access in C# .net <p>How can i send and receive data though parallel port using C# .net? Also can u guys please explain how to use parallel port to receive data?</p>
<p><a href="http://www.codeproject.com/KB/cs/csppleds.aspx?df=100&amp;forumid=21021&amp;exp=0&amp;select=974134" rel="nofollow">I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port</a></p>
What is a good (natural-language) naming scheme for belonging or property interfaces <p><em>NOTE: This is <strong>not</strong> the popular interface naming question about using or not using <strong>"I"</strong> at the beginning.</em></p> <p>I encounter often the problem to name an interface, which indicates a belongin...
<p>The problem is the way you choose to describe the "belonging of a property".</p> <p>Most of your examples you gave can be mapped to the other categories you mentioned.</p> <p>Just a few, for example:</p> <p><em>HasListener</em> => implements <strong>Listenable</strong></p> <p><em>ContainsChildren</em> => impleme...
How to Check a Condition in Access Database <p>Using Access Database</p> <p>How to use case condition?</p> <p>My Query</p> <pre><code>Select ID, Name, Intime, case when Outtime=Intime then ‘000000’ else Outtime end as Out from table </code></pre> <p>The above query was accepting in SQL 2000...
<p>I believe you can use the IIF function.</p> <pre><code>Select ID, Name, Intime, IIF(Outtime=Intime,‘000000’,Outtime) as Out from table </code></pre> <p>Taken directly from the documentation:</p> <blockquote> <p>IIf(expr, truepart, falsepart)</p> <p>The IIf function syntax has these arguments </p> </b...
Object does not retrieves from viewstate <p>I am about to gone mad why? why? why?</p> <p>protected void Page_Load(object sender, EventArgs e) { AttachedPartnersViewState vs = ViewState[SessionVariables.Company_AttachedPartnersViewState] as AttachedPartnersViewState;</p> <pre><code>protected override void ...
<p>SaveViewState is before the Render Method. ViewState is encoded and written out to the page to be posted back in. If you add ViewState info after the Render, it is not written back out the the page. Hence it will not be read back in on the postback. Think of ViewState as a hidden input.</p> <p>Links:</p> <p><a...
benchmark and the cause for difference between c# and java <p>I have a puzzling situation and I would need an expert opinion as to the cause of the phenomenon explained below. A couple of weeks ago, I have conducted a session titled "An overview .NET for Java developers" and as a part of it I wrote a quick class C# (3...
<p>For one thing: in Java you're using the platform's default encoding. That may well be a fixed "single byte per character" encoding, which is clearly going to be simpler than using UTF-8, which .NET does by default.</p> <p>In addition, you're writing <em>two</em> newlines in .NET, and only <em>one</em> in Java.</p> ...
Need to display a 'loading' panel on an ASP.NET 2.0-3.5 page <p>I have a page that displays a gridview with some checkboxes and drop-down lists to filter the results. However, the trip to the database to get the data that the gridview binds to can be lengthy.</p> <p>I tried methods from various examples of in-process...
<p>You would probably be best served by loading the page's content (sans grid), then making a remote call to kick off the lengthy retrieval process. <a href="http://encosia.com/2008/02/05/boost-aspnet-performance-with-deferred-content-loading/" rel="nofollow">Here</a> is an article that can help you with the deferred l...
How do you do page performance tests? <p>I know everyone who reads the question will think "Firebug!" right away. Maybe some will think "YSlow!" and "Google Page Speed!"</p> <p>While I really like these tools, I'm more concerned with how the quickly the page will render in IE 6/7/8. All of the above tools require Fire...
<p>I am not sure it is a useful endeavor to optimize for only one vendor:</p> <ul> <li>regarding HTML, most browsers are written to optimize for standard layout techniques (tables, table-less, etc.) </li> <li>the rendering engines are quite different between IE6 and IE8, so already that is like two different browsers...
Eclipse Key Bindings Conflicts <p>I am extending eclipse's platform with my own view. This view contains one action in its toolbar.</p> <p>I want to create a key binding shortcut associated to <kbd>Ctrl</kbd>+<kbd>R</kbd> for this actions. To do that I created a my.context (my context extends org.eclipse.ui.window con...
<p>I am not sure why your context does not isolate your bindings from the eclipse one, but if <code>CTRL+R</code> is already associated with "Run to Line" command, you could simply change its handler by yours, as described in <a href="http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg36457.html" rel="nofoll...
Why does Spotlight sometimes not run my query? <p>I'm playing around with the Spotlight API, both the Carbon and Cocoa versions, and I seem to have the same problem crop up every once in a while: The query <strong>never</strong> runs, and never fires any notifications. However, I want to stress that most of the time it...
<p>I start a Spotlight query in applicationDidFinishLaunching and have no issues so I don't think that is your problem.</p> <p>I have a couple things to try. Rather than passing nil to name in addObserver:selector:name:object try passing NSMetadataQueryDidFinishGatheringNotification for name and make a second call pas...
SQL query result monthly arrangement <p>I have two tables</p> <pre><code>(1) MonthlyTarget {SalesManCode, TargetValue}; (2) MonthlySales {SalesManCode, SaleDate, AchievedValue}; </code></pre> <p>I have to make a query that produces a result like the following table:</p> <pre><code>{SalesManCode, JanTar, JanAch, Fe...
<p>What database are you using? I have a stored procedure that simplifies doing that type of pivot for Microsoft SQL Server 2005 ...</p> <p>If you are using SQL Server 2005:</p> <p>Run this to install the <a href="http://dot-dash-dot.com/files/pivot_query.sql" rel="nofollow">pivot_query procedure</a>.</p> <p>Here i...
When using Sequel ORM; when to use Core or Model? <p>I'm looking to expand my ruby knowledge beyond scripting, test code and file parsers by writing some web services. I'm thinking of using <a href="http://sequel.rubyforge.org/documentation.html" rel="nofollow">sequel</a> as an ORM. </p> <p>What advantages are there t...
<p>Sequel core is more a less a version of SQL in ruby. It's good for reporting, data processing, or when you want to manipulate sets of objects at once.</p> <p>Sequel::Model is an object-relational mapper, allowing you to assign behavior to specific types of rows. If most of your work is dealing with individual row...
Perl loop stuck reading file? <p><strong>Closing this question. Will drink red bull. Sleep. Code and come back with brand spanking new question with unit test cases.</strong></p> <p>UPDATE: The new file is <a href="http://wtfperl.pastebin.com/m50b16ec6" rel="nofollow">here</a></p> <p>Also the config file is <a href="...
<p><strong>FINAL POST FOR THIS QUESTION:</strong> Based on your latest updates, I believe the following code illustrates how there is no problem with using <code>/:/</code> as the first argument to <code>split</code>. It also points out that it is easier to read code when one uses arguments to functions rather than rel...
Labels on both sides of a HSlider or VSlider control <p>Is there some way to have labels on both sides of a VSlider control? </p> <p>I need this to show meters on one side and feet on the other side....</p> <ul> <li>Sami</li> </ul>
<p>I don't believe its possible unless you extend those existing controls.</p>
C# exiting a using() block with a thread still running onthe scoped object <p>What happens to a thread if it is running a method in an object that was freed by exiting a using block?<br/> Example:</p> <pre> using (SomeObject obj = new SomeObject ()) { obj.param = 10 ; Thread newThread = new Thread(...
<p>Interesting things will happen.</p> <p>Specifically, the dispose method on SomeObject will be called, either before or after Work has been called as it may or may not have been scheduled to run by that point. </p> <p>After that, it depends on what the dispose method of SomeObject does; if it, say, releases a SqlCo...
Directshow in C# for windows mobile- strategy? <p>I'm trying to figure out how to add some directshow capabilities to a C# application (.net cf 3.5 running on mobile 6 and up), and I'm having a hard time figuring out how to bridge the gap between using unmanaged c++ class(es) in managed C#.</p> <p>I've already written...
<p>You could probably look at <a href="http://directshownet.sourceforge.net/" rel="nofollow">the desktop DShow.NET library</a> as a guide to porting. Alex Mogurenko's <a href="http://alexmogurenko.com/blog/programming/windows-mobile-how-to-play-audiovideo-c-or-directshownet-cf-part-i/" rel="nofollow">recent blog on pla...
What are the advantages of LePUS3 over UML? <p>When searching online for object oriented concepts such as <a href="http://en.wikipedia.org/wiki/Composite%5Fpattern">the composite design pattern</a> I often found them represented in the LePUS3 notation. I am not really familiar with this modeling language.</p> <p>Is i...
<p>LePUS3 was designed to be an improvement over other modeling languages and is specifically designed to be an enhancement to UML. The benefits of LePUS3 are laid out in <a href="http://www.springerlink.com/content/w74v6u527234031q/">the paper that introduced it</a>, and you can see a summary of these benefits on the ...
Anyway to put Webbrowser control popups inside a new webbrowser instance <p>They reason i want to do this is so that I can actually have some control over the popup because there is a certain button that I'd like to click. </p> <p>Thanks</p> <p>Edit: using windows forms, here is the code for the webbrowser control</p...
<p>If I understand your question...</p> <p>Take a look at the NewWindow2 event. In particular, you want to set the ppDisp parameter to a "new InternetExplorer" object.</p>
Skip projects with ant iterate-projects <p>We have an ant build script which contains this bit:</p> <pre><code>&lt;target name="test"&gt; &lt;antcall target="iterate-projects"&gt; &lt;param name="test-depends" value="false" /&gt; &lt;param name="target" value="test" /&gt; &lt;/antcall&gt; &lt;/target&gt; ...
<p>You can use such technique:</p> <pre><code>&lt;target name="lucene" unless="skip_test"&gt; ... &lt;/target&gt; </code></pre> <p>To skip the target you have to define property</p> <pre><code>&lt;target name="test"&gt; &lt;property name="skip_test" value="true"/&gt; &lt;antcall target="iterate-projects"&gt; ...
What is a good way to find the latest created file in a folder in c#? <p>I have a network folder which can contain up to 10,000 files (usually around 5000).</p> <p>What is the fatest way I can get the filepath of the most recently created file in that folder using c#?</p> <p>Currently I am using the below, but wonder...
<p>Sorting the files is taking you O(nlogn) time. If all you need is the most recently created, it would be faster to just scan through the files and find the most recent---O(n).</p>
Does IE 7 and 8 use Internet explorer event model? <p>I am reading "Javascript The Definitive Guide". In this book, Events and Event handling, there are three event-handling models, the original event model, the standard event model and Internet explorer event model.</p> <p>It says upto IE6 it uses Internet explorer e...
<p>Internet Explorer 7 and 8 continue to stick with the Microsoft event model from IE6, and do not use the W3C event model.</p>
Specifying TkInter Callbacks In Dictionary For Display Launcher Function <p>I am having trouble building a Python function that launches TkInter objects, with commands bound to menu buttons, using button specifications held in a dictionary.</p> <p>SITUATION</p> <p>I am building a GUI in Python using TkInter. I have ...
<p>When your <code>lambda</code> executes is when scope applies, but the issue is a bit subtler.</p> <p>In the first case that <code>lambda</code> is a nested function of <code>launchEmployee</code> so the Python compiler (when it compiles the enclosing function) knows to scan its body for references to local variable...
linq over strings C# <p>Could someone please give an example of how to use ling to query over a long string of text and find a substring within that string?</p> <p>regards</p>
<p>I wouldn't use LINQ, I would use <a href="http://en.wikipedia.org/wiki/Fail-fast" rel="nofollow"><code>String.Substring</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.string.indexof.aspx" rel="nofollow"><code>String.IndexOf</code></a>, or a <a href="http://msdn.microsoft.com/en-us/library/system...
Most efficient way to monitor a queue <p>What is the most efficient way to monitor a queue.</p> <p>The follwoing piece of code is the biggest hog of resources :</p> <pre><code>/// &lt;summary&gt; /// Starts the service. /// &lt;/summary&gt; private void StartService() { while (true) { //the check on c...
<p>You should probably include some type of thread sleep into that method, otherwise its going to be using 100% CPU. Alternatively, you could create a wait handle, and set it when you add a message to the queue.</p>
How can I do this LINQ query on a condition that something not exist in a table? <p>In our database, a file is "Processing" if the column "Pending" is set to false on the FileTable and that files FileID doesn't exist in the Transaction table.</p> <p>How can I construct a LINQ query that basically says,</p> <p>where f...
<p>Use:</p> <pre><code>where !f.Pending &amp;&amp; !db.Transactions.Any(trans =&gt; trans.ID == f.ID) </code></pre> <p>That should work at least <em>logically</em> - you'll have to see whether it generated the right SQL, of course :)</p>
How do I query for entities that are "nearby" with the GeoPt property in Google App Engine? <p>How should I create a GQL query that returns the nearest entities (from my current location) based on their GeoPt property? Should I just created a 'distance' function that calculates for a set of entities with a reasonably ...
<p>App Engine doesn't treat GeoPt properties specially - it has no built in spatial indexing. There are a number of third-party libraries that add support for spatial indexing, however. The best one (in my opinion) being <a href="http://code.google.com/p/geomodel/">geomodel</a>.</p>
How can I get an enum value from its description? <p>I have an enum representing all material assembly codes in the system:</p> <pre><code>public enum EAssemblyUnit { [Description("UCAL1")] eUCAL1, [Description("UCAL1-3CP")] eUCAL13CP, [Description("UCAL40-3CP")] eUCAL403CP, // ... } </code></p...
<p>You'd need to iterate through all the static fields of the enum (that's how they're stored in reflection) finding the Description attribute for each one... when you spot the right one, get the value of the field.</p> <p>For example:</p> <pre><code>public static T GetValue&lt;T&gt;(string description) { foreach...
Does using JRuby mean a duplicate of Ruby on all applications? <p>For example, if I install Rails for regular Ruby, am I required to have a special install of Rails for JRuby? So that I have duplicates for everything?</p>
<p>The simple answer is yes. JRuby represents a separate installation of Ruby on your system so Gems must be installed on both JRuby and Ruby separately.</p>
How to validate hostname (may be IP) and port number (CString) <p>I have an dialog for HTTP proxy configuration with hostname and port edit boxes. </p> <p>My question is how can I validate user input for correct hostname and port?</p> <p>May be I have to use some regular expression for hostname validation or there is...
<ol> <li>Port number is an unsigned short from 1-65535, ports under 1024 are reserved for system services http, ftp, etc.</li> <li>I don't believe that you can <a href="http://en.wikipedia.org/wiki/Hostname#Restrictions%5Fon%5Fvalid%5Fhost%5Fnames">validate host name</a> (or should) especially when you have locallized ...
Simple jQuery ajax example not finding elements in returned HTML <p>I'm trying to learn jQuery's ajax functions. I've got it working, but jQuery doesn't find elements in the returned HTML DOM. In the same folder as jquery, run this page:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:...
<p>I've managed to load snippets off of full html-documents just fine by using <code>.load()</code>.</p> <p>To create a new block with extracted html into the DOM I do this:</p> <pre><code>$('&lt;div&gt;&lt;/div&gt;').appendTo('body').load('some-other-document.html div#contents'); </code></pre> <p>If it's not workin...
Is there a way of writing PDF byte data to an IFrame clientside <p>Odd question I know but say one has PDF byte data contained within a hidden field on a page which also has an IFrame on it.</p> <p>Is there a way of writing the pdf data to the IFrame using JavaScript such that the IFrame will load in the adobe plug-in...
<p>Nope there is no interface that would allow you to this sort of thing in the web-side security sandbox. The reason you aren't just downloading the PDF from the server is?...</p>
How do you implicitly convert a string value to an enumeration using LinqToSql? <p>I asked a <a href="http://stackoverflow.com/questions/1007811/how-do-i-use-my-enumeration-in-a-linqtosql-query">previous question</a> about mapping an enumerated value on a table using LinqToSql and the answer was to use the O/R Designer...
<p>I'd add a getter property to my LINQ to SQL object that looks something like this:</p> <pre><code>public TGender Gender { switch(this.DbGender) { case "M": return TGender.Male; } } </code></pre> <p>Or, if you don't want to use a huge switch statement, you can add an attribute to your enum, t...
Holding the session in Flex <p>I am getting the session generated in Flex Application in a hidden text field, but when i refresh the page it gets back me to login page... </p> <p>How can i hold the session of the page until the browser is not closed... </p> <p>I am getting the session value from PHP.</p>
<p><strong>Good method:</strong> </p> <p>Flash should not have any actions with server sessions (it`s a bad style). Before you show any page (mask it as preloading) you must ask your server for some data. Server already know users and its sessions and must return you the data or an message, probably like this: "user d...
What are the differences between a web service and a Windows service? <p>What are the differences between a web service and a Windows service?</p> <p>My experience has mostly been with Windows services, and I have never created a web service. </p> <p>Do web services behave similarly to Windows services?<br /> Can the...
<p>They're about as different as two things can be.</p> <p>A Windows service is an application that runs without a user being logged into the system, usually to process some data on the machine that needs no user intervention to work with.</p> <p>A Web service is a website that, when contacted, returns XML (typically...
Methods for modular customization of locale messages? <p>There many levels for the customization of programs.</p> <p>First of course is making it <strong>speak your language</strong> by creating i18n messages where tools like gettext and xgettext do a great job.</p> <p>Another comes when you need to <strong>modify th...
<p>In Java, these localized strings are handled by ResourceBundles. ResourceBundles have a concept of variants. For example, you could have a base English resource, called <code>messages_en.propertie</code>s. Then you could customize for a specific variant of English with <code>message_en_US.properties</code> or <code>...
RSA Encryption Failed with Error Code = -2146893819 <p>I'm working on some code that dropped on me when another developer (and the only person who knew anything about this system) left. I'm trying to figure out why my client and server are not connecting. I'm getting the following error:</p> <p>"Genuine channels opera...
<p>Error code -2146893819 is hex 80090005 which, in the MS crypto libraries, is <code>NTE_BAD_DATA</code>.</p> <p>That's about as far as I got before I lost interest (that tends to happen to me a lot with crypto stuff) and it's only slightly more helpful than what you've got, so I've made it community wiki.</p> <p>Yo...
Should Lookup Table Foreign Keys Always be Indexed? <p>If I have a lookup table with very few records in it (say, less than ten), should I bother putting an index on the Foreign Key of another table to which it is attached? For that matter, does the lookup table even need an index on the Primary Key? </p> <p>Specifi...
<p>Yes, always have an index.</p> <p>The query optimizer of a modern database management system (DBMS) will make the determination as to which is faster: (1) actually reading from an index on a column, (2) performing a full table scan.</p> <p>The table size (in number of rows) needs to be "large enough" for use of t...
Remove Invalid data from VarChar column <p>I have a database with a column of VarChar type, within which are integers (which I want to keep) and miscellaneous non-numeric values (which I want to remove). If I alter the table and add a new integer column, how can I copy only the integers into the new integer column? </...
<p>I'd give this a shot (will work with MSSQL, not sure about other database systems)...</p> <pre><code>update MyTable set MyNewIntField = cast(MyOldVarcharField as int) where isnumeric(MyOldVarcharField) = 1 </code></pre>
Oracle Analytic Question <p>Given a function zipdistance(zipfrom,zipto) which calculates the distance (in miles) between two zip codes and the following tables:</p> <pre><code>create table zips_required( zip varchar2(5) ); create table zips_available( zip varchar2(5), locations number(100) ); </code></pre> ...
<p>This is what I came up with :</p> <pre><code>SELECT zr, min_distance FROM (SELECT zr, min_distance, cnt, row_number() over(PARTITION BY zr ORDER BY min_distance) rnk FROM (SELECT zr.zip zr, zipdistance(zr.zip, za.zip) min_distance, COUNT(za.locations) over( ...
Matrix-like Idle Animation for Emacs <p>As is, my emacs is set up to show green text on a black background. On seeing it, a friend remarked that I just took it because of the Matrix-like appearance it gives. So, now what I want to do is implement an idle animation for it where, like in the matrix, changing text falls d...
<p>You might want to check out the package zone: <kbd>M-x zone</kbd></p> <p>The <code>'zone-pgm-drip</code> is like the Matrix drip, only one character at a time. I'm sure it could be enhanced to be more flood like. Also, the <code>'zone-pgm-jitter</code> has text flooding down, but it's just the text currently on t...
load testing with vs2008, how do I get stats from the system under test? <p>When running a webtest or load test on a website using VS2008 Test edition how can I get the CPU etc of the webserver? I am sure I am being very slow here but I cannot work out how to set it up!</p> <p>I can remote onto the webserver if that h...
<p>You can do that by adding the counter sets to your load test. <a href="http://msdn.microsoft.com/en-us/library/ms404676.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms404676.aspx</a></p>
Image diff viewer SVN <p>We use Tortoise SVN for accessing our SVN server. I was wondering if anyone knew of a image diff viewer that would show two revisions of the image side by side to see any any changes. Similar to the TortoiseMerge that's included with it by default, only for image files.</p>
<p><a href="http://tortoisesvn.tigris.org/TortoiseIDiff.html">TortoiseIDiff</a> ?</p>
How to create correctly escaped file:// URI in C#? <p>What would be the correct way to create a fully URL-encoded <code>file://</code> URI from a local path, i.e. where all special characters such as blanks etc are escaped?</p> <p>Given the following input</p> <pre><code>C:\Data\Input Document.txt </code></pre> <p>I...
<p>it is already encoded</p> <p>uri.AbsolutePath should give you <code>"C:/Data/Input%20Document.txt"</code></p>
Performance of Interlocked.Increment <p>Is <code>Interlocked.Increment(ref x)</code> faster or slower than <code>x++</code> for ints and longs on various platforms?</p>
<p>It is slower since it forces the action to occur atomically and it acts as a memory barrier, eliminating the processor's ability to re-order memory accesses around the instruction.</p> <p>You should be using Interlocked.Increment when you want the action to be atomic on state that can be shared between threads - it...
Copy source control history when I branch, then delete trunk, in TFS <p>I have a TFS project that ought to be a folder under another project, so I want to move the source control history (We don't use the other features of TFS for this project, so I don't care about the project site). I've branched the code into the ne...
<p>My recommendation is to use the Move (aka rename) feature. All history will be preserved in-place. And you can still recreate old builds in the other project by sync'ing back to the appropriate version.</p> <p>If you do decide to Branch, it doesn't matter whether you delete the original source or not. Nothing in...
wxPython: how to search for text in a TextCtrl? <p>I feel like I must be missing something completely obvious, but I don't see how to search for text in a multi line textctrl. Is there an API for searching forwards and backwards through a text control?</p> <p>I do not want suggestions involving the FindReplaceDialog, ...
<p>I think you're expected to get the text using <a href="http://docs.wxwidgets.org/stable/wx%5Fwxtextctrl.html#wxtextctrlgetvalue" rel="nofollow">GetValue</a> and search it as a string.</p>
Why does Maven javadoc fail with error "cannot read options"? <p>When I run <code>mvn javadoc:javadoc</code>, I get the following error:</p> <pre> [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] An error has occurred in JavaDocs report generation:Exit code: 1 ...
<p>I figured it out, but first I tried various things:</p> <ul> <li>Uninstalling every JDK and JRE on my system, and then reinstalling Java to a path with no spaces</li> <li>Removing every environment variable I wasn't using, and cleaning up my PATH</li> <li>Relocating Maven and my local repo to directories with no sp...
Anyone know a YUI-based Image Magnifier? <p>Does anyone know of a YUI-based image magnifier?</p> <p>I'm looking for something similar to the JQuery <a href="http://www.mind-projects.it/projects/jqzoom/demos.php#demo1" rel="nofollow">"JQZoom" plugin</a>. </p> <p>Mousing over the image displays the matching portion of ...
<p>Have a look at this one: <a href="http://www.julienlecomte.net/blog/2007/08/9/" rel="nofollow">http://www.julienlecomte.net/blog/2007/08/9/</a></p> <p>Doesn't exactly do the same as that jQuery plugin (magnification box is directly over the original image, like a lens, rather than being in a separate box)</p>
Authlogic and Namespace in Rails <p>Does anyone have an example of setting up Authlogic with a namespace in Rails? I have an "admin" namespace, which contains many "admin" related controllers (products, categories, etc.).</p> <pre><code>map.namespace :admin do |admin| admin.resources :products, :active_scaffold =&...
<p>The resource user_sessions shouldn't be in your admin namespace.</p>
Dynamic class creation in Objective-C <p>Is there an equivalent of selectors for classes? How can I create a instance of a class from a string?</p>
<p>You want <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation%5FFunctions/Reference/reference.html#//apple%5Fref/c/func/NSClassFromString" rel="nofollow"><code>NSClassFromString</code></a>.</p> <pre><code>NSString *theClassForMe = @"NSMutableArray"; id...
How to save portlet positions <p>I will be using jQuery's functionality to create portlet widgets for my web application suit. I haven't started as of yet, but will do soon, so this is the planning</p> <p>Now, currently, the page loads, and the widgets load into their default positions. A user can move them around, ch...
<p>The general plan would be to do something like this</p> <p><strong>in jQuery</strong></p> <p>on widget drop ajax POST to /widget.php with position info(maybe container name + item index) ('leftBar',3), maybe account # that is specific to user, as well as the identifier for the module</p> <pre><code>$.post("widget...
mysql search prepending "the" or "and/&" ambiguity <p>I'm trying to do a title search in mysql across two different databases to match up data from seperate sources. In both db1 or db2, the titles will sometimes start with "The first title" in one db, and just "first title" in the other db, or "far and away" vs "far &a...
<p>Do you have the luxury of a preprocessing step? If you do, you might consider canonicalizing the titles on the two databases before comparing them.</p>
how to make transparent background with freeimage? <p>I use freeimage.net in my web project. I rotate a picture(.jpg) with RotateClassic function,but after that the background is black. How to make it transparent? thanks for any help.</p>
<p>You need to check out the CSS opacity property.</p> <p><a href="http://webdesign.about.com/od/css3/a/aa121306.htm" rel="nofollow">http://webdesign.about.com/od/css3/a/aa121306.htm</a></p>
What's the equivalence of an SQL WHERE in Lambda expressions? <p>Here's what I have:</p> <pre><code>decimal sum = _myDB.Products.Sum(p =&gt; p.Price).GetValueOrDefault(); </code></pre> <p>I also have two dates: <code>DateTime start</code>, <code>DateTime end</code><br/> I want to retrieve the sum of all of the produc...
<p>Use <a href="http://msdn.microsoft.com/en-us/library/bb534803.aspx" rel="nofollow">Enumerable.Where</a></p> <pre><code>decimal sum = _myDB.Products .Where(p =&gt; (p.Date &gt;= start) &amp;&amp; (p.Date &lt;= end) ) .Sum(p =&gt; p.Price) .GetValueOrDefault();...
Dozer object on GAE/J <p>I'm trying to write application using GWT and GAE/J (Google AppEngine with Java). For my application i need to use DTO. In order to convert Pojo into JDO Entities I want to use <a href="http://dozer.sourceforge.net" rel="nofollow">Dozer library</a>. So when i'm trying to convert object I'm gett...
<p>I am not familiar with GAE/J, but the error (NoClassDefFoundError) definitely tells you the class loader cannot find the dozer class. Are you sure it's on the classpath? What happens if you try to run the same line:</p> <p><code>Mapper mapper = new DozerBeanMapper();</code></p> <p>outside of your container, just f...
Java's >> versus >>> Operator? <p>I'm without my Java reference book and I'm having a tough time finding an answer with Google.</p> <p>What is the difference between the ">>" and ">>>" operators in Java?</p> <pre><code>int value = 0x0100; int result = (value &gt;&gt; 8); System.out.println("(value &gt;&gt; 8) = " + ...
<p>Signed integers use the high-order bit to denote sign.</p> <p>So <code>&gt;&gt;</code> preserves the sign, while <code>&gt;&gt;&gt;</code> doesn't. This is why <code>&gt;&gt;</code> is referred to as the <em>arithmetic</em> shift and <code>&gt;&gt;&gt;</code> is the <em>logical</em> shift.</p> <p>This way, you can...
Saving JPEG screenshot as a BYTE buffer in C <p>In one of my previous questions I asked how to take a screenshot and save it as JPEG without the use of GDI+ due to the constrains of having to use only C. At the end I answered the question myself with the help of of some of the comments there. Using a very terse C vers...
<p>Instead of calling GdipSaveImageToFile, you should use GdipSaveImageToStream. This will let you save the image into a stream directly, instead of writing it to a file.</p> <p>See the <a href="http://msdn.microsoft.com/en-us/library/ms534041.aspx" rel="nofollow">GDI image functions</a> for details.</p> <p>In order...
applescript - quicktime export to image sequence problem <p>I am trying to export a snapshot of a movie using Quicktime. This is the code that does the snapshot: </p> <pre><code>export document 1 to file target_file as image sequence using settings "JPEG, 10 fps" </code></pre> <p>This saves the image as PNG rather a ...
<p>Setting according to the QuickTime Player dictionary is expecting a file (specifically a <code>.qtes</code> or <code>.set</code> file) containing the settings.</p> <p>You can save a .qtes file of your most recently used <em>Image Sequence</em> settings by using the following AppleScript:</p> <pre><code>set file2sa...
SOAP servers and clients with Zend framework (Getting errors) <p>I am testing a server and client i made on my webspace.</p> <p>when i try to call a simple "testServer" function defined in a ServerMap class, I get "Looks like we got no XML document"</p> <p>..?</p> <p>I called getFunctions on the client and testServe...
<p>If you are outputting to the browser, it is hiding the xml cause it is in a . Browsers ignore tags they don't understad.</p> <p>Do a echo htmlentities($output); to see the xml tags.</p>
Segmentation fault operating a camera with MATLAB <p>I am using Matlab to operate a camera. It is an IDT SharpVision camera, and I am using the Matlab interface provided by the company. When I try to acquire an image, I get a segmentation fault. I have tried preallocating memory by creating an empty array for the im...
<p>This sounds like a driver issue since the fault is occurring here:</p> <p>QCamChildDriver.dll:0x160fdde4(0x0f99ef08, 15, 0x00ced938, 0x00ced938)</p> <p>One possible issue - the driver might be in conflict with your OS, especially if you are running Vista or any 64 bit OS.</p> <p>If it is a driver issue, you might...
Best way to learn how to combine Blueprintcss and Compass/Sass? <p>I would like to apply Blueprintcss and Compass/Sass to a Rails project.</p> <p>Should I learn Blueprint first or Compass/Sass first or are there any guides on how to use the two of these together?</p> <p>Also, does it make any difference that it's a R...
<p>When I first encountered Compass, I knew neither Compass nor Blueprint. I started out by watching the Compass <a href="http://vimeo.com/4335944" rel="nofollow">screencast</a> and then by trying to use it. As Sass is similar to CSS (CSS on steroids ;-)), I was able to get working real soon. Having the <a href="http:/...
How can I randomly sample the contents of a file? <p>I have a file with contents</p> <pre><code>abc def high lmn ... ... </code></pre> <p>There are more than 2 million lines in the files. I want to randomly sample lines from the files and output 50K lines. Any thoughts on how to approach this problem? I was thinking...
<p>Assuming you basically want to output about 2.5% of all lines, this would do:</p> <pre><code>print if 0.025 &gt; rand while &lt;$input&gt;; </code></pre>
What would be a good naming guideline to use in Asynchronous Programming Model? <p>I am doing some refactoring on a piece of code to transform all blocking operations to their async counterparts. My code is in C# and is doing an UPnP query followed by an HTTP query. For this, I use the APM methods of UdpClient and WebC...
<p>To express to client code what the intention of your code is, i would prefix all methods that have async behaviour with <code>run</code>. Eg: <code>runSOQuery</code>, <code>runDiskCheck</code> and so on. </p> <p>Maybe stupid but even clearer to client code could be <code>fireAndForget</code>, but not sure if I unde...
How do I debug wireless problems on a mobile app when it has to be wired to run in debug mode? <p>I'm trying to track down some bugs on a Windows Mobile 5.0 app. The testers can reproduce these bugs no problem, but I can't. They are using the devices across a wireless network, but I'm always running the app in an emu...
<p>You can get the debugger working over the wireless by <a href="http://msdn.microsoft.com/en-us/library/ms228708.aspx" rel="nofollow">manually running conmanclietn2.exe and cmaccept.exe</a>, but the fact that the debugger is then using the connection may well affect your testing (depends on what the issues you're try...
Choose between datatypes and call matching methods? <p>Here is what I am trying to do:</p> <pre><code>if (a==true) { dbA objectInstance = new dbA(); } else { dbB objectInstance = new dbB(); } objectInstance.Name = "New name"; </code></pre> <p>I get "the name objectInstance does not exist in the current cont...
<p>Yes, <code>dbA</code> and <code>dbB</code> would need a common base class or interface and that base class or interface would need to have the <code>Name</code> property as part of its public contract.</p> <p>Then you could do this:</p> <pre><code>SomeBase objectInstance; if (a==true) { objectInstance = new ...
Near-Duplicate Image Detection <p>What's a fast way to sort a given set of images by their similarity to each other. </p> <p>At the moment I have a system that does histogram analysis between two images, but this is a very expensive operation and seems too overkill. </p> <p>Optimally I am looking for a algorithm that...
<p>There has been a lot of research on image searching and similarity measures. It's not an easy problem. In general, a single <code>int</code> won't be enough to determine if images are very similar. You'll have a high false-positive rate.</p> <p>However, since there has been a lot of research done, you might take a ...
Best way to combine fragment and object caching for memcached and Rails <p>Lets say you have a fragment of the page which displays the most recent posts, and you expire it in 30 minutes. I'm using Rails here.</p> <pre><code>&lt;% cache("recent_posts", :expires_in =&gt; 30.minutes) do %&gt; ... &lt;% end %&gt; </code...
<p>Evan Weaver's <a href="http://github.com/fauna/interlock/tree/master">Interlock Plugin</a> solves this problem. </p> <p>You can also implement something like this yourself easily if you need different behavior, such as more fine grained control. The basic idea is to wrap your controller code in a block that is only...
ASP.Net MVC: File Structure, Controllers, and Views: How do I separate admin from rest? <p>Basically how can I get this:</p> <p>sitename/Admin/Forum/Index versus sitename/Forum/Index</p> <p>Background: To learn MVC I've taken on creating a cheesy forum application. Before knowing anything about MVC I just jumped rig...
<p>I think that your admin or console web application should always go into its own project. This way you can have more control if ever it is to be deployed to an intranet setting, if you need to hide certain functionality from your main site, etc. Co-mingling these two concerns under one site rarely ends up being a ...
Flex AdvancedDataGrid databind complete event <p>Is there some way in Flex where I can tell when all of the data has finished binding to my AdvancedDataGrid? I have a bunch of label functions that run and I need to a busy cursor while the grid gets populated. I then want to remove it when it's all done. And also fire a...
<p>Okay, I figured it out myself. The updateComplete event gets triggered every time the grid datasource gets updated.</p>
What is the time complexity of 'assoc' function in scheme? <p>What is the time complexity of this nifty function 'assoc'?</p>
<p>I would assume that <code>assoc</code> is O(n)*, assuming that <code>equal?</code> is O(1) in your usage of the function. This is because it's trivial to write your own version of <code>assoc</code>:</p> <pre><code>(define (my-assoc v lst) (cond ((null? lst) #f) ((equal? v (caar lst)) (car lst)) (...
Reading binary file in Python and looping over each byte <p>In Python, how do I read in a binary file and loop over each byte of that file?</p>
<pre><code>f = open("myfile", "rb") try: byte = f.read(1) while byte != "": # Do stuff with byte. byte = f.read(1) finally: f.close() </code></pre> <p>By suggestion of chrispy:</p> <pre><code>with open("myfile", "rb") as f: byte = f.read(1) while byte != "": # Do stuff with...
Count the <li>s in a <ul> with jQuery <p>I have a simple list like this:</p> <pre><code>&lt;ul id="cyclelist"&gt; &lt;li&gt;Item 1&lt;/li&gt; &lt;li&gt;Item 2&lt;/li&gt; &lt;li&gt;Item 3&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>and I am using jQuery to cycle through the list. The first problem is finding if t...
<p>Try <code>$('#cyclelist li').length</code></p> <p>The problem is that $('#cyclelist') only has one element--the unordered list as a whole. If you want to know the number of list items in your unordered list, you can just add the additional selector 'li'. </p>
Can a many-to-many join table have more than two columns? <p>I have some tables that benefit from many-to-many tables. For example the team table.</p> <p>Team member can hold more than one 'position' in the team, all the positions are listed in the position db table. The previous positions held are also stored for thi...
<p>Yes, a many-to-many junction table can have additional attributes (columns).</p> <p>For example, if there's a table called PassengerFlight table that's keyed by PassengerID and FlightID, there could be a third column showing the status of the given passenger on the given flight. Two different statuses might be "co...
How best to use ViewerFilter on a TreeViewer? <p>I am applying a <code>ViewerFilter</code> to a tree of a few branches, but mostly leaves. The filter really applies to the leaves, using properties within the leaf. All branches are left untouched so that their leaves can appear.</p> <p>However I would like to filter ou...
<pre class="lang-java prettyprint-override"><code>class MyFilter extends ViewerFilter{ private boolean isLeaf(Object element){ // implement this } private boolean isEvenLeaf(Object leaf){ // implement this } @Override public boolean select(Viewer viewer, Object parentElement, Object element){ ...