Tuesday, June 1, 2010

Administrator permissions required to access/save/delete/…
I am Administrator!

A really annoying thing with Windows UAC is when you are logged in to an account with administrator privileges, but you keep getting prompts for “Admin permissions required…”.

Its the UAC, but before you go turning that off, more specifically its the “Admin Approval Mode” in UAC. For the built-in Administrator account this is disabled by default, but it is enabled for the administrators group. To disable:

  • Start > Administrative Tools > Local Security Policy > Local Policies > Security Options.
  • Then find (third from the bottom) "User Account Control: Run all administrators in Admin Approval Mode", right-click, properties, Disable.

You can see it already disabled (default) for the Built-in Admin account a few above (10 from bottom).

This worked for Server 2008, but I presume its similar for Vista, Windows 7, all UAC?

PS: while you’re busy configuring, check out god mode ;-)

Thursday, November 19, 2009

Classic ALT+TAB on Windows 7

When it comes to ALT+TAB preview I like the classic XP style. It shows the application icons, plain and simple and great for my workflow. Windows 7 instead shows low res thumbnails of the running applications that all look too much the same, and flashes the applications around in the background like a bunch of popup advertising…

Anyway good-ol-classic it is still there with a little help from the second ALT key:

ALT + (tap the other ALT key) + TAB

That is; while holding down the first ALT key, tap and release the second ALT key, then tap the TAB key as usual to scroll.

Anyone know a setting to make it default?

Update: see comments below for a Registry key setting to make this default.

Saturday, November 14, 2009

Using jQuery Selectors to Select all/Select none in checkboxes

jQuery is fun! Using jQuery Selectors you can select page elements in all sorts of ways - in this example to select/unselect all checkboxes where name starts with 'chk-' (formatted 'chk-{id}'):

<a href="#" title="Select all" onclick=
"$('input[name^=chk-]').attr('checked', 'checked')">
all</a>
|
<a href="#" title="Select none" onclick=
"$('input[name^=chk-]').removeAttr('checked')">
none</a>

<input id="chk-200" name="chk-200" type="checkbox" />
<input id="chk-201" name="chk-201" type="checkbox" />
...
Gotta love jQuery!

Tuesday, October 27, 2009

Visual Studio 2010 and Local Report Viewer for 2008 RDL

With the release of Visual Studio 2010 Beta 2, the Reporting Services local report viewer has finally come out of it's 2005 timewarp, to handle 2008 RDL and proper export functionality.

I found some of the new ReportViewer 10.0 assemblies in the ‘Add Reference’ dialog box - enough to run the app on the dev machine - but not ProcessingObjectModel.dll which I had to dig out of the GAC (GACView makes it easy to copy out).

Deploying these 3 new dll’s with a .NET 3.5 application and reports still based on 2005 RDLC, seems to run fine…

Saturday, September 12, 2009

Running a Web Server on a dynamic IP address

Modern broadband internet speeds make it easy to host your own development/test web server. But the dynamic IP address supplied by most ISPs requires some extra steps to maintain the pointer from the web to your server.

Handling dynamic IP is relatively easy with a DNS service that can handle dynamic IP updates. There are many services available, and I recently moved all my domains to EveryDNS based on their features and straightforward service.

DNS setup

I wanted to keep my existing hosted services and also point sub-domain names to my own development/test server. So I set up the main sites as primary domains (steps 1,3 in image below) pointing to various hosted services:

    
mydomain.com, 'A' record to IP of professional hosting service
mail.mydomain.com, 'CNAME' record to ghs.google.com

and then some dynamic domains (steps 1,2,3 in image below) as sub-domains pointing to the test server:
    
abc.mydomain.com, 'A' record to IP of my-server
xyz.mydomain.com, 'A' record to IP of my-server

dyndomain
Note the DNS names that EveryDns give you, you’ll need to go to your registrar and point your domain name to these name servers (all 4 of them, nice!).

Allow a few minutes or so for this info to filter through the servers, and you should be able to browse to your site.

Updating the dynamic IP

To keep EveryDns automatically updated with your server IP address you call a special page on their website; they check the source of your request and update their records accordingly. There are a few update clients available that do this for you (and some routers provide built in support), but I wanted a bit more control and it was fun to roll my own using powershell.

In summary this script gets your current IP address, compares it to the last IP address update, and if different does a new update:

$getUrl = "http://whatismyip.com/automation/n09230945.asp"
$setUrl = "http://dyn.everydns.net/index.php?ver=0.1"
$user = "your-username"
$pass = "your-password"
$log = "path-to-log-file"
$update = "path-to-cache-file"
$timestamp = (Get-Date).ToString("yyyy.MM.dd HH:mm:ss")

# check

$ip = (new-object System.Net.WebClient).DownloadString($getUrl)
if ($error) {
Add-Content $log "[$timestamp] FAIL** Get ip failed with: $error"
exit
}
if ((Test-Path $update) -and ($ip -eq (Get-Content $update))) {
exit # nothing to do
}

# update

$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential($user, $pass)
$result = $webclient.DownloadString($setUrl)

# verify

if ($error) {
Add-Content $log "[$timestamp] FAIL** Update id failed with: $error"
exit
}
$code = [Regex]::Match($result, "Exit code: (\d+)").Groups[1].Value
if ($code -eq 0) {
Set-Content $update $ip -Force
Add-Content $log "[$timestamp] UPDATE Set ip: $ip"
}
else {
Add-Content $log "[$timestamp] FAIL** Received exit code: $code"
}

To automate the running of the script, create a new task in Windows Task Scheduler; I chose to Trigger the task at startup and repeat every 5 minutes, and Action start program Powershell with arguments -command "& 'path-to-my-powershell-script-file' " (mind the quotes, single inside double).

Its well worth the effort to be able to spin up new test/demo sites at will.

Thursday, August 20, 2009

Git diff and difftool, open all files immediately, not in serial

The default behaviour for git diff and git difftool is to open each file in a new window one at a time, only opening the next file after the previous has closed - its a one-by-one, one direction process.

I wanted them to open all at once, so that in a external diff tool such as BeyondCompare all files would open immediately in tabs within a single window.

Hunting around I found a couple of related workarounds (here and here), which involved copying the appropriate before/after files to temp directories and doing a folder diff. But I wanted something simpler, more lightweight, and the breakthrough came when I played with background tasks in bash.

The result of some testing was git diff --name-only to get a file list and git difftool & to diff in a background task; initially using a for-loop, followed by some input/improvements (David and kaizer.se), until the following was finally settled on:

Git diffall

1. Write the following code to a file called git-diffall and place in your path (I put it in …/my-git-install-dir/cmd/ )

#!/bin/sh
git diff --name-only "$@" | while read filename; do
git difftool "$@" --no-prompt "$filename" &
done

2. And run it in git (with usual diff input parameters), for example:

git diffall
git diffall HEAD
git diffall --cached
git diffall rev1..rev2

The initial journey started here at StackOverflow, but I thought this was good content for a first blog post - hope you find it useful.