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 Computers

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)

Kustom Page: Coming up next

Posted by Daniel on 08/09/2009 at 03:55 p.m. in Kustom Page

It’s a week on Wednesday since I first pushed Kustom Page out the door and into the world, and I am rather proud of it. It is currently purring along on the new server commissioned just before launch, and have been tempting people to signup.

Quick Stats:

Active Users: 10 (2 people haven’t confirmed their accounts, and therefore aren’t counted)
Websites: 12
Domains: 19

While obviously not mind boggling, I personally feel it’s not all that bad considering it’s been out a week, and is still in very early beta.

Thanks to everyone who has signed up!

What’s coming up next?

In the next release, due around the 17th on the 23rd of September, we are working hard to get the following features packed in:

Blogging System – This is the big feature for this release. It supports all the common blogging tasks: Blogging (obviously), Comments, Categories and RSS Feeds.

I’m also planning on moving this blog over to the Kustom Page blog as soon as possible.

Blog

Redirect Domains – Allows you to setup domains that point to another domain. Say you have 2 domains registered, one hardtospelldomain.com and hardtospeldomain.com, you can make it so that the incorrectly spelt domain redirects to your correctly spelt one.

Domains

View My Site Link – While only a very minor “feature”, this has to be the most requested feature by beta users. You can now click View My Site from any admin page, and it will open a new browser window containing your site.

view website

Kustom Page Beta has launched!

Posted by Daniel on 04/09/2009 at 01:47 p.m. in Kustom Page

Late last night I finally managed to push a beta version of Kustom Page out the door, 5 months after writing the first line of code. And I must say, it finally feels like it’s getting somewhere.

The beta is still very rough, and still very basic, but it’s time to get people (like you) involved in the process and make sure that we’re actually on the right track to building a product people really want.

We are aiming at doing 2 weekly releases during beta – so chances are, if you find a bug, it’ll be fixed in the next release. You can log bugs using the Support link above the menu on all Kustom Page screens.

We have heaps planned for the next release, so stay tuned!

So feel free to sign up and give it a whirl!


kp2

It's been a while

Posted by Daniel on 20/08/2009 at 12:26 a.m. in Cars

And wow, it’s been busy. I have bought a new car, started a new project, found someone to help with that project, setup a home office. And it’s even starting to feel like spring.

So here’s an update of recent happenings… I’ll try to keep it short. I promise.

Car

Decided that after two years of my trusty Corolla, it was time to move up in the world. Don’t get me wrong, it was a great car, haven’t done anything mechanical to it in over two years. But I had a huge desire to get something more.

That something ended up being a twin-turbocharged Subaru Legacy wagon. I may have spent a tad too much on it already (Tyres, Battery and the break calliper stuffed up last week, now break pads) but, somehow, the whole shine of it still hasn’t disappeared. That car does something to you, it’s an amazing machine.

Home Office

When we moved into our flat, everything got chucked where ever it would fit. It could have been worse, but sitting in a corner looking at walls, to me at least, is very uninspirational. So the time came last night to change that around. We have ended up with the room effectively divided in two. One half for the “office” and the other half for living.

New lounge office layout

Kustom Page

Kustom Page lives again!

I have spent the last 4 and a half months developing a hosted content management system along with my cousin, Alex. Due for public beta in late September, we are working to re-invent what content management is all about. Forget the days where you spend your weekend reading the help documentation just to find that the latest version is different. Or that you go to upgrade your companies website, and everything breaks.

Our aim is to create something that just works. And always works. Leaving you to worry about driving traffic to your site and increasing your profits.

kp

Will be releasing more info on Kustom Page in the coming months, offering beta invite codes, and even releasing some of the code, so stay tuned!

Spring

Feels like winter dragged on and on, but as we get closer to September, it’s feeling like spring’s getting here. And what a great feeling that is. Bring on summer already!

Looking to Wellington from Petone Beach

Installing SQL 2008 on Windows 7

Posted by Daniel on 26/06/2009 at 11:01 p.m. in Computers

Decided it was finally time to upgrade my dev vm to Windows 7, and install a shiny new copy of SQL 2008. Did a test install inside Sun’s Virtual Box at work, and it all went smoothly.

So with that in mind, I went ahead and installed it on a new VM at home. And SQL basically told me that it wasn’t going to install, to be polite. Great. Built another VM, same problem. Went to bed after that.

After talking to Craig at work this morning, I thought I’d give it a shot on my work machine, just to see what would happen. Same error. Tried some of the suggestions Craig made, still doesn’t seem to work.

Best part? The errors I get. Really useful. Not.

SQL Error
useful

Am yet to find a solution. Have had a Google. Found nothing amazingly useful. Wondering if it’s worth getting the image from MSDN again, based on the fact it worked before I copied it to my iPod. Will update when I have found a fix.

[Update] Found this - doesn't seem to solve my problem sadly.

[Update 2 - 2:24pm 26/06/2009] Just downloaded the ISO image again, and seems to work now on both my work machine and a VM I built today. No idea what happened. The new VM threw the first error, but when I re-mounted the ISO, it worked. Hopefully I can get it installed tonight.

Major flaws in the new "Boy Racer" law

Posted by Daniel on 28/05/2009 at 12:17 a.m. in Cars

I must say, I am amazed at the stupidity surrounding some of the laws in the process of being introduced here in New Zealand surrounding “boy racers” - Full article here http://www.stuff.co.nz/national/crime/2446391/New-laws-this-year-to-crush-cars.

“Street racing includes sustained loss of traction, noisy vehicles, and operating vehicles in an anti-social manner.”

One has to wonder about who decides what is acceptable and what isn’t, is the the police? Then what training/tools will they get to determine if a car, is say, too noisy? I have a big bore exhaust on my car, and I know that it is below the current noise law in New Zealand (96 decibels), but how would you prove that to the officer that has just pulled you up? Sure, I have a silencer for it, but really, look around, no one uses them, and why would they? You don’t speed $100’s to shove something in the end which makes it sound terrible.

Sustained loss of traction is fair enough, as it is normally done on purpose, but what’s sustained? More than 5 seconds? 10? And where? I can imagine say a  driver of a family wagon accidentally putting their foot down a tad to much in the wet at a traffic light having their car impounded.

“The new laws will also provide local councils with the power to draft bylaws outlining "anti-cruising" areas, banning boy racers.”

So the tax payer is dishing out more money (in a recession) to stop people from driving around, effectively, in circles. Where is the fairness in this?

Sure you might say that the “boy racers” shouldn’t be driving around there in the first place, but where else are they going to go? They’re already banned from being able to meet anywhere. So they just cruise around the city streets. Of course, some are stupid, and do things they shouldn’t, but the majority I see here in Wellington on a Friday or Saturday night in Courtney Place just drive up and down, sticking to the speed limit and letting people cross at crossings. There doesn’t seem to be much wrong with this to me. Maybe I’m missing something?

I must also question what makes a boy racer. Everyone seems to have different views on it. The police and law makers seem to think that it’s anyone who has touched anything since it’s left the factory.

Sure, I drive around in a car with aftermarket parts and a big bore, but I don’t consider myself a boy racer. Why? Simple, I have never, nor will ever, race my car. I don’t go out the Hutt on Thursdays, I don’t drive up and down Courtney Place all night, and I don't “cruise” around. I, for the major part, drive my car from A to B. But of course, because of the modifications, and the fact I’m a young guy, people jump to the conclusion of boy racer. Which I think is a little unfair on the bunch of people that enjoy working on cars but don’t take part in the whole boy racer scene.

A few other points

- Courts can order destruction of cars involved in three illegal street-races or burnouts in four years.

Based on what? The car? Or the person? Because if it comes down to the number plate on the car, there’s going to be a lot of problems, especially if the car is sold and the new owner isn’t fully aware of the cars history.

- Destruction orders can apply even if the car is owned by someone else.

Does the owner of the car get a chance to challenge this? What if their kids run off with the car one night and it gets impounded. Or the car is stolen?

- Police get new powers to remove learner and restricted drivers from the road if they breach their licences, including seizing ignition keys and immobilising cars.

Signs of desperation. Maybe better education is need around why there are the different stages of licensing? Try and find me a person on their restricted license who hasn’t driven after 10 or with passengers.

- Fines for breaching licences reduced from $400 to $100, but demerit points raised from 25 to 35 seen as a greater deterrent.

And they think its going to stop people driving illegally? Really? They’re dreaming. I know of plenty of people who drive around with people when they’re not supposed to, or in hours they’re not supposed to, without a single care in the world.

- Tough new penalties for failing to stop, with a third offence resulting in a year's loss of licence and mandatory jail of up to three months.

Ouch. Seems a little extreme for not stopping at a sign. I know they’re there for safety blah blah, and I know you’re meant to stop, but some stop signs are in the stupidest of places. I used to travel through one daily where it made no sense to stop at all. And on the very odd occasion someone did actually stop at it to follow the rules, it was nothing for someone to nearly go up the back of them.

That’s not to say all stop signs are like that, but that’s not the point.

I hope like hell some of these laws don’t go through. Or there goes yet another part of our freedom. Give boy racers some where to go, and they will get out of the cities/towns. Simple. Make them sign a dotted line saying its their fault if they crash. And leave the common car enthusiast to enjoy driving without the annoyance of being treated as a boy racer.

Faster broadband promised. Yet again

Posted by Daniel on 01/04/2009 at 03:58 p.m. in Computers

Seems like this has been promised again and again for New Zealand. And so far there have been very few improvements. And off goes John Key promising “quantum faster” internet speeds (Stuff article). And yes, I agree that it’s great. Hopefully something happens this time.

But there’s still a few problems here.

New Zealand isn’t the most connected country in the world as it is, and we don’t exactly have huge “pipes” to the global internet backbone. Key is talking about 100mbps connections in homes and businesses which is great apart from the fact that most content isn’t in New Zealand. Instead we’d all be squashed into the Southern Cross cable decreasing speed to international resources.

But the biggest issue is data caps. New Zealand ISP’s love giving out low data caps for high prices, which is bearable at best with lower internet speeds. But if we’re connecting to the world at 100mbps, that 10gb plan of yours isn't gonna’ last too long.

Things have changed from the one shared computer per household of the 90’s and early 2000’s. Hardware is cheap – so it’s becoming the norm for people to have multiple machines accessing the web concurrently and for longer periods, meaning that more data is being transferred. For example I flat with 3 other people, we have a 10gb cap and we each have at least one computer. Our cap is gone long before our billing period is over, but it’s cheaper to pay the extra data costs than upgrade to the 20gb plan.

Think about your average YouTube video for example – they’re roughly 5-10mb in size. And that’s for a low definition stream. Add that up between the people in your household based on the number of videos they watch, it’s not too hard too see where your usage is going in just this area alone. Never mind general web surfing. And what about general downloads? Faster speeds make downloading big files (Game trails etc) painless, so it’s instantly more appealing to do so.

Or what about when you want to work from home (Something that Key is also pushing) via VPN? You need a consistently fast and stable connection. You wouldn’t want to wake up one morning to realise you’ve been restricted to 56kbps for breaching your data cap. Or get your internet bill to find you owe $100’s in extra data costs. And in the world of large files, this becomes a problem.

It also makes you think twice before using “cloud computing” applications. I love Live Mesh and use it on all my machines and it saves a lot of hassle. But while at home I have to be a bit more careful with my usage. For example I saved a large file into my documents at work recently by accident. When I got home I fired up Mesh only to realise it was trying to pull down 500mb. Luckily I stopped it at about 5mb, but they point is that 500mb shouldn’t matter. It’s the 21st century.

So my message to the government is this: Gives us fast internet sure, but before/when you do, do something about the miserable data caps ISPs enforce on us. Fast internet is nothing if we can’t make use of it.

Comments welcome

MyOS - A different type of WebOS

Posted by Daniel on 28/03/2009 at 04:22 a.m. in Computers

Something about the concept of a WebOS/Webtop/Web Desktop has always interested me. It seems like a cool idea to have your whole “operating system” running in a browser on some companies (or persons) server somewhere in the world. You would have access to all of your applications and documents anywhere in the world.  So it all sounds great right? Not quite so.

In a traditional WebOS you have an account which stores your settings an documents. You use the applications the vendor has included, and if you need something else, well you’re more than likely out of luck. Same goes for if you want to change some of the “system” files to fix a bug or make your own enhancement say. You are served up code form the vendor and there’s little you can do to control it. You just hope that it, and “your” applications work (though at the same time it should be of some comfort the vendor has tested their code).

This got me thinking – Why not have a WebOS that more closely matches a standard desktop operating system? Something with programming API’s for accessing the file system etc. Something where everyone has their complete own virtual file system, they can install their own applications without affecting other users. Even run the core system files from their own instances so if they feel like tinkering with how it works they can. And best of all - Allow users to develop their own applications using a range of built-in libraries and controls.

So about 5 months ago I started writing a JavaScript framework for my idea. It only took a few weeks to realise my original framework wasn’t going to be flexible enough to follow the desktop OS model I’m attempting to follow. So I started from scratch. And, so far, the new frameworks managed to fit what I need.

At a low level it takes care of loading application classes and stylesheets and keeping track of the core systems like authentication. Up higher are classes that create a common application framework making it far easier to get windows with control in them up on screen. The framework takes care of registering the users application with the Task Manager so it can keep track, and the loading/saving of application settings plus more.

So far MyOS is still very simple (and only runs in Firefox). Everything’s read-only and there’s currently no way to read/change files… or do much else from a users level. But from a developers level there is a lot of functionality to explore. You should be able to write complete applications without needing to write a single line of HTML, and there are a couple of objects based on C# like Lists and Dictionaries. There is even a registry-like library in the works. The only downside is that there’s little documentation at this point around the developer stuff.

FireShot capture #2 - 'MyOS' - localhost_1034_desktop 
MyOS Desktop with File Explorer and Dev Studio running (Please excuse the ugly red X button)

If you would be interested in helping with MyOS (Programming, Design, Documentation, Ideas etc) then please contact me! I’d love to work with someone on the idea. Sure it may never be a commercial application, but if you have some spare time and find these types of things interesting, it could be a bit of fun.

Want to see it?

You can play around with the latest public release at http://myos.danielwylie.me  - it includes a read-only version of Dev Studio. The ‘Run’ and ‘Explorer’ applications currently contain the most recent programming style – most of the other applications haven’t been updated in a while.

Previous Page - Next page