24 October 2009

life update - software learning

I'm currently reading Journey of the Software Professional: Sociology of Computer Programming. It's proved so far to be a unique insight into how developers go from seeing a problem to providing a solution, good or bad. It's quite hard going as there's a lot of detailed analysis into how we work, but it's certainly given me food for thought.

In another area of self improvement, I recently passed 70-536: TS: Microsoft .NET Framework - Application Development Foundation, and am currently reading up on the ASP.NET exam with a view to gaining the MCTS cert. Much as I had hoped I'd left exams behind years ago, it is proving to be a useful exercise in filling in the gaps in my knowledge. Today I finally got around to creating something with Web Parts, which I wouldn't otherwise have done, another plan filed away in my cognitive library (cf. Journey of the Software Professional).

23 October 2009

backuppc and windows vista

Steps I took to get a backuppc server on an ubuntu 8.10 pc in order to be able to back up a windows vista business pc. I've only documented the non-obvious and undocumented items here.
  • Added a user called backup to the vista pc.
  • Added the backup user to the "administrators" group. I tried the "backup operators" group but it didn't give access to the user profiles. It looks like robocopy has some black magic that allows it to bypass ACLs when a member of backup operators.
  • Enabled admin shares (ie \\machine\C$) by adding DWORD registry key "LocalAccountTokenFilterPolicy" to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System and setting the value to 1. See How to access Administrative Shares on Vista (C$) by PaulSpoerry
  • Removed the "-N" from the SmbClientFullCmd etc options in backuppc's transfer (xfer) settings as it didn't seem to be using the provided password. Troubleshooting was aided by running "/usr/share/backuppc/bin/BackupPC_dump -v -f vistamachine" directly as user backuppc.
  • Hide the backup user from the welcome screen by adding DWORD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList\backup with value 0 to the registry. "backup" is the name of the user to hide, 0 means hide, 1 means show.
enjoy.

See also:
Current status: This has only been partially successful so far. The backup runs but has lots of files missing due access denied errors on many of the important folders. It looks like I will have to manually give "backup operators" permissions to these folders. Sigh. Vista is proving to be less than easy for me to support.

11 April 2009

git-svn imports for open source projects

I've just written a lengthy open letter to github in the hope that they will support continuous centralized imports from svn to git.

If they don't wish to rise to the challenge (and I wouldn't hold it against them), I am wondering if it would be viable to run a server on fasthosts or something funded by donations that would do nothing but continuously import from svn servers, and push the result to github.

That's all for now.

mini police eye in the sky

Just a quick note on an idea that's been bothering me.

How about a mini semi autonomous police surveillance helicopter?

Would cheaper than a real helicopter, but still offers many of the advantages of having an eye in the sky that can go direct to the scene without contending with traffic etc.

Something like a electric model helicopter with 2+ blades for stability, with a petrol generator for longer run times.

Electronics and gyros to make it naturally stable, and a gps & altimeter for auto navigation.

Carrying a payload of normal and infrared cameras for information gathering.

Transmitting a live video feed over long range radio, and offering long distance control, so it could be controlled centrally by an operator.

I reckon these could be produced for a few thousand pounds each and provide excellent assistance to the force.

29 January 2009

format all documents in a visual studio solution

Here's a handy macro script for visual studio I knocked together today.
It runs "edit, format document" on every document of the listed file types.

You have to keep an eye on it as it's interactive and does sometimes pop up a message and wait for an answer.

You can get the vb file at http://github.com/timabell/vs-formatter-macro
More info at http://wiki.github.com/timabell/vs-formatter-macro

Below is the original code. Note that this is older than the version available on github above.


Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Public Module Formatting

Dim allowed As List(Of String) = New List(Of String)
Dim processed As Integer = 0
Dim ignored As Integer = 0
Dim errors As StringBuilder = New StringBuilder()
Dim skippedExtensions As List(Of String) = New List(Of String)

Public Sub FormatProject()
allowed.Add(".master")
allowed.Add(".aspx")
allowed.Add(".ascx")
allowed.Add(".asmx")
allowed.Add(".cs")
allowed.Add(".vb")
allowed.Add(".config")
allowed.Add(".css")
allowed.Add(".htm")
allowed.Add(".html")
allowed.Add(".js")
Try
recurseSolution(AddressOf processItem)
Catch ex As Exception
Debug.Print("error in main loop: " + ex.ToString())
End Try
Debug.Print("processed items: " + processed.ToString())
Debug.Print("ignored items: " + ignored.ToString())
Debug.Print("ignored extensions: " + String.Join(" ", skippedExtensions.ToArray()))
Debug.Print(errors.ToString())
End Sub

Private Sub processItem(ByVal Item As ProjectItem)
If Not Item.Name.Contains(".") Then
'Debug.Print("no file extension. ignoring.")
ignored += 1
Return
End If
Dim ext As String
ext = Item.Name.Substring(Item.Name.LastIndexOf(".")) 'get file extension
If allowed.Contains(ext) Then
formatItem(Item)
processed += 1
Else
'Debug.Print("ignoring file with extension: " + ext)
If Not skippedExtensions.Contains(ext) Then
skippedExtensions.Add(ext)
End If
ignored += 1
End If
End Sub

Private Sub formatItem(ByVal Item As ProjectItem)
Debug.Print("processing file " + Item.Name)
Try
Dim window As EnvDTE.Window
window = Item.Open()
window.Activate()
DTE.ExecuteCommand("Edit.FormatDocument", "")
window.Document.Save()
window.Close()
Catch ex As Exception
Debug.Print("error processing file." + ex.ToString())
errors.Append("error processing file " + Item.Name + " " + ex.ToString())
End Try
End Sub

Private Delegate Sub task(ByVal Item As ProjectItem)

Private Sub recurseSolution(ByVal taskRoutine As task)
For Each Proj As Project In DTE.Solution.Projects
Debug.Print("project " + Proj.Name)
For Each Item As ProjectItem In Proj.ProjectItems
recurseItems(Item, 0, taskRoutine)
Next
Next
End Sub

Private Sub recurseItems(ByVal Item As ProjectItem, ByVal depth As Integer, ByVal taskRoutine As task)
Dim indent As String = New String("-", depth)
Debug.Print(indent + " " + Item.Name)
If Not Item.ProjectItems Is Nothing Then
For Each Child As ProjectItem In Item.ProjectItems
taskRoutine(Child)
recurseItems(Child, depth + 1, taskRoutine)
Next
End If
End Sub

End Module

18 December 2008

password-free ubuntu login with facebrowser

If you trust everyone who has physical access to a pc (if not then you are encrypting your files, right?) then there seems little point in having to type a password just because more than one user uses the pc.

So here's how to log in from the gdm "face browser" with a single click.
Instructions tested with Ubuntu 8.04 Hardy Heron and 8.10 Intrepid Ibex.


as root, create a new file containing the usernames of all the users you want be able to log in through gdm without entering a password:

sudo -i
echo 'username' >> /etc/gdm/nopassusers

now still as root modify the pam settings for gdm to check this file and allow this user in based on being in the list:
vi  /etc/pam.d/gdm

vi /etc/pam.d/gdm

and modify to contain the new listfile item

#%PAM-1.0
auth requisite pam_nologin.so
auth required pam_env.so readenv=1
auth required pam_env.so readenv=1 envfile=/etc/default/locale
auth sufficient pam_listfile.so item=user sense=allow file=/etc/gdm/nopassusers onerr=fail #add this line
@include common-auth
auth optional pam_gnome_keyring.so
@include common-account
session required pam_limits.so
@include common-session
session optional pam_gnome_keyring.so auto_start
@include common-password

now simply restart gdm (or the whole machine) and try your new one-click login

/etc/init.d/gdm restart



Notes:
This means the keyring isn't unlocked, so you may have to type in your password anyway before your wireless connects.


references:
http://mirror.hamakor.org.il/archives/linux-il/05-2004/10149.html
http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_listfile.html

10 September 2008

error "Not a valid object name" filtering an ex-svn git repo with renames

Under git version 1.5.4.3, which as of writing is the current in ubuntu 8.04 hardy heron, trying to split out a folder from a git repo where the repo was an import from subversion (svn), and the folder was renamed in the past causes a failure as show below:

#!/bin/bash -v
rm -rf test-case
mkdir test-case
cd test-case/
svnadmin create svnrepo
export repo="`pwd`/svnrepo"
mkdir -p import/a
echo '1' >> import/a/file.txt
svn import -m 'initial import' import file://$repo/trunk/
svn co file://$repo/trunk/ checkout
echo '2' >> checkout/a/file.txt
svn ci -m "file modified" checkout
svn mv -m "moving file" file://$repo/trunk/a file://$repo/trunk/b
svn up checkout
echo '3' >> checkout/b/file.txt
svn ci -m "modified again" checkout
svn log -v checkout
mkdir -p gitcopy/a
git svn clone file://$repo/trunk/ gitcopy/a
cd gitcopy/a
git filter-branch --subdirectory-filter a #fails [1]
cd ../../
mkdir gitcopy/b
git svn clone file://$repo/trunk/ gitcopy/b
cd gitcopy/b
git filter-branch --subdirectory-filter b


The marked line above fails with the following error:
[1] Rewrite bcfe73ef303832b6112a2419dc1da5f782672c14 (3/3)fatal: Not a valid object name bcfe73ef303832b6112a2419dc1da5f782672c14:a

This has been fixed in the latest build of git: version 1.6.0.1.294.gda06a and no longer fails.

The "fatal: Not a git repository" error message that filter branch produces doesn't seem to matter.