Author Archives: Mike Lane

Posting Source Code on WordPress.com

Wordpress-logo

Posting source code to WordPress.com is simply a matter of wrapping your code between tags that specify (among other things) the language you are using. For example:

your-code-here

The above code is displayed like this when your post is previewed or published:

your code here

The supported languages are:

actionscript3 bash clojure coldfusion
cpp csharp css delphi
erlang fsharp diff groovy
html javascript java javafx
matlab (keywords only) objc perl php
text powershell python r
ruby scala sql vb
xml

If a language is not specified the default is language is text (i.e. no syntax highlighting).

Some additional optional shortcodes are also supported and should be placed in the opening [code] tag (with a space between each one). Here are some examples of the ones that I have found most useful:

  • firstline (number) — Use this to change what the line numbering starts at. It defaults to 1. For example: firstline="3"
your code here
  • gutter (true/false) — If false, the line numbering on the left side will be hidden. Defaults to true. For example: gutter="false"
your code here
  • highlight (comma-seperated list of numbers) — You can list the line numbers you want to be highlighted. For example: highlight="1".
your code here

The following shortcodes are also supported:

  • autolinks (true/false) — Makes all URLs in your posted code clickable. Defaults to true.
  • collapse (true/false) — If true, the code box will be collapsed when the page loads, requiring the visitor to click to expand it. Good for large code posts. Defaults to false.
  • htmlscript (true/false) — If true, any HTML/XML in your code will be highlighted. This is useful when you are mixing code into HTML, such as PHP inside of HTML. Defaults to false and will only work with certain code languages.
  • light (true/false) — If true, the gutter (line numbering) and toolbar (see below) will be hidden. This is helpful when posting only one or two lines of code. Defaults to false.
  • padlinenumbers (true/false/integer) — Allows you to control the line number padding. true will result in automatic padding, false will result in no padding, and entering a number will force a specific amount of padding.
  • title (string) — Set a label for your code block. Can be useful when combined with the collapse parameter.

Sources:

http://en.support.wordpress.com/code/posting-source-code/

 

Windows Server 2012 Essentials – How to Skip Domain Join to Install the Client Connector

Windows 8 Logo

The Essentials Experience Role on Server 2012 provides (amongst other things) full client backup and restore capabilities – much like the now discontinued Windows Home Server. However, on Server 2012 joining the domain is mandatory for clients.

There is a workaround and it is possible to connect clients to the server without joining the domain – simply enter the following command in an elevated command prompt:

reg add "HKLM\SOFTWARE\Microsoft\Windows Server\ClientDeployment" /v SkipDomainJoin /t REG_DWORD /d 1

Below is a registry file that produces the same result:

Windows Registry Editor Version 5.00

; ##############################################################
; Skip Domain Join on Server 2012 R2 - Windows Server Essentials
; ##############################################################

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Server\ClientDeployment]
"SkipDomainJoin"=dword:00000001

We can now Connect Computers to the Server without joining the domain.

Note that domain features will not be available for clients that connect to the server in this way. This is only supported on Windows 7 & 8 (Professional and above).

Sources:

http://social.technet.microsoft.com/Forums/windowsserver/en-US/aa40963c-7235-40f7-85f5-8f8d030a7c13/how-to-skip-domain-joining-during-client-deployment-in-a-windows-server-2012-essentials-network?forum=winserveressentials

My First Windows Phone App (for Absolute Beginners)

Windows8-Phone-Logo

I’ve been interested in beginning Windows Phone / Windows 8 development in my spare time. I have been looking at some excellent video tutorials presented by Bob Tabor on Channel 9:

As I am an absolute beginner I wanted to create a simple app that would be of use to me. I ended up just laying out information from a .pdf using the panorama template for Windows Phone 8.1. Essentially it is just a fancy “Hello World” kind of app with graphics created / edited using Inkscape …

I found that this was a good exercise for starting to learn the basics of working with grids and layouts – textblocks, stackpanels and simple text formatting. This is the the app as it stands right now:

Changing the application name is very simple – just change the Panorama Title in MainPage.xaml:

         <!--Panorama control-->

        <phone:Panorama Title="TheraTog Care">

 

Next I commented out the code for the longlistselector so that I could hard-code my own data:

<!--Panorama item one-->
            <phone:PanoramaItem Header="Caution">
                <!--Single line list with text wrapping-->
                <!--<phone:longlistselector margin="0,0,-22,0" itemssource="{binding items}">
                    <phone:longlistselector.itemtemplate>-->
                        <!--<DataTemplate>-->

 

Then I setup columns and rows inside my grid:

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="50" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

Note: There are actually multiple instances of line 61 – one for each line of data displayed.

 Images were positioned into Grid rows:

                    <Image Source="Assets/No.png"
                           Grid.Row="1"
                           Height="30"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Right">
                    </Image>

 

Basic TextBlock formatting was straight-forward with margins, text-wrap and grid positions defined:

                    <TextBlock
                        Margin="18,5,0,0"
                        TextWrapping="Wrap"
                        Grid.Row="5"
                        Grid.Column="1"
                        Text="Wash seperate from other items of clothing">
                    </TextBlock>

 

The white background with black text was achieved with a white Border around a TextBlock:

                   <Border Background ="White"         
                            Grid.Row="7"
                            Grid.Column="1"
                            Margin="18,25,0,0">
                        <TextBlock
                        Margin="0,5,0,5"
                        TextWrapping="Wrap"
                        Grid.Row="8"
                        Grid.Column="1"
                        Foreground="Black"
                        TextAlignment="Center"                       
                        Text="Remove tabs before washing">
                        </TextBlock>
                    </Border>

 

For the About page I installed a NuGet package called YLAD (Your Last About Dialogue). I followed the documentation to add the text that I wanted to the About page. Then I just needed to add an Application Bar and link it to the About page:

        </phone:Panorama>

    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="MenuItem1_Click" Text="about"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>

 

As you can see the code for the Application Bar comes after the closing phone:Panorama and Grid tags. On line 715 I set the Mode to Minimized so that the Application Bar takes up as little space as possible. Line 717 is my first click event handler – below is the code behind in MainPage.xaml.cs:

        private void MenuItem1_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/YourLastAboutDialog;component/AboutPage.xaml", UriKind.Relative));
        }

 

Line 35 navigates to the YLAD About page.

While there is nothing complicated in this app I did already learn that I should be doing things differently. I should have defined a style to manage my textblocks. This would have really helped when i came to making changes to the formatting of my text and would have greatly reduced the amount of redundant code and copying and pasting that I did.

I used Inkscape to produce the graphics and a Windows Store app called Vector to produce the different size tiles that I needed for the start screen.

Other things to fix would be the size of the Panorama Title and a new Panorama background.

I have to say that I am surprised how much I have learned even from trying to produce something as simple as this. I’d like to have a go at a To-Do list for my next app …

 

Inkscape – Change the white background workspace to a transparent color

Windows 8 Logo

If you want to change the default workspace color in Inkscape from white to another color – here’s how to do it:

  • Press Ctrl, Shift and D to open the Document Properties window
  • Click on the Background color

Inkscape-background

  • Change the RGBA value to 888888FF

Inkscape-Backround-Color

Note: 888888 defines the color in hex – FF makes the color fully transparent.

Your workspace will now have a grey background.

Source: http://stackoverflow.com/questions/3510482/transparency-vs-white-background-in-inkscape

Enemy Territory – Cannot Adjust Gamma (Brightness)

Windows 8 Logo

I just installed Enemy Territory on Windows 8.1 and ran into a problem – I could not adjust the brightness (gamma) in the game. The slider would work and the brightness would flicker but then return to the default value.

I tried adjusting the Compatibility mode for the game and tried adjusting the gamma using the console in game:

/set r_gamma 1.5
/r_ignorehwgamma 1

The error in the console was this:

set DeviceGammaRamp failed

The solution turned out to be very simple – just turn off f.lux and everything was OK again!

If you have not heard of f.lux before it is a program that makes the color of your computer’s display adapt to the time of day.

Ubuntu Server 14.04 (Trusty Tahr) – Quick Headless Transmission Setup

ubuntu-server-logo

This is a quick post with a brief explanation of how to set up transmission on Ubuntu Server (currently 14.04 (Trusty Tahr)).

First make sure your repositories are up-to-date:

sudo apt-get update

Install transmission:

sudo apt-get install transmission-cli transmission-common transmission-daemon

Check to make sure that the transmission-daemon is not running – if it is it will overwrite any configuration changes that we make later:

sudo service transmission-daemon stop

Locate the transmission-daemon settings file:

sudo find / -iname settings.json

Two locations are found for this file:

/etc/transmission-daemon/settings.json
 /var/lib/transmission-daemon/info/settings.json

We will edit /etc/transmission-daemon/settings.json:

sudo nano /etc/transmission-daemon/settings.json

The changes that I made to settings.json are in red. You will need to provide your own settings to configure your setup:

"download-dir": "your-download-location",
"incomplete-dir": "your-download-location",
"rpc-password": "password",
"rpc-username": "username",
"rpc-whitelist": "127.0.0.1,192.168.0.*",
  • download-dir and incomplete-dir are directories where complete and incomplete torrents are stored. They do not have to be different directories.
  • rpc-password and rpc-username are the username and password for web access administration.
  • rpc-whitelist defines access to transmission. Localhost (127.0.0.1) is defined by default. I added ,192.268.0.* to allow any machine on my LAN access.

Start the transmission-daemon:

sudo service transmission-daemon start

Verify that everything is working by opening a broswer and pointing it to http://server-ip:9091.

Sources:

https://forum.transmissionbt.com/viewtopic.php?f=8&t=8361

http://www.webupd8.org/2009/12/setting-up-transmission-remote-gui-in.html

Ubuntu Server 14.4 (Trusty Tahr) – add-apt-repository: command not found

ubuntu-server-logo

The last time I encountered the add-apt-repository: command not found error I was using Ubuntu Server 12.4 Lucid. The solution then was to install python-software-properties as follows:

sudo apt-get install python-software-properties

 

This did not resolve the issue on my minimal virtual machine installation on Trusty so I installed apt-file – which is an apt package searching utility:

sudo apt-get install apt-file

 

Update apt-file:

apt-file update

 

Finally use apt-file to search for the add-apt-repository package:

apt-file search add-apt-repository

 

As you can see add-apt-repository is in software-properties-common:

software-properties-common: /usr/bin/add-apt-repository
software-properties-common: /usr/share/man/man1/add-apt-repository.1.gz

 

After installing software-properties-common I was able to use add-apt-repository without any further issue:

sudo apt-get install software-properties-common

VMware vSphere 5.5 – Call “HostStorageSystem.ComputeDiskPartitionInfo” for object “storageSystem” on ESXi failed

Intel NUC

I recently installed VMware vSphere 5.5 on my Intel (Haswell) NUC (D34010WYH1).

Today I got the following error when I tried to create a VMFS 5 datastore on the SATA hard drive that I installed in my NUC:

Call "HostStorageSystem.ComputeDiskPartitionInfo" for object "storageSystem" on ESXi failed

A quick search of the internet took me to this solution which required logging as root and manually deleting partition on the drive.

Fortunately I found a simpler solution.

I was able to create a datastore using the (legacy) VMFS 3 filesystem and then just upgraded it to VMFS 5.

Installing VMware vSphere ESXi 5.5 on an Intel (Haswell) NUC (D34010WYH1)

Intel NUC

My vSphere hardware has long been due an update and I have finally got my hands on an Intel NUC ! Here is my (completely un-supported) parts list:

The D34010WYH1 NUC gives me the option of storing virtual machines on a 2.5 inch HDD or SSD inside the NUC (and the 1TB WD Red drive gives me a good amount of local storage to play around with). The RAM is low voltage (1.35v) which is required. The 32 Gb USB 3 flash drive is over-kill (only 4GB is required for vSphere 5.5) but it is very small (and pretty fast too). I needed the HDMI adapter to connect the NUC to my HDTV during vSphere installation.

The installation process is quite straight-forward and you will need the following:

Before installing vSphere we need to create a custom .iso image that includes the two .vib drivers that we downloaded. This is done using ESXi Customizer.

ESXi-Customizer 01

The first time you run ESXi Customizer select the vSphere 5.5 ,iso image and the network driver (net-e1000e-2.3.2.x86_64.vib) to create a customized image.

Run ESXi Customizer again and this time select the customized .iso image and add the sata driver (sata-xahci-1.10-1.x86_64.vib) to create a final customized .iso image.

I chose to burn my customized .iso to CD and install using a USB DVD drive – if you want to use a flash drive to install you will need to use UNetbootin.

UNetbootin

In UNetbootin select the Diskimage radio button and then browse to the location of your final custom .iso. Select the flash drive to copy files to and then click the OK button.

In the BIOS of my NUC I disabled the UEFI option in the Boot menu. After that I booted from my USB DVD drive and installed vSphere to a USB 3 flash drive.

[I did test installing from one flash drive to another too and this also worked without any issues].

Sources:

http://trainingrevolution.wordpress.com/2013/12/30/installing-vsphere-esxi-5-5-on-an-intel-nuc-d54250wyk/

http://www.virten.net/2013/09/esxi-5-x-installation-on-intel-nuc-fails-with-no-network-adapters/