Friday, April 9, 2010

Haar Training Object Detection

Thanks to David J. Barnes we're starting to work with Haar Training for a side project. Check out his masterful work @ Quotient Robotics

Thursday, July 16, 2009

Adding sln. file to existing website

Just in case you ever lose track of your solution file...most of the time your default location for sln. file saving is set to somewhere other than your website folder, follow these steps to add one to your website.

1) From the Visual Studio menu choose "File | New | Project..."
2) From the resulting dialog, under "Other Project Types" choose "Visual Studio Solutions" and create a blank solution.
3) From the Visual Studio menu choose "File | Add | Existing Web Site" and point it to your web site to add it to your new solution.

Good to go.

Tuesday, June 23, 2009

Javascript Back and Reload

I needed a quick way to allow my users to click on a link to bring them back one page and reload that page so that some of the filtering options that I was implementing would take. I simply used a combination of the javascript: history.go(-1) function and a Response.Cache.SetNoStore(); on the page that was to be reloaded (set in the Page_Load event in the cs file).

Wednesday, March 25, 2009

The magic of Dynamic Headers in a GridView

Very basic, but useful if you have a GridView with multiple views. I used this when I needed to Load a GridView with one set of information and then using an OnSelectedChange event show another set of info...all the while changing the HeaderText.

In your ASPX page don't declare a HeaderText field.

In your cs. file use this...(adjust column value to suit your GridView)
this.GridMyRequests.Columns[2].HeaderText = "Requestor";

Wednesday, March 11, 2009

Finally :: Auto Adjusting TextBox Height

It took a while to find what I was looking for, but I've finally found it! A way to Auto Adjust the Height of a Multiline TextBox or TextArea. The solution that I found involves a small bit of javascript, but does some pretty cool automagic auto adjusting. Give it a try HERE.

Here's the code, adjust to your Specs using textarea or ASP:TextBox Controls:

<body onload="cleanForm();">
<script type="text/javascript">
<!--
function countLines(strtocount, cols) {
var hard_lines = 1;
var last = 0;
while ( true ) {
last = strtocount.indexOf("\n", last+1);
hard_lines ++;
if ( last == -1 ) break;
}
var soft_lines = Math.round(strtocount.length / (cols-1));
var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;");
if ( hard ) soft_lines = hard_lines;
return soft_lines;
}
function cleanForm() {
var the_form = document.forms[0];
for ( var x in the_form ) {
if ( ! the_form[x] ) continue;
if( typeof the_form[x].rows != "number" ) continue;
the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
}
setTimeout("cleanForm();", 300);
}
// -->
</script>

<form action="index.php" method="get">
<p><textarea cols="60" rows="2" name="reason">Some text</textarea></p>
</form>

Tuesday, March 3, 2009

Use Compare Validator to check your Integers!

Here's an easy way to check to make sure that the User enters an Integer in an Integer field.
<asp:CompareValidator ID="CompareValidatorErrors" ErrorMessage="Please Enter an Integer" Type="Integer" Operator="DataTypeCheck" ControlToValidate="TxtNumberErrors" runat="server"></asp:CompareValidator>

You can specify the ValidationTypeProperty within the Type property to specify (Currency, DateTime, Double, Integer, String) to Compare against.

Monday, March 2, 2009

Calculate DateDiff and Convert Seconds to Hours/Minutes


You can use this simple DATEDIFF function to calculate the difference, in seconds, between a SubmitDate and CompleteDate.

SELECT DATEDIFF(s, SubmitDate,CompleteDate)
FROM Table
WHERE Column1=ID Value


This will allow you to use the result from above (seconds) to convert the seconds into HH:MM format.

DECLARE @NumberOfSeconds INT
SET @NumberOfSeconds = Result from above
SELECT CAST(@NumberOfSeconds / 3600 AS VARCHAR(3)) + ':' +
RIGHT('0' + CAST(@NumberOfSeconds % 3600 / 60 AS VARCHAR(2)), 2)