iPhone 4

Posted by Daniel on 03/08/2010 at 10:42 a.m. in Computers

As you may have all heard, the iPhone launch in New Zealand was far from… smooth. Both Apple and Vodafone didn’t announce anything in the week leading up to the 30th. The night of the 29th came, and went. Still nothing. Then launch day, and still nothing.

I had pretty much given up on getting one on Friday, but decided to make one last attempt to get some information, so I headed over to Vodafone on Lambton quay with Brett and Brock. And, amazingly, we got told they were going to be on sale at 12, in very low numbers. In his words, “I can’t say how many we have, but we have at least three, so you might want to hang around.”

So we sat down and started the line, on the concrete, on a cold, Wellington winters day.

Sitting in line...

Mojo Old Bank was awesome, and donated some drinks to the first few people waiting in line to keep us warm. Then the news camera’s showed up. The shame. Not something I wanted to be on the news for, not that I’ve ever wanted to be on the news before.

Amazing Vodafone dropped the price of the phone while we were waiting in line. The 16gb model on a $60 a month plan went from $660 to $560. The 32gb on the same plan dropped a large amount as well (wasn’t paying attention to it though, so can’t remember from what/to what).

And then the clock hit 12. And the first four people in line got called into the store, me being the first, which turned out to be a bad thing as the news people wanted to interview me when I got outside, not that they used it in the end.

But I got my phone.

iPhone 4 Box iPhone 4 iPhone 4

 

 

And so far, I love it. It’s a huge step up from my trusty old Nokia N95 (old being the keyword there). The screen is amazing. Seriously. It makes my Nokia, or even mum’s iPhone 3GS, look dim and washed out. And pixel-y. Even the lack of a physical keypad doesn’t annoy me like it did on the LG phone I had a few years back (and sold after 2 weeks).

I’m also not sure what the antenna issue is all about – yes, I can reproduce it if I grip both the sides very tightly, which lets be honest, 99.9% of people wouldn’t do in day to day use. I have yet to have it drop a call. Although, I’m right handed. I can see how it may be slightly more of an issue for left handed people, I’m still not convinced however.

Would I recommend it? Yes. Sure it’s not perfect, but it does what it sets out to do, and it does it very well.

Kustom Page sneak peak

Posted by Daniel on 08/06/2010 at 09:12 p.m. in Kustom Page

The next release of Kustom Page is still a few weeks off, but I thought I would give you a sneak peak of what's been happening (and to prove Kustom Page is still alive and crankin')

There have been a huge number of performance and code improvements over the last few releases, and this one is no different. We have spent hours and hours working away behind the scenes fixing everything from database speed issues to javascript issues.

But of course, none of that is actually very interesting until you start using it, so here's some "sneak peak" screen shots of the next version of Kustom Page, and a little something else that's on the way.

View draft and deleted page

You can now see pages you have saved as drafts (and edit them) and deleted pages.

New page editor

Designed to make it easier to managed your pages, it allows you to view to do notes, revisions and your drafts all from one easy screen.

Set page names (properly)

You will be able to set your page names properly!

See?

Sneak peak of something else that's coming very soon

.Net 4.0 with MVC 2.0 on IIS 7.5

Posted by Daniel on 07/06/2010 at 12:38 a.m. in Development

This one has had me stumped for a while – ASP.NET MVC 2 sites refused to run on IIS 7.5 (Windows 7). It would either complain and break. Or show me the files in the directory. After a bit of Googling around – I found a solution (that works for me at least):

Step 1:

Install the .Net Framework 4 into IIS using:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe –i

You will need to run it as Administrator if you have UAC turned on.

Step 2:

Install the correct IIS component’s (Control Panel > Add/Remove Windows features > Internet Information Services > World Wide Web Services)

  • Common HTTP features
    • HTTP Errors
    • HTTP Redirection
  • Health and Diagnostics
    • Request Monitoring
    • Tracing

Step 3:

Set the app pool to use ASP.NET 4.0

Screen shot 2010-06-07 at 12.32.35 AM

 

Screen shot 2010-06-07 at 12.33.01 AM

You show now be able to browse to your sites. Not sure why it doesn’t install into IIS by default though…

C# Convert XML to an object or list of an object

Posted by Daniel on 27/04/2010 at 10:52 a.m. in Development

Instead of doing my normal “write up an object and then parse the xml into it’s properties”, I decided to have a look at the XML deserialiser (well, deserializer in C# itself) – which has worked, and has saved me a lot of time.

Obviously you will need to create your object first, so here’s a person one:

[XmlRoot(ElementName = "person")] 
public class Person 
{
    public string FirstName { get; set; } 
    public string LastName { get; set; } 
}

Note the XmlRoot attribute – you will need to set this to the XML node that contains your properties.

Next you will need an XML document, here’s my sample one:

	<people>
		<person>
			<FirstName>Daniel</FirstName>
			<LastName>Wylie</LastName>
		</person>
		<person>
			<FirstName>Jhon</FirstName>
			<LastName>Smith</LastName>
		</person>
			<person>
			<FirstName>Sam</FirstName>
			<LastName>Brown</LastName>
		</person>
	</people>

And of course, the XML Deserialiser class

using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace SampleApplication.Common 
{ 
    public class Convertors 
    { 
        /// <summary> 
        /// Converts a single XML tree to the type of T 
        /// </summary> 
        /// <typeparam name="T">Type to return</typeparam> 
        /// <param name="xml">XML string to convert</param> 
        /// <returns></returns> 
        public static T XmlToObject<T>(string xml) 
        { 
            using (var xmlStream = new StringReader(xml)) 
            { 
                var serializer = new XmlSerializer(typeof(T));
                return (T)serializer.Deserialize(XmlReader.Create(xmlStream)); 
            } 
        }

       /// <summary> 
       /// Converts the XML to a list of T
       /// </summary> 
       /// <typeparam name="T">Type to return</typeparam> 
       /// <param name="xml">XML string to convert</param> 
       /// <param name="nodePath">XML Node path to select <example>//People/Person</example></param> 
        /// <returns></returns> 
        public static List<T> XmlToObjectList<T>(string xml, string nodePath) 
        { 
            var xmlDocument = new XmlDocument(); 
            xmlDocument.LoadXml(xml);

            var returnItemsList = new List<T>();

            foreach (XmlNode xmlNode in xmlDocument.SelectNodes(nodePath)) 
            { 
                returnItemsList.Add(XmlToObject<T>(xmlNode.OuterXml)); 
            }

            return returnItemsList; 
        } 
    } 
}

Usage:

var List<Person> = Convertors.XmlToObjectList<Person>(PeopleXML (Load how you wish), "//People/Person");

Useful Windows 7 keyboard shortcuts

Posted by Daniel on 23/04/2010 at 12:03 p.m. in Computers

Right, I know I’m miles behind the times here – but I have just found a whole bunch of new Windows 7 keyboard shortcuts that mean I hardly have to pickup that thing we call a mouse.

My all time favourite ones are the Windows Key + Up Arrow and Windows Key + Down Arrow for maximizing and restoring windows, which is obviously very useful.

Of the new ones I have just found, my favourite is Windows Key + T which selects the first item on the taskbar for you. You then use the arrow keys to navigate your open windows, and hit enter to select the one you want. Of course, good old Alt-Tab will do the same, just in a slightly less eye candy based way.

windowst

The other one that caught my attention was the Windows + Shift + Left/Right Arrow which moves the whole window, maximized or not, between your monitors (assuming you have more than one, which you should).

Aero snaps is also something you should have a play with if you haven’t heard about it yet – take a restored window, and drag it to the top of your screen – it should now maximize. You can do the opposite to restore the window as well. This also comes in very useful when dragging full screen windows between monitors, so you no longer need to install any of those “display helpers” (Unless you want your taskbar on more than one monitor).

Microsoft have a list of useful Windows + Key shortcuts here:
http://www.microsoft.com/nz/digitallife/basics/windows-7-shortcut-keys.mspx

Awesome pictures of the Courtney Place exchange

Posted by Daniel on 26/02/2010 at 08:39 p.m. in Networks

Being someone who’s always been interested in networks/telecommunications, I  got rather excited when I saw @freitasm posting images from his tour of the Telecom exchange on Courtney Place.

All images and tweets (Shown here as titles) courteously of @freitasm from GeekZone. Thanks! Can’t wait to read your post on the tour later.

The cables coming into the Courtenay Exchange

68835101[1]

Some serious power

68836062[1]

And more power for the Exchange

68836317-bee4f7d98fa60ffcf153b2f8f8ee050a.4b849a6e-scaled[1]

I hope these generators don't start while we are here

68837123-196ca148f651d19a833c886c00e2a6d7.4b849ac7-scaled[1]

And some @telstraclearnz gear inside @telecomnz exchange (Tweet)

68838755-93383133a348375aa2582bfb44281d2a.4b849b03-scaled[1]

And the copper gets inside

68839798[1]

And here is the fibre coming in @telecomnz (multiple these for a few around here)

68841177[1]

An old copper cabinet from the 80s... Can see no space for unbundling, no ventilation in old design

68857844[1]

And these are the latest copper cabinets

68862272-16534b7a5b7fa60dc78b58a9389a1312.4b849ebb-scaled[1]

This cabinet allows unbundling and comes with power

 

68862794[1]

And this is the equipment inside the cabinet

68863416[1]

(For some reason Live Writer has moved the images to my server - to view the originals, see the tweets)

Simple C# BlogML Parser

Posted by Daniel on 10/02/2010 at 04:38 p.m. in Development

I promised that I would be releasing some code from Kustom Page – And here it is, straight from the guts of Kustom Page!

This little class read in an XML document, formatted to the BlogML standard, and give you an object back. The library is very very simple. You will need to do validation etc yourself (And I highly recommend you do).

Sample Usage

var blogMLImport = BlogMLObject.Parse("BlogML.xml");

            var blogMLImport = BlogMLObject.Parse("BlogML.xml");

            foreach (var post in blogMLImport.Posts)
            {
                Console.WriteLine(string.Format("Post: {0} Written by: {1} on: {2}", post.Title, post.Authors.First().Title, post.DateCreated));
            }

Download Library (8 kb)

Blog "Re-Brand"

Posted by Daniel on 11/12/2009 at 06:22 a.m. in Other

After well over a year of my dark, black theme, I decided it was time for something new. The old theme was something that I whipped up in a couple of hours one cold winters night, and never got around to updating again. The font was small and hard to read, the content was squashed, and man, there was a lot of crap on the page. It was also running on a very old version of BlogEngine.Net, and an upgrade was going to be a nightmare. So I decided it was time for “Daniels Blog – Version 2”.

I started off playing around with WordPress, as Kustom Page hadn’t even been born yet. It went well – it was easy to use, and seemed to do most of what I wanted. And then I started working on Kustom Page, and the whole WordPress conversion stopped.

So after hanging out with Blog Engine for 6 or so months longer, Kustom Page reached a stage where I could comfortably move this blog over, and not have to worry too much about it. Well that was my dream. Turned out some parts of Kustom Page made sense in “developer land”, but not so much in the real world. So I went back to the drawing board, fixed up the major flaws, and tried again.

And here we are. My whole blog, with every bit of content and comment that’s ever been posted, running on Kustom Page, with it’s shiny new theme!

Converting UTC Dates to a user specified time zone in C#/ASP.NET

Posted by Daniel on 01/12/2009 at 04:43 p.m. in Development

I have been pissing around with this one for months – when someone posts anything on Kustom Page, the date gets stored in UTC, which is all good for storing date. But, of course, when they want to display a date on their site, say a blog post date, it comes up with that UTC date, which, if you live in New Zealand like I do, is 12 hours behind when you actually posted it. And who posts blogs at 3am in the morning?

My aim was always to allow users to set their own time zone, and then pass the dates through a convertor wherever it will be displayed on the screen. Sounds easy right? Actually it is. After reading this post at least.

So I wrote up a quick little class that takes care of that conversion, and can also return you a list of time zones

 public class TimezoneConvertor
    {
        public static DateTime Convert(DateTime UTCDate, string TimezoneID)
        {
            return TimeZoneInfo.ConvertTimeFromUtc(UTCDate,
                                                   TimeZoneInfo.FindSystemTimeZoneById(TimezoneID));
        }

        public static string Convert(DateTime UTCDate, string TimezoneID, string Format)
        {
            return TimeZoneInfo.ConvertTimeFromUtc(UTCDate,
                                                   TimeZoneInfo.FindSystemTimeZoneById(TimezoneID)).ToString(Format);
        }

        public static ReadOnlyCollection GetTimeZones()
        {
            return TimeZoneInfo.GetSystemTimeZones();
        }
    }

Obviously you’ll need to know the users time zone, which you could store in the database, or wherever you normally store your users settings.

For those of you using ASP.NET MVC, here’s a quick little conversion method to a list of SelectItems

   public static List TimeZoneSelectList(string SelectedName)
        {
            var timeZones = TimezoneConvertor.GetTimeZones();
            var listOfTimeZones = new List();
            foreach (var zone in timeZones)
            {
                var item = new SelectListItem();
                item.Text = zone.DisplayName;
                item.Value = zone.Id;

                if(item.Text == SelectedName)
                    item.Selected = true;

                listOfTimeZones.Add(item);
            }

            return listOfTimeZones;
        }

File Sorter

Posted by Daniel on 29/10/2009 at 04:03 a.m. in Development

I got sick of sorting out files... So I wrote a quick little C# app that does all the work for me. Reads in filenames setup as ProgramNameS01E10.avi etc

 

using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace TorrentSorter
{
class Program
{
   public static string FileInfoRegex = @"(.+)S(\d+)E(\d+)(.+)";
   public static string PathToScan = "";
   public static string OutputDirectory = "";
   static void Main(string[] args)
   {
      // If there aren't any arguments passed in at start, we need to ask the user for the info
      if (args.Length == 0)
      {
         Console.Write("Directory to scan: ");
         PathToScan = Console.ReadLine();
         Console.Write(string.Format("{0}Directory to move too: ", Environment.NewLine));
         OutputDirectory = Console.ReadLine();
      }
      else
      {
         PathToScan = args[0];
         OutputDirectory = args[1];
         // Allow people to pass in a custom regex pattern if run with arguments
         if (args.Length == 3)
            FileInfoRegex = args[2];
      }
      // Start processing the files
      ProcessDirectory(PathToScan, true);
      Console.WriteLine("Done!");
      Console.ReadKey();
   }
   static void ProcessDirectory(string filePath, bool recursive)
   {
      // If recursive is true, then we'll go through all the directories we can find and process them
      if (recursive)
      {
         foreach (var directory in Directory.GetDirectories(filePath))
         {
            ProcessDirectory(directory, recursive);
         }
}
      // Gets a list of files from given directory
      var listOfFiles = Directory.GetFiles(filePath).ToList();
      foreach (var file in listOfFiles)
      {
         var info = new FileInfo(file);
         var reg = new Regex(FileInfoRegex);
         var match = reg.Match(info.Name);
         // If theres a match, and the extention is not .torrent (for people who store the .torrent files in the directory they're using), start sorting
         if (match.Success && info.Extension.ToLowerInvariant() != ".torrent")
         {
            Console.Write(string.Format("{1}Moving file {0}...", info.Name, Environment.NewLine));
            // Get the program name and season number from the Regex matches
            string programName = FixFileName(match.Groups[1].Value);
            string seasonNumber = match.Groups[2].Value;
            // Work out the program and season folder. Append the word season in front of the number
            string programFolder = Path.Combine(OutputDirectory, programName);
            string seasonFolder = Path.Combine(programFolder, string.Format("Season {0}", seasonNumber));
            // Create the program folder if it doesn't already exist
            if (!Directory.Exists(programFolder))
               Directory.CreateDirectory(programFolder);
            // Create the season folder if it doesn't already exist
            if (!Directory.Exists(seasonFolder))
               Directory.CreateDirectory(seasonFolder);
            // Check that the file doesn't already exist, and copy it
            if (!File.Exists(Path.Combine(seasonFolder, info.Name)))
            {
               File.Copy(file, Path.Combine(seasonFolder, info.Name));
               Console.Write("done.");
            }
            else
            {
               Console.Write("already done.");
            }
         }
      }
   }
   /// 
   /// Removes the crap out of file names
   /// 
   /// 
   /// 
   protected static string FixFileName(string fileName)
   {
      fileName = fileName.Replace(".", " ");
      fileName = fileName.Replace("_", " ");
      fileName = fileName.Replace("-", " ");
      fileName = fileName.Replace("+", " ");
      fileName = fileName.Trim();
      return fileName;
   }
}
}

Don't have a c# complier? Download exe:

FileSorter.exe (6.50 kb)

Previous Page - Next page