Generic attributes would be awesome

Generic attributes would be awesome

Profile for Saitek Cyborg v3.0 Mouse

I have been looking for a new mouse for several weeks now and recently bought the Saitek Cyborg v3.0 Mouse. Unless you did not know, I love the Saitek Cyborg kit to bits, more for thier profiling software than anything else.

I have bought a couple of keyboards specifically for gaming but never a mouse. My main requirement for the mouse was to have very good movement tracking (acceleration, dpi etc) and a dynamic DPI setting and I settled on the Saitek mouse after looking through many other models of mouse highly recommended by gamers.

This mouse has 7 buttons:

  • Left, right and middle
  • Forwards and backwards
  • An extra thumb button
  • And a mode selector button

There are 3 modes on the mouse, which means you can profile up any button on the mouse to do something other than its default action. The other nice thing is that you can specify the desired DPI that you wish in each mode.

I have a profile that represents High, Medium and Low DPI and I use that extra thumb button as an additional shift state to allow me to boost the mouse senstivity should I need. The nice thing is that I can run around with high sensitivity then look down a scope and hold the thumb button to increase my accuracy.

The wire is nice and long but it does feel a little light and slightly cheap (it wasn’t cheap). This might be because I am more used to a wireless with batteries in it.

Grab my profile here and here’s a preview:

Moving profile folders to another drive

I use the Run app in windows an awful lot. I know the new start menu in Vista/7 offer a more advanced indexed version of the run command but I just can’t shake the habit. Also it doesn’t do the common folders a developer is looking for, such as Desktop, Temp folder etc etc.

The main problem with it after you have moved all of the profile folders to another drive, is that you cannot get to folders like the desktop, Windows just cannot find them anymore. I know you could probably go into the registry and start hacking around and telling Windows where else to go for the user folders but that just never sat quite right with me.

So here is a neat little trick I found, goto the user folder (C:\Users\Logaan) and create a shortcut with the same name as the folder you wish to get to.

Its so simple and I cannot believe that I found this years ago.

Its so cool you can even create links to other folders that you cannot usually get to in this fashion.

Enjoy.

Composite WPF Presentation Model item template

Neat little template I designed for use at work which is an improvement over the ViewModel code snippet.

Download PresentationModel item template

How to use

It is a bit unusual the way I have written this. Instead of specifying the file name for the item, it is the view name that is to be used.

When prompted for the ViewName, specifying “MainWindow” will create:

A xaml user control called MainWindowView.xaml.

An interface called IMainWindowView.

An interface called IMainWindowViewModel.

A class called MainWindowViewModel.

(Some of this is very similar to the ViewModel code snippet)

Interface Properties

Basically rip-offs of the prop and propg code snippets you get with Visual Studio but without the scope or accessor keywords.

iprop

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>iprop</Title>
			<Shortcut>iprop</Shortcut>
			<Description>Code snippet for an automatically implemented property on an interface</Description>
			<Author>Alex Boyne-Aitken</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>Property type</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>Property name</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[$type$ $property$ { get; set; }$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

ipropg

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>ipropg</Title>
			<Shortcut>ipropg</Shortcut>
			<Description>Code snippet for an automatically implemented property with a 'get' accessor for interfaces</Description>
			<Author>Alex Boyne-Aitken</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>Property type</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>Property name</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[$type$ $property$ { get; }$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

How to learn Programming

Read a fantastic article on Life Hacker on how to teach yourself computer programming: http://lifehacker.com/5401954/programmer-101-teach-yourself-how-to-code

My only comment would be pick a language that is based on C-like syntax (rather than use Python or VB) because although the syntax may seem harder, the syntax is more transferrable to other languages and it would give you a head start.

In my personal experience, a book only served as a reference. I found books that taught me how to do something soon became too basic for my needs and often there are plenty of guides on the internet that is a good replacement. Instead you will find much of my library consists of reference books, hint, tips and advanced topics.

CyTS library stalling

On our guild website, we have a block in the portal that shows who is currently on teamspeak. This uses the CyTS library to connect and get such information and occasionally it would cause the portal to stop loading.

In each case I would get home, load it up and not find any problems at all. Well today was a different matter, I was able to pin point the exact issue. For some reason the library connects to the server but then stalls when receiving information from the server.

I should tell you know, this is not a perfect fix but it does the job. I did look into other options like switch socket blocking on and off and such other approaches, but it seems that if fgets reads more than 1 byte, it stalls. This is a bug in PHP that has hung around for a while.

I have changed the _readcall function to read the first byte, check it for failure then continue with the rest.

function _readcall()
{
	if (!is_resource($this->sCon))
		return false;

	// HACK : Workaround to fail fast
	$first = fgets($this->sCon, 1);

	if($first === false)
		return false;

	$sRead = '';
	do
	{
		$cRead = $first.fgets($this->sCon);
		$first = '';

		$sRead .= $cRead;
	} while ($cRead != CYTS_SYN && $cRead != CYTS_OK && strtoupper(substr($cRead, 0, 5)) != "ERROR");
	return $sRead;
}

View model property

Because I am so lazy :P

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>View model property snippet</Title>
			<Shortcut>vmprop</Shortcut>
			<Description></Description>
			<Author>Alex Boyne-Aitken</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
        <Literal>
          <ID>name</ID>
          <ToolTip>Property name</ToolTip>
          <Default>Field</Default>
        </Literal>
        <Literal>
          <ID>field</ID>
          <ToolTip>Field name</ToolTip>
          <Default>field</Default>
        </Literal>
        <Literal>
          <ID>type</ID>
          <ToolTip>Type</ToolTip>
          <Default>object</Default>
        </Literal>
			</Declarations>
			<Code Language="csharp">
        <![CDATA[
    $type$ $field$;
    public $type$ $name$
    {
        get { return $field$; }
        set
        {
            if ($field$ == value)
                return;

            $field$ = value;
            SendPropertyChanged("$name$");
        }
    }
			$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

MSBuild creating lots of temp files

UPDATE:

I found a msdn forum post with exactly the same issue: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/42647eff-ecb8-412c-a884-a152b6fdd40d

It turns out that it is NOT msbuild but it is SN.exe leaving the temp files behind when resigning assemblies. I suppose you could easily come to this conclusion when watching the build and those files are flashing by so quickly.

On reflection a custom task will not help either…

This post has more details on the issue with a link to a hot fix for Server 2003: http://blogs.msdn.com/pfedev/archive/2008/10/24/sn-exe-and-empty-temp-files-in-temp.aspx

If you are using Server 2008 I would not recommend installing it.

Continue reading ‘MSBuild creating lots of temp files’ »

Simpler version of the 7-Zip backup

I have tested the 7-Zip backup I had constructured that I posted about a while back and I have come to realise that it is a tad bit too complicated. I even went through the process of creating a proxy application to try and get it to be a bit more cleverer but in the end I simplified it down to just 4 parts; the logic, settings and file lists.

Backup.cmd

@ECHO OFF

ECHO 7-Zip backup script
ECHO Written by Alex Boyne-Aitken
ECHO Last update: 07/11/2009
ECHO.

ECHO TRACE: Parse arguments: '%~f1'
IF EXIST %~f1 GOTO labelBegin

ECHO.
ECHO ERROR: Settings file not found!
GOTO labelWaitEnd

:labelBegin

ECHO.
ECHO TRACE: Reading settings
FOR /F "eol=# tokens=1,2 delims==" %%i IN (%~f1) DO (
SET %%i=%%j
ECHO TRACE: %%i = '%%j'
)

SET varTimeStamp=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%-%TIME:~0,2%-%TIME:~3,2%
SET varTargetBackupSet=%varBackupPath%\%varTimeStamp%-backup.zip

ECHO.
ECHO TRACE: Backup set: '%varTargetBackupSet%'
ECHO TRACE: Command line: '"%varPathToSevenZip%\7z" a -t%varArchiveType% "%varTargetBackupSet%" @"%varInclusionsFile%" -xr@"%varExclusionsFile%"'

ECHO.
ECHO TRACE: Executing backup
"%varPathToSevenZip%\7z" a -t%varArchiveType% "%varTargetBackupSet%" @"%varInclusionsFile%" -xr@"%varExclusionsFile%"

IF /I NOT "%varWaitAtEnd%" == "true" GOTO labelEnd

:labelWaitEnd
PAUSE
:labelEnd

Settings.txt

# The path to the where the 7z.exe executable is
varPathToSevenZip=C:\Program Files\7-Zip

# The path where to store the backup sets
varBackupPath=D:\Backups

# The file path to the inclusions file
varInclusionsFile=D:\Logaan\Documents\Tools\7ZipBackup\Settings\Inclusions.txt

# The file path to the exclusions file
varExclusionsFile=D:\Logaan\Documents\Tools\7ZipBackup\Settings\Exclusions.txt

# Whether to wait at the end of the backup
varWaitAtEnd=true

# Type of backup archive to create
varArchiveType=zip

Exclusions.txt

*.svn

Inclusions.txt

D:\Logaan\Documents
D:\Logaan\Favorites
C:\Users\Logaan\Desktop
D:\Logaan\Saved Games

How to use it

Place the batch file and settings files in a folder somewhere.

Update the setttings file with the correct paths.

Pass the path to the settings file to the backup batch file.

C:> backup D:\Logaan\Documents\Backup\settings.txt

Or create a scheduled task.

Edit Action