my semi-major axis is wrong

Nov 16
Permalink

Never Forget

For The Fallen With proud thanksgiving, a mother for her children, England mourns for her dead across the sea. Flesh of her flesh they were, spirit of her spirit, Fallen in the cause of the free.

Solemn the drums thrill; Death august and royal Sings sorrow up into immortal spheres, There is music in the midst of desolation And a glory that shines upon our tears.

They went with songs to the battle, they were young, Straight of limb, true of eye, steady and aglow. They were staunch to the end against odds uncounted; They fell with their faces to the foe.

They shall not grow old, as we that are left grow old: Age shall not weary them, nor the years condemn. At the going down of the sun and in the morning We will remember them.

They mingle not with their laughing comrades again; They sit no more at familiar tables of home; They have no lot in our labour of the day-time; They sleep beyond England’s foam.

But where our desires are and our hopes profound, Felt as a well-spring that is hidden from sight, To the innermost heart of their own land they are known As the stars are known to the Night;

As the stars that shall be bright when we are dust, Moving in marches upon the heavenly plain; As the stars that are starry in the time of our darkness, To the end, to the end, they remain.

Oct 16
Permalink

Sarah Mania! Sarah Palin’s Greatest Hits (via tpmtv)

Oh dear. Give me GWB any day over this fuckwit.

Oct 15
Permalink

Ugh..

I hate not knowing where I’m going on campus..I need sleep.

Oct 11
Permalink

iPhone: Hotmail, Yahoo! or Gmail on Mail..

..but there’s a catch: You need to have used the PwnageTool on your iPhone/iPod. There are plenty of guides on the interweb on how to do this, so I won’t go into detail here, but as an average user of my shiny new iPhone and someone who uses webmail daily, having it connected with my iPhone is a massive bonus. So here is how you do it:

(Thanks go to this video on YT: http://uk.youtube.com/watch?v=XzTgFvnIar4&feature=related)

STEP 1. PRISON BREAK

Follow this excellent guide at iClarified.com to break your device out of prison: http://www.iclarified.com/entry/index.php?enid=1558

REMEMBER: You do this at your own risk. Any damage or problems caused by doing this are not my fault or those who wrote the programs or the guides. The chances are if anything does go wrong, you only need to click restore in iTunes and you’ll be sorted. It’s almost impossible to completely trash your device using these programs, but make sure iTunes has backed up your device beforehand anyway.

I successfully flashed my iPhone first time round with this guide and everything is working perfectly, including the Phone and SMS functions.

STEP 2. SET UP YOUR WEBMAIL

Open the Cydia app on your SpringBoard and touch Search on the bottom-bar. Type in the search “mobilet” and you should have Mobile Terminal on the list. Touch that and click the Install button at the top right and then Confirm. Wait for it to do it’s business then do the same for an app called “freepops”. Again wait for it to download and install. Now do the same for an app called “freepop toggle”. This will enable you to switch off the POP server to save battery, but isn’t essential. Restart your device once this is all done.

When your device is alive again in the menu, scroll along until you find the new Terminal app and open it. Now type the following exactly with the keypad and hit return after each command:

ssh localhost -l root

If after you enter this, it asks for you to confirm, type ‘yes’ and return. Now type:

freepopsd -p 110 &

Now press the home button and go to Settings->Mail etc.->Add Account->Other. Enter your details and make sure the Email Address and Password match your webmail account (Hotmail, Yahoo etc.). Click Save at the top right and it should pop up a message telling you that you can’t access your webmail through your device yada yada yada. Lies.

Click next to go to the server details page. For incoming server, type in “localhost” and enter your webmail address and password again. For the outgoing server you’ll need to enter the address of your ISP’s SMTP server or if you don’t use Hotmail check with your provider. This is only needed if you want to send mail from your device so if you don’t want to, just enter “localhost” again and click Save at the top right.

It should now try to verify your details and connect the dots. Once the check marks appear on the right hand side, you’re all done.

Go to Mail and click your webmail account and it should start downloading your email!

Good luck!

Jun 21
Permalink

Probably the sexiest and most genius piece of video art ever.

Jun 12
Permalink

Getting started with LINQ to XML

Now I’m not going to lie, getting started with LINQ if you’re a non-professional programmer like myself can be a journey. It is however, a journey well worth taking..

Recently I decided to create my own version of the Vista Game Launcher script which lets you annihilate all those random processes and services that hang around on Vista like thugs outside a corner-shop. Even though my machine is great for gaming after my recent upgrade, it helps gain even more precious resources for the game to use. The script has a few problems though:

  1. It takes a degree is Computer Science to even deduce how to add a game to the list of games you can launch.
  2. Like I said above, it annihilates everything that isn’t needed and the only way to restore what was closed/stopped is by restarting the entire computer.

While it’s not very efficient or user-friendly, it does the job. As usual though, like always, I want more. So I ended up creating another whacky program to do it all for me. I’ve always struggled with programming XML routines in VB.NET and now C#. I don’t know why, but I’ve just never been able to get my head around serialisation and all that business. Then along comes LINQ, swaggering in the door like a cocky little kid who knows more than you and is half your age (I’m 22 by the way).

So, I needed a way to quickly read and change an XML file, which I use to define a “launch profile”. These profiles define the options for the specific set of games and/or programs which will be shown in the “launch list”, so they’re going to be altered and read quite often in the process of using the program. This is where LINQ comes in.

Using LINQ

For this little article, I’ll be using the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<LaunchProfile name="Default">
  <Options>
    <CloseExplorer value="true">
      <DisableGlass value="false" />
      <DisableThemes value="false" />
      <DisableEverything value="true" />
    </CloseExplorer>
    <CloseProcesses value="true" />
    <CloseServices value="true" />
    <DashboardMode value="true" />
  </Options>
</LaunchProfile>

To begin reading from an XML file stored locally, you have two options: use the XDocument class, or the XElement class. Using the XDocument class in this scenario is a bit pointless as all it does is encapsulate the XML file as an XElement object. Save XDocument for other, more low-level activities young man/woman/thing!

So, first we define an XElement object to much up the entire XML File, and use the ubiquitous ‘Load’ method to get all our information into the object:

XElement xe_XmlFile = XElement.Load(xmlFilePath);

Now if we add a breakpoint after this code and  press F5 in Visual Studio and debug our program, you’ll notice that the xe_XmlFile variable now contains all the information from the root-node onwards in our XML File. Lovely jubbly.

Just like above, you now have two options:  you can iterate through xe_XmlFile using the usual foreach looping OR you can go the new-school route: LINQ Queries. In this little article I’ll show you the LINQ Query route, for a few reasons:

  1. LINQ Queries are extremely easy to learn, but just as hard to master. 
  2. They resemble SQL queries almost to a tee, but are much more intuitive.
  3. You can gather huge amounts of data in only two lines of code.

We first want to get the name attribute of the <LaunchProfile> tag so we know what profile we’re dealing with. This is almost criminally easy:

XElement xe_XmlFile = XElement.Load(g_defaultXml);
// Get the name of this <LaunchProfile>:
string xs_ProfileName = xe_XmlFile.FirstAttribute.Value.ToString();

As you can see, we’ve already loaded the XML file into our XElement object, then we’ve declared a new string to hold our profile name. Often, you’ll only use one attribute within a given element like I have, so using the FirstAttribute property will enable you to retrieve it’s value easily. Once this is done, we can use the same method to get the values of the elements within the <Options> node, but this time, we’re going to select a specific element, using it’s XName, and then get it’s value:

XElement xe_Options = xe_XmlFile.Element("Options");
bool b_closeProcs = bool.Parse(
                    xe_Options.Element("CloseProcesses").
                    FirstAttribute.Value);

Of course, in our situation, we have more than one value that we need to determine, so we the most efficient to do this would be to use another one of those handy LINQ Queries:

var xe_opVals = (from el in xe_Options.Descendants()
                 select new
                 {
                     Option = el.Name,
                     Value = bool.Parse(el.FirstAttribute.Value)
                 });

foreach (var opVal in xe_opVals)
{
    Console.WriteLine("Option: {0}, Value: {1}",
                      opVal.Option, opVal.Value);
}

Above you can see I’ve made use of one very cool feature of LINQ and that’s generic properties. You can create properties for any value returned by a query on the fly, which can then be accessed via your anonymous type (xe_opVals) anywhere in your code. Awesome.

And there you have it! A perfectly working skeleton of an XML based custom settings class using LINQ to XML. Your brain should be buzzing by now (in a good way I hope) so I’ll let you figure out how to implement it in your own way. Hopefully in the near future, I’ll be expanding on the topic to include some of the more advanced functions of LINQ.

Happy coding!