All my childhood geek fantasies are about to come true…
August 21st, 2011 § Comments Off § permalink
All my childhood geek fantasies are about to come true…
June 15th, 2011 § Comments Off § permalink
For a project I’m working on now I wanted a numeric editor, something that would only allow input of digits. I found a jQuery numeric plugin that does the job. I also created a custom EditorTemplate for both decimal and int data types. For the int EditorTemplateyou have to name the file ‘Int32.cshtml’.
@model System.Int32?
@Html.TextBox("",
(Model.HasValue) ? ViewData.TemplateInfo.FormattedModelValue : "",
new { data_integer = true, @style = "width:90px;" })
The decimal template has the same code except the ‘data-’ attribute is data_decimal. Then in $(document).ready(function () {} I included the following code taken from the plugin template example, modified to utilize the ‘data-’ attribs that I generated in the templates.
$(":input[data-decimal]").numeric();
$(":input[data-integer]").numeric(false, function () { alert("Integers only"); this.value = ""; this.focus(); });
$(":input[data-positivedecimal]").numeric({ negative: false }, function () { alert("No negative values"); this.value = ""; this.focus(); });
$(":input[data-positiveinteger]").numeric({ decimal: false, negative: false }, function () { alert("Positive integers only"); this.value = ""; this.focus(); });
$("#remove").click(
function (e) {
e.preventDefault();
$(".numeric,.integer,.positive").removeNumeric();
}
);
June 3rd, 2011 § Comments Off § permalink
April 14th, 2011 § Comments Off § permalink
I’m doing a quick one-off scheduling app for work and needed to present in the user interface the dates of the current and next three weeks’ Monday, Wednesday, and Friday. The DayOfWeek enumerator’s corresponding int values come in handy. The snippet below uses the int value of the DayOfWeek value from DateTime.Now to create an offset which is then subtracted from DateTime.Now to find the date of Sunday of the current week.
DateTime now = DateTime.Now; int dayOfWeekOffset = (int)now.DayOfWeek; DateTime firstDayOfWeek = now.AddDays(-dayOfWeekOffset);
From there you can add days to firstDayOfWeek to find the date of the relevant week day. For example:
//this week's Wednesday DateTime wednesday = firstDayOfWeek.AddDays(3); //next week's Friday DateTime friday = firstDayOfWeek.AddDays(12);
March 14th, 2011 § Comments Off § permalink
I run 64 bit Windows 7 Ultimate on a Dell Precision M4500 as my main development machine. I also use Tortoise SVN for source control and have been having a lot of trouble making commits to my repositories (failed commits, corruptions, locks, etc.). It was becoming a real headache. On top of that I was having another problem that I thought was unrelated. Frequently at startup I was getting the warning that my disk was corrupted and required a consistency check. Eventually after researching the problems with the repository commits I found this post. Since installing SP1 I haven’t had either issue come up again. Problem solved.
March 10th, 2011 § Comments Off § permalink
I switched to WordPress from dasBlog. Still no promises that I’ll actually post anything though.