As you can see, Ookii.org has gotten a revamp. Now you may wonder, why make such a radical update to a site when the content doesn't change that often? The main reason is that I wanted to get my hands dirty with some modern web technology.
While web development has never been particularly important to me, it was something I knew how to do and I kept somewhat up-to-date with. This dates back to making the site for my high school (at the time in Frontpage). However, as I'd been busy with my Ph.D. in Japan, I had very little time to keep up to date with stuff I didn't have any need to use in my research. Now that I've finished and haven't started my new job yet, it was the ideal time to brush up a little.
Back when I started this site, I wrote it in ASP.NET 2.0. I hand-rolled an AJAX library, because jQuery was years from being invented and actually AJAX support in websites wasn't all that common yet. The AJAX parts of the site used web services that returned data in XML, because no one had thought to start using JSON yet either. "Mobile browsers" at the time meant IE for Windows Mobile, which didn't support script at all and was barely on par with IE6 on the desktop otherwise. And speaking of IE6, supporting that was still very much a priority at the time.
But things have changed, and the goal was to re-familiarize myself with the state of the art. So this site is written in ASP.NET MVC 4, using the Entity Framework for data access. On the client, it uses HTML5 and CSS3, with scripts utilizing jQuery and a few related libraries. The site now has a responsive layout thanks to Zurb Foundation (try it: resize your browser window and watch the layout change), which has the side-effect of making it much more friendly for mobile devices. I've also used Knockout.
I have to say I was surprised at how much web programming has changed. ASP.NET MVC is light-years beyond the old web forms. Not only are the frameworks much better and the HTML/CSS much cleaner (at least, as long as you only target modern browsers), the tooling (in the form of Visual Studio 2012 in my case) also has improved tremendously.
Besides just redesigning the layout, I've also made a new front page that de-emphasizes the blog a little (since I don't update it that often), and instead provides a few more useful links as well as news about my Let's Plays from the associated Twitter account.
Note that not everything uses the new layout. Currently, only the blog has been updated. I intend to move other sections of the site to the new layout over time.
Let me know what you think, or if you find something that's broken.
Yes, I realise this blog is all but dead. However, I will soon finally complete my Ph.D. at the University of Tokyo (so, yay me!), and as a result I can now finally release a few things that had been put on hold while I was writing my Ph.D. thesis. In addition, I will probably release a few projects related to my research that may hopefully be of interest to some people.
First up is a small update to Ookii.CommandLine. This update adds command line argument aliases, some updates for usage help generation, and code snippets to help with creating argument classes.
In addition, I used NuGet to create a symbols package and published it on SymbolSource, which you should apparently be able to use as a symbol server in Visual Studio without manually downloading the symbols.
Windows Virtual PC 7 is the successor to Virtual PC 2007, and the only version of Virtual PC that can run on Windows 7. It's freely available to anyone, and if you have Windows 7 Professional or Ultimate, you can also download Windows XP Mode, a virtual machine of Windows XP that allows you to run applications that may not otherwise work on Windows 7.
It seems however that Microsoft has removed the UI for using floppy disks with Windows Virtual PC 7. It was there in Virtual PC 2007, and now it's not. However, here's the thing: they only removed the UI, not the functionality itself.
The functionality for using floppy disks is still available in Windows Virtual PC 7, but it's only accessible via the COM object, which is not very convenient. Fortunately, Windows 7 also includes PowerShell, a very powerful shell scripting environment, that allows us to make things a bit easier.
Below, I present three PowerShell scripts: one to create virtual floppy disk images, one to attach floppy disks to a VM, and one to release them. The latter two can be used with both virtual floppy disk images, or a real floppy drive on the host computer.
You can download all three scripts here. Or you can just copy/paste them into a file, whichever you prefer. Note that you'll need to configure PowerShell to allow unsigned scripts to run, or sign the scripts.
Anyway, here are the scripts:
Create-VirtualFloppy.ps1:
param( [parameter(Position=0, Mandatory=$true)][string]$Path ) $vpc = New-Object -ComObject "VirtualPC.Application" if( -not [System.IO.Path]::IsPathRooted($Path) ) { # CreateFloppyDiskImage requires an absolute path [Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath $Path = [System.IO.Path]::GetFullPath($Path) } $vpc.CreateFloppyDiskImage($Path, 2)
Attach-VirtualFloppy.ps1:
param( [parameter(Position=0, Mandatory=$true)][string]$VirtualMachineName, [parameter(Position=1, Mandatory=$true)][string]$FloppyPath, [parameter(Mandatory=$false)][Switch]$HostDrive ) $vpc = New-Object -ComObject "VirtualPC.Application" $vm = $vpc.FindVirtualMachine($VirtualMachineName) if( $vm -eq $null ) { Write-Error "Virtual machine $vm not found." } else { if( $HostDrive ) { $vm.FloppyDrives.Item(1).AttachHostDrive($FloppyPath) } else { if( -not [System.IO.Path]::IsPathRooted($FloppyPath) ) { # AttachImage requires an absolute path [Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath $FloppyPath = [System.IO.Path]::GetFullPath($FloppyPath) } $vm.FloppyDrives.Item(1).AttachImage($FloppyPath) } }
Release-VirtualFloppy.ps1:
param( [parameter(Position=0, Mandatory=$true)][string]$VirtualMachineName ) $vpc = New-Object -ComObject "VirtualPC.Application" $vm = $vpc.FindVirtualMachine($VirtualMachineName) if( $vm -eq $null ) { Write-Error "Virtual machine not found." } else { if( $vm.FloppyDrives.Item(1).ImageFile -ne $null ) { $vm.FloppyDrives.Item(1).ReleaseImage() } elseif( $vm.FloppyDrives.Item(1).HostDriveLetter -ne $null ) { $vm.FloppyDrives.Item(1).ReleaseHostDrive() } else { Write-Warning "No virtual floppy is attached to the virtual machine $VirtualMachineName." } }
Using the scripts is pretty simple. Run PowerShell, navigate to the directory where you put the scripts, and invoke them. Remember that you need to enable execution of unsigned scripts (Set-ExecutionPolicy RemoteSigned), or sign the scripts.
The following example creates a virtual floppy drive image called sample.vfd, attaches it to the Windows XP Mode virtual machine, and then releases it again:
.\Create-VirtualFloppy.ps1 sample.vfd .\Attach-VirtualFloppy.ps1 "Windows XP Mode" sample.vfd .\Release-VirtualFloppy.ps1 "Windows XP Mode"
Please note that the virtual machine must be running for attach and release to work.
The following example attaches the host floppy drive A and then releases it again:
.\Attach-VirtualFloppy.ps1 "Windows XP Mode" A -HostDrive .\Release-VirtualFloppy.ps1 "Windows XP Mode"
And that's it! Now you can use floppy disks with Windows Virtual PC 7 once again.
Last month, on September 13th to 17th, I attended the 36th International Conference on Very Large Databases (VLDB 2010) in Singapore, to present a paper at the Ph.D. workshop.
Not only was this the first time I've been to such a large international conference (which was very interesting because it allowed me to talk to a lot of experts in my field and see what other people are doing), it was also the first time I ever visited Singapore.
Fortunately, I was able to get some time for sightseeing, and these pictures are the result. :)
With the release of .Net 4.0 I have updated the FormatC syntax highlighter (used for all code samples on ookii.org) to support new keywords introduced in Visual Basic 10.0 and C# 4.0.
That's not the only update, however. FormatC 2.0 also has the ability to escape contextual keywords (previously, it would treat them as keywords regardless of the context), type name highlighting support for Visual Basic and improved XML literal support in Visual Basic.
PowerShell support is also improved; FormatC will try to use the parser included with PowerShell 2.0 to parse the code. Unfortunately, this web server does not have PowerShell 2.0 installed, so the online version of the highlighter will still use regular expressions to highlight PowerShell code.
If you have any feedback about FormatC, please leave it as a comment on this blog post.
Sample C# code highlighted using FormatC:
public static int SumAuthorPrices(IEnumerable<Book> books, string author) { if( books == null ) throw new ArgumentNullException("books"); return (from b in books where b.Author == author select b.Price).Sum(); }
Sample Visual Basic code highlighted using FormatC:
Public Shared Function ConvertToXml(ByVal books As IEnumerable(Of Book)) As XDocument If books Is Nothing Then Throw New ArgumentNullException("books") End If Return <?xml version="1.0"?> <Books> From b In Books Select <Book Author= b.Author Price= b.Price > b.Title </Book> </Books> End Function
Sample XML code highlighted using FormatC:
<?xml version="1.0"?> <Books> <Book Author="Peter F. Hamilton" Price="18.99"> The Evolutionary Void </Book> </Books>
Sample T-SQL code highlighted using FormatC:
SELECT title, author, publisherName FROM Books b INNER JOIN Publisher p ON b.publisherId = p.id WHERE b.price >= 10
Sample PowerShell code highlighted using FormatC (this used the parser-based method, not regular expressions):
foreach ($file in Get-ChildItem) { if ($file.Length -gt 100kb) { Write-Host -ForegroundColor Green $file Write-Host $file.Length Write-Host $file.LastAccessTime } }