Tuesday, November 30, 2010

Western Union Scam! Another one.

Firslty, the scam.

"Don't send me money, just send it someone else, friend or family and show me proof you can afford to buy the product / rent the room etc, show me proof using a photocopy of the receipt"

How the scam works?

Western Union, don't need any proof of you or the recipient to take the money, ridiculous if you ask me!

Secondly, a list of scammers I'm picking up along the way, I'll be adding to it:

anzy84@hotmail.com / Anzia Scott

timmsproperty@gmail.com / Sherwood Tim

amoo9989@hotmail.com / Amoo Raymond

aidataube@yahoo.de / Aida Taube

Phone numbers

070 2404 4128
07045 766243
07045 734145

conta
ct you, they are scammers. The more people who can the address, the better.


If in doubt, never use Western Union and use TinEye.com for reverse picture search.


Wednesday, October 06, 2010

Can't download Chrome behind a Corporate Network?

There seems to be an issue with the Chrome installers:

ChromeSetup.exe
and
ChromeStandaloneSetup.exe

The only one I found to work was the ones from FileHippo:

There was a way to download straight from Google but it doesn't seem to work anymore, unless I'm doing it wrong.

The filename should be

chrome_installer.exe


Friday, July 30, 2010

HTC Desire SPP 2.1 Issues

If you have an HTC Desire and you are having issues with your Bluetooth code, such as:


  • Service Discovery doesn't work or flaky
  • Can't see Misc devices, i.e. those with a Bluetooth device type of Headset, Phone or Comp
  • If you have issues communicating via SPP (Serial Port Profile)
  • Just plain not working
You will need to upgrade the ROM on the phone, these may all be fixed with HTC Desire 2.2 update which out "today", but if not its the bluez bluetooth code that has been fixed.

The only ROM that fully supports all of this is the http://www.cyanogenmod.com/ ROM, I've tried all ROMS this one is the only one that works correctly, but its based on the Nexus One ROM, so you won't have Sense, but if someone updates the ROMs with the latest BlueZ stuff, it *should* work.

OpenSource ftw?

I had similar issues when developing for a J2ME app on my old K800i, but what could I do?

Finding Bluetooth Service Address on Windows

If you have connected to a device, but want to write code to discover it, you need to know the service address/guid of the bluetooth device, in order to talk to it.

On Windows if you navigate to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\BTHENUM\

You will see the devices connected and then in HardwareID you will see the value at the end for SPP it is usually.


BTHENUM\{00001101-0000-1000-8000-00805f9b34fb}

Wednesday, July 14, 2010

Could not create the driver from NHibernate.Driver.SqlServerCeDriver

Using Fluent NHibernate and MsSqlCeConfiguration, I wanted to use an SQL Compact DB for my Database by changing the FluentConfiguration but I started getting the errors from the InnerException.

"Could not create the driver from NHibernate.Driver.SqlServerCeDriver"

The fix is simples,

You need to add a reference to

"System.Data.SqlServerCe"

Located in

"C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll"

If you don't have it, you'll need to install it from.

http://www.microsoft.com/sqlserver/2005/en/us/compact-downloads.aspx

Once you've added it you need to set the

"Copy Local" to true.

Then you should be good to go.

Wednesday, July 07, 2010

Failed object initialization (ISupportInitialize.EndInit). Error on Windows XP


Failed object initialization (ISupportInitialize.EndInit). Method not found: 'System.Windows.Threading.DispatcherOperation System.Windows.Threading.Dispatcher.BeginInvoke(System.Delegate, System.Object[])'


If you get this error, looking at the MSDN page for the method call

http://msdn.microsoft.com/en-us/library/cc190824(VS.90).aspx

It says at the bottom:

Version Information
.NET Framework
Supported in: 3.5 SP1, 3.0 SP2


The computer was running 3.5 vanilla, install the update and you'll be good to go.

Sunday, June 20, 2010

Bit of Hex Education

So I've started my Virtua Tennis Savegame editor, so in order to follow, I need to teach you about hex. So firstly, the easy stuff.

If you want to get properly confused, go to the Wiki Page but here's a nicer one:

http://www.itnewb.com/v/Introduction-to-Hexadecimal-or-Base-16-Number-System

Hex is base 16, i.e. numbers go from 1-16, we usually deal with base 10, (since that's the number of fingers we have), but hex is from 0 to 15, inclusive, so we get our 16.

Also instead of having 10 to 15, we have A-F, (aside, why A-F, why not A-Z and we get even more numbers?).

So therefore, lets take 29 in denary

Binary = 11101

Hex = 1D

So easier to store and easier to read, if that was just denary, the most we could store is 100 values from 00-99, in hex, we can store 00-FF which is 256 values.


Next thing to know is Endianness, so Big endian and Little Endian and Most Significant and Least Significant bit.

In a big endian systems, the most significant bit is the furthest to the right, go back to our 29 in binary.

16 8 4 2 1
1 1 1 0 1

So in this instance, the most significant bit is the bit in the 16's column and least significant bit is the 1's column. This is how everyone learns binary.

The Virtua Tennis Savegame is stored in LSB, so therefore in this case it'd be.

1 2 4 8 16
1 0 1 1 1

So once we figure out the values, you'll need to swap the values backwards in order to make the change, but since we are doing it in hex it'll be like this.

Hex = 0A 01

Big Endian = 0A 01 = 2561
Little Endian = 01 0A = 266

The reason I think it's stored in Little Endian is because the PC Port, was just emulated, from the Dreamcast version which runs in Little Endian.

http://www.netbsd.org/ports/dreamcast/faq.html#endian

So there's my Hex Education, I'm sure I'm missing stuff. This is just a tasty for when we start hacking the file.

Saturday, June 19, 2010

Fixing N95 8GB keypad and save yourself money!

Problem: My N95 8GB keypad stopped working and just broke into pieces, cost for some one to fix it, £30-£40.

I'm a cheap bloke, so I decided to fix it, this is how I did it!

Firstly, I looked for a new case this is called "housing", so ebay time.


Ebay search for N95 8GB


It took about 3 weeks for the delivery and it was about £3.50 and from Hong Kong! (How do they make money?) I bought a White one to make it look sexy.

It should come with the Torx 4/5/6 tools, for you to dismantle your phone, i.e. the for the screws that look like stars.

This is probably the best video

http://www.youtube.com/watch?v=jc33lBQzVy8

I just did it myself, I then found I needed to get a new membrane for £8

Ebay search for N95 8GB Membrane

I then replaced it, so for under £15 I managed to fix my keypad, get a new case and learn how my phone goes together.

This post is shorter but it took me a while to find what I needed and get replacements and keep my phone working till I get my HTC Desire!!

Wednesday, June 16, 2010

Getting HTC Desire working with ADB

Got an HTC Desire, I tried installing the Drivers with the Android SDK, it wouldn't work, I first had to enable USB Debugging.


Settings -> Applications -> Development -> USB Debugging


Plugging it in, it wanted to install ADB (Android Debug Bridge)I first tried updating the .inf file


;HTC Desire
%SingleAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C87
%CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C87&MI_01



This made it install. Yay!
But, running adb devices in the tools folder of the SDK showed it wasn't working.

I then looked on HTC Site for Drivers and found the HTC Sync here:http://www.htc.com/www/support.aspx



Downloaded installed it and then removed the Device and added it again.
adb devices then showed it and Eclipse then saw it.
Yay!


Friday, June 04, 2010

Bitmap Serialize

So I've been tasked to fix a database full of pictures that weren't displayed, no matter what I tried, the Image (Stored as a byte array) was always invalid.

So I thought I'll save the file and see if I can get an image fixer on it, I just used a FileStream opened it and wrote to it


var fileStream = new FileStream("output.dat", System.IO.FileMode.Create);
fileStream.Write(bytes, 0, bytes.Length);
fileStream.Close();


Upon opening the file, I was expected to see something beginning with "Exif" or "JPG" or something, but what I saw was even better.


System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


A, ha!! The actual Bitmap object was being saved, not the actual Image, therefore I put together a bit of code to get me the Image and put it back as the Image for my code to work correctly. In this case, I could fix it, but if I couldn't I'd have to have a bit of a legacy converter for it.



public static Bitmap BitmapObjectToBitmap(byte[] data)
{
using (var ms = new MemoryStream(data))
{
var bf = new BinaryFormatter();
Bitmap bitmap = (Bitmap)bf.Deserialize(ms);
return bitmap;
}
}


Then the working code for the Image to Byte Array



public static byte[] ImageToByteArray(Image image, ImageFormat format)
{
using (var ms = new MemoryStream())
{

var bm = new Bitmap(image);
bm.Save(ms, format);
return ms.ToArray();

}
}



Comments welcome!!

Transfer Data between two SQL Server's

Everyone probably knows this, but hey ho.

I needed some data from one of my tables in one server to be inserted into another, here is the simplez SQL to do it.




insert into Server1.Database.dbo.Table(Col1,Col2,Col3)
select Col1,Col2,Col3
from Server2.Database.dbo.Table



Edit:
thanks to @duncansmart just a bit more info, I'm running on 2008 R2, on previous systems you may need to run


Execute sp_addlinkedserver Server1


To link in the other Server

Monday, May 24, 2010

Facebook Privacy Checks

Here is a list of Facebook Privacy scanners I've found.

1.) Save Face by Untangle is an automated script that will go through your settings and disable them.

http://www3.untangle.com/saveface

All you have to do is drag it on to your Bookmark toolbar for later.

2.) Reclaim Privacy, which is a scanner which gives you a breakdown on which settings / info you are leaking to the internet, as 1.) you just need to drag the bookmark on to your bookmarks toolbar.

http://www.reclaimprivacy.org/

Now you should log in to Facebook and click number 1, it will automatically go through your settings. (Easier to turn on Info then turn it off in my books)

Now click number 2, then update any settings it tells you to. Some I leave public, such as "find me via search" and "send me a message" set to everyone.

Now once you've done that we have another link to click.

3.) Profile Watch, this will scan your profile as an external person could and will show you info you are still showing the world.

http://www.profilewatch.org

4.) Honourable mention is an Application, so this shows you what your Apps can see about you and send to people.

Privacy Check

http://www.rabidgremlin.com/fbprivacy/




Hopefully this helps everyone!

Wednesday, May 19, 2010

InvalidateRequerySuggested on GUI Thread

I've been having issues where buttons weren't getting enabled on my WPF application, only by clicking the form would they work.

I found that I need to force the refresh using CommandManager.InvalidateRequerySuggested but that didn't work, the reason being I wasn't on the GUI Thread, I was on another thread, so here is my little helper class to do it.


public static void RaiseInvalidateRequerySuggested()
{
Dispatcher dispatcher = null;

if (Application.Current != null)
{
dispatcher = Application.Current.Dispatcher;
}

if (dispatcher != null && !dispatcher.CheckAccess())
{
dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)CommandManager.InvalidateRequerySuggested);
}
}



This tries to get the application, then gets the dispatcher for the application, makes sure you have access, and then dispatches the Invalidate to that thread.

bingo.

Tuesday, May 18, 2010

Dieting for Programmer

Right,

I've decided to do a post on dieting, not exactly technical but very much of the, "Healthy body, Healthy mind" manta, so my history, I used to be nearly 16 stone so I'm not from the "always been thin, eat what you like" bunch of twats most diet people are.

So here is my diet plan / life plan thing.

Firstly, we need to work out our BMR (Basal Metabolic Rate) basically the amount of calories you'd burn by sitting still all day.

http://www.bmi-calculator.net/bmr-calculator/

So I'm going to take me as an example, I'd probably over weight currently due to being on a bulk, long story my figures.

Age: 24
Weight : 13 stone, 1 pounds
Height: 6 foot, 2 inches.

(Hint: 14 pounds in a stone for all you cool metric kids)

( 13 * 14) + 1 = 169 lbs

my BMR = 1895.47

Now we use Harris Benedict Equation to work out our calories

http://www.bmi-calculator.net/bmr-calculator/harris-benedict-equation/

Since we're programmers, * 1.2

My calories for a day should be 2274.564

Now, in order to lose weight, we need to create a deficit, so the recommended number I feel is 500 calories, anything more, your body thinks its being starved and will hold onto your fat and not let go. It think its in a field starving and needs to keep you warm till you find an animal to eat.


So our Dave's Daily Diet Allowance is.... 1774.564(we're going to round it up for ease of use.) 1800 calories.

Now if you get any good food you'll see your RDA (recommended daily allowance) of what to eat, the average man is 2500 calories and each woman is 2000 calories. so if I stuck to it, I'd be putting weight on if I sat around doing nothing all day.

Type Male Female
Calories 2500 2000
Protein 55g 45g
Carbs 300g 230g
Of those carbs sugar 120g 90g
Fat 95g 70g
of that fat, Saturate 30g 20g
Fibre 24g 24g


So here are your RDA off the side off a Cornflakes packet! :), so here we have our aim, since you are probably eating more than your need you need to try and curb a little bit off this list too. So just try and keep within your boundaries and just count calories for now.

Time for the diet. I know from before we have 1800 calories to play with over the course of the day, time to split it, you should refine this to how you live, but you always must eat something at the times



  • Breakfast - 8am - 500 calories

  • Snack - 11am - 100 calories

  • Lunch - 1pm - 400 calories

  • Snack - 4pm - 100 calories

  • Dinner - 7pm - 600 calories

  • Snack - 11pm - 100 calories



Now that is my breakdown for my calories, I've give myself the most calories for my main meals, your main meal of the day is your breakfast. Skipping this is the worst mistake for your diet, it starts your metabolism kicks it into gear!

Now a sample diet


  • Porridge - Main stay of dieters, keeps you full for longer, since its a complex carb (takes a while to breakdown, simple carbs is sugar which takes minutes rather than hours

  • Apple + Skips

  • Chicken Salad with lots of trimmings or Soup and bread or jacket potato

  • Handful of nuts, Almonds are meant to be the best, full of protein

  • Lamb chop and lots of vegs and mash

  • Cottage Cheese and ryhvitta, cottage cheese is a slow releasing protein, so makes your metabolism work while you sleep





So that's a sample day, now all you have to do is tailor the diet to your calories, the foods you like and your lifestyle.

Keep a food diary for a week See how many calories and such you are eating, doesn't have to be 100% accurate, but gives you an idea where you are eating the worse!

If you feel you are snacking and want more food, increase your calories. This diet is meant to be one you're on for the rest of your life, not a quick fad one.

You are allowed one cheat meal a week make yourself feel bad when you eat it, thinking of the calories etc! But enjoy it, know that its bad for you etc.


Regarding food things I've learnt.


  • Anything with Hydrogenerate Fat avoid like the plage, seriously.

  • Eat protein!! It fills you up and your body works harder to digest it

  • Omega 3 1000mg capsules are amazing, ASDA sells them, eat at least 5 a day

  • When hungry drink a pint of water and wait 20 minutes, then see if you are hungry

  • Any exercise is better than none, don't over do it, or you'll get pissed off and stop

  • Don't let anyone say, "you look good as you are"

  • Weightwatchers meals are pretty nice!





So that's it, any comments would be grateful and I'll update the post if I need to!

Hope I haven't rambled too much!

Monday, May 17, 2010

GPS Degrees, Minutes, Seconds to Decimals C#

I have been trying to connect to a device and get the GPS Data, I was using the library provided by Microsoft's Coding4Fun.
http://blogs.msdn.com/coding4fun/archive/2006/10/31/912287.aspx and written by Scott Hanselman... how can he be wrong!?

The issue I came across was the precision was out by quite a bit, so the parsing was incorrect, for my device. I'm not sure if NMEA standard is 100% standard, so I'm just posting this code here in case other people have issues.

ProcessGPRMC and ProcessGPGGA both need to be updated, I have created a method to do this.


private static double DDMMSSToDecimalDegrees(string data)
{
var ddmmss = (Convert.ToDouble(data) / 100);

var degrees = (int)ddmmss;

var minutesseconds = ( (ddmmss - degrees) * 100 ) / 60.0;

return degrees + minutesseconds;

}



There is also the issue to do with North, Southern, Western and Eastern Hemisphere where the value has go to be negated. :)


So the update methods needs to look like this


public void ProcessGPGGA(string data)
{
try
{


string[] fields = Regex.Split(data, ",");

//Time: Hour, Minute, Second
//Time is Zulu
GPGGA.Hour = Convert.ToInt32(fields[0].Substring(0, 2));
GPGGA.Minute = Convert.ToInt32(fields[0].Substring(2, 2));
GPGGA.Second = Convert.ToInt32(fields[0].Substring(4, 2));

//Latitude

GPGGA.Latitude = DDMMSSToDecimalDegrees(fields[1]);


if (fields[2] == "S")
GPGGA.LatitudeHemisphere = Cardinal.South;
else
GPGGA.LatitudeHemisphere = Cardinal.North;


if (GPGGA.LatitudeHemisphere == Cardinal.South)
GPGGA.Latitude = GPGGA.Latitude * -1;



//Longitude

GPGGA.Longitude = DDMMSSToDecimalDegrees(fields[3]);


if (fields[4] == "W")
GPGGA.LongitudeHemisphere = Cardinal.West;
else
GPGGA.LongitudeHemisphere = Cardinal.East;



if (GPGGA.LongitudeHemisphere == Cardinal.West)
GPGGA.Longitude = GPGGA.Longitude * -1;



//GPS Signal Quality
GPGGA.GPSQuality = (GPSQuality)Convert.ToUInt32( fields[5] );

//Satellites
GPGGA.NumberOfSatellitesInUse = Convert.ToInt32(fields[6]);

//HDOP
GPGGA.HDOP = Convert.ToDouble( fields[7] );

//Altitude
GPGGA.Altitude = Convert.ToDouble(fields[8]);

//increase message count
GPGGA.Count ++;
}
catch(Exception e)
{
System.Diagnostics.Trace.WriteLine("Chaos in ProcessGPGGA! " + e.ToString());
}
}




public void ProcessGPRMC(string data)
{
string[] fields = Regex.Split(data, ",");


//Time: Hour, Minute, Second
//Time is Zulu
GPRMC.Hour = Convert.ToInt32(fields[0].Substring(0, 2));
GPRMC.Minute = Convert.ToInt32(fields[0].Substring(2, 2));
GPRMC.Second = Convert.ToInt32(fields[0].Substring(4, 2));

GPRMC.Day = Convert.ToInt32(fields[8].Substring(0, 2));
GPRMC.Month = Convert.ToInt32(fields[8].Substring(2, 2));
GPRMC.Year = Convert.ToInt32(fields[8].Substring(4, 2));

GPRMC.DataValid = Convert.ToChar(fields[1]);

//Latitude

GPRMC.Latitude = DDMMSSToDecimalDegrees(fields[2]);


if (fields[3] == "S")
GPRMC.LatitudeHemisphere = Cardinal.South;
else
GPRMC.LatitudeHemisphere = Cardinal.North;


if (GPRMC.LatitudeHemisphere == Cardinal.South)
GPRMC.Latitude = GPRMC.Latitude * -1;



//Longitude

GPRMC.Longitude = DDMMSSToDecimalDegrees(fields[4]);


if (fields[5] == "W")
GPRMC.LongitudeHemisphere = Cardinal.West;
else
GPRMC.LongitudeHemisphere = Cardinal.East;



if (GPRMC.LongitudeHemisphere == Cardinal.West)
GPRMC.Longitude = GPRMC.Longitude * -1;



GPRMC.GroundSpeed = Convert.ToDouble(fields[6]);

//TODO: MagVar and Course
GPRMC.Count++;
}



That's it for now, I haven't implemented the rest of the project. I'll post all the updated code when I get somewhere, github maybe?

Friday, May 14, 2010

Get WhoIs Information from a domain name in C#

I needed to get the WhoIs information for a domain using the simplest way possible.

I could have used a WebService such as WebServiceX.net's http://www.webservicex.net/whois.asmx

But I decided to just talk to the whois servers directly, all I needed to do was open a socket send a request and then read from the socket.

I used the list from http://www.nirsoft.net/whois_servers_list.html then wrote some code, here is an example of how I did it for anyone that needs the information.




using System;
using System.Net.Sockets;
using System.IO;


namespace WHOISConsole
{
class Program
{
static void Main(string[] args)
{

string whoisServer = "whois.nic.uk";

string domainName = "bbc.co.uk";

Console.WriteLine(GetWHOIS(whoisServer,domainName));

Console.ReadKey();
}

///
/// Get the WHO IS Info for a domain name
///

/// The server to use, changes per domain
/// Domain we are looking up
///
public static string GetWHOIS(string whoisServer, string domainName)
{
// Port 43 is standard
using (var tcpClient = new TcpClient(whoisServer, 43))
{
// get the underlying stream
using (var networkStream = tcpClient.GetStream())
{
// we need to write to the stream
using (var streamWriter = new StreamWriter(networkStream))
{
// write the domain and a new line, CRLF
streamWriter.WriteLine(domainName);

// flush it to actually send it
streamWriter.Flush();
}

using (var streamReader = new StreamReader(networkStream))
{
// now read from the stream
return streamReader.ReadToEnd();
}

}
}

}
}
}





Any comments please post below. Thanks.

Remote Desktop Sharing Files

With remote desktop the way to share files is via the Local Resources tab, you can then select a drive.

This can be tiresome as you would have share a whole drive over the Internet / Network, the workaround I use, is to create a Mapped Drive to the folder I want to share.

I then share that mapped drive, this means I don't have to wait while all the data is sent, so it makes it very fast.

Not sure why MS can't just support single file send like VNC.

Edit: Thanks to smellyhippy from irc.freenode.net #c##, you can just use copy and paste, I was trying drag and drop.


I have also allowed anonymous comments. :)

Wednesday, April 28, 2010

Agent Killer - DirectX Game

This is a game I made for my final year of Uni, I'm releasing it cos its hilarious! I'm going to fix the code, make it run with XNA and OpenGL I think.



Download

You'll need a decent card I think to get it running, it *should* work.

Have fun!

Sunday, April 25, 2010

//TODO

Well here is a list of things on my to do list, of things I'm planning on doing or looking at, I will be updating this as I complete them

Books to read


  • Art of Unit Testing

  • DDD

  • Applying DDD with .net

  • Code Complete 2

  • Pragmatic Programmer

  • Working Effectively with Legacy Code

  • Passionate Programmer

  • Mythical Man Month



Things to Do


  • TASM Series

  • Ruby for the C# Programmer Series

  • Dissecting Malware

  • Design Patterns Series

  • Dieting for Programmers!



Projects


  • Finish Website sarkie.webhop.org -27-April-2010

  • Restart the blog-07-April-2010

  • WPF Auto Follow Friday

  • OpenRASTA site checker devserver.webhop.org - 16/05/2010

  • Ruby CD System

  • Virtua Tennis Savegame Editor

  • DirectX Game, rebuild and update

  • XNA Breakout Game

  • OpenGL Breakout Game

  • Abstracted Game using DirectX, XNA and OpenGL

  • UnrealScript Mod

  • Source Engine MOD, USEMP



That's it for now, I'm sure I'm forgetting loads! But that's enough to start me with, anything else I'm missing?

Saturday, April 24, 2010

Links, Precedence, Style-sheets, Oh my.

So I am currently developing my site and I wanted links to be different to my overall colour scheme for links. I therefore added a page style sheet to change them, no matter what I did, the overall one would take precedence instead of the page one.


a:link, a:visited,a:hover, a:active
{

text-decoration:underline;
color:#FFFFFF;
}



So I wanted to change it to just white underlined, this was first too over kill, since it was changing links in the footer. I then made it class based


.projectList a:link
{
text-decoration:underline;
color:#FFFFFF;
}


This still did not work for some reason, firebug showed my Site.css was winning now. (odd)

Thanks to ye-old faithfull W3Schools
I found :link pseudo classes http://www.w3schools.com/css/pr_pseudo_link.asp


This meant I could change it per link basis, (win) I now had.


a.downloadLink:visited
{
color:#FFFFFF;
}

and my link

Download



Now it bloody works!! :)

Friday, April 09, 2010

XML to PDF using NFOP, C# .NET

I was using this

http://www.codelathe.com/blog/index.php/2009/02/28/generate-pdf-from-cnet/

Don't download the 1.0 build version

Get the 2.0 version source

http://sourceforge.net/projects/nfop/files/nfop/nfop-v2.0.0/nfop_fw2-2.0.0.zip/download

and get the .dll out of the build dir, or you will get lots of manifest errors and such

Thursday, April 08, 2010

Chrome User Agent

Since I can't access my banking website with Chrome but I can with safari, this is how you change the User Agent easily

Make a .bat or .cmd file open with notepad and paste



start chrome --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.1 Safari/525.1"

Wednesday, April 07, 2010

WMV C# Meta Information Update Example

I have recently downloaded all the www.dimecasts.net Videos, I then tried to play them on my Xbox, but they weren't in order, so made it quite hard to follow. I therefore created an App to edit the WMV titles, which the Xbox reads.

This code is "ok", I should really make the code into a wrapper library, but this is just a bit of a proof of concept really.

Firstly, you need to add the WMP.dll to the form using the Toolbox, which should appear as the Windows Media Player Control, it will then add two references

AxWMPLib
WMPLib

Then the main code for getting the Meta Data is



private string GetTitle(string filePath)
{
var mediaPlayer = new WindowsMediaPlayerClass();

IWMPMedia mediaItem = mediaPlayer.add(filePath);

return mediaItem.getItemInfo("Title");

}



I got all the attribute names running code like this



for (int i=0; i<mediaitem.attributeCount; i++) {
Console.WriteLine(mediaitem.getAttributeName(i) + " = " + mediaitem.getItemInfo(mediaitem.getAttributeName(i)) );
}



The code for setting it also very simple




private void SetTitle(string filePath, string title)
{
var mediaPlayer = new WindowsMediaPlayerClass();

IWMPMedia mediaItem = mediaPlayer.add(filePath);


mediaItem.setItemInfo("Title", title);
}




Here is the source code:
http://sarkie.webhop.org/Files/WindowsMediaEditor.zip