input
stringlengths
51
42.3k
output
stringlengths
18
55k
Most elegant UI for categorizing items? <p>I have a collection of items that the user needs to group/categorize in several ways. For the sake of an example, let's say it's a collection of cars and the user wants to categorize them in the following ways:</p> <ul> <li>Color (red, silver, blue, black, etc.)</li> <li>Body...
<p>It sounds like you have two tasks: Task 1 Categorize Objects, where for a series of objects, the user assigns each a category (value) on each of multiple dimensions (attributes). Task 2: Create and Modify Dimension and Categories. </p> <p>Outside of data modelers, object-oriented programmers, and database designers...
release configuration management <p>Our windows deliverable has different sets of config files and binary assets for different customers. Right now the configuring is done by hand before packaging and its error prone. What do you think of using branches for each customer, and having the package build/script automerge...
<p>I suppose it depends on how many things have to change. For config files, I like to keep a single file under source control and use a build script to set the environment-specific (or in your case client-specific) items.</p> <p><a href="http://automaticchainsaw.blogspot.com/2008/02/automate-config-changes-for-differ...
Format Date with fmt:formatDate JSP <p>I am trying to format a date with: </p> <pre><code>&lt;fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/&gt; </code></pre> <p>newsletter is an object with a <code>createdOn</code> property which is <code>java.util.Date</code>.</p> <p>When I invoke the previou...
<p>Try </p> <pre><code>&lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %&gt; </code></pre>
What is the best way to know when the UIViewController above me in the stack has been popped? <p>I have a <code>UIViewController</code> that manages the display of some data. When the user wants to edit this data I push an edit <code>UIViewController</code> onto the stack. When the user is finished editing the top view...
<p>I think viewWillAppear will do the trick.</p> <p>Otherwise your edit view controller could call a new method of delegate pointing to your parent controller. In there, you can update the data model and display. For instance:</p> <pre><code>- (BOOL)textFieldShouldReturn:(UITextField *)textField { if ([delegate r...
Is there an ORM for Perl? <pre> create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int ) </pre> <p>How I can use basic ORM in Perl by taking a simple table like the one above and mapping it to Perl objects? Next I'd like to perform basic operations li...
<p>Rule #1, don't write your own.</p> <p>There are quite a number of ORMs on CPAN, including ...</p> <ul> <li><a href="http://search.cpan.org/dist/DBIx-Class">DBIx::Class</a> - probably #1 in popularity at the moment</li> <li><a href="http://search.cpan.org/dist/Rose-DB-Object">Rose::DB::Object</a></li> <li><a href="...
What do I need to write Java-based web applications and test them on my personal computer? <p>I currently have Apache HTTP Server, but I'm guessing I'll need Tomcat (and then have to configure it in a way that makes it not open to the public), a Java JDK (which I already have, but should probably update), and an IDE (I...
<p>I'd recommend having a database server installed as well- you can go pretty far with the various pure Java implementations, but anything significant will probably benefit from having a copy of MySQL around.</p> <p>I'd also get some sort of version control going- tortoiseSVN works really well for windows. Even if yo...
Error: Failed to generate a user instance of SQL Server <p>I'm trying to connect to an MDF. I've even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where previously I had 05 dev and express). I've verified that the paths are all correct, and th...
<p>ok, it works now! guess it was a compound problem ... the steps I took to resolve it are as such:</p> <ol> <li>Changed the following property in the connection string (note the subtle difference): <code>AttachDbFilename=|DataDirectory|CustomerDb.mdf;</code></li> <li>Deleted the contents of the following directory: ...
Visual Studio variable declaration <p>I have a project that has the following line in the additional includes section:</p> <p>"$(SOMEPATH_SHORTNAME)\include"</p> <p>Can someone tell me where I can find $(SOMEPATH) defined? I can't find it by simply searching in Visual Studio</p>
<p>If it's not an environment variable, the place to look is the macros. In the property sheets, click the (...) button beside the "Addition Include Directories" line, and expand the "Macros>>" button in the dialog that pops up. </p>
What are the actual performance differences between Int64 and Int32 on 32 and 64 bit MS Windows? <p>What are the actual performance differences between Int64 and Int32 on 32 and 64 bit MS Windows?</p> <p>It would also be great to see some actual timings of Int64 vs Int32 on each of the two operating system variants. ...
<p>As far as hardware, Int64 will be more efficient on an x64 and IA64 than x86 because the 64-Bit processors have 64-Bit registers to perform the operations on them. </p> <p>Int32 will be equally as efficient on all x86, x64, and IA64. </p> <p>On an x64 and on an IA64 both Int32 and Int64 are equally as efficient.</...
How do I get a human-readable file size in bytes abbreviation using .NET? <p>How do I get a human-readable file size in bytes abbreviation using .NET?</p> <p><strong>Example</strong>: Take input 7,326,629 and display 6.98 MB</p>
<p>using Log to solve the problem....</p> <pre><code>static String BytesToString(long byteCount) { string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB if (byteCount == 0) return "0" + suf[0]; long bytes = Math.Abs(byteCount); int place = Convert.ToInt32(Math.Fl...
Reg-Free COM in an ASP.Net application <p>I am wondering if it is possible to use Reg-Free COM in an ASP.Net application?</p>
<p>According to this it is: <a href="http://www.mazecomputer.com/sxs/help/iis6aspnet2.htm" rel="nofollow">http://www.mazecomputer.com/sxs/help/iis6aspnet2.htm</a></p> <p>I haven't tried, it I've just been researching the same idea...</p>
Hibernate JPA to DDL command line tools <p>There are Hibernate tools for mapping files to ddl generation; ddl to mapping files and so on, but I can't find any command line tools for simple DDL generation from JPA annotated classes.</p> <p>Does anyone know an easy way to do this? (Not using Ant or Maven workarounds)</p...
<p>I'm not sure, whether this is considered a workaround, because you already referred to it in your question. You can use <a href="http://tools.hibernate.org/">Hibernate Tools</a> to generate DDL from JPA annotated classes. You just need hibernate tools and its dependencies on the classpath and should be fine with som...
Are there any Ajax-based UML modeling tools? <p>I'm looking for something like <a href="http://ondras.zarovi.cz/sql/demo/?keyword=default" rel="nofollow">WWW SQL Designer</a> for UML Modeling.</p>
<p>This one is not in Ajax, it's in flash, at least it is online: <a href="http://www.gskinner.com/gmodeler/launch.html" rel="nofollow">http://www.gskinner.com/gmodeler/launch.html</a></p>
How to highlight input text field upon clicking it in Safari? <p>I would like the value of the input text box to be highlighted when it gains focus, either by clicking it or tabbing to it.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script&gt; function focusTest(el) { el.select(); } &lt;/script&gt; &lt;input typ...
<p>I noticed Safari is actually selecting the text then removing the selection quickly.</p> <p>So I tried this quick workaround that works in all browsers:</p> <pre><code>function focusTest(el) { setTimeout (function () {el.select();} , 50 ); } </code></pre> <p>Edit :<br /> Upon further testing it turns out the On...
What do Streams do when implementing AES encrption in .NET? <p>The Rijndael encryption algorithm is implemented in .NET using 3 streams in the following example: <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx" rel="nofollow">Rinjdael</a>.</p> <p>Can someone explain t...
<p><code>swEncrypt</code> is a <code>StreamWriter</code> - its job is to convert text into binary data</p> <p><code>csEncrypt</code> is a <code>CryptoStream</code> - its job is to convert binary data into encrypted binary data</p> <p><code>msEncrypt</code> is a <code>MemoryStream</code> - its job is to store the data...
How do I read the value of a checkbox in a word (*.doc) file in VB.net using a Range object? <p>How do I read the value of a checkbox in a word (*.doc) file in VB.net using a range object?</p> <p>This is what I have so far:</p> <pre><code>Dim app As New Word.Application Dim doc As Document doc = app.Documents.Open("C...
<p>Any particular reason you're not reading the value of the checkbox using the name of the checkbox itself?</p> <p>If the range defined by your bookmark contains a checkbox, then, depending upon how the checkbox is inserted, it will be found in either the <code>InlineShapes</code> collection (if checkbox inserted inl...
How do I write unit tests in PHP? <p>I've read everywhere about how great they are, but for some reason I can't seem to figure out how exactly I'm supposed to test something. Could someone perhaps post a piece of example code and how they would test it? If it's not too much trouble :)</p>
<p>There is a 3rd "framework", which is by far easier to learn - even easier than <em>Simple</em>Test, it's called phpt.</p> <p>A primer can be found here: <a href="http://qa.php.net/write-test.php">http://qa.php.net/write-test.php</a></p> <p><strong>Edit:</strong> Just saw your request for sample code.</p> <p>Let's...
Garbage Collector Flash Player <p>Is there a way to force the flash garbage collector to clean up freed memory? I've seen that it takes a lot of time for flash to clean up not referenced memory...</p>
<p>Unfortunately there isn't. It's something Grant Skinner has written lots about, so check <a href="http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html" rel="nofollow">his blog</a>.</p>
How to find out Subversion repository version? <p>How can I determine current version of my repository to see if I need to upgrade it (svnadmin upgrade)?</p> <p>In reality I'm hosting SVN with 3rd party and I want to find out if I need to ask them to upgrade my repos or not.</p> <p>I'm asking since 1.5 server will ke...
<p>Have a look at <code>&lt;REPO&gt;/db/format</code>. After upgrading to 1.5 format, my <code>format</code> file shows:</p> <pre><code>3 layout sharded 1000 </code></pre> <p>Before it used to be:</p> <pre><code>2 </code></pre>
C++ Opening a file and inputting data to a class object <p>Simple question, hopefully an easy way and just want to verify I'm doing it the correct / efficient way.</p> <p>I have a class T object, which is typically put into a vector that is created in my main() function. It can be any kind of data, string, int, float...
<p>You made the old mistake of testing against eof in the condition. EOF is not set until you try and read past the end of file. So this method will insert one extra value into the vector that you don't want.</p> <pre><code>template &lt;class T, class U&gt; void get_list(vector&lt;T&gt;&amp; v, const char *inputFile, ...
Image DPI Explained <p>Attempting to write a definition of DPI has lead me to:</p> <p>DPI (dots), PPI (points), LPI (lines) all refer to the same concept hereafter referred to as DPI.</p> <p>DPI is a device dependent measurement. It says, "This is the resolution of this device."</p> <p>Vector based files are not ti...
<p>Because a bitmapped image has no physical size, it has no dpi. If you have a file format where physical size is modeled, you can have a (modeled) dpi.</p> <p>You might want to make a distinction between addressability and covered area. If a dot is not square but a circle, the covered area is larger.</p> <p>b.t.w. ...
Computing a mean confidence interval without storing all the data points <p>For large <code>n</code> (see below for how to determine what's large enough), it's safe to treat, by the central limit theorem, the distribution of the sample mean as normal (gaussian) but I'd like a procedure that gives a confidence interval ...
<p>Here's an article on <a href="http://www.johndcook.com/standard_deviation.html" rel="nofollow">how to compute the mean and standard deviation in a single pass</a>, not storing any data. Once you have the these two statistics, you can estimate a confidence interval. A 95% confidence interval would be [mean - 1.96*st...
What's the optimal GZIP compression setting for IIS? <p>You can set the HcDynamicCompressionLevel anywhere from 0-10. I've heard 10 is bad (high CPU usage), but what's the magic number that works the best? </p>
<p>10 was bad when CPUs were two orders of magnitude slower than they are now. The gzip algorithm is pretty fast as far as compression algorithms go these days, so I'd set it to 10 and see what happens.</p>
Using varchar instead of date field types in MySQL <p>Is there any reason to use a varchar field instead of a date field in MySQL? I'm looking at an existing site and I see the developer has done this. Is there any reason to?</p>
<p>Unless it really <em>is</em> acting primarily as a string — say, it wants to preserve date formatting style, locale-named months, named timezones etc. and doesn't care about being computable — no, varchar would not be a good choice.</p> <p>Handling real date datatypes can be problematic/non-portable acr...
Easiest way to sort DOM nodes? <p>If I have a list like this:</p> <pre><code>&lt;ul id="mylist"&gt; &lt;li id="list-item1"&gt;text 1&lt;/li&gt; &lt;li id="list-item2"&gt;text 2&lt;/li&gt; &lt;li id="list-item3"&gt;text 3&lt;/li&gt; &lt;li id="list-item4"&gt;text 4&lt;/li&gt; &lt;/ul&gt; </code></pre> ...
<p>Though there's probably an easier way to do this using a JS Library, here's a working solution using vanilla js.</p> <pre><code>var list = document.getElementById('mylist'); var items = list.childNodes; var itemsArr = []; for (var i in items) { if (items[i].nodeType == 1) { // get rid of the whitespace text no...
How do I create a list control with Rich text in FLEX? <p>I am a FLEX newbie, trying to port a Javascript-based prototype into FLEX. One thing my original prototype had was an unordered list (ul) which had list items that had rich text inside it, i.e. I had a mix of differently styled and colored text and some images i...
<p>No help yet? I founded it. It's called ItemRenderers <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_1.html" rel="nofollow">http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_1.html</a></p> <p>Much like the renders in Java Swing.</p>
ld: duplicate symbol <p>I'm working on a school project and I'm getting some weird errors from Xcode. I'm using TextMate's Command+R function to compile the project. Compilation seems to work okay but linking fails with an error message I don't understand. </p> <p>ld output:</p> <blockquote> <p>ld: duplicate symbol...
<p>My first thought was that you're including it twice on the linker command but it appears to be complaining about having the same function in <code>main.o</code> and <code>generics.o</code>.</p> <p>So it looks like you're including the <code>io_functions.cpp</code> file into the <code>main.cpp</code> and <code>gener...
How to find whether a Windows user belongs to specified group? <p>Currently we have a DLL that checks whether a username/password is a valid Windows user using the Windows API LogonUser method. We need to enhance it so it checks whether the user belongs to a specified group as well. Is there a Windows method that does ...
<p>you can use "NetUserGetLocalGroups" function in netapi32.dll to get all groups a given user belongs to and then check if specified group name exists in groups name returned by function. you can find function usage <a href="http://www.pinvoke.net/default.aspx/netapi32/NetUserGetLocalGroups.html" rel="nofollow">here</...
C++ odd compile error: error: changes meaning of "Object" from class "Object" <p>I don't even know where to go with this. Google wasn't very helpful. As with my previous question. I'm using TextMate's Command+R to compile the project. </p> <blockquote> <p>game.h:16:error: declaration of ‘Player* HalfSet::Player() ...
<p>In C++ you cannot name a function the same name as a class/struct/typedef. You have a class named "Player" and so the HalfSet class has a function named "Player" ("Player *Player()"). You need to rename one of these (probably changing HalfSet's Player() to getPlayer() or somesuch).</p>
Looking for VB.NET open source projects to learn from <p>I'm looking for some small, vb.net open source projects that make good use of unit testing. Similar to <a href="http://stackoverflow.com/questions/236156/could-you-recommend-any-open-source-projects-where-the-source-is-extensively-te">this</a> question, but for V...
<p>For some reason there are not too many VB.NET OSS projects (compared to C#). A good one you can look at however is <a href="http://cthru.codeplex.com/" rel="nofollow">SilverUnit</a>, a testing framework for Silverlight written in VB.NET</p>
Is there any popup editor function in iphone? <p>I'd like to popup a simple dialog with an editor box, to let user enter some value then just return. I am wondering whether iPhone SDK has that kind of support.</p> <p>Thanks.</p>
<p>I found a solution at : <a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/1704-uitextfield-inside-uialertview.html" rel="nofollow">http://www.iphonedevsdk.com/forum/iphone-sdk-development/1704-uitextfield-inside-uialertview.html</a></p> <p>Here is the code which works for me. </p> <pre><code>UIAler...
Assign default value to a datacolumn in a select statement <p>I want to assign default values to a column in my select sql query so that if the value of that column is null I get that default value in my recordset. Is there anyway to do this?</p> <p>Example:</p> <pre><code>select col1 (some default value) from tblna...
<p>The preferable way is to use ANSI compatible function <a href="http://msdn.microsoft.com/en-us/library/ms190349.aspx">COALESCE</a>:</p> <pre><code>SELECT COALESCE(column_name, default_value) FROM table_name; </code></pre> <p>You also could read <a href="http://databases.aspfaq.com/database/coalesce-vs-isnull-sql.h...
ASP.NET MVC UpdateModel with a sorta complex data entry field <p>how do i do the following, with an ASP.NET MVC UpdateModel? I'm trying to read in a space delimeted textbox data (exactly like the TAGS textbox in a new StackOverflow question, such as this) into the model.</p> <p>eg.</p> <pre><code>&lt;input type="Tags...
<p>What you need to do is extend the DefaultValueProvider into your own. In your value provider extend GetValue(name) to split the tags and load into your LazyList. You will also need to change your call to UpdateModel: </p> <pre><code>UpdateModel(q, new[] { "Title", "Body", "Tags" }, new QuestionValueProvider...
Is there a way to put aspx files into a class library in Visual Studio 2008 .NET 3.5? <p>I've got a lot of pages in my site, I'm trying to think of a nice way to separate these into areas that are a little more isolated than just simple directories under my base web project. Is there a way to put my web forms into a s...
<p>At first thought, I don't think this is possible, due to the way ASPX is non-precompiled..</p> <p>However, you can create classes that inherit from <code>Page</code> and place them into a DLL to re-use code-behind functionality. This can of course include control instantiate logic if required, but there is no desig...
Asp.net Date Binding Issue with Nulls <p>I have a nullable date in my database. I am connecting to it with a LinqDataSource, and binding with a FormView. It allows you to place dates fine, but if you remove the date I need it to insert the null value to the db. It is instead throwing an exception.</p> <pre><code>&lt;a...
<p>I don't know if it was the best way, but I fixed it by subscribing to the FormView Updating event and placed the following code:</p> <pre><code>object o = e.NewValues["StartDate"]; if (o.ToString() == "") e.NewValues["StartDate"] = null; </code></pre>
Advice on which language/Framework to choose for web application? <p>I am a c++ developer trying to create a web application using a language or framework that meets the following criteria:</p> <ol> <li>Very fast development time</li> <li>Text searching and other text manipulation</li> <li>Easy to configure and mainta...
<p>I'll go ahead and put the word in for <a href="http://www.djangoproject.com/" rel="nofollow">django</a>.</p> <p>Which is sometimes called python's answer to rails.<br /> I've recently had the chance to do some ruby programming and if your coming in new to either language I think ruby or python are pretty easy to st...
how to combine a template from other processed templates? <p>I have a django project pro1 with several apps: app1, app2, app3 and so on. I want to display some top level template that contains blocks from each and every app:</p> <p>example_base_template.html:</p> <pre><code>[header /] [left nav bar]{{ app1 rendered t...
<p>You can use a <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#include" rel="nofollow">{% include %}</a> tag. But It doesn't help you a lot. The better solution is to write custom <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags" rel="nofollow">inclusion t...
Is there a specification of the group leader protocol that handles IO? <p>In Erlang, every process has a group leader, and when a process wants to print something (i.e. it calls the io library or does something similar), it will send a message to its group leader.</p> <p>My question is, where can I find the specificat...
<p><a href="https://erlangcentral.org/erlang-rationale-2/" rel="nofollow">The Erlang Rationale (video)</a> or <a href="http://www.erlang-factory.com/upload/presentations/329/EFKR10-ErlangRationale.pdf" rel="nofollow">(slides)</a>; is a good source of information, as is the source code for <a href="http://github.com/mf...
How do you organise your STL headers? <p>I am working on a large project that uses the STL and have a question about your preferred way to organise your STL <code>#includes</code>.</p> <ul> <li>Do you prefer to #include each header in the source file it is used. For example, if both <code>foo.cpp</code> and <code>bar...
<p>I only include the header files that are really needed in every source, and not 'catch all' headers, to keep dependencies (and hence compile times) as low as possible.</p> <p>Precompiled headers can work irrespective of this (i.e. I rely on precompiled headers to speed up the compiling process, not to get declarati...
ERROR : [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified <p>While connecting .net to sybase server I got this error message:</p> <blockquote> <p>[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified</p> </blockquote> <p>This has worked...
<p>If you're working with an x64 server, keep in mind that there are different ODBC settings for x86 and x64 applications. The "Data Sources (ODBC)" tool in the Administrative Tools list takes you to the x64 version. To view/edit the x86 ODBC settings, you'll need to run that version of the tool manually:</p> <pre><co...
IAutomationObject not found when running Flex application <p>i get the following error when trying to run a flex application (which has been working fine!). I was playing around with some different setttings trying to optimize the compiled size. I've put these settings back to the defaults as much as I thought but stil...
<p>I haven't encountered this, but here are some suggestions on things I would try:</p> <ul> <li>Did you exclude any classes in the compiler settings?</li> <li>If you're using Flex Builder, try doing a clean (Project > Clean...).</li> <li>If that doesn't help, remove all eclipse and flex builder files from your projec...
How to build native Mac OS X installer (on a non-Mac platform)? <p>How can I build a native Mac OS X installer for my application, on a non-Mac platform?</p> <p>For example, I have a windows pc and a Java application. I want the windows pc to build an installer (possibly inside a .dmg archive) that works with Apple in...
<p>It is now possible to create a native Mac OS X installer on a non-Mac platform. As Louis Gerbarg, the tricky bit is the BOM (bill-of-materials) file. However an open source version of mkbom (based on the osxbom code by Joseph Coffland) is now available at:</p> <p><a href="http://hogliux.github.io/bomutils" rel="nof...
MSI packaging guidance <p>We're in the process of packaging combinations of our products/modules. Some of them are stand-alone some are interdependent. All versions must be deployable side-by-side. As it is we're considering two choices:</p> <ol> <li>One MSI per package and version</li> <li>One MSI per product/module ...
<p>If you install the same component twice, Windows Installer will just reference-count the first installation, so there's not much in the way of difference between the two. If you're already separating your components into merge modules, you're guaranteed that the components will share their GUIDs, and you will get th...
Zend framework; Getting controller to use different viewer <p>I am using the Zend Framework.</p> <p>I have a controller named 'UserController' that has a public function displayAction().</p> <p>I would like to know how I can get that action method to use a different viewer than the default display.phtml.</p> <p>Any ...
<p>You can use </p> <pre><code>$this-&gt;render('actionName'); </code></pre> <p>or, alternatively, you can call a view script directly by calling</p> <pre><code>$this-&gt;renderScript('path/to/viewscript.phtml'); </code></pre> <p>For more information, you can take a look at <a href="http://framework.zend.com/manual...
Acegi Security: How do i add another GrantedAuthority to Authentication to anonymous user <p>i give users special URL with access key in it. users accessing the public page via this special url should be able to see some additional data as compared to simple anonymous user. </p> <p>i want to give some additional role ...
<p>Why not just create a wrapper class that delegates to the original, but adds on a couple of extra GrantedAuthorities:</p> <pre class="lang-java prettyprint-override"><code>public class AuthenticationWrapper implements Authentication { private Authentication original; private GrantedAuthority[] extraRoles; ...
Include another MSI file in my setup project <p>I'm trying to make a setup program for an ASP.NET web site. I need to make sure the target machine has sqlxml installed.</p> <p>I must verify the target machine has the software installed, and if not, launch a .msi file either before or after the main installation.</p> ...
<p>Unfortunately, you can't run one installer from another, since only one can be running at a time. You need to chain them together and run one after the other. Google "msi chaining". This is often the reason why products like Visual Studio use an external setup.exe which then runs the installers one after the othe...
Using foreach (...) syntax while also incrementing an index variable inside the loop <p>When looking at C# code, I often see patterns like this:</p> <pre><code>DataType[] items = GetSomeItems(); OtherDataType[] itemProps = new OtherDataType[items.Length]; int i = 0; foreach (DataType item in items) { // Do some s...
<p>If you are using C# 3.0 that will be better;</p> <pre><code>OtherDataType[] itemProps = items.Select(i=&gt;i.Prop).ToArray(); </code></pre>
Transforming selected text with a hotkey <p>I have this code:</p> <p>myVariable</p> <p>which I want to change into</p> <p>trace("myVariable: " + myVariable);</p> <p>using a direct hotkey like <kbd>alt</kbd> - <kbd>f12</kbd> to do it. I.e not using <kbd>ctrl</kbd> - <kbd>space</kbd> and arrow buttons.</p> <p>is it ...
<p>I don't know if it's possible to bind hotkeys for templates. One way for somewhat similar behavior could be using proper template name and "insert automatically".. </p> <p>That is, you would write <em>trcc</em> (for example) and Eclipse would automatically expand it to a template <em>trace("${name}: " + ${name});</...
Using Volume Shadow Copy Service (VSS) in Delphi <p>Does anyone have sample code to copy open (in-use and locked by another program) files using Volume Shadow Copy Service (VSS) API?</p> <p>There was an article about this in The Delphi Magazine (September 2005). But that code is no longer available and even if it was,...
<p>there is a digital edition on usb stick of the "The Delphi Magazine". you can order that on their webpage.</p> <p>maybe someone has created a torrent of that stick.</p> <p><strong>update</strong></p> <p><strike>i found that sample here: <a href="http://www.google.com/codesearch/p?hl=de#XIdFp1PskBE/VSS/VssAPI.pas"...
How to redirect to the requested URI after authentication using Zend_Auth? <p>I am using a simple <a href="http://framework.zend.com/manual/en/zend.auth.html">Zend_Auth</a> setup to authenticate users for one of my applications, using a check in the preDispatch() method in a <a href="http://framework.zend.com/manual/en...
<p>We had the same problem and actually did store request URI in session variable. If you don't put any specific, unserializable object into Zend Request, I think it also will be ok to persist it. </p> <p>However it depends on what throughput you're expecting. Serializing objects like Zend Request may not be the best...
Building my first ASP application <p>I've just been tasked with building a web application using ASP (.net) and am looking for some advice on where to start. In a nutshell the application needs to be able to.</p> <ul> <li>Handle user verification / authentication</li> <li>Handle sessions</li> <li>Do SOAP messaging</...
<p>Use Visual Studio 2008 if you can. Its support for Ajax client libraries and javascript intellisense is very good. (Check out the <a href="http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx" rel="nofollow">jQuery add in</a>) </p> <p>ASP.NET has built in Login controls (and the me...
How to get a ReadOnlyCollection<T> of the Keys in a Dictionary<T, S> <p>My class contains a <code>Dictionary&lt;T, S&gt; dict</code>, and I want to expose a <code>ReadOnlyCollection&lt;T&gt;</code> of the keys. How can I do this without copying the <code>Dictionary&lt;T, S&gt;.KeyCollection dict.Keys</code> to an array...
<p>DrJokepu said that it might be difficult to implement a wrapper for Keys Collection. But, in this particular case, I think the implementation is not so difficult because, as we know, this is a read-only wrapper. </p> <p>This allows us to ignore some methods that, in other case, would be hard to implement.</p> <p>H...
NAnt extension function, Project object <p>Is there a way to access the <code>Project</code> object from a NAnt extension function, as can be done from an extension task?</p> <p>In this example, I want to use the <code>BaseDirectory</code> property inside the <code>Bar</code> function:</p> <pre><code>[FunctionSet("fo...
<p>Great question Tom. The abstract base class, <strong>FunctionSetBase</strong>, has a property called <strong>Project</strong> that you can access from the <strong>Bar</strong> function. However, I noticed that the Bar function is declared static, which is not always necessary (but not wrong).</p> <p>The following s...
Is Vista Ultimate 64 w/SP1 okay for a development machine? <p>I am updating my rig and I need to make a decision between staying with XP x64 or going to Vista x64. I do very little development, really just building products from my developers. The other 90% of my work is done with Google Apps, Skype, Office, etc...</p>...
<p>I am fine with Vista 64 bits for .net and php.</p> <p>A lot of conversation about it are already on SO. Here is some important point your might take in consideration <strong>for .Net</strong>:</p> <ul> <li><p><a href="http://stackoverflow.com/questions/208985/nunitexe-cannot-work-on-vista-64bits-if-x86-build">Unit...
Iterate though Generic List in C# <pre><code>public class Item { private int _rowID; private Guid _itemGUID; public Item() { } public int Rid { get { return _rowID; } set { } } public Guid IetmG...
<p>Are you putting a constraint on the generic type V? You'll need to tell the runtime that V can be any type that is a subtype of your <code>Item</code> type.</p> <pre><code>public class MyGenericClass&lt;V&gt; where V : Item //This is a constraint that requires type V to be an Item (or subtype) { public void D...
How to share config settings between mutiple applications <p>I have a project where there are multiple applications that have some common configuration values. I would like to have a shared .config file that is available to all of the applications using the .Net configuration object model. Each application would also h...
<p>Some sections in the app.config allow for a reference to an external file.</p> <pre><code>&lt;appSetting configSource="somefile.config"/&gt; </code></pre>
Compact Framework - System.Threading.Timer stops when the user turns off the screen <p>I have an application that needs to "poll" a webservice to see if the user has any new messages waiting. I have no control over the webservice so I cannot switch to a "push" mechanism, I'm stuck making a request every X number of se...
<p>Hate to answer my own question, but I was pointed to <a href="http://blog.opennetcf.com/ctacke/PermaLink,guid,169fcc25-a42f-4a8f-b8af-6b6c85d8819d.aspx" rel="nofollow" title="this">this</a>, which was able to perform even when the device is asleep. Looks like it's working perfectly.</p>
Infragistics grid "on-demand" appearance <p>We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and we want to configure row/cells appearances "on-demand" in order to be able to provide sort of "dynamic appearance".</p> <p>For example, I want some cell to be red or green, depending on its ...
<p>I had to do exactly this with the IG WebGrid a few years back, and it was ... shall we say ... painful. However, the WebGrid had the advantage of a single render point -- once the HTML was emitted, we were set!</p> <p>For dealing with this in WinGrid, I tried a variety of different events, both on the grid and the ...
MOSS SpNavigationNode.Children always empty <p>I'm trying to return all the child nodes of a set of navigation nodes in sharepoint, the SDK implies I should be doing something like this:</p> <pre><code>NodeColl = objSite.Navigation.TopNavigationBar Dim Node as SPNavigationNode For Each Node In NodeColl if Node.IsV...
<p>I have this same problem, I found the solution as</p> <pre><code>using (SPSite site = new SPSite("http://server")) { using (SPWeb web = site.OpenWeb()) { SPNavigationNode quicklaunch = web.Navigation.GetNodeById(1025); if (quicklaunch != null) { foreach (SPNavigationNode ...
<assemblyBinding> ignored in parent web.config <p>I have a folder containing several websites, all using the same assemblies in the GAC. Each website also contains some 'custom' assemblies of their own that refer to the common assemblies.</p> <p>There is a web.config in this folder, defining common settings for the si...
<p>It is supposed to happen. You did nothing wrong. </p> <p>for more information, please take a look at <a href="http://msdn.microsoft.com/en-us/library/2fc472t2%28vs.71%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/2fc472t2(vs.71).aspx</a></p>
(DataGridView + Binding)How to color line depending of the object binded? <p>I would like to add a backcolor for specific line depending of a Property of the object binded.</p> <p>The solution I have (and it works) is to use the Event <code>DataBindingComplete</code> but I do not think it's the best solution.</p> <p>...
<p>You can also attach an event handler to RowPostPaint:</p> <pre><code>dataGridView1.RowPostPaint += OnRowPostPaint; void OnRowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { MyObject value = (MyObject) dataGridView1.Rows[e.RowIndex].DataBoundItem; DataGridViewCellStyle style = dataGridView1....
WindowsPrincipal.IsInRole() not returning the expected result <p>So here's my current code:</p> <pre><code>List&lt;string&gt; rowGroups = GetFileGroups((int)row.Cells["document_security_type"].Value); bool found = false; System.Security.Principal.WindowsPrincipal p = new System.Security.Principal.WindowsPrincipal(Syst...
<p>I have to point out, are you actually escaping your '\' character correctly inside your strings? As in "domainA\\groupA"?</p>
Is it a bad idea to get rid of the mx: in your Flex code? <p>I am a newbie at Flex, and I don't like the way you have to write the namespace mx: for every control declaration you write. It makes the code cluttery. I would like to write:</p> <pre><code>&lt;Panel ... </code></pre> <p>rather than</p> <pre><code>&lt;mx:...
<p>I think that removing the mx namespace will almost certainly cause you trouble with name conflicts as your project gets larger.</p> <p>Personally I think the mx namespace makes the code clearer rather than more cluttered, especially if you have component based flex development or a lot of your own controls. Having...
How do I pass a string parameter greater than varchar(8000) in SQL Server 2000? <p>You get a compilation error if you define the string parameter to have a size greater than 8000</p> <p>e.g. </p> <pre><code>The size (9000) given to the type 'varchar' exceeds the maximum allowed for any data type (8000). </code></pre>...
<p>you need to store it as TEXT instead of varchar for string larger than 8000 in sql 2000</p>
How can I insert strings with quotes into Perl DBI queries? <p>What is the preferred way to insert strings that can contain both single and double quotes (",') into MySql using DBI? For example, <code>$val1</code> and <code>$val2</code> can contain quotes:</p> <pre><code>my $dbh = DBI-&gt;connect( ... ); my $sql = "i...
<p>Use a bound query using </p> <pre><code>$sth = $dbh-&gt;prepare("insert into tbl_name(col_one,col_two) values(?,?)"); $sth-&gt;execute($val1, $val2); </code></pre> <p>If you use bound variables, everything is escaped for you.</p> <p>Update: Changed my example to correspond with the example edited into the questio...
Simple Excel Applescript <p>I am new to Applescripts and Excel 08? I want to write one that colors arbitrarily preselected cells in Excel 08 specific colors. I can get it to write want in an preselected cell and even bold the font...but for some reason it will not change the color of the cell...</p> <pre><code>print...
<p>I was able to set the color of a particular cell in Excel 08 (and 2011 now) using the following AppleScript:</p> <pre><code>tell sheet "Sheet1" of theWorkbook set color of interior object of range C2:C2 to {255, 255, 0} end tell </code></pre> <p>I had to specify the color on a particular range and use the Red,...
Can MOSS 32 bit and 64 bit exist in the same farm? <p>I am trying to setup a failover location for MOSS. The current farm is built on 32 bit Windows 2003. The servers ar the failover location are all 64 bit Windows 2008.</p> <p>Is there any way to make these two environments talk and stay in sync? I have considered a ...
<p>You can mix 32 bits and 64 bits in the same farm, it's fully supported. </p> <p>However, it's highly recommenced to keep each tiers in the same bit width (for example all WFE 64 bits, application server 32 bits, SQL servers 64 bits).</p> <p>From msdn @ <a href="http://technet.microsoft.com/en-us/library/cc261700....
What is the best way to see what files are locked in Subversion? <p>I finally got my group to switch from SourceSafe to Subversion. Unfortunately, my manager still wants to use exclusive locks on every single file. So I set the svn:needs-lock property on every file and created a pre-commit hook to make sure the prope...
<p>What you're looking for is the <a href="http://svnbook.red-bean.com/en/1.8/svn.ref.svnadmin.c.lslocks.html"><code>svnadmin lslocks</code></a> command.</p> <p>I have this set up at work because we keep some Word documents in our Subversion repository (with <code>svn:needs-lock</code>). I have a cron job set up that ...
How do you read a byte array from a DataRow in C#? <p>I have a <code>DataSet</code> with a <code>DataTable</code> that correctly fills a single <code>DataRow</code> through a <code>TableAdapter</code>.</p> <p>I am able to pull data from the DataRow with code like this:</p> <pre><code>dataFileID = (int)this.dataFileDa...
<p>The code above works, make sure you set your debugger to compile for Debug, NOT Release. </p> <p>Keith</p>
Upload large files in .NET <p>I've done a good bit of research to find an upload component for .NET that I can use to upload large files, has a progress bar, and can resume the upload of large files. I've come across some components like <a href="http://ajaxuploader.com">AjaxUploader</a>, <a href="http://krystalware.c...
<blockquote> <p>1) Is it possible to resume a file upload on the client without using flash/java/Silverlight?</p> </blockquote> <p>No. The actual HTTP protocol itself does not support resume of partial uploads, so even if you did use flash or silverlight, you'd still need to use something else like FTP on the server...
Open a .BAS DTS Package in SQL 2000? <p>You can save a SQL Server 2000 DTS package as a VB .BAS file. Is is possible to open a .BAS file in SQL Server Enterprise Manager (or some other way) to add the DTS package to the server? Initally, it appears that SQL Server only lets you import .DTS files.</p>
<p>Actually, it is possible although it's fiddly:</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa176248%28SQL.80%29.aspx" rel="nofollow">Running a DTS Package Saved as a Visual Basic File</a></p>
Can Boost Spirit be used to parse byte stream data? <p>Can Spirit (part of Boost C++ library) be used to parse out binary data coming from a stream? For example, can it be used to parse data coming from a socket into structures, bytes, and individual bit flags? Thanks!</p>
<p>Boost Spirit allows for a parser to be defined using <a href="http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form" rel="nofollow">Extended Backus–Naur Form (EBNF)</a> syntax with <a href="http://en.wikipedia.org/wiki/Template_metaprogramming" rel="nofollow">template meta-programming</a>. It is very flex...
Trying to send an HTTP request over sockets <p>I'm having trouble sending out a simple HTTP request using Actionscript 3's Socket() object. My onConnect listener is below:</p> <pre><code>function sConnect(e:Event):void { trace('connected'); s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\r\n');...
<p>You have to write another "\r\n" to the stream before the flush to tell the HTTP server that you're finished sending the headers.</p>
Converting Plain Text to Clickable link or Link to PlainText in asp.net <p>I need your advice with converting plain text to an URL.</p> <p>The scenario will be this: The user will select some entry and then click a "convert to link" button. </p> <p>The entry text the user selected will convert to <code>(link: selecte...
<p>If you must save processed input for some reason</p> <pre><code>(link: here) </code></pre> <p>must be converted to</p> <pre><code>(link: &lt;a href="http://www.mysite.com?t=here"&gt;here&lt;/a&gt;) </code></pre>
Win32: How to use RegisterTypeLib API from standard user <p>The Win32 API call <a href="http://msdn.microsoft.com/en-us/library/ms221570.aspx" rel="nofollow">RegisterTypeLib()</a> is used to create the registry keys necessary to register a type library.</p> <p>Unfortunatly, on Windows XP, it tries to write those regis...
<p>You can use the <code>RegOverridePredefKey()</code> API to map the <code>HKEY_CLASSES_ROOT</code> regtree to <code>HKEY_CURRENT_USER\Software\Classes</code>:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms724901.aspx"><code>http://msdn.microsoft.com/en-us/library/ms724901.aspx</code></a></li> </ul>...
Compact Framework - any implementation of the Image.FromStream (Stream, Boolean, Boolean)? <p>In a .NET CF application I wrote, one of the features is to acquire frames from remote cameras. Frames are acquired as single jpeg images and displayed on the screen when available.</p> <p>It was a good enough solution, but I...
<p>If the dimensions of the JPEG are large (like 1200 x 1600 or something), then one of the speed problems you're having on your device with the Bitmap constructor is the size of the Bitmap is has to create in memory (the bitmap would be 1200 x 1600 also, even if it's then displayed on a 240 X 320 screen). If you can ...
How to create a 'global event' in actionscript / flex? <p>What is the best way to create a 'global event' in flex/actionscript - preferably using a static class?</p> <p>I want to raise an event to indicate that a stylesheet is loaded in order to show components that require that stylesheet. So I want each portion of t...
<p>Make a <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">Singleton</a> and add listeners to it, nice and simple.</p>
Is there any good replacement for SharePoint Designer? <p>If you've ever used SharePoint Designer, you'll know it's bad. Really bad.</p> <p>Is there any good replacement for that? Is there any consideration I must take account of if I want to build my own Visual Studio Add-in connector to connect to it?</p> <p>Anythi...
<p>You can get the Sharepoint Explorer add-in for Visual Studio which will allow you to browse around sites:</p> <p><a href="http://blog.thekid.me.uk/archive/2007/10/29/vs-net-developer-add-in-for-sharepoint-available-for-download.aspx" rel="nofollow">http://blog.thekid.me.uk/archive/2007/10/29/vs-net-developer-add-in...
Automatically wrapping I-search? <p>In Vim I can <code>:set wrapscan</code> so that when I do an incremental search, the cursor jumps to the first match whether the first match is above or below the cursor.</p> <p>In Emacs, if I start a search via <code>C-s</code>, the search fails saying <em>Failing I-search</em> if ...
<p>The easiest way to do this is to use the following defadvice:</p> <pre><code>(defadvice isearch-repeat (after isearch-no-fail activate) (unless isearch-success (ad-disable-advice 'isearch-repeat 'after 'isearch-no-fail) (ad-activate 'isearch-repeat) (isearch-repeat (if isearch-forward 'forward)) (...
Representing Monetary Values in Java <p>I understand that BigDecimal is recommended best practice for representing monetary values in Java. What do you use? Is there a better library that you prefer to use instead?</p>
<p><code>BigDecimal</code> all the way. I've heard of some folks creating their own <code>Cash</code> or <code>Money</code> classes which encapsulate a cash value with the currency, but under the skin it's still a <code>BigDecimal</code>, probably with <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecim...
programatically convert word docx to doc without using ole automation <p>i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable an...
<p>One option without using OLE automation would be to wrap the converter dlls coming with compatibility pack in order to convert from docx to doc without automating Office.</p> <p>This requires only that the Compatibility Pack of Office is installed on the machine.</p> <p>The Office converter dlls convert from the d...
What techniques can you use to profile your code <p>Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.</p> <p>The target language is C++.</p> <p>I am interested in wha...
<p>No joke: In addition to dumping timings to std::cout and other text/data oriented approaches I also use the Beep() function. There's something about hearing the gap of silence between two "Beep" checkpoints that makes a different kind of impression.</p> <p>It's like the difference between looking at a written she...
WPF Binding to Grid Column Width <p>I'm attempting to bind a <code>DependancyProperty</code> in one of my usercontrols to the <code>Width</code> property of a <code>Column</code> in a <code>Grid</code>. </p> <p>I have code similar to this:</p> <pre><code>&lt;Grid x:Name="MyGridName"&gt; &lt;Grid.ColumnDefinitions...
<p>Well I have got a bit of a kludge working, I'll explain how for future generations:</p> <p>Essentially I have a 2 column, multi row grid with a splitter right aligned in the first column so it can be resized by the user if the content it contains requires more space. To complicate things I have a user control being...
How to spawn a process and capture its STDOUT in .NET? <p>I need to spawn a child process that is a console application, and capture its output.</p> <p>I wrote up the following code for a method:</p> <pre><code>string retMessage = String.Empty; ProcessStartInfo startInfo = new ProcessStartInfo(); Process p = new Proc...
<p>Here's code that I've verified to work. I use it for spawning MSBuild and listening to its output:</p> <pre><code>process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.OutputDataReceived += (sender, args) =&gt; Console.WriteLine("received output: {0}", args.Data); proce...
irritating select() behaviour in c <pre><code>while (xxx) { timeout.tv_sec=TIMEOUT; timeout.tv_usec=0; FD_ZERO(&amp;set); FD_SET(sd,&amp;set); switch (select(FD_SETSIZE,&amp;set,NULL,NULL,&amp;timeout)) xxxxx } </code></pre> <p>works fine, however</p> <pre><code>FD_ZERO(&amp;set); FD_SET(sd...
<p>select modifies its arguments. You really do have to re-initialize it each time.</p> <p>If you're concerned about overhead, the cost of processing the complete FD_SET in the kernel is somewhat more significant than the cost of FD_ZERO. You'd want to only pass in your maximum fd, not FD_SETSZIZE, to minimize the ker...
How can I programmatically test an HTTP connection? <p>Using Java, how can I test that a URL is contactable, and returns a valid response?</p> <pre><code>http://stackoverflow.com/about </code></pre>
<p>The solution as a unit test:</p> <pre><code>public void testURL() throws Exception { String strUrl = "http://stackoverflow.com/about"; try { URL url = new URL(strUrl); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.connect(); assertEquals(Http...
How to avoid, that URL.equals needs access to the internet in Java? <p>The <code>equals()</code> method of the URL class in the Java class library makes a DNS request to get the IP for the hostname, to check the two IP's for equality. This happens even for URLs that are created from the same <code>String</code>. Is the...
<p>Use <a href="http://docs.oracle.com/javase/8/docs/api/java/net/URI.html" rel="nofollow">java.net.URI</a> instead of URL.</p>
Parse HTML via XPath <p>In .Net, I found this great library, <a href="http://www.codeplex.com/htmlagilitypack">HtmlAgilityPack</a> that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby...
<p>I'm surprised there isn't a single mention of lxml. It's blazingly fast and will work in any environment that allows CPython libraries.</p> <p>Here's how <a href="http://codespeak.net/lxml/xpathxslt.html">you can parse HTML via XPATH using lxml</a>.</p> <pre><code>&gt;&gt;&gt; from lxml import etree &gt;&gt;&gt; d...
What do I need to change to allow my IIS7 ASP.Net 3.5 application to create an event source and log events to Windows EventLog? <p>ASP.Net 3.5 running under IIS 7 doesn't seem to allow this out of the box.</p> <pre><code> if (!EventLog.SourceExists("MyAppLog")) EventLog.CreateEventSource("MyAppLog",...
<p>I've copied this answer from <a href="http://stackoverflow.com/questions/2587453/log4net-eventlogappender-does-not-work-for-asp-net-2-0-website">here</a> (the question was Log4Net but the answer still applies). The technet link misses a vital step.</p> <h3>Create a registry key</h3> <p><code>HKEY_LOCAL_MACHINE\SYS...
Stack Overflow Exploit in C <p>The question is actually about stack overflows in C. I have an assigment that I can not get done for the life of me, I've looked at everything in the gdb and I just cant figure it.</p> <p>The question is the following:</p> <pre><code>int i,n; void confused() { printf("who called m...
<p>I probably shouldn't do your homework for you. But the basically:</p> <p>You need to get a character buffer somewhere in memory to store the string you want to execute. Obviously, you can do this the same way you are getting the other functions called (i.e. you put the text on the stack as well). After you have ...
How to split a web address <p>So I'm using python to do some parsing of web pages and I want to split the full web address into two parts. Say I have the address <a href="http://www.stackoverflow.com/questions/ask" rel="nofollow">http://www.stackoverflow.com/questions/ask</a>. I would need the protocol and domain (e.g....
<p>Dan is right: urlparse is your friend:</p> <pre><code>&gt;&gt;&gt; from urlparse import urlparse &gt;&gt;&gt; &gt;&gt;&gt; parts = urlparse("http://www.stackoverflow.com/questions/ask") &gt;&gt;&gt; parts.scheme + "://" + parts.netloc 'http://www.stackoverflow.com' &gt;&gt;&gt; parts.path '/questions/ask' </code></...
Alternative to StyleCop for Visual Studio? <p>I like <a href="http://code.msdn.microsoft.com/sourceanalysis">StyleCop</a>'s static code analysis and rules enforcement. However, it is severely lacking in several key departments. </p> <ul> <li>Adding new rules isn't officially supported and from what I hear pretty dif...
<p>Adding rules is, or is going to be, <a href="http://blogs.msdn.com/sourceanalysis/archive/2008/08/19/stylecop-4-3-is-released.aspx">officially supported</a>:</p> <blockquote> <p>As promised, we will also be releasing SDK documentation for StyleCop explaining how to author custom rules and how to integrate t...
Importance of closing SQLConnection objects when using the SQLDataReader object <p>My present contract engagement is at a large E-Commerce company. Their code base which has origins going back to .Net 1.0 has caught me by surprise to contain many issues that raise the level of smell beyond the last crap I took. </p> <...
<p>Nothing wrong with inline sql if the user input is properly parameterized, and this looks like it is. </p> <p>Other than that, yes you do need to close the connections. On a busy web site you could hit your limit and that would cause all kinds of weirdness.</p> <p>I also noticed it's still using an arraylist. S...
Is there a time when && (AndAlso) does not matter over & (And) <p>If I am evaluating two variables and not two method calls does it matter weather I use "&amp;&amp;" or "&amp;"</p> <pre><code>//some logic that sets bool values boolean X = true; boolean Y = true; if (X &amp; Y){ // perform some operation } if (X ...
<p>Always use &amp;&amp; if you are performing a true/false logic test. A single &amp; performs a bit-wise 'and'. It make work like a logic test in some cases but it is not guaranteed to work for all logic cases. The most common use of a single &amp; is when applying a bit-mask.</p> <p>Examples (&amp;&amp;):</p> <p...
How to password protect streaming videos with php <p>What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.</p> <p>I know how to do authentication with php, but I'm not sure how to setup authentication so th...
<p>Both nginx and lighttpd web servers have X-Send-File headers you can return from PHP. So you can do your checks in PHP and then conditionally server out the file.</p> <pre><code>if (check_user_can_access()){ header('X-sendfile: /path/to/file'); } else { header('HTTP/1.1 403 Fail!'); } </code></pre> <p>Ligh...
How to create an automated way of monitoring to see if this application is running <p>We have a application that should always be running. Does anyone know of a way to create an automated way of monitoring to see if this application is running (possibly using a batch file)? If it is not running, then send an email noti...
<p><a href="http://www.nagios.org/" rel="nofollow">Nagios</a> is generally what's used by systems administrators that I've come across. You can script it to do whatever check you need and alert based on a variety of conditions. Works well with cacti so you can graph stuff too :)</p> <p>If you want to ensure that your ...
How do I translate init.d scripts from Ubuntu/Debian Linux to Solaris? <p>I have several init.d scripts that I'm using to start some daemons. Most of these scripts I've found on the internet and they all use start-stop-daemon. My understanding is that "start-stop-daemon" is a command that is specific to Linux or BSD di...
<p>start-stop-daemon is a Linux thing, and not used that much on Solaris. I guess you can port the command though, if you want to reuse your init scripts.</p> <p>Otherwise it depends on what version of Solaris you are using. Starting with Solaris 10 and also OpenSolaris they use a new startup script framework "Solaris...
How can I print the lines in STDIN in random order in Perl? <p>I want to do the inverse of <a href="http://www.manpagez.com/man/1/sort/" rel="nofollow">sort(1)</a> : randomize every line of <strong>stdin</strong> to <strong>stdout</strong> in Perl. </p>
<p>I bet real Perl hackers will tear this apart, but here it goes nonetheless.</p> <pre><code>use strict; use warnings; use List::Util 'shuffle'; my @lines = (); my $bufsize = 512; while(&lt;STDIN&gt;) { push @lines, $_; if (@lines == $bufsize) { print shuffle(@lines); undef @lines; } } pr...
Setting focus to a button from from text box? <p>I have a few text boxes and buttons on my form.</p> <p>Lets say txtBox1 is next to btnSubmit1, txtBox2 is next to btnSubmit2, txtBox3 is next to btnSubmit3.</p> <p>How can I set the focus on btnSubmit3 when the user starts to type something in txtBox3. Meaning..... if ...
<p>If you use a panel, you should be able to set a defaultbutton. I´m not sure if it´s an win forms application or a web forms application, but this is how you should do it with web forms:</p> <pre><code>&lt;asp:Panel id="panel1" runat="server" DefaultButton="Button1"&gt; &lt;asp:TextBox id="textbox1" runat="serv...
How to add CardSpace support to your ASP.NET application <p>I like the idea of CardSpace but unlike OpenID it seems like a real PITA to support it in your ASP.NET web application. I've found many examples, even a tutorial in one of the books I own... but it would seem a lot more is required than what they suggest.</p> ...
<p>For card space take a look at the open source library SharpSTS a https://sharpsts.com/</p> <p>They also have links to a number of card space resources that might help you get started at: https://sharpsts.com/resources.aspx </p>