input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Ant and the available task - what if something is not available? <p>When I use the task, the property is only set to TRUE if the resource (say file) is available. If not, the property is undefined.</p>
<p>When I print the value of the property, it gives true if the resource was available, but otherwise just prints th... | <p>You can use a condition in combination with not:</p>
<p><a href="http://ant.apache.org/manual/Tasks/condition.html">http://ant.apache.org/manual/Tasks/condition.html</a></p>
<pre><code> <condition property="fooDoesNotExist">
<not>
<available filepath="path/to/foo"/>
</not>
... |
Why shouldn't Helpers have html in them? <p>I have heard that it's best not to actually have any html in your helpers; my question is, Why not? And furthermore, if you were trying to generate an html list or something like that, how can I avoid actual tags?</p>
<p>Thanks!</p>
<p>-fREW</p>
| <p>My advice - if it's small pieces of HTML (a couple of tags) don't worry about it. More than that - think about partials (as pulling strings of html together in a helper is a pain that's what the views are good at).</p>
<p>I regularly include HTML in my helpers (either directly or through calls to Rails methods like... |
Running subversion under apache and mod_python <p>My Apache server runs on some non-default (not-root) account. When it tries to run a python script which in turn executes a subversion check-out command, 'svn checkout' fails with the following error message:</p>
<pre><code>svn: Can't open file '/root/.subversion/serve... | <p>It sounds like the environment you apache process is running under is a little unusual. For whatever reason, svn seems to think the user configuration files it needs are in /root. You can avoid having svn use the root versions of the files by specifying on the command line which config directory to use, like so:</... |
Reddit's commenting system (hierarchial) <p>For those of you who have looked at Reddit's source code, where exactly is the logic where it manages the comments hierarchial structure?</p>
<p>I downloaded the code, but couldn't even find the database structure let alone where the reads and writes are for the commenting.<... | <p>The class definition for the Comment model is in <a href="https://github.com/reddit/reddit/blob/master/r2/r2/models/link.py#L591" rel="nofollow">r2/models/link.py</a> .</p>
|
What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net? <p>What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net?</p>
| <ul>
<li><a href="http://www.castleproject.org/projects/dynamicproxy/" rel="nofollow">DynamicProxy</a> from Castle is
probably the most used tool for
doing AOP on the CLR.</li>
<li><a href="http://www.springframework.net/docs/1.2.0-M1/reference/html/aop.html" rel="nofollow">Spring framework</a> also offers
AOP capabili... |
What's the best practice to fork an open source project? <p>I need to customize an open-source project. The changes are for a specific organization and will not be useful to the public project. The code changes include disabling features not needed by the organization (affecting 5% of the code), customizing other featu... | <p>The best thing to do is not to fork it. Why not figure out how to improve it so it will do what you want it to do and not lose any existing functionality. If code size is an issue, maybe you can spend some of the time you would spend forking it on improving the existing projects efficiency.</p>
|
Sharepoint: How to set the permission to edit WSS user profile <p>I'm running a SharePoint Application on a MOSS 2007 with a form based user authentication without using the MySite feature. So all the settings on the SSP administration site which only concern the user profile on the MySites should normally not affect t... | <p>Those things are handled by your shared service provider. So gå there then:</p>
<p>User profiles and properties -> View profile properties</p>
<p>You can also do all sorts of other stuff regarding profiles, mysites, etc there.</p>
|
Where to put controller parent class in CakePHP? <p>I have two controllers which share most of their code (but must be, nonetheless, different controllers). The obvious solution (to me, at least) is to create a class, and make the two controllers inherit from it. The thing is... where to put it? Now I have it in app_co... | <p>In cake, components are used to store logic that can be used by multiple controllers. The directory is /app/controllers/components. For instance, if you had some sharable utility logic, you would have an object called UtilComponent and a file in /app/controlers/components called UtilComponent.php. </p>
<pre><cod... |
Source Control for multiple projects/solutions with shared libraries <p>I am currently working on a project to convert a number of Excel VBA powered workbooks to VSTO solutions. All of the workbooks will share a number of class libraries and third party assemblies, in fact most of the work is done in the class librari... | <p>You don't mention in your question what source control you are using. As it doesn't sound like you need to limit your outside developers access to the rest of the repository I would not bother with setting up multiple repositories. I would assume that unless your code runs into the millions of lines size that reposi... |
Show weights in JgraphT <p>I have implemented this Graph: </p>
<pre><code>ListenableDirectedWeightedGraph<String, MyWeightedEdge> g =
new ListenableDirectedWeightedGraph<String, MyWeightedEdge>(MyWeightedEdge.class);
</code></pre>
<p>In order to show what the class name says; a simple listenable dir... | <p>I assume that the class MyWeightedEdge already contains a method such as </p>
<pre><code>public void setWeight(double weight)
</code></pre>
<p>If this is indeed the case, then what you need to do is:</p>
<p>Derive your own subclass from <em>ListenableDirectedWeightedGraph</em> (e.g., <em>ListenableDirectedWeighte... |
Integrate StackOverflow into IDEs? <p>Okay, this is just a crazy idea I have. StackOverflow looks very structured and integrable into development applications. So would it be possible, even useful, to have a StackOverflow plugin for, say, Eclipse? </p>
<p>Which features of StackOverflow would you like to have directly... | <p>Following up on Josh's answer. This VS Macro will search StackOverflow for highlighted text in the Visual Studio IDE. Just highlight and press Alt+F1</p>
<pre><code>Public Sub SearchStackOverflowForSelectedText()
Dim s As String = ActiveWindowSelection().Trim()
If s.Length > 0 Then
DTE.ItemOperat... |
Applescriptable mySQL client - low cost or free? <p>Can anyone recommend a MySQL front end client or OS X that is AppleScriptable? Preferably low cost or free.</p>
| <p>I would suggest just using the command-line mysql client and using the <code>do shell script</code> command in applescript to invoke it:</p>
<pre><code>do shell script "mysql -e 'select * from customer'"
</code></pre>
|
How to search through archived files with Perl <p>What is your preferred method for reading through the contents of zipped directories with Perl ?</p>
| <p>There are several modules on CPAN for working with various archive formats (zip, tar, etc.), the one you're probably after is <a href="http://search.cpan.org/~adamk/Archive-Zip-1.24/lib/Archive/Zip.pm" rel="nofollow">Archive::Zip</a>.</p>
|
DataGrid Edit Problem <p>I have a DataGrid, with an ItemTemplate that has an image and label. In the EditItemTemplate the label is replaced by a textbox. My problem is that the edit template only shows when I click the Edit button the second time. What gives?</p>
| <p>Make sure you check for Page.IsPostback before binding your datagrid. It may be the case that you are binding during every page load.</p>
<pre><code>If Not Page.IsPostBack() Then
DoDataBinding()
End If
</code></pre>
|
What is a good alternative for SourceSafe on a USB Drive? <p>I like to keep my source files on a USB drive for the portability. To date I have been using Visual SourceSafe for this purpose. What is a good alternative to VSS that fulfils these criteria:</p>
<ul>
<li>Entire database can be held on a USB "pen" drive</li>... | <p>I would use SVN (Subversion). </p>
<p>You can use SVN in "file" mode (w/o using the network).
combine this with tortoiseSVN, which integrates to explorer, and you have a nice little portable repository.</p>
<p>For Visual Studio integration, there is the commercial($49) VisualSVN (which I believe is the setup used... |
How to prevent blank xmlns attributes in output from .NET's XmlDocument? <p>When generating XML from XmlDocument in .NET, a blank <code>xmlns</code> attribute appears the first time an element <em>without</em> an associated namespace is inserted; how can this be prevented?</p>
<p>Example:</p>
<pre><code>XmlDocument x... | <p>Thanks to Jeremy Lew's answer and a bit more playing around, I figured out how to remove blank <code>xmlns</code> attributes: pass in the root node's namespace when creating any child node you want <em>not</em> to have a prefix on. Using a namespace without a prefix at the root means that you need to use that same ... |
How can I script a no-cost notification of batch file errors/returns? <p>I have a problem with stopping a service and starting it again and want to be notified when the process runs and let me know what the result is. </p>
<p>Here's the scenario,
I have a text file output of an "sc" command. I want to send that file ... | <p>Here's how I'm doing this.
First I got <a href="http://blat.net" rel="nofollow">blat mail</a> (public domain smtp mailer) and dropped it into d:\blat directory. My Exchange server allows me to email without id/password and just assumes that I am the person in the 'from' field of the blat command.</p>
<pre><code>@e... |
Advantages to Using Private Static Methods <p>When creating a class that has internal private methods, usually to reduce code duplication, that don't require the use of any instance fields, are there performance or memory advantages to declaring the method as static?</p>
<p>Example:</p>
<pre><code>foreach (XmlElement... | <p>From the <a href="http://msdn.microsoft.com/en-us/library/ms245046.aspx">FxCop rule page</a> on this:</p>
<blockquote>
<p>After you mark the methods as static, the compiler will emit non-virtual call sites to these members. Emitting non-virtual call sites will prevent a check at runtime for each call that ensures... |
Semantic merge tool <p>Background: In my job, we use SVN, C# and VisualStudio. Part of my task regularly involves global renames. Often I end up with a broken build after renaming something and then merging in changes.</p>
<p>The question: is there a solution out there that can look at my changes, notice the global re... | <p>There is a commercial tool for exactly that use case called <a href="http://www.semanticmerge.com/" rel="nofollow">Semantic Merge</a>. They provide a 15-day free trial, open source projects may use it for free (<a href="http://www.semanticmerge.com/pricing.html" rel="nofollow">contact the support</a>).</p>
|
Mathematica Downvalue Lhs <p>Does anybody know if there is a built-in function in Mathematica for getting the lhs of downvalue rules (without any holding)? I know how to write the code to do it, but it seems basic enough for a built-in</p>
<p>For example:</p>
<pre><code>a[1]=2;
a[2]=3;
</code></pre>
<p><code>BuiltI... | <p>This is like <code>keys()</code> in Perl and Python and other languages that have built in support for hashes (aka dictionaries). As your example illustrates, Mathematica supports hashes without any special syntax. Just say <code>a[1] = 2</code> and you have a hash. [1]
To get the keys of a hash, I recommend addin... |
Will my index be used if all columns are not used? <p>I have an index on columns A, B, C, D of table T</p>
<p>I have a query that pulls from T with A, B, C in the WHERE clause.</p>
<p>Will the index be used or will a separate index be needed that only includes A, B, C?</p>
| <p>It depends!</p>
<pre><code>WHERE A like '%x%'
and B = 1
and C = 1
//
WHERE A = 1
OR B = 1
OR C = 1
//
WHERE DateAdd(dd, 1, A) = '2008-01-01'
AND B = 1
AND C = 1
</code></pre>
<p>These will not rely on the index, because the index is not useful.</p>
<p>Click on "display estimated execution plan" to con... |
Tips for budgeting QA hours <p>Sometimes for QA it gets difficult to budget and track the QA hours as a person can spend enormous amount of time retesting the defects and performing regression if any. We can take ,as an example, a web application with 50 use cases. </p>
<p>What are some tips for budgeting QA hours?</p... | <p>Past history is a good indication of future performance. How long did the last regression take?</p>
|
Reproducing the blocked exe "unblock" option in file properties in windows 2003 <p>When I download my program from my website to my windows 2003 machine, it has a block on it and you have to right click on the exe, then properties, then select the button "Unblock".</p>
<p>I would like to add detection in my installer ... | <p>This is done using NTFS File Streams. There is a stream named "Zone.Identifier" added to downloaded files. When IE7 downloads certain types of file that stream contains:</p>
<pre><code>[ZoneTransfer]
ZoneId=3
</code></pre>
<p>The simplest way to set it is to create a text file with those contents in it, and use mo... |
Structure of projects in version control - .NET specific <p>This post is similar to <a href="http://stackoverflow.com/questions/16829/structure-of-projects-in-version-control">this previously asked question.</a> I really want to set up my SVN repository in TTB format, but when creating a project in Visual Studio 2008 ... | <p>We went with a very simplistic approach:</p>
<p><strong>File Structure:</strong></p>
<ul>
<li>Solution Folder (contains solution file, build scripts, maybe more?)
<ul>
<li>Project Folder</li>
<li>Project Folder 2</li>
<li>References (contains shared assemblies for the solution).</li>
</ul></li>
</ul>
<p>Then we j... |
What are the different types of indexes, what are the benefits of each? <p>What are the different types of indexes, what are the benefits of each?</p>
<p>I heard of covering and clustered indexes, are there more? Where would you use them?</p>
| <ul>
<li>Unique - Guarantees unique values for the column(or set of columns) included in the index</li>
<li>Covering - Includes all of the columns that are used in a particular query (or set of queries), allowing the database to use only the index and not actually have to look at the table data to retrieve the results<... |
Prevent visual studio creating browse info (.ncb) files <p>Is there a way to prevent VS2008 creating browse info file files for C++ projects.<br />
I rarely use the class browser and it isn't worth the time it takes to recreate it after every build, especially since it runs even if the build failed.</p>
<p>EDIT - it's... | <p>In the project properties, you will find the browse information under:</p>
<p>Configuration Properties -> C/C++ -> Browse Information</p>
<p>Just tell it not to generate browse information. All it is used for is quickly browsing between code components (like using 'Go to Definition') and so forth. I personally l... |
What is the best approach to centralzing error messages in an application? <p>All throughout an application wherever error messages (or other user messages) are used I typically hard-code a string. Obviosly this can be really bad (especially when you may have to come back and localize an app). What is the best approach... | <p>Create the strings in a resource file. You can then localise by adding additional resource files.</p>
<p>Check out <a href="http://geekswithblogs.net/dotNETPlayground/archive/2007/11/09/116726.aspx" rel="nofollow">http://geekswithblogs.net/dotNETPlayground/archive/2007/11/09/116726.aspx</a></p>
|
How to configure Tomcat JULI logging to roll log files? <p>I have a several webapps which use java.util.logging. Tomcat 5.5 is configured to use the Juli logger so that each webapp has its own log file. The problem is that Juli does not have properties for maximum file size and file count. Using Juli the files will ... | <p><strong>Update:</strong> I see your point now after reading more. "Tomcat's JULI implementation is not intended to be a fully-featured logging libary, only a simple bridge to those libraries. However, JULI does provide several properties for configuring the its handlers. These are listed below." Funny that they say... |
Does XSLT have a Split() function? <p>I have a string in a node and I'd like to split the string on '?' and return the last item in the array.</p>
<p>For example, in the block below:</p>
<pre><code><a>
<xsl:attribute name="href">
/newpage.aspx?<xsl:value-of select="someNode"/>
</x... | <p>Use a recursive method:</p>
<pre><code><xsl:template name="output-tokens">
<xsl:param name="list" />
<xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />
<xsl:variable name="first" select="substring-before($newlist, ' ')" />
<xsl:variable name="r... |
How to have a Label inherite a Composite's GC in SWT <p>I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites. </p>
<p>I wrote the following code:</p>
<pre><code>composite.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event e) {
... | <p>Use <strong>composite.setBackgroundMode(SWT.INHERIT_DEFAULT)</strong>, but do not paint the composite directly - paint an image and set it as the background image using <strong>composite.setBackgroundImage(Image)</strong>. Unless I'm missing a trick, this means you only have to regenerate the image when the composit... |
Long compile times and lost productivity <p>How long can a compile time get before it starts becoming a <a href="http://xkcd.com/303/">distraction</a> to you?</p>
<p>For me:</p>
<ul>
<li><1 sec, I don't notice</li>
<li>>1 min, I'm going for coffee</li>
<li>>10 min, S.O. here I come</li>
</ul>
<p>(any other progra... | <p>Certainly its never short enough not to <a href="http://xkcd.com/303/" rel="nofollow">distract me from working</a>.</p>
|
How to check for null values before doing .AddDays() in SSRS? <p>I have the following as the value for my textbox in SSRS report: </p>
<pre><code> =iif(IsNothing(Fields!MyDate.Value), "", Format(Fields!MyDate.Value.AddDays(30), "MMMM dd, yyyy"))
</code></pre>
<p>It gives me an "#Error" every time MyDate is null.</... | <p>The problem, of course, is that VB's IIF statement evaluates both sides regardless of the outcome. So even if your field is null it's still evaluating the "Value.DateAdd" call.</p>
<p>If I recall correctly, SSRS has its own "DateAdd" function that you can use instead. So you can do something like this (check the do... |
Sell me on const correctness <p>So why exactly is it that it's always recommended to use const as often as possible? It seems to me that using const can be more of a pain than a help in C++. But then again, I'm coming at this from the python perspective: if you don't want something to be changed, don't change it. S... | <p>This is the definitive article on "const correctness": <a href="https://isocpp.org/wiki/faq/const-correctness">https://isocpp.org/wiki/faq/const-correctness</a>.</p>
<p>In a nutshell, using const is good practice because...</p>
<ol>
<li>It protects you from accidentally changing variables that aren't intended be c... |
GUI Design: How do you do it? <p>Do you draw your windows before constructing them? What do you use?</p>
<p>I've tried the Pencil plugin for FF. I've tried MS Visio. I've tried paper & pencil. I've tried Designer Vista. etc. etc. etc.</p>
<p>I'm currently leaning toward paper & pencil, but what about y... | <p>Balsamiq Mockups looks pretty nice</p>
<p><a href="http://www.balsamiq.com/products/mockups" rel="nofollow">http://www.balsamiq.com/products/mockups</a></p>
|
What's the best way to read and parse a large text file over the network? <p>I have a problem which requires me to parse several log files from a remote machine.
There are a few complications:
1) The file may be in use
2) The files can be quite large (100mb+)
3) Each entry may be multi-line</p>
<p>To solve the in-use ... | <p>If you are reading a sequential file you want to read it in line by line over the network. You need a transfer method capable of streaming. You'll need to review your IO streaming technology to figure this out.</p>
<p>Large IO operations like this won't benefit much by multithreading since you can probably proces... |
Too many "pattern suffixes" - design smell? <p>I just found myself creating a class called "InstructionBuilderFactoryMapFactory". That's 4 "pattern suffixes" on one class. It immediately reminded me of this:</p>
<p><a href="http://www.jroller.com/landers/entry/the_design_pattern_facade_pattern" rel="nofollow">http:/... | <p>A good tip is: Your class public API (and that includes it's name) should reveal intention, not implementation. I (as a client) don't care whether you implemented the builder pattern or the factory pattern.</p>
<p>Not only the class name looks bad, it also tells nothing about what it does. It's name is based on its... |
What's the difference between the open source licences <p>I read all the licenses, and frankly I am kindda baffled by the many choices available. I know some relax the limitation of the license so that open source stuff can be used in commercial applications.<br>
But other than that, why are there so many licenses out ... | <p>Yes, there are important differences among the different licenses available. To explain them here, as you asked, would be like reinventing the wheel.</p>
<p>I suggest looking at the site @raphael75 suggested: <a href="http://choosealicense.com/" rel="nofollow">Choose an open source license</a></p>
|
Is there a way to add a Subversion section to the right click menu for TextMate? <p>I'd like to be able to click on a file to revert it, or check in a directory, etc. It would be much more convenient to have these available from the right click menu.</p>
| <p>Have you seen this?</p>
<p><strong>ProjectPlus</strong></p>
<p>ProjectPlus is a plug-in for TextMate which extends the functionality of project-related features.</p>
<p>Feature list:
* SCM status badges:
* Support for SVN, Git, Mercurial, Bazaar and Svk
* Displayed in the project file list and the window proxy ic... |
What are the dangers of making a method virtual? <p>I've been doing some mocking with RhinoMocks and it requires that mocked methods be made virtual. This is fine except we have a custom framework which contains the methods that I want to mock which are currently not marked as virtual.</p>
<p>I can't forsee any proble... | <p>Actually it can be very problematic if the method is not designed to be overridden and someone overrides it. In particular, never call a virtual method from a constructor. Consider:</p>
<pre><code>class Base {
public Base() {
InitializeComponent();
}
protected virtual void InitializeComponent() {... |
Could a truly random number be generated using pings to psuedo-randomly selected IP addresses? <p>The question posed came about during a 2nd Year Comp Science lecture while discussing the impossibility of generating numbers in a deterministic computational device.</p>
<p>This was the only suggestion which didn't depen... | <p>I'll put my rep on the line (at least, 2 points of it per downvote).</p>
<p>No.</p>
<p>A malicious machine on your network could use ARP spoofing (or a number of other techniques) to intercept your pings and reply to them after certain periods. They would then not only know what your random numbers are, they would... |
Is there any way in .NET to programmatically listen to HTTP traffic? <p>I'm using browser automation for testing web sites but I need to verify HTTP requests from the browser (i.e., images, external scripts, XmlHttpRequest objects). Is there a way to programmatically instantiate a proxy for the browser to use in order ... | <p>I have briefly looked into the same thing and have considered two solutions (but haven't tried them yet).</p>
<p>The first suggestion I have would be to use the HttpListener class (and possibly Webclient or other System.Net http related classes to re-post the requests to your application) as a proxy for the WebBrow... |
NLP: Building (small) corpora, or "Where to get lots of not-too-specialized English-language text files?" <p>Does anyone have a suggestion for where to find archives or collections of everyday English text for use in a small corpus? I have been using Gutenberg Project books for a working prototype, and would like to i... | <ul>
<li>Use the <a href="http://en.wikipedia.org/wiki/Wikipedia:Database_download">Wikipedia dumps</a>
<ul>
<li>needs lots of cleanup</li>
</ul></li>
<li>See if anything in <a href="http://prdownloads.sourceforge.net/nltk/nltk-data-0.9.5.zip">nltk-data</a> helps you
<ul>
<li>the corpora are usually quite small</li>
</... |
What's the difference between a worker thread and an I/O thread? <p>Looking at the processmodel element in the Web.Config there are two attributes.</p>
<pre><code>maxWorkerThreads="25"
maxIoThreads="25"
</code></pre>
<p>What is the difference between worker threads and I/O threads?</p>
| <p>Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and latency of communicating over the network and transferring data.</p>
<p>I/O threads are set aside as such because they will be doing I/O (as the name implies) and may have to wait for "long" periods o... |
Why is my stored procedure receiving a null parameter? <p>Ok, this is a curly one. I'm working on some Delphi code that I didn't write, and I'm encountering a very strange problem. One of my stored procedures' parameters is coming through as <code>null</code>, even though it's definitely being sent <code>1</code>.</p>
... | <p>In my programs, I have <strong>lots</strong> of code very similar to your first snippet, and I haven't encountered this problem.</p>
<p>Is that <strong>actually</strong> your code, or is that how you've represented the problem for us to understand? Is the text for the SQL stored in your DFM or populated dynamically... |
What is the best web based Subversion client? <p>What is your favorite web-based svn client? I'd like one that supports commits via the web.</p>
<p>One tool per post please! Please include platform and notable features (e.g. read-write support).</p>
<p>I'm referring to browser-based clients that users would go to lik... | <p>All web clients that I know of are read only, meaning that you can only browse the files, make diffs, set up RSS feeds, but you can not modify the repository in any way.</p>
<p><a href="http://www.websvn.info/" rel="nofollow">WebSVN</a> is the PHP interface that I installed at the office and that I use everyday. It... |
Is programming a subset of math? <p>I've heard many times that all programming is really a subset of math. <a href="http://c2.com/cgi-bin/wiki?ProgrammingIsMath">Some suggest</a> that OO, at its roots, is mathematically based, but I don't get the connection, aside from some obvious examples:</p>
<ul>
<li>using inducti... | <p>It's math in the sense that it requires abstract thought about algorithms etc.<br />
It's engineering when it involves planning schedules, deliverables, testing.<br />
It's art when you have no idea how it's going to eventually turn out.</p>
|
How can I perform a HEAD request with the mechanize library? <p>I know how to do a HEAD request with httplib, but I have to use mechanize for this site. </p>
<p>Essentially, what I need to do is grab a value from the header (filename) without actually downloading the file.</p>
<p>Any suggestions how I could accomplis... | <p>Mechanize itself only sends GETs and POSTs, but you can easily extend the Request class to send HEAD. Example:</p>
<pre><code>import mechanize
class HeadRequest(mechanize.Request):
def get_method(self):
return "HEAD"
request = HeadRequest("http://www.example.com/")
response = mechanize.urlopen(request... |
Encapsulating SQL in a named_scope <p>I was wondering if there was a way to use "find_by_sql" within a named_scope. I'd like to treat custom sql as named_scope so I can chain it to my existing named_scopes. It would also be good for optimizing a sql snippet I use frequently.</p>
| <p>While you can put any SQL you like in the conditions of a named scope, if you then call <code>find_by_sql</code> then the 'scopes' get thrown away.</p>
<p>Given:</p>
<pre><code>class Item
# Anything you can put in an sql WHERE you can put here
named_scope :mine, :conditions=>'user_id = 12345 and IS_A_NINJA(... |
Where does Console.WriteLine go in ASP.NET? <p>In a J2EE application (like one running in WebSphere), when I use <code>System.out.println()</code>, my text goes to standard out, which is mapped to a file by the WebSphere admin console.</p>
<p>In an ASP.NET application (like one running in IIS), where does the output o... | <p>If you use <code>System.Diagnostics.Debug.WriteLine(...)</code> instead of <code>Console.WriteLine()</code>, then you can see the results in the <strong>Output</strong> window of Visual Studio.</p>
|
Which distro of Linux is best suited for Java web apps? <p>There are so many Linux distributions to choose from! What is the "best" linux flavor for a web hosting environment running primarily:
Apache HTTP, Tomcat or JBoss, MySQL and Alfresco (not necessarily all in the same instance).</p>
<p>Are there any significan... | <p>They all use similar tools to administer things like webmin, and sshd.</p>
<p>What are you more familiar with. Red Hat based systems(fedora, mandriva) or Debian based systems(Ubuntu). This family divide will determine a few things. First rpm packaging vs deb packaging.</p>
<p>You also want to look at the level of ... |
How do I upload a HTML form with a username, password, multiple file uploads and then process it with PHP? <p>How to post a username, password and multiple binary files from a single html form and process it using php? I'm not allowed to use ajax.</p>
| <p>first off check out these pages on PHP.net</p>
<ol>
<li><a href="http://us3.php.net/features.file-upload">file upload info</a></li>
<li><a href="http://us3.php.net/manual/en/function.move-uploaded-file.php"><code>move_uploaded_file</code></a></li>
</ol>
<p>But to get you started here's a couple stub files.</p>
<p... |
Moving WCF service from IIS to a Windows service <p>We have an existing WCF service that makes use of wsDualHttpBinding to enable callbacks to the client. I am considering moving it to netTcpBinding for better performance, but I'm quite wary of moving away from the IIS-hosted service (a "comfort zone" we currently enjo... | <p>So as you cannot host using WAS there are a couple of things to realise.</p>
<ul>
<li>If the service crashes it doesn't restart by default (although you can change this in service properties)</li>
<li>IIS will recycle the application pool if it hangs or grows too big; you must do this yourself if you want the same ... |
How to change directory security attributes using InstallShield? <p>I'd like to change the security attribute of a directory that InstallShield creates under the <code>CSIDL_COMMON_APPDATA</code> - can someone please advise on how to do that during the installation process?</p>
<p>It's a script-defined folder.</p>
<p... | <p>Under InstallShield 2008 it's </p>
<pre><code>Installation Designer > Components > [somecomponent] > Destination Permissions
</code></pre>
<p>Note that the directory properties are attached to the component, while individual File permissions are set under the 'Files' node</p>
<p>This assumes you are lett... |
How can you automate Firefox from C# application? <p>Start with the simplest task of capturing the URL in Firefox from a C# application. It appears using user32.dll Windows API functions will not work as is the approach for capturing the URL within IE. </p>
| <p><a href="http://watin.sourceforge.net/" rel="nofollow">WatiN</a> has support for Firefox.</p>
|
How does cherrypy handle user threads? <p>I'm working on a django app right and I'm using cherrypy as the server. Cherrypy creates a new thread for every page view. I'd like to be able to access all of these threads (threads responsible for talking to django) from within any of them. More specifically I'd like to be ab... | <p>CherryPy's wsgiserver doesn't create a new thread for every request--it uses a pool. Each of those worker threads is a subclass of threading.Thread, so all of them should be accessible via threading.enumerate().</p>
<p>However, if you're talking specifically about cherrypy.thread_data, that's something else: a thre... |
How to make XMLHttpRequest work over HTTPS on Firefox? <p>When I try to send an HTTP GET request through XMLHttpRequest it works on non-secure HTTP.</p>
<p>But when sent over HTTPS, different browsers gave different results:</p>
<p>On Firefox 3.0.2:
- The GET request doesn't reach the web server.</p>
<p>On IE 7:
- T... | <p>Try placing your closure after the open:</p>
<pre><code>// send HTTP GET request
try
{
xmlHttp.open("GET", "/[relative path to request]", true);
}
catch (e)
{
alert('Error sending HTTP GET request!');
return false;
}
// we won't be handling any HTTP response
xmlHttp.onreadystatechange=function()
{
/... |
How to create a resizable CDialog in MFC? <p>I have to create a dialog based application, instead of old CFormView type of design. But CDialog produces fixed-size dialogs. How can I create dialog based applications with resizable dialogs?</p>
| <p>In addition to setting the style to <code>WS_THICKFRAME</code>, you'll probably also want to have a system to move and resize the controls in a dialog as the dialog is resized. For my own personal use I've created a base class to replace CDialog that has this capability. Derive from this class and in your <code>Init... |
TFS Build Server drop location error <p>We're using TFS Build Server to ensure that all files checked in by developers are going to compile to a working source tree, cuz there's nothing worse than a broken build!</p>
<p>Anyway we've having some problems with the drop location that Build Server wants to use, we keep ge... | <p>I'm pretty good with TFS - but a dev not a network guy. I would GUESS that while the NETWORK SHARE itself allows 100 connections, is it possible the underlying server it is running on doesn't have some sort of limitation?</p>
<p>Have you checked event logs? </p>
<p>This problem seems specific enough I would enco... |
Emulate hard disk in .NET <p>Is there a way to emulate a disk drive in .NET, intercepting read/write/lock operations?<br />
I would like to create something with a front-end similar to <a href="http://en.wikipedia.org/wiki/GMail_Drive" rel="nofollow">GMail Drive</a> in C#.</p>
<p>Thanks,
Tom</p>
| <p>On Linux you can use the Mono.Fuse API (<a href="http://www.jprl.com/Projects/mono-fuse.html" rel="nofollow">http://www.jprl.com/Projects/mono-fuse.html</a>) to implement .NET-based file systems with user-land code.</p>
|
How can I read the RGB value of a given pixel in Python? <p>If I open an image with <code>open("image.jpg")</code>, how can I get the RGB values of a pixel, if I have the coordinates of the pixel?</p>
<p>Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?</p>... | <p>It's probably best to use the <a href="http://www.pythonware.com/products/pil/">Python Image Library</a> to do this which I'm afraid is a separate download.</p>
<p>The easiest way to do what you want is via the <a href="http://effbot.org/imagingbook/image.htm">load() method on the Image object</a> which returns a p... |
How can I improve CVS performance in a multi-site scenario? <p>I am currently working in a project with developers working on three sites. One of the sites is in Delhi, India while the other two are in Europe. The communication between the European offices and the office in Delhi has poor bandwidth and quite bad latenc... | <p>Why isn't switching an option? </p>
<p>I would highly recommend to switch to SVN or git instead. And that you do this conversion as soon as possible... like today :)</p>
<p>There are even <a href="http://www.google.ca/search?rlz=1C1CHMG_enCA291&sourceid=chrome&ie=UTF-8&q=cvs+to+svn" rel="nofollow">svn... |
How to register file types/extensions with a WiX installer? <p>I didn't find an explicit answer to this question in the WiX Documentation (or Google, for that matter). Of course I could just write the appropriate registry keys in HKCR, but it makes me feel dirty and I'd expect this to be a standard task which should ha... | <p>Unfortunately there's no way to do a "safe" association with Windows Installer. </p>
<p>We just write everything out to the registry and then have a separate component that takes over the system-wide default and is only installed if no other application has already registered itself as the default.</p>
<p>With Vis... |
Compress Script Resources of ASP.Net <p>How do you compress Script Resources of ASP.Net? I saw a file there reached up to 255 KB! I tried finding solutions, but so far it only talks about scripting dynamic and static files. I checked the compression temp folder of IIS and found no compressed scripted resource there. Th... | <p>If you're running IIS6 the guys at OrcsWeb have a nice wee article -</p>
<blockquote>
<p><a href="http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx" rel="nofollow">http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx</a></p>
</blockquote>
<p>We have customers running the port80 software becaus... |
Initializing a static std::map<int, int> in C++ <p>What is the right way of initializing a static map? Do we need a static function that will initialize it? </p>
| <p>Using C++11:</p>
<pre><code>#include <map>
using namespace std;
map<int, char> m = {{1, 'a'}, {3, 'b'}, {5, 'c'}, {7, 'd'}};
</code></pre>
<p>Using <a href="http://www.boost.org/doc/libs/1_36_0/libs/assign/doc/index.html">Boost.Assign</a>:</p>
<pre><code>#include <map>
#include "boost/assign.hp... |
How unique is the php session id <p>How unique is the php session id? I got the impression from various things that I've read that I should not rely on two users never getting the same sessionid. Isn't it a GUID?</p>
| <p>It's not very unique as shipped. In the default configuration it's the result of a hash of various things including the result of gettimeofday (which isn't terribly unique), but if you're worried, you should configure it to draw some entropy from /dev/urandom, like so</p>
<pre><code>ini_set("session.entropy_file",... |
Vim extension (via Python)? <p>is it possible to extend vim functionality via custom extension (preferably, written in Python)?</p>
<p>What I need ideally is custom command when in command mode. E.g.</p>
<p>ESC</p>
<p>:do_this</p>
<p>:do_that</p>
| <p>vim supports scripting in python (and in perl as well, I think).</p>
<p>You just have to make sure that the vim distribution you are using has been compiled with python support.</p>
<p>If you are using a Linux system, you can download the source and then compile it with</p>
<pre><code>./configure --enable-pythoni... |
IE6 freezes due to *server* configuration <p>Our web site (running Rails) freezes IE6 nearly every time. The same code, deployed on a different server, does not freeze IE6. Where and how should we start tracking this down?</p>
| <p>You need to determine the difference between them, so I'd start out with the following:</p>
<pre><code>curl -D first.headers -o first.body http://first.example.com
curl -D second.headers -o second.body http://second.example.com
diff -u first.headers second.headers
diff -u first.body second.body
</code></pre>
|
DIV with overflow:auto and a 100% wide table <p>I hope someone might be able to help me here. I've tried to simplify my example as best I can.</p>
<p>I have an absolutely positioned DIV, which for this example I've made fill the browser window. This div has the overflow:auto attribute to provide scroll bars when the c... | <p>I had a problem with excessive horizonal bar in IE7. I've used D Carter's solution slighty changed</p>
<pre><code><div style="zoom: 1; overflow: auto;">
<div id="myDiv" style="zoom: 1;">
<table style="width: 100%"...
...
</table>
</div>
</div>
</code></pre>
... |
How to resolve a .lnk in c# <p>I need to find out the file/directory name that a .lnk is pointing to using c#.</p>
<p>What is the simplest way to do this?</p>
<p>Thanks.</p>
| <p>I wrote this for video browser, it works really well </p>
<pre><code>#region Signitures imported from http://pinvoke.net
[DllImport("shfolder.dll", CharSet = CharSet.Auto)]
internal static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
[Flags()]
enum... |
GetExitCodeProcess() returns 128 <p>I have a DLL that's loaded into a 3rd party parent process as an extension. From this DLL I instantiate external processes (my own) by using CreateProcess API. This works great in 99.999% of the cases but sometimes this suddenly fails and stops working permanently (maybe a restart of... | <p>Quoting from the MSDN article on <a href="http://msdn.microsoft.com/en-us/library/aa915088.aspx" rel="nofollow">GetExitCodeProcess</a>:</p>
<p>The following termination statuses can be returned if the process has terminated:</p>
<ul>
<li>The exit value specified in the
ExitProcess or TerminateProcess
function </li... |
Experiences with OpenLaszlo? <p>In a <a href="http://stackoverflow.com/questions/112351/recommendations-for-starting-web-programming">related question</a>, I asked about Web Development. I came across something called <a href="http://www.openlaszlo.org/">OpenLaszlo</a> yesterday and thought it looked interesting for d... | <p>I worked on a website for about a year in which the entire UI was developed in Laszlo. I've also developed AJAX applications using JS frameworks such as JQuery, Prototype and Scriptaculous.</p>
<p>In my experience, the total effort required is considerably less when using Laszlo, and the class-based object model he... |
listing all functions in a python module <p>I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. </p>
<p>I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods availabl... | <p>You can use <code>dir(module)</code> to see all available methods/attributes. Also check out PyDocs.</p>
|
Writing XML files using XmlTextWriter with ISO-8859-1 encoding <p>I'm having a problem writing Norwegian characters into an XML file using C#. I have a string variable containing some Norwegian text (with letters like æøå). </p>
<p>I'm writing the XML using an XmlTextWriter, writing the contents to a MemoryStream l... | <p>Why are you writing the XML first to a MemoryStream and then writing that to the actual file stream? That's pretty inefficient. If you write directly to the FileStream it should work. </p>
<p>If you still want to do the double write, for whatever reason, do one of two things. Either</p>
<ol>
<li><p>Make sure that ... |
Balanced Distribution Algorithm <p>I'm working on some code for a loosely coupled cluster. To achieve optimal performance during jobs, I have the cluster remap its data each time a child enters or exits. This will eventually be made optional, but for now it performs its data balancing by default. My balancing is basica... | <p>@<a href="#139914" rel="nofollow">zvrba</a>: You do not even have to sort the list. When traversing the list the second time just move all items with less the average workload to the end of the list (you can keep a pointer to the last item at your first traversal). The order does not have to be perfect, it just chan... |
What's the difference between TRUNCATE and DELETE in SQL <p>I wrote up an answer to this question by mistake in response to a question about the difference between DROP and TRUNCATE, but I thought that it's a shame not to share so I'll post my own answer to my own question ... is that even ethical? :)</p>
<p>Edit: If ... | <p>Here's a list of differences. I've highlighted Oracle-specific features, and hopefully the community can add in other vendors' specific difference also. Differences that are common to most vendors can go directly below the headings, with differences highlighted below.</p>
<p><hr></p>
<h1>General Overview</h1>
<p>... |
When writing XML, is it better to hand write it, or to use a generator such as simpleXML in PHP? <p>I have normally hand written xml like this:</p>
<pre><code><tag><?= $value ?></tag>
</code></pre>
<p>Having found tools such as simpleXML, should I be using those instead? What's the advantage of doin... | <p>Good XML tools will ensure that the resulting XML file properly validates against the DTD you are using.</p>
<p>Good XML tools also save a bunch of repetitive typing of tags.</p>
|
Data in a table with carriage return? <p>In SQL SERVER Is it possible to store data with carriage return in a table and then retrieve it back again with carriage return.</p>
<p>Eg:</p>
<pre><code>insert into table values ('test1
test2
test3
test4');
</code></pre>
<p>When I retrieve it, I get the message in a lin... | <p>You can store Carriage return in the database. The problem here is that you are using SQL Server Management Studio to display the results of your query. You probably have it configured to show the results in a grid. Change the configuration of SSMS to show results to text and you will see the carriage returns.</p... |
Does the latest release May 2008 of .NET enterprise library have the updater app block? <p>Does the latest version of the enterprise library (<a href="http://msdn.microsoft.com/en-us/library/cc512464.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc512464.aspx</a>) come with the updater application block?... | <p>Looks like it doesn't:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/cc511823.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc511823.aspx</a></p>
<p>It's now in the 'Archived Application Blocks' section of the MSDN docs.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/cc485231.asp... |
Are there alternatives to CGI (and do I really need one)? <p>I am designing an application that is going to consist of 3-4 services that run as separate processes and are linked by a suitable IPC. The system is going to have a web interface and I want to use whatever webserver is there.</p>
<p>The web interface should... | <p>OK, I overlooked this previously. Explaining my question here brought me onto it:</p>
<blockquote>
<p>Instead of creating a new process for every request, FastCGI can use a single persistent process which handles many requests over its lifetime. -- <a href="http://en.wikipedia.org/wiki/FastCGI" rel="nofollow">Wik... |
How do I change the Status labels in Bugzilla <p>I don't want to change how the Status field works I just want to change the labels to
the states that the old system uses. (the old systems consists of spreadsheets and paper :P
<br>
We are using 3.0</p>
<pre>
* UNCONFIRMED --> PRELIMARY
* NEW --> DESIGN REVI... | <p>If you log into the bugzilla system as an administrator you'll see on the bottom a link that says "Field Values", click that, on the next page you'll see "Resolution", go there then click on the resolution you'd like to change,</p>
|
Possible causes of Java VM EXCEPTION_ACCESS_VIOLATION? <p>When a Java VM crashes with an EXCEPTION_ACCESS_VIOLATION and produces an hs_err_pidXXX.log file, what does that indicate? The error itself is basically a null pointer exception. Is it always caused by a bug in the JVM, or are there other causes like malfunction... | <p>Most of the times this is a bug in the VM.
But it can be caused by any native code (e.g. JNI calls).</p>
<p>The hs_err_pidXXX.log file should contain some information about where the problem happened.</p>
<p>You can also check the "Heap" section inside the file. Many of the VM bugs are caused by the garbage collec... |
Where should a Subversion repository be? <p>Should it be on the development servers or a Subversion server?</p>
<p>I suppose this could be expanded to any client-server version control system.</p>
| <p>The physical repository should be on a stable system that gets regular backups. </p>
<p>Generally, a development server does not fit this description... it may be acceptable to put the apache server on the dev server and host the files remotely on a stable, backed-up file server (though there are a number of pitfal... |
Client/JS Framework for "Unsaved Data" Protection? <p>We have a typical web application that is essentially a data entry application with lots of screens some of which have some degree of complexity. We need to provide that standard capability on making sure if the user forgets to click the "Save" button before naviga... | <p>One piece of the puzzle:</p>
<pre><code>/**
* Determines if a form is dirty by comparing the current value of each element
* with its default value.
*
* @param {Form} form the form to be checked.
* @return {Boolean} <code>true</code> if the form is dirty, <code>false</code>
* ... |
Base constructor in C# - Which gets called first? <p>Which gets called first - the base constructor or "other stuff here"?</p>
<pre><code>public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}
</code></pre>
| <p>Base class constructors get called before derived class constructors, but derived class initializers get called before base class initializers. E.g. in the following code:</p>
<pre><code>public class BaseClass {
private string sentenceOne = null; // A
public BaseClass() {
sentenceOne = "The quick br... |
Workaround for J2ME Hessian limitations? <p>The official J2ME implementation of Hessian seems to have serious limitations : complex objects are not supported.<br> This limitation is not mentioned anywhere on the online documentation, but if you google "hessian j2me" you will find posts about this problem. No solutions ... | <p>This is somewhat confusing as a Hessian is a matrix of mixed second partial derivatives, and a library that couldn't handle complex numbers would indeed be a problem.</p>
<p>Why'd they have to reuse a well-established name with other meanings?</p>
|
What is the best way to store a large amount of text in a SQL server table? <p>What is the best way to store a large amount of text in a table in SQL server?</p>
<p>Is varchar(max) reliable?</p>
| <p>In SQL 2005 and higher, VARCHAR(MAX) is indeed the preferred method. The TEXT type is still available, but primarily for backward compatibility with SQL 2000 and lower.</p>
|
NSIS get path of current installer file that is running <p>Is there an NSIS var to get the path of the currently running installer?</p>
| <p>Found it: $EXEPATH</p>
|
Firebug - how can I run multiline scripts or create a new JavaScript file? <p>Is there a way in Firebug to start a new script file to apply to page? Basically I want to do work like I'd normally do on the Firebug console but be able to to paste in multi-line functions, etc. It doesn't seem like the console is amenabl... | <p>Down in the lower-right corner of the FireBug UI you should see a red square icon with an up arrow. Use that and stretch it to a size you like.</p>
<p><hr /></p>
<p><img src="http://i160.photobucket.com/albums/t162/JasonBunting/FireBug1.gif">
<br /><br />
<img src="http://i160.photobucket.com/albums/t162/JasonBunt... |
Is it possible to compile .NET IL code to machine code? <p>I would like to distribute my .NET programs without the .NET framework. Is it possible to compile a .NET program to machine code?</p>
| <p>Remotesoft has one:
<a href="http://www.remotesoft.com/linker/">Salamander .NET Linker</a></p>
<p>I don't have any experience with it though.</p>
|
How do I test if another installation is already in progress? <p>Assuming I'm trying to automate the installation of something on windows and I want to try to test whether another installation is in progress before attempting install. I don't have control over the installer and have to do this in the automation framewo... | <p>See the description of the <a href="http://msdn.microsoft.com/en-us/library/aa372909(VS.85).aspx">_MSIExecute Mutex</a> on MSDN.</p>
|
How to avoid SSIS FTP task from failing when there are no files to download? <p>I'm using SQL Server 2005, and creating ftp tasks within SSIS. </p>
<p>Sometimes there will be files to ftp over, sometimes not. If there are no files, I don't want the task nor the package to fail. I've changed the arrow going from the... | <p>I understand that you have found an answer to your question. This is for other users who might stumble upon this question. Here is one possible way of achieving this. <code>Script Task</code> can be used to find the list of files present in an FTP folder path for a given pattern (say <code>*.txt</code>). Below examp... |
Are "dirty reads" safe to use in Terracotta? <p>"Dirty reads", meaning reading an object's value even though it is write-locked by another thread, are <a href="http://www.terracotta.org/confluence/display/howto/Recipe?recipe=dirty-read" rel="nofollow">described</a> on Terracotta's website, yet I've heard that they shou... | <p>A dirty read is a dirty read. Terracotta, being distributed/clustered, only adds the possibility to read even older values of the shared mutable state that you are accessing without proper synchronization.</p>
<p>You should note that, under the memory model in Java 5, you are not guaranteed to <em>ever</em> read an... |
Why does Java not have block-scoped variable declarations? <p>The following method does not work because the inner block declares a variable of the same name as one in the outer block. Apparently variables belong to the method or class in which they are declared, not to the block in which they are declared, so I theref... | <p>Well, strictly speaking, Java <em>does</em> have block-scoped variable declarations; so this is an error:</p>
<pre><code>void methodName() {
for (int j = 0; j < 10; j++) {
int i = j * 2;
}
System.out.println(i); // error
}
</code></pre>
<p>Because 'i' doesn't exist outside the for block.</p>
<p>The p... |
What's the best way to count keywords in JavaScript? <p>What's the best and most efficient way to count keywords in JavaScript? Basically, I'd like to take a string and get the top N words or phrases that occur in the string, mainly for the use of suggesting tags. I'm looking more for conceptual hints or links to real-... | <p>Once you have that array of words cleaned up, and let's say you call it <code>wordArray</code>:</p>
<pre><code>var keywordRegistry = {};
for(var i = 0; i < wordArray.length; i++) {
if(keywordRegistry.hasOwnProperty(wordArray[i]) == false) {
keywordRegistry[wordArray[i]] = 0;
}
keywordRegistry[wor... |
Flex Post Event Screen Updates <p>I came across this topic today while investigating something very strange. Doing certain things in our Flex app can cause the number of frames rendered to rocket, from 12fps to ~30fps: loaded animations start playing at high speed and the GUI starts to lock up.</p>
<p>Since everything... | <p>Flex sets the frame rate to 1000 during "phased instantiation" of Flex components, which occurs only during initial load of a flex swf. This allows it to build all components very quickly.</p>
<p>Are you waiting for the Flex app to be fully loaded and constructed? You should be waiting for FlexEvent.CREATION_COMP... |
INotifyPropertyChanged property name - hardcode vs reflection? <p>What is the best way to specify a property name when using INotifyPropertyChanged? </p>
<p>Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) b... | <p>Don't forget one thing : <code>PropertyChanged</code> event is mainly consumed by components that will <strong>use reflection</strong> to get the value of the named property.</p>
<p>The most obvious example is databinding.</p>
<p>When you fire <code>PropertyChanged</code> event, passing the name of the property as... |
Javascript to detect whether the dropdown of a select element is visible <p>I have a select element in a form, and I want to display something only if the dropdown is not visible. Things I have tried:</p>
<ul>
<li>Watching for click events, where odd clicks mean the dropdown is visible and even clicks mean the dropdo... | <p>here is how I would preferred to do it.
focus and blur is where it is at.</p>
<pre><code><html>
<head>
<title>SandBox</title>
</head>
<body>
<select id="ddlBox">
<option>Option 1</option>
<option>Option 2... |
Visual Studio 2008 source control for small teams <p>I work on a small web team where I am the only .NET developer currently using Visual Studio 2008 Professional to build and maintain a few web applications. I am about to start training another member of our team so we purchased him a copy of Visual Studio 2008 Profe... | <p><a href="http://subversion.tigris.org/">Subversion</a> has good integration with Visual Studio 2008 through <a href="http://www.visualsvn.com/">VisualSVN</a> and <a href="http://ankhsvn.open.collab.net/">Ankh</a>. </p>
<p>SourceSafe is dangerous. You're right that a filesharing-based SCM is a bad idea, and Microsof... |
Should try...catch go inside or outside a loop? <p>I have a loop that looks something like this:</p>
<pre><code>for (int i = 0; i < max; i++) {
String myString = ...;
float myNum = Float.parseFloat(myString);
myFloats[i] = myNum;
}
</code></pre>
<p>This is the main content of a method whose sole purpos... | <p>PERFORMANCE:</p>
<p>There is absolutely no performance difference in where the try/catch structures are placed. Internally, they are implemented as a code-range table in a structure that is created when the method is called. While the method is executing, the try/catch structures are completely out of the picture u... |
RoR: Accessing models from with application.rb <p>i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before_filter to check that the user of the user in the session has a 'can_access_admin' flag.</p>
<p>i hav... | <p>just a guess but it seems that your session[:user] is just storing the id, you need to do:</p>
<pre><code>@user = User.find(session[:user])
</code></pre>
<p>or something along those lines to fetch the user from the database (along with its associations). </p>
<p>It's good to do the above in a before filter too.</... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.