Tuesday, August 18, 2009
Windows 7 on Macbook Pro Unibody - Sound Driver Issue Resolved
To resolve this issue, download the fixed drivers here
Thats one issue ticked off the list.
MSN Connection Issue (Error code 0x80072efd) Resolution
Seems that Live Messenger does not let you connect unless the date/time is somewhat sane, which is perfectly acceptable. What is not acceptable is the terrible error message.
Windows 7 on Macbook Pro Unibody - Driver Issues
- Bluetooth driver 'isntalled' but device manager reports it is still using the MS driver
- iSight driver is the same issue
- Nvidia driver did not install
- ACPI support is abissmal
- Speaker sound volume is very low
- Sound does not switch to headphones when plugged in
Ill be addressing these issues as i fix them or try to fix them. If anyone has any tips let me know
Thursday, June 25, 2009
Removing Empty Lines From Code In Visual Studio
Replace ^\n$ with (nothing)
To use it, bring up the Replace dialog (Ctrl+H for me, depends on the environment profile you are using), tick the box at the bottom to use regular expressions, select "entire solution" to process all files (or set to your needs), and type the above regex into the "find" box and hit "Replace All". VOILA! All redunant empty lines are gone.
Of course this is a very simple regex and does not take into account the context of the blank line, so you may still end up with single blank lines where they are not needed (inside methods for example). But its a start - if anyone has a better regex for C# that conforms to Microsoft's recommendations please post. Also post any fantastically configurable free tools that you know of.
Ideally i think the view of code should be independant from the stored format of the code. In other words, VS should give more formatting options and apply it automatically when a file is viewed, so every developer can 'view' the code the way they like, but under the hood its stored in source control in a standard format - like a model/view separation concept
Procreate Version 1.1 Released!
The following changes have been made amongst others:
- Added overlays, which are drawn in the scene regardless of the rendering mode - things like hydrogen bonds, atom labels, etc
- Added ability to automatically add hydrogen atoms to the molecule in their correct position
- Fixed the renderers so they aline double, triple, etc bonds correctly
- Optimised the scene rendering
- Improved the speed of the PDB importer
- Improvements to the extension API
Try it out and let me know what you think! I have another release in the works which will add a bunch of cool new features, coming soon. If you have any requests let me know ill see if i can get it in there.
Thursday, April 16, 2009
Windows Media Player 11 Library - Apply Media Information Changes
I use WMP 11 because it does everything i want and comes with Windows - nuff said. If you use another player fair enough but dont post comments here about how other players are better, im well aware of them. Anyway i recently got myself a new 8GB SDHC card to replace my dead 4GB SD card to use in my Dopod D810. After using it for a bunch of MP3s, it became obvious very quickly that i needed to cleanup my music collection and update the meta data so they would be sorted correctly in the mobile media player. This is some useful information i found along the way and is a response to, what seems to be, a very misunderstood part of WMP and rightfully so.
Organising the Collection
WMP is actually really cool at doing this. The online metadata is fairly up-to-date and enabled me to organise my collection fairly quickly with the correct artist, album and song title information. The process i used was:
- Display my collection using the Additional Views -> Folder view, since although the MP3 tag may not have reflected it, my collection was logically organised into folders representing albums
- Browse to a folder (album) that i noticed wasnt being sorted correctly in the mobile media player
- Highlight all the songs, right click and select 'Find Album Info'. Select 'all songs are from the same album' if prompted. This usually yielded a fairly good search result where the correct album was in the top 3 hits. It seems to yield a much better search result than right clicking the blank album cover and selecting 'Find album info' since you are given the option to select that all songs are from the same album
- Manually match any unmatched songs. It appears that WMP matches based on song length more than any other piece of information. Title also appears to have some influence
- Click finish. Sometimes you then have to right click the blank album cover and select 'Update album info' and give it a few seconds to download the album art
Of course if you ripped the MP3s directly from a CD in WMP then usually this step is not necessary since it will be done using the CD information at the ripping stage.
Apply Media Information Changes
Doing that above gave me a very accurate set of songs. To my surprise though, the changes are not automatically applied to the files on disk, leaving the WMP database of information out of sync with the underlying files. I guess this is done for performance reasons ... although personally i think the small delay required to update ~10 files would hardly be noticed amongst the above process.
Anyway, you apply the changes to the underlying files using the Library -> Apply Media Information Changes option. This seems to be the step that gives most people a lot of hassle and i also encountered most of the problems which i was able to solve. This usually involves the progress bar not moving at all, or appearing to move but jumping back to 0 percent constantly. The following fixed the issue for me:
- In the options, ensure the Library -> Retrieve additional information from the Internet option is turned OFF completely (neither of the suboptions). This will stop the apply process from retrieving any meta data from the internet which can be an extremely slow operation for large music collections. In theory, if you followed the above steps each album should have the correct meta data anyway and it is unlikely to EVER change.
- The Player -> Connect to the internet setting, which supposedly overrides all other settings appears to have no effect when applying media changes. In other words, if you turn this OFF, it is not the same as turning off the option i mentioned in step 1. So make sure you perform step 1
- WMP does not apply media changes to files that are read-only. I would have expected WMP to simply make the change regardless, but this is not the case. This does mean you can use this to your advantage however, and make files readonly that you DONT want WMP to sync with its internal database. To make all music files writable, go to the root folder of your music collection and right click the folder and select properties. Then untick the 'readonly' attribute and click OK -> Apply to all subfolders.
Hope this helps someone - working with software all day every day i was easily able to work out why WMP wasnt doing what it was supposed to. However i can see why the vast majority of people get frustrated with this function and end up turning to another player just because they cant update their media information. Its a shame because i think the library management in WMP is quite good - if they provided decent quality album art it would be even better!
Saturday, March 14, 2009
Battlefield Heroes Beta Key Scraping With WatiN
I am pretty excited about the impending release of Battlefield Heroes. Ive been a huge fan of the BF franchise since BF2 and this free-to-play game looks like it is going to be a lot of fun. I signed up for a beta key some time ago and had all but given up of getting one, until I received it the other day out of the blue. It turns out they are getting ready to roll out the game sometime soon and as such are slowly giving out keys to everyone who has signed up in the order that they signed up. So i fired up the game and was pretty excited by what i saw - not only is it fun but my wife was pretty excited by what she saw too. Now she doesnt usually get into games so i was pretty keen to get my wife involved in one of my favourite activities. So all i needed to do was get her a key - problem is that since i signed up over 100 000 people have since decided its a good thing too. Thats a long queue to wait for a beta key. Then i found out that a site called BFHVerse has 60 keys to give out. Naturally every man and his dog wants one so the problem then becomes being able to grab a key within 2 seconds of it being posted before someone else does. Then i saw a particular post that caught my eye - one of the keys was apparently 'not working' because the way it had been printed on the coupon was all screwed up:
Because of this, the general consensus in the comments of the post was that the image was too badly scrambled and there was no point trying to use it. Bingo! This badly printed coupon was a stroke of luck - it meant i might have enough time and little competition to use this beta key. After studying this for a while and using Paint.NET i was able to make out all of the digits except the last three:
This gave me an idea - ive been wanting to try out the WatiN automated web testing framework for a while and there was currently a need to use it at work. This was the perfect opportunity to try it out and write an application to automatically search through all the possible combinations and try and find the remaining digits!
I made the following assumptions which i felt were pretty sound:
- The first 17 digits were correct
- The first unknown digit had a flat left edge, leading me to conclude it was either an 'E' or 'B'
- The other two unknown digits were indiscernible and could be any number, or any character
- The characters 'I', 'O', 'S' are generally not use in keys because they can be confused with '1', '0' and '5' respectively
- From analysing the other beta keys, it appeared that only certain characters were actually used, so they were a good starting point
Based on these assumption, there were around 1000 combinations of possible keys. This was a feasible amount so i came up with the following quick code to use WatiN to automatically fill in the beta key registration page with the various combinations until a valid key was found:
namespace BattlefieldHeroesBetaKeyFinder
{
using System;
using System.Globalization;
using WatiN.Core;
public class Program
{
//private const string BetaKeyFormat = "16D57-47H26-E5120-43E4H";
private const string BetaKeyFormat = "16D57-47H26-E5120-43{0}";
private const string AccountName = "TestUser";
private const string AccountPassword = "Password";
private static char[] Slot1Digits = { 'E' };//{ 'B', 'D', 'E', 'F' };
private static char[] Slot2Digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'L', 'R', 'T' };
private static char[] Slot3Digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'L', 'R', 'T' };
private static int slot1Offset;
private static int slot2Offset;
private static int slot3Offset;
[STAThread]
static void Main(string[] args)
{
string betaKey = "Not yet assigned";
using (IE ie = new IE("http://beta.battlefield-heroes.com/activate"))
{
do
{
string digits = Program.GetNextDigits();
if (digits == null)
{
betaKey = "No key found";
break;
}
betaKey = String.Format(CultureInfo.InvariantCulture, Program.BetaKeyFormat, digits);
Console.Write("Trying - " + betaKey);
//Console.WriteLine();
ie.TextField(Find.ByName("key")).TypeText(betaKey);
ie.TextField(Find.ByName("sec_name")).TypeText(Program.AccountName);
ie.TextField(Find.ByName("sec_pass")).TypeText(Program.AccountPassword);
ie.TextField(Find.ByName("sec_pass_confirm")).TypeText(Program.AccountPassword);
ie.CheckBox(Find.ByName("agreement")).Checked = true;
ie.Button(Find.ByValue("Activate My Key")).Click();
if (ie.ContainsText("That key appears to be invalid."))
{
Console.WriteLine(", FAILED");
}
else if (ie.ContainsText("That key has already been activated."))
{
Console.WriteLine(", IN USE");
}
else
{
Console.WriteLine(", SUCCESS!");
break;
}
}
while (true);
Console.ReadKey(true);
}
}
private static string GetNextDigits()
{
if (slot3Offset >= Program.Slot3Digits.Length)
{
slot3Offset = 0;
slot2Offset++;
}
if (slot2Offset >= Program.Slot2Digits.Length)
{
slot2Offset = 0;
slot1Offset++;
}
if (slot1Offset >= Program.Slot1Digits.Length)
{
return null;
}
return new string(new char[] { Program.Slot1Digits[slot1Offset], Program.Slot2Digits[slot2Offset], Program.Slot3Digits[slot3Offset++] });
}
}
}
The program took about 2 seconds per attempt and after about 10 minutes of trying i found the key that worked! All this and it had only taken me about an hour to create it all. Unfortunately it turns out that the key had already been registered, but the exercise had taught me a lot. The point of this post is not really to say that the above code is awesome, more that WatiN is an extremely useful package that can be used to autofill and scrap webforms with ease. I highly recommend you check it out. Im just happy that the BF Heroes beta key administration didnt pick up my multiple attempts and ban my IP.
Oh and btw...for those curious types out there, the correct beta key is included as a comment in the above code :)