Election API prototype

The project sputtered a few times before it really got going, but it seems well on its way. My first elections calculator was built to demonstrate the flaws of voting systems. This new one, however, is intended for the development community.

Most voting system implementations are just plain Plurality (aka first past the post), which is prone to a great many flaws. Instead of implementing better voting systems libraries in each language, why not provide a general web service API?

The tool speaks JSON and provides and is completely stateless. You send your full request (ballots, desired voting system, etc) and it returns the winner (or winners) and an explanation as to how it reached that conclusion. All data is stored locally in cookies; The only server communication is for the result calculation.

I’m only about half-way done: four more algorithms to go (Schulze, STV, CPO-STV and Schulze STV) and a fair bit of polishing on the UI. Late December? Early January? Something like that.

Update: It’s up and available.

French Onion Soup

I don’t think I’ve ever had onion soup before, so I’m kind of winging it on this one. The first attempt turned out tasty enough to share, as inauthentic as it may be.

Ingredients

  • ¼ cup margarine
  • 4 onions, sliced
  • 1 tsp sugar
  • 1 tbsp flour
  • 2½ cups water
  • 2½ cups onion broth
  • ½ cup red wine
  • croutons
  • vegan cheese, sliced (Earth Island Mozzarella works well, but I’m looking forward to trying Daiya’s)

Method

  1. Melt the margarine in a soup pot. Stir in the sugar. Add the onions and cook until caramelized (about 10 minutes).
  2. Stir in the flour until the mix thickens.
  3. Add the water, broth and wine. Bring to a boil, then simmer covered for 10 minutes.
  4. Ladle the soup into ramekins, placing a single layer or croutons on top, then multiple layers of the sliced cheese
  5. Bake at for 10 minutes at 220°C.

Sesame ginger cookies

The following recipe comes from The Veganomicon, my newest of cookbooks.

IMG_8672

Dry ingredients

  • 2¼ cups flour
  • ½ tsp baking powder
  • ½ tsp baking soda
  • ½ tsp salt
  • ½ tsp ground ginger
  • ½ tsp ground cinnamon

Wet ingredients

  • ½ cup vegetable shortening
  • ½ cup chunky peanut butter
  • ¼ cup brown rice syrup
  • 1¼ cups sugar
  • ½ cup soy milk
  • 1 tsp vanilla extract
  • ½ tsp almond extract

Additional ingredients

  • 5 oz. candied ginger, diced finely
  • ⅓ cup sesame seeds

Method

  1. Sift together the dry ingredients in one bowl.
  2. Beat the wet ingredients in another until smooth.
  3. Add the dry to the wet.
  4. Mix in the candied ginger.
  5. Roll small balls of batter first in the sesame seeds, then in some extra sugar before placing on a cookie sheet.
  6. Bake at 350°F for 13 minutes.

Pumpkin cheesecake cupcake

Cheesecupcake? Cupcheesecake? Whatever. Delicious. The recipe is loosely based off of the pumpkin tofu cheesecake from La Dolce Vegan, but with necessary substitutions based on ingredient scarcity.

Ingredients

  • 425g firm tofu and 300g silken tofu (I was short and used 350g firm tofu and an 8oz tub of Tofutti creamcheese)
  • 1¼ cups sugar
  • 1 cup pumpkin purée
  • ¼ cup flour
  • 1 tsp vanilla extract
  • ½ tsp maple extract (I used about 2 tbsp maple syrup)
  • 1 tsp cinnamon
  • ½ tsp salt
  • ¼ tsp ground ginger (I doubled this as I love ginger)
  • ¼ tsp ground cloves
  • 1 tbsp maple syrup (Omitted as per above)

The crust was just graham cracker crumbs with a bit of melted margarine and sugar.

Method

  1. In a set of about 8 ramekins, crumble the crust into the corners, forming a thin bottom and a reasonable ring around the outside.
  2. Blend the above ingredients (wet first, then dry) and pour the smooth mixture into the ramekins, on top of the crumble crust
  3. If desired, sprinkle some crumbled pecans, sugar and cinnamon on top. Drizzle some maple syrup if you’d like too. It’s not necessary, but they spice up an otherwise bland surface.
  4. Bake for 75 minutes at 150°C then let cool overnight in the fridge.

A conflict of interests

Exhibit A: The Canadian Charter of Rights and Freedoms, Fundamental Freedoms section

2. Everyone has the following fundamental freedoms:
(a) freedom of conscience and religion;
(b) freedom of thought, belief, opinion and expression, including freedom of the press and other media of communication;
(c) freedom of peaceful assembly; and
(d) freedom of association.

Exhibit B: Bill 13 — Miscellaneous Statutes Amendment Act, 2009

“specified municipality” means any of the following:
(a) the City of Richmond;
(b) the City of Vancouver;
(c) the Resort Municipality of Whistler.

32 (1) Subject to this section and section 34, an officer or employee of a specified municipality or a person authorized by the council of a specified municipality has the authority to enter on property, and to enter into property, without the consent of the owner or occupier for the purpose of enforcing, in accordance with subsection (4), the specified municipality’s bylaws in relation to signs.

(1) Subject to subsection (2), the Council may make by-laws for the purposes of enforcing its by-laws, including establishing one or more of the following penalties to which a person convicted of an offence in a prosecution under the Offence Act is liable:

(a) a minimum fine;
(b) a maximum fine of up to $10 000;
(c) in the case of a continuing offence, for each day that the offence continues either or both of
(i) a minimum fine under paragraph (a), or
(ii) a maximum fine under paragraph (b);
(d) imprisonment for not more than 6 months.

The timing of this and the location constraint suggest that this is motivated by the coming Olympics. The short of it is if you have a sign they don’t like, they can fine you $10,000 and put you in jail for 6 months. I’d think that the Charter of Rights and Freedoms would trump this. How is it even being discussed then?

If this concerns you, please contact your MLA. If you don’t know who your MLA is, find out.

Partitioning control of electoral reform from vested interests

Fox and Henhouse by Marj Joly

One of the key problems in electoral reform is that those who hold the power to change it benefit from the current system; It got them into office, right? Maybe there’s a way we can move that power out of those most disinclined to seriously consider it.

Just a thought. Every 10 years (5? 15?) hold a guaranteed referendum on what electoral system we should be using and switch to the preferred alternative. If the current system is FPTP, use FPTP as the referendum mechanism (likewise if it’s IRV, Schulze, etc).

Furthermore, the first referendum would occur in 10 years from now. Often candidates will run on platforms that include democratic reform, but abandon it once elected. By putting the first election far enough in the future, it can be ratified without directly threatening the power base of the current representative.

We don’t want the fox guarding the henhouse, right?

Single and multiple winner systems

Currently, Vancouver uses plurality to elect one mayor and plurality at large to elect 10 councillors. In so much as I’d love to see a multiple-winner Condorcet method used to elect both sets, I understand that such algorithms are too difficult for most to follow in multiple winner scenarios. While I think STV is a reasonable compromise, I dislike how IRV ignores votes and misrepresents large demographics when electing a single representative.

Winners Plurality IRV/STV Condorcet
Single Trivial to implement, but horrible results Simple to implement, but poor results Understandable method with good results
Multiple Simple to implement, but poor results Understandable method with good results Good results, but too complex for most to understand

It’s unreasonable to suggest that we should use one method for single winner elections (Condorcet for the mayor) and another for multiple winner elections (STV for the councillors); I think that idea just wouldn’t sell. That being said, maybe IRV/STV is a imperfect, but reasonable stepping stone.

I’m not fully convinced yet, but I think small increments towards fairer representation is more realistic than giant leaps towards awesome.

Pumpkin pie

I got this recipe from La Dolce Vegan and tried it out on family a few days ago. It worked so well I thought I’d pass it along to others.

Pie crust

  • 2 cups pastry flour
  • 1 tsp salt
  • ¾ cup margarine
  • ¼ cup soy milk
  1. Sift the flour and salt together.
  2. Add the margarine and mix together until it becomes a coarse meal.
  3. Add the milk in and mix until a dough forms.
  4. Roll into a ball and refrigerate for at least an hour.
  5. Roll it out into pie shell.

Filling

  • 400 ml pumpkin purée
  • ½ cup soy milk
  • ½ cup maple syrup
  • ¼ cup cornstarch
  • ½ tsp salt
  • ¼ cup sugar
  • 1 tsp ground cinnamon
  • 1 tsp ground ginger
  • ¼ tsp allspice
  • 1 tsp vanilla extract
  1. Mix the milk and syrup together and slowly add the cornstarch, whisking if necessary.
  2. Add the remaining ingredients and blend until smooth.
  3. Pour the mixture into the pie crust.

Topping

  • ¼ cup walnuts
  • ¼ cup sugar
  • ¼ cup flour
  • ½ tsp ground cinnamon
  • 2 tbsp margarine
  1. Crumble the walnuts as fine as you can. The dustier the better.
  2. Add the remaining dry ingredients and mix well.
  3. Add the margarine in and combine.
  4. Sprinkle on top of the pie evenly.
  5. Bake at 375°F for 40-45 minutes. Done!

Watch Steam for price drops

This could probably be done a little better, but the core idea is here: Watch a set of specified games on Steam and, if the price drops, send out a notification email. Set this up on a daily cron job and you’ll be notified when the game you’re looking for drops in price. Might be months, but it’ll likely happen.


$games = array(
    "Batman: Arkham Asylum" => array(
        "id" => 35010,
        "known" => "$49.99 USD"
    )
);
foreach ($games as $name => $values) {
    $doc = new DOMDocument();
    @$doc->loadHTMLFile(
        "http://store.steampowered.com/app/{$values['id']}/"
    );
    $current = $doc->getElementById("game_area_purchase") \
        ->getElementsByTagName("div")->item(1)->nodeValue;
    if ($current != $attributes['known']) {
        mail(
            'youraddress@example.com',
            'Price drop on steam',
            "$name dropped to $current"
        );
    }
}

Maybe better would be to collect the price from each day over a set of games and graph this data over time. It’s not necessary, but I’d be curious to see that extension of this idea.

Open Data in Vancouver

Some months ago, a co-worker pointed me towards VanMap, an online tool that provides fine detail on the City of Vancouver: property lines, zoning information, sewer mains, etc. The down-side to this site is that it only functions in Windows and that the underlying data isn’t directly available.

Fortunately, there’s talk of opening the city’s data in a permissive licensing model like the Creative Commons. Andrea Reimer‘s talk this evening about the progress towards that goal was informative, considering I wasn’t aware the problem was being worked on.

Brought up during this talk was the September 16th Hackathon. I’m not 100% clear yet on what the focus will be, but it’s there for the curious. One of their previous projects is VanTrash, which is a neat tool that can remind you when your trash pickup is. Pretty sweet, eh?

vantrash

Update

Looks like Vancouver’s Open Data Catalogue is up in beta form. Go take a look for it is super.