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…
July 20th, 2011 § Comments Off § permalink
I recently bought a Kindle (version 3) and am in danger of it becoming permanently attached to my person. I baby my gadgets and of course wanted to get a screen protector for it. The problem is that I’m a tightwad and think the prices charged for screen protectors are beyond ridiculous. Luckily, Amazon was kind enough to include one (two actually) with every Kindle: the clear plastic overlays front and back meant to protect your Kindle from scratches in its box. I simply peeled them of and stuck them to a sheet of wax paper for easy handling while measuring and cutting. I turns out that the width of the sheets matches the height of the Kindle’s screen so you only need to make two cuts. But the sticky side is covered with lint you say? No problem there. You can wash both sides with dish washing liquid without sacrificing the adhesive. To dry, simply apply the sticky side to a clean bathroom mirror or other pane of glass and wipe dry. When you peel it back off the glass the sticky side will be dry. Voila!
Admittedly the downside is that this DIY approach introduces glare to the screen, but so far I haven’t been bothered. You loose nothing by giving it a try of course. Good luck.
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();
}
);
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);
April 1st, 2011 § Comments Off § permalink
I came up with this to get the time portion of a datetime data type formatted in
12 hour time with the AM/PM on the end:
SELECT SUBSTRING(CONVERT(CHAR(26), GETDATE(), 9), 12, 6) + ' ' + SUBSTRING(CONVERT(CHAR(26), GETDATE(), 9), 25, 2) somedate
Example outputs look like 10:30 AM or 4:10 PM.
I’m not sure if this is the most efficient way, but it seems to work whether the
time has single or two digit hours both before and after noon. Replace
the GETDATE() function, which I’ve stuck in for demonstration purposes, with your
datetime column reference. If there is a better way to do this please
post a comment.
March 29th, 2011 § Comments Off § permalink
I bought a Logitech Illuminated Keyboard a few weeks ago. The key action is short like a laptop keyboard so it makes for quick typing. The illuminated keys are a nice feature. I keep my work area dimly lit with a dark Visual Studio scheme to make things easier on the eyes. I considered the wireless version and tried it out, walking back and forth between the two at the store. It had similar feel with perhaps slightly mushier action. The other more obvious difference is that the wireless version’s keys have rounded edges, which to me contributed to a less precise feel. The wireless feature wasn’t compelling enough to offset the feel of the wired version. So far I’m pleased and would recommend it.
March 25th, 2011 § Comments Off § permalink
ColorPic is a handy desktop app for grabbing colors from anywhere on your screen. It has a lot of features including multiple palettes and a color mixer if you want to tweak the color you just grabbed. I find I use it a lot when I’m working in Visual Studio and need the hex code for markup. The only thing it is missing is an alpha slider for getting the full hex code with opacity for Xaml.
March 17th, 2011 § Comments Off § permalink
Another recommended Visual Studio extension is Snippet Designer. I use this one a lot. About the second or third time I type the same code pattern I use this extension. It is a lot easier than writing the snippet by hand. You simply highlight the relevant code block and choose ‘Export Snippet’ from the right-click context menu. In the resulting snippet editor window you then select the sections to be replaced, set their properties in the grid at the bottom, set the overall properties of the snippet (description, shortcut, filename, etc.) in the property panel and save.
March 15th, 2011 § Comments Off § permalink
I’ve been trying to get more out of my programming environment with minimal or no investment if possible or targeted investment when necessary. One thing I’ve done in the minimal (read ‘free’) vein was to add the ‘PowerCommands for Visual Studio 2010’ and ‘Productivity Power Tools’ extensions. They add a host of usability improvements. I turned off the ‘Fix Mixed Tabs’ and ‘Ctrl+Click Go To Definition’ functions of Power Tools. The Mixed Tab feature tries to clean up any place in your code where you have a mixture of tabs and spaces. I found it annoying on a day to day basis. The Ctrl+Click got in the way of ctrl+click drag for copying. It doesn’t prevent it, but if you happen to click but fail to hold then the tool tries to navigate to the definition. For that I personally prefer F12 anyway.
To add (or remove) these extensions in Visual Studio go to Tools > Extension Manager and search for them in the Online Gallery or follow the links above to read more.