Petrol price “boycotts"

Posted at 11:31 p.m. on 29/03/2011 by Daniel

This is more a rant than a useful, informative post… You’ve been warned. I also originally posted it on Tumblr, so you may have read it before.

Over the last few weeks as petrol prices head up, I’ve noticed a few groups on Facebook claiming that if you don’t buy petrol for one day, the petrol companies will notice, and drop their prices. The latest one claims that it’s not a “don’t buy petrol” boycott (it actually is), and that we can get petrol back to $1 per litre.

I just have one question for all of these groups/boycotts/crazy people - what do you actually think this is going to achieve? I’m sorry, but I just don’t get it. The days of $1-1.50 petrol are over. Oil is a finite resource. They’re not making more of it in a big factory somewhere. They’re not finding huge new reserves of the stuff anymore. And us humans are using more of it than ever before. Cross that with the unrest in Libya (who make some awesome crude) and the weakening New Zealand dollar, and it’s not looking good.

The original boycotts worked by basically saying “Don’t buy petrol on this day”. Uh, yeah, great, what happens when you’re tank’s empty though, say a few days later? You go to the petrol station, and fill up. The petrol companies know this. They also know that the grandma who pops in every week without fail isn’t going to be in on some Facebook shenanigans. So they’re not at all bothered by the original “boycotts”.

In fact, they’re probably laughing at everyone who clicks that ‘Attending’ button.

The latest one (in the first picture) strikes me as the most ambitious (stupid) though.

Boycott one petrol company (BP in this case) in the hope that they will first actually notice, and then lower their prices, which is supposed to bring down the prices of all the other companies. There are currently 6,774 people “attending” this effort, if you can call it that, on Facebook. Now I think it’s safe enough to say that a group of those people don’t actually own cars, so say that 2,000 of them don’t buy petrol from BP for a few weeks (until they forget about it, or get bored and find a new group to join) - BP still has its regulars. And it still has a large number of corporate fuel card holders.

People seem to think that getting oil out of the ground is cheap and easy. Have you ever tried digging a hole thousands of feet into the ground, in the middle of the ocean, in the hope that you might hit oil? Didn’t think so. It takes years of planning, searching and development to find it. And that’s only to get it out of the ground. It still has to be floated around the world on a huge ship, refined into petrol (or diesel, if you swing that way) at a refinery, and then shipped out on another huge ship, to petrol stations. They’re doing this all for $2.20 a litre.

Actually, that’s a lie. The petrol companies only see around half of that. Most of it goes to the government in GST, emission trading schemes and other taxes. The importer gets some of that as well of course, and the shipping company.

I even made a pretty graph (all good “arguments” need graphs, right?)


(Data from here)

So basically, the oil company is doing ALL of that work for you, for around $1.10 a litre. Yes they used to be able to do it for less, but, as I said above, times have changed, and things are a little tougher now.

Don’t want to pay so much for petrol? Catch the bus, ride that bike you’ve had in the shed for years, walk, swim, hop on one leg… So many other options! Why not spend the time you’re wasting arguing on Facebook doing something useful? The world would appreciate it more.

Me? I’m going to fill up with some nice juicy petrol from BP. I might even go a little go a little crazy and splash out on some premium fuel…

It's coming soon...

Posted at 10:41 p.m. on 28/03/2011 by Daniel

It's been eight long (and exciting) months of development, and two months of private testing, but Kustom Page will be relauching soon. We are just ironing out the last few major roadblocks, and are expecting to have something out the door very shortly.

We have re-written almost the entire application. It is now more powerful, faster and easier to use than the previous versions. It also allows us to extend the system a lot further than before.

Here's some eye candy of the latest build, enjoy!

 
 

 

Simple C# Email Template 'System'

Posted at 02:04 a.m. on 02/12/2010 by Daniel

As part of the new email system in Kustom Page, I decided to build a quick little template system, based off models, that could populate email fields, instead of doing a string.Format.

You pass it in a model (C# object), it runs through each of the properties, and applies them to the template file. Simple? Yes.

using System;
using System.Collections.Generic;
using System.Reflection;
using System.IO;

namespace KustomPage.Emailer.Client.TemplateEngine
{
    public class TemplateEngine<T>
    {
        private readonly T _templateModel;
        private readonly string _templateFilePath;

        public TemplateEngine(T templateModel, string templateFilePath)
        {
            _templateModel = templateModel;
            _templateFilePath = templateFilePath;
        }

        /// <summary>
        /// Renders the template.
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            IEnumerable<KeyValuePair<string, object>> modelProperties = GatherModelPropertiesAndValues();
            var output = LoadTemplate();

            foreach (var modelProperty in modelProperties)
            {
                output = output.Replace("<<" + modelProperty.Key + ">>", ObjectToString(modelProperty.Value));
            }

            return output;
        }

        /// <summary>
        /// Loads the template.
        /// </summary>
        /// <returns></returns>
        private string LoadTemplate()
        {
            return File.ReadAllText(_templateFilePath);
        }

        /// <summary>
        /// Converts the objects to a string.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        private static string ObjectToString(object value)
        {
            if (value == null)
                return string.Empty;

            if (value.GetType() == typeof(string))
                return (string)value;

            if(value.GetType() == typeof(DateTime))
            {
				// Add formatting here at some point
                DateTime dateTime = (DateTime)value;
                return dateTime.ToString();
            }

            return value.ToString();
        }

        /// <summary>
        /// Gathers the model properties and values into a dictionary
        /// </summary>
        /// <returns></returns>
        private IEnumerable<KeyValuePair<string, object>> GatherModelPropertiesAndValues()
        {
            IDictionary<string, object> properties = new Dictionary<string, object>();
            foreach (PropertyInfo propertyInfo in _templateModel.GetType().GetProperties())
            {
                string name = propertyInfo.Name;
                object value = propertyInfo.GetValue(_templateModel, null);

                properties.Add(name, value);
            }

            return properties;
        }
    }
}

Sample usage

Model

using System;
namespace KustomPage.Emailer.Client.Tests.TemplateEngine
{
    public class TemplateModel
    {
        public string Name { get { return "Daniel"; } }
        public string URL { get { return "http://www.kustompage.com/"; } }
        public DateTime Date { get; set; }
    }
}

And using it...

var model = new TemplateModel { Date = DateTime.Now };
TemplateEngine<TemplateModel> templateEngine = new TemplateEngine<TemplateModel>(model, "EmailTemplates/Test.txt");
var output = templateEngine.Render();

Sample template

Hello <<Name>>,


Pelase verify your account by clicking on the link below:

<<URL>>

This message was generated at <<Date>>

New Car

Posted at 12:00 a.m. on 20/09/2010 by Daniel

After years of wanting one, I finally decided to take the plunge, and bought an old Corolla. A 1977 KE30, in bright yellow, to be exact. Why? Want a project, something to call my own. I was also sick of paying mechanics to fix my Subaru. With the Corolla, I can do it myself for the most part.

It currently has a 1.3L 4K engine, mated to a T50 5 speed gearbox, which, to be honest, is extremely gutless. Tempted to do a 4AGE conversion at some point, depending on cost, and time.

So far I’ve tidied up the wiring under the dash (previous owner had used cello tape…), installed a new choke cable, replaced the steering wheel and boss kit with something that fits properly and made it run a little smoother.

Still have a long way to go though, currently doesn’t idle properly with the headlights on, there’s a few spots of rust I need to take out over summer, and it could do with a re-paint. Also needs a stereo and alarm, badly.

My biggest complaint with it would be the ride comfort, it’s terrible, especially at motorway speeds, it crashes and bangs around. The tyres rub quite badly on the front as well, may need to put harder springs in the front. The brakes also have no feel to them whatsoever, which can be a little scary.

Photos

Sitting in the sun.

Rhys installing new wiper blades.

Rhys installing new wiper blades.

 

New steering wheel. Can now see speedo, old one blocked it.

   

iPhone 4

Posted at 10:42 p.m. on 02/08/2010 by Daniel

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 at 09:12 a.m. on 08/06/2010 by Daniel

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 at 12:38 p.m. on 06/06/2010 by Daniel

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 at 10:52 p.m. on 26/04/2010 by Daniel

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");

  Next Page