Thursday, September 29, 2011

European Crisis De-euphemismified

Politicians use euphemisms so no one can understand the truth. The media use euphemisms because they don't understand the truth.

Here, for your viewing pleasure, is a breakdown of the some of the terms used in the discussion about the European debt crisis*. I've used Greece and Germany as examples (represented by their flags), but this really applies to any country. For example, Iceland's government defaulted on its debt to the UK.

The key thing to understand that when people say "Greece is being bailed out", what they are really saying is "Greece is being given European taxpayer money so they can pay foreign banks back".

And as for all the self congratulating yesterday that the crisis had been averted, mark my words: Greece will default.

Oh, and if you are wondering why I'm drawing up flowcharts about economics when I'm supposed to be an engineer, it is because I have layers, like a parfait**.

* This is available in wallet size, so you can carry it around and look like a dork!
** Euphemism for "I took an economics course once and now I think I understand world economies, plus its lunchtime and I'm bored."

Saturday, September 24, 2011

Poker pile-on

Full Tilt Poker, an online poker site, just recently was called a Ponzi scheme. The US governement has upped its attack on poker sites, and in the process, will cost Americans a lot of money.

Full disclosure: I have $14 in my account at I also used my frequency player points to buy a mug and a cap. I originally deposited $50 back in 2005, took out $100 in 2006, and have vacillated between $10 and $30 in the account since then. Obviously, I have a lot riding on this. If Pokerstars goes under, I'm going to have to have that difficult conversation with the wife: "I know I've made some bad decisions. That massage chair for $800 which I never used. Those fur coats for the dogs. Three big screen TVs in 3 years, each time saying, yes, this one is finally big enough for me*. But now, its going to be Kraft dinner and tuna for the next few weeks. Wait, what?! I just found $14 in the couch ... never mind!"

Back in 2006, the US government slipped a section into the SAFE Port Act that made sending money to online gambling sites illegal. This was a big blow; some sites pulled out of the US and others declared they would still serve Americans. The next few years, online floated along in a grey area (like Canadians getting US satellite signals or picking up a chocolate bar off the ground and still eating it) and then "Black Friday" (Apr. 15, 2011), where the US government arrested representatives of the big online poker sites and shut down the websites. Their big claim is that poker site "tricked" banks by disguising charges. Now the US has made a further complaint, that Full Tilt is a Ponzi scheme and doesn't have enough money to allow players to get their deposits back.

This is so annoying. Hey, you know what else is a Ponzi scheme? CPP! The money young people give to the Canadian Pension Plan isn't invested or put in the friendly giant's mattress; it pays for the old retired fogies. But don't worry, when you're an old fogy, there will be a new batch of suckers to pay for your retirement. Or something.

That was annoying thing #1. Here's number #2**: poker players warned about this. Hey Sherlock, if you make it hard to get money out of a poker site guess what? It becomes hard to get money out of a poker site. The reality is people are going to play online poker because casinos are creepy. I'd rather sit in my underwear and play poker with my wife sitting in her nightie on the couch next to me ... wait. Okay, that's a bad example because 14% of the time you'll see that exact scene in a casino. But you get my point. And with the US government making it much harder to legitimately get money on/offline, you push poker players into having to use shadier methods. Like sending checks to the pokersite with sneaky names like the "Ace of Spades Non-Gambling Charity Foundation".

Annoying #3 is poker is not gambling! I know, you might think it is because there are cards and a dealer, like blackjack (which is gambling). But its not, because there are players that consistently win. What's that? Your aunt Sally wins at blackjack? No, actually she doesn't. She's stealing from you uncle. But the other reason why it can't be a game of chance is that you don't have to show your cards to win. You can bluff. The last reason is that you get to check your cards first before you voluntarily put money it. In blackjack, craps, and roulette you have to pay before you get your cards, the dice are rolled, or the wheel is spun (raggedy man!) Not gambling mean laws that apply to gambling don't apply to poker.

So what we have is an activity that adults freely engage in and the US government has declared war on. So what that a bunch of players are going to lose a bunch of money. Collateral damage.

Now Full Tilt isn't helping by mismanaging its funds. But the scary thing is the exactly same thing would happen if everyone decided they wanted their money in their TD checking account (worse ... see below). The US government is making a big deal about the fact Full Tilt has $400MM in liabilities and $40MM in cash. But what they don't mention is these sites make about $1MM a day in profit. Like all businesses, cashflow is much more important that net assets. But if the US would stop being so anti-online poker, these sites could set up in the US and be regulated. This is win-win, because they would pay taxes and they would be regulated so they would be required to keep some percentage of deposits available.

Okay, now something that will scare the hell out of you. Full Tilt had 10% of its deposits in reserve. In banking, this is called the "reserve rate". And Canada phased out "reserve rates" back in the 90s. Yes, that means that banks in Canada are free to lend out 100% of the money you deposit. But don't worry. Because the powers that be are dealing with this huge gambling problem.

* Phrasing!
** This is like saying "number number 2", but it made me laugh, so it stays in.

Tuesday, September 20, 2011

Unite without unions?

Air Canada flight attendants, members of CUPE (Canada's largest union), are planning to strike tomorrow. It was only back in June that the government nearly had to legislate the Air Canada call-centre staff back to work. Some questions come to mind when I hear all this. Why aren't there strikes at Westjet? Why does the government have to legislate people back to work? Why are unions necessary?

When I was in college, the teachers at my high school went on strike. They needed people to help the students, so I volunteered. My dad, at the time, didn't say much, as I was an adult. But I think it was pretty scandalous, me being a scab. Frankly, I needed some money, and I felt bad for the kids, so I decided to help. I didn't have to physically cross any picket line, however.

In the years that followed, I started to feel bad about doing that. That is about the time I read a lot of Noam Chomsky, and thought "the man" was screwing everyone over. I worked at a lumber mill one summer, and I remember a poster in the shop: "Your boss needs you, you don't need your boss." I've come to realize that capitalism is a heartless economic system, but it better and freer than any other system out there.

Collective bargaining is entrenched in law in Canada, while in other places it is voluntary. Here is why I think mandatory collective bargaining is not necessary.

Say I go into Walmart and I want to buy a $10 soccer ball. I say to the manager, "I want 10% off this ball." He says no, and I leave the store. Both of us are free to bargain and then agree to terms.

Now lets say I go into Walmart and I represent a soccer league (a collective). I say to the manager, "I'm going to buy 100 soccer balls and I want 10% off." There is now incentive for the manager to deal with me. He can sell a lot of balls at once and since he's just dealing with me, there are savings (rather than selling 100 balls to 100 people). He counters with 5%, and we are both free to accept or decline the terms.

Imagine that I want my 10% but he is unwilling to give me that, so I barricade his doors and shut down his store. This is essentially what Canada's collective bargaining laws are like. There is already incentives for management to deal with a group of people, rather than just each person separately. There is no need to make it law. But when it becomes law, it distorts the normal functioning of the market.

If employees bargain as a group, they gain some leverage over a company. But there needs to be balance, or else it is just legalized extortion. If a collective's demands outweigh the cost to fire all of them and retrain new employees, then the company must have that option. Of course, smart companies know that this is a last resort and would only be done if the employee collective was being totally unreasonable. But company management understands the broader picture. Public companies have stockholders who must be paid. They know the market climate. Employees are just one piece of the puzzle.

Because employers are not allowed to fire unionize employees, we end up with a system that constantly needs government interference and legislation. If collective bargaining were voluntary, like all contracts, the market would function much better.

It is tough to talk about this because I know many people with government pensions. I think talking about pensions (specifically) and unions (in general) usually gets bogged down in the historical function of unions, which was to protect workers from oppressive and unsafe working conditions. I don't really think these are an issue anymore because they are now covered by Canadian law. And I don't think non-unionized companies are unpleasant to work for.

I think my biggest concern with unions is they foster an "us" vs. "them" attitude between employees and management. This is why, I believe, Westjet doesn't have strikes. The union isn't necessarily concerned about budgets and cashflows. Its mandate is to get the best working conditions and the highest salary. I don't even think they are that concerned about maintaining workers for the future. For example, if there is a 10% cut to a school districts budget, and the teachers union declares they have to let go 10% of the teachers (mostly the new hires), they are being disingenuous. Everyone could take a 10% pay cut and then everyone could keep their job. (Of course, upper union managment couldn't afford $1000 pants anymore*.) These are the types of compromises that other companies make all the time. Smart companies know that everyone taking a pay cut while times are tough will significantly save training money in the future when business picks back up. These are the types of things that unions aren't really concerned with.

I think unions may have outlived their usefulness. I think people should be free to enter into legal contract with whoever, and however, they want. I think workers and management, pulling together with the same goal (success of the business) is a much more effective strategy. Of course, if I ever get a unionized job with a pension, forget I said any of this.

*I'm serious. I'll tell you about it someday.

Tuesday, July 5, 2011

Greek Tragedy

You may be asking yourself: what is going on in Europe with this so-called debt crisis? Why is everyone freaking out about Greece? What's "contagion", and is their an ointment for it? Is there a financial zombie apocalypse happening? I'm going to try and answer all these questions. This is an interesting topic because people make it more complicated than it is. You can actually relate it to things like your household budget very easily.

Let's start simply, with budgets. Countries, like households, have income and expenses. Countries get income through taxes. Taxes tend to be related to a countries gross domestic product (GDP), so the more stuff a country makes, the more its government makes in taxes. If a government spends more than they earn in a given year, it is called a deficit. Do this enough, and that will lead to debt.

Debt isn't a bad thing, as long as it is a reasonable percentage of income. Most of us are comfortable going into debt to buy a house or a car. In Canada, household debt as a percentage of yearly disposable income has steadily increased from 90% in 1990 to about 140% today. The same idea can be applied to countries. For example, Canada's debt to GDP ratio is about 34%, which is reasonable. However, this is only the debt owed to Canadians, called "internal debt". We also have debt we owe to foreigners, which is about 75% of GDP. This is called "external debt".

You may be asking, how can countries have debt? Where does the money come from? Let's go back to our household. Say you buy a house and get a loan from the bank. This is "external" debt, because you borrowed from someone else. But say you want to buy a car but the bank won't lend you money. You could raid your kids college fund, or you borrow from your rich aunt. These could be thought of as "internal" debt.

How do these translate into a countries debt? Well, most countries issue bonds, which are basically I.O.U.s which both citizens and foreigners can buy. You give the government some cash and the government promises to pay you back. The interest rate the government agrees to give you depends on a how risky lending them money is. Stable countries have relatively low interest rates because they don't need to entice people to give them money. Unstable developing countries need to pay more to entice people to give them money because there is a real risk that they could default. The free market determines the interest rate on bonds. For example, the current Greek 2-year bond rate is 28% (i.e., if you lend Greece money for two years, they'll give you 28% a year interest!) Compare this to Canada's 2-year bond rate of about 1.5%.

What does "Greece has a debt crisis" mean? What it means, basically, is Greece spends more than it earns, and it can't make regular payments on the debt it owes to citizens and foreigners. As of 2010, Greece owes 165% of GDP to foreigners (mainly European banks) and 130% of GDP to citizens (mainly entitlement programs like pensions and benefits). Because they are having trouble paying people, no one will lend them any money, and if they will, it is at insane interest rates. This is like not being to pay down a credit card with 10% interest, so you get a credit card with 20% interest to try and make payments -- clearly not a sustainable situation.

(I'm going to take a quick aside here. You may be thinking, "Why do countries have to ask anyone for money? Why don't they just print it?" Some countries do that. The U.S. is doing that right now with their "quantitative easing". The problem is that unless you are a totally self-sustaining country, you have to buy stuff from other countries. If you debase your currency too much, the price for other stuff like oil and grain will just keep getting higher and higher. Eventually, when everyone loses confidence in your currency, hyper-inflation happens. For example, Zimbabwe has a $100 trillion dollar bill.)

Since Greece is a part of the European Union, the fact they are in trouble is affecting everyone. The European Union will help them out, BUT Greece has to get things under control. Foreign banks have put pressure on Greece not to restructure the debt they owe to them (restructure is a fancy term for saying: "I'm broke, so do you want some of what I owe you or none?") Internal debt is much easier to muck around with, so that is what Greece is doing.

Just like we raided our child's college fund to pay for our car, countries can do similar things. Eliminating pensions and benefits are one way. Pensions are a liability, whose cost is born by future generation. To get Greece's spending under control (so Greece can continue to pay back debt to foreigners), the EU is asking them to undertake "austerity measure" (also called "belt tightening" or "belt selling and giving the profits to banks"). If Greece does this, the EU will lend them some more money.

Let's create a detailed example to show what is going on. You buy a house, and are paying a $1000/month mortgage. You want a car, so you take the money out of your kids college fund, and are repaying that back at $500/month. Then your wife loses her job so your monthly income takes a hit. What do you do? You start getting credit cards, at progressively higher interest rates to continue living the life you are accustom, plus paying down your mortgage and replenishing the college fund. But things reach a breaking point. No one will lend you more money. So you go to your rich aunt and say, help, I need money. She looks at your situation and says, "Okay, I'll lend you the money, but you need to balance you budget. You can't spend more than your earn, so you'll have to cut back. No eating out and no new video games. If you do that, I'll lend you the money." You say, "Auntie, don't you know the bank manager? Perhaps he can reduce my mortgage so I can pay less per month?" The bank manager is not pleased to hear this, which your Aunt conveys to you. "Sorry, I think you're going to just have to stop paying into the college fund until you get back on your feet." Given all the pressure, you relent. You cut back (but wife and kids aren't happy), and the college fund payments stop, but the mortgage payments continue on at the same rate, and you get some much needed spending money to make it to next month.

Sounds like a reasonable story, right? Wrong. Greece (and Ireland) should do what Iceland did, and that is say "screw you" to the bank. Iceland had huge foreign debt, but rather than destroy their own country for some foreigners, they shared the pain all around. It isn't perfect. But defaulting is a safety valve in the capitalist system, and is required. The reason is there are always two parties to every transaction: a lender and a lendee. Both have to be kept responsible so neither abuses the system. Lenders have to do their due diligence to make sure they are lending money to people who are able to pay it back. Also, lendees have to be responsible and not take on too much debt. But when things get out of control, all parties involved need to share the pain.

Don't get me wrong, countries like Greece have to stop this insane socialist experiment and balance the books. Democratic governments always have this danger: that they will get caught in a cycle of bribing people with their money. As Thatcher said, "Socialism works until you run out of other people's money to spend."

The final issue is this stupid word "contagion". I hate it. It sounds like financial crises are colds that other people can catch. This is nonsense. The reality is if one person in a community gets laid off, then chances are others are getting laid off too. If a recession hits a community and a bunch of people's houses got foreclosed, you wouldn't say, "We've got to get this foreclosure contagion under control before it spreads to other people." The PIGS nations (Portugal, Ireland, Greece, and Spain) are in trouble because they spend more than they earn. If other nations (I'm looking at you Italy) start having the same problems, its not because they were infected with anything, but because they too spent more than they earned.

Saturday, July 2, 2011

How I Learned to Stop Worrying and Love the Mart

Revelation Chapters 6:12: "And I beheld when he had opened the sixth seal, and, lo, there was a great earthquake; and the two most unholiest of shoes were joinithed togetherith, forming a monstrosity which shall markith the feet of his dark army."

This picture was taken at Walmart, which many consider the evilest of stores. In this blog post, I'm going to try and convince you of something: Walmart isn't really that bad.

I watched a documentary about Walmart (I think it was "The High Cost of Low Price") and it made me not like Walmart. I didn't shop there for years and instead went to Zellers or Superstore. After a few years of pain and suffering, I changed my mind.

Zellers is that absolute worst store in the world for customer service. I have left my basket (full of stuff) and walked out of Zellers more than any other store I've been to. These people just do not want my money.

Question: How many idiot cashiers does it take to determine the price of a can of beans? Answer: It is actually a trick question. It takes three of them, milling about, to figure out they need to call a manager to come over and answer it. When the line-up goes back into the housewares section, it is time to get off your cell phone and open another till.

Many Zellers have self check-outs, which are awesome because 4 tills can be watched by one person, but they never use them. Instead, they have gone to the committee-of-three cashiers model because apparently they only hire people with 1/3rd of a brain. Cashiers are the one place where you want an abundance of staff, because that is where money changes hands.

The other day at Safeway, I tried to buy a chocolate bar and the scanner wasn't recognizing it. The cashier asked a bagboy to go check the price, and I said forget it. The cashier said to me, "Can I offer you the chocolate bar for 50 cents?" Impressive customer service.

Which brings me to Walmart. That store is a joy to go to. The aisles are wide, the staff are friendly, and they get you through those tills fast. There are always dozens of cashiers on.

I'm going to try and read your mind. Right now you are saying:
"But Walmart destroys mom and pop stores."
"Walmart treats its employees bad and bust unions."
"They keep prices too low." What?

Mom and pop stores suck. There, I said it. My wife worked retail for years. Small business owners are crappy to their employees. Here's an actual conversation:
  • "So, there will be a staff meeting on Sunday for 1 hour after the store closes."
  • "You know that you have to pay everyone a minimum of 3 hours, right?"
  • "What?"
  • "That's the law."
  • "I've never heard of that. I'll tell you what, I'll make it 45 minutes, and I'll bring it cookies."
  • "You can bring in anything you want, but you have to pay us for 3 hours."
My wife was never invited to a staff meeting again. You think Walmart can pull that sh!t?

I remember when I worked for Dairy Queen back in GP, the owner used to get some of us guys to go over and mow his lawn and do general yardwork -- during work hours. There is no way that is legal. The mythical mom and pop don't exist -- all business owners are dicks.

The advantage to mom'n'pop stores is that mom and pop will spend money in the community and not ship it back to corporate headquarters, or to foreign shareholders. This is one of the best arguments against Walmart. Unfortunately, it doesn't carry the weight on we look into it.

Let's take the Croc-o-pedic shoes in the photo above. Let's say they cost $10 at Walmart, which can be broken down into:
  • $5 - wholesale cost of shoes, which goes to some Chinese manufacturer
  • $2 - wages to employees
  • $2 - overhead like rent and power
  • $1 - profit to head office and/or shareholders
The problem with mom'n'pop stores is they buy the same stuff from China, but they don't have the clout to get them to lower their prices. So you get the same foam-a-geddon shoe, but its more expensive, say $15.
  • $7 - again, wholesale to China
  • $4 - wages (assuming mom'n'pop are better to their employees)
  • $4 - overhead (because they have a smaller store that is not in some industrial park, so the relative cost is higher)
So in this example, buying your mac-goofy-shoes at Walmart causes $6 to leave the community, while buying them at mom'n'pops pulls $7 out of the community. This is just ignoring the fact you spent more of your hard earned money on the shoes. The only time that mom'n'pop stores have an advantage is when they are selling locally made products. In that case, I fully support local businesses. But if you are buying Chinese-made shiny crap, then buying from mom'n'pops is just throwing your money away.

Note: I have nothing against Chinese products. They are awesome. But America really screwed up. You know the expression, "A capitalist will sell you the rope to hang him"? In the pursuit of short-term profits, they outsourced all their knowledge. So now, there is really nothing China can't make. I for one, will welcome our Chinese overlords.

On a final note, the reason these fitness shoes alegedly work is they make it more difficult to keep your balance and walk, so you have to work harder and therefore burn calories and tone your muscles. I see elderly people wearing these and I think, What the hell are you doing, this is going to make you more likely to fall. I guess you'll lose a bunch of weight when you are in the hospital with a broken hip.

Tune in next time when we open the Seventh Seal of the Apocalypse!

Sunday, June 5, 2011

Creating my first Android app, Part 4

This is the last post in a four part series. Go here to read Part 1, Part 2, and Part 3.

This is the final blog about creating apps. First, I'm going to clean up some functionality from the last blog. Second, I'm going to show you how to email a note.

If you "packaged" the app and downloaded to your phone, you would notice it worked, but notes would not be saved between instances of the program. Actually, the notes are saved, but the list of notes aren't.

Here's the solution. We need to store the list of note titles in the database every time we save a note, and then load them every time we try and load a note. It involves modifying two blocks. First, modify the [ButtonNoteSave.Click] block:

  1. Click [My Blocks], click [DatabaseNotes], click+drag [call DatabaseNotes.StoreValue] just below the [call add items to list] block.
  2. Click [Built-In], click [Text], click+drag [text text] to the "tag" slot. Click on the second "text" on the [text text] block, which allows you to edit it. Rename it "TagNoteTitles". This will be the tag where we will store the list of Note Titles. Confusing enough for you?
  3. Click [My Blocks], click [My Definitions], click+drag [global ListNoteTitles] to the "valueToStore" slot.
Now when you save a note, the current list of note titles will be saved into the database. That way, if we close the app and start it again, that list of titles is stored. As I said before, there is no easy way to extract what exactly is in the database, so we need to keep track of it.

Second, we need to load the list. This can be done in several different places, but for simplicity, lets do it before we load a note. We need to modify the [ListNoteLoad.BeforePicking] block.
  1. Click [My Blocks], click [My Definitions], click+drag [set global ListNoteTitles to] just above the [set ListNoteLoad.Elements to] block.
  2. Click [My Blocks], click [DatabaseNotes], click+drag [call DatabaseNotes.GetValue] to the "to" slot.
  3. Click the block we created above named [text TagNoteTitles]. We want to copy it, so press CTRL+C, and press CTRL+V. This should create a duplicate of this text block which we can drag over to the "tag" slot on the [call DatabaseNotes.GetValue] block.
So before we load a note, the list named "ListNoteTitles" is pulled from the database.

Emailing a note

On to being able to email yourself (or some other person) a note. The biggest problem I had with other note apps was the notes were trapped on the phone. To get them off, you had to cut and paste the note into an email.

The basic idea is the note title is the email subject, the note message is the email body, and the email address in the TextBoxEmail is where the email is to be sent. The app will call a component called Activity Starter (which we named AppEmail). Activity Starter can be used to start the camera, open the browser, open a map, etc.

The steps are below:
  1. Click [My Blocks], click [ButtonEmail], click+drag [when ButtonEmail.Click] to the editor.
  2. Click [My Blocks], click [AppEmail], click+drag [set AppEmail.Action] to the notch.
  3. Click [Built-In], click [Text], click+drag [text text] to the "to" slot. Edit the text to say "android.intent.action.VIEW".
I'll be honest; I'm not sure what this does exactly. But I read it on another blog and it works. Did I shatter any ideas you had that I wasn't a hack? Good. Now we have to pass all the interesting information to the Activity Starter. This involves a huge string of text with the email address, subject, and body.
  1. Click [My Blocks], click [AppEmail], click+drag [set AppEmail.DataUri] to the notch below [AppEmail.Action].
  2. Click [Built-In], click [Text], click+drag [call make text] to the "to" slot.
  3. Click [Built-In], click [Text], click+drag [join] to the "text" slot. The [call make text] block will create a new open slot named "text". Click and drag two more [join] blocks to the [call make text] block so there are three total.
  4. Click [Built-In], click [Text], click+drag [text text] to the [join] blocks. It needs to go to the first slot. Do this three times for all three [join] blocks. Edit them to say "mailto:", "?subject=", and "&body=".
  5. Click [My Blocks], click [TextBoxEmail], click+drag [TextBoxEmail.Text] to the top right [join] block. The other two need to be filled in with [TextBoxTitle.Text] and [TextBoxMessage.Text]. I think you are getting the hang of this by now.
  6. Click [My Blocks], click [AppEmail], click+drag [call AppEmail.StartActivity] to the notch below [set AppEmail.DataUri].
When the [Email Note] button is pressed in the app, your email program will come up ready to send the note. All you have to press is [Send]. (Your phone may ask you to specify which mail program to use, if you have more than one.)

So there you go! You have a useful app for recording, playing, storing, and emailing notes. You can go on to add a bunch of extras, like bitmaps for the buttons, icons for the app, etc. to make your app look really pretty (see the picture above for my finished app -- note the gaudy yellow/red/blue color scheme). If you have any questions, please feel free to post comments on my blog. They are moderated (only because I was getting a bunch of Chinese spam) but I usually respond within a day or so. And by "so", I mean weeks or months later. Or never. These are all acceptable definitions of "so'.

I may, at sometime in the future, decide to bore everyone again, and post some of the games I've made. Or maybe not.

Wednesday, June 1, 2011

What catchy title for a post uses the word thermodynamics?

Understanding thermodynamics can help you in the world (seriously). There are four laws of thermodynamics, but one and two are most interesting. They are paraphrased below:

Law 1 - Energy cannot be created or destroyed, it can only change form.
Law 2 - When changing form, some energy is always lost as waste heat.

Put another way: "Not only can you not win, you can't break even."

Practical application #1
I read a story about a plan to put wind turbines near a highway to try and recapture the wind created by the fast passing cars. Sounds like a great idea, right? Use Law 1 above and tell me what is wrong with it.

Where does the energy come from? When the highway is empty, the wind turbine won't turn, so the cars must be providing the energy. And that is exactly what they found when they tested it. The fuel efficiency of each car was found to be reduced slightly. The energy created by the cars was being changed from mechanical energy (motion of the car) into wind energy (motion of the air molecules) into mechanical energy (motion of the turbine) into electrical energy.

The worst part is, as Law 2 states, every time you change form, you waste some energy. So you are basically burning gasoline to create electricity, but in the most inefficient way possible. It is sort of a Rube Goldberg contraption of idiocy.

So you may be asking yourself, "Where exactly is the practical application of thermodynamics you promised?" And here it is. You can yell at the monitor when you read these types of dumb ideas and your partner and/or dog and/or fish and/or D&D action figure can nod their head at how smart you are. Or maybe shake their head at how crazy you are. I'm not sure.

Practical Application #2
If the 1st practical application wasn't enough, here is a second one, which actually involves money and prison!

I had a co-worker pitch an idea for an invention to me. He said that his brother-in-law had a patent for a machine that could generate energy very cheaply. It was made from an outer hub with seven magnets, which was attached to an inner ring with .... (he paused and looked around, like he was about to blow my mind and didn't want any other minds around us to blow -- no collateral mind blowing) six magnets. "Because the magnets are spaced like that, the hub magnets are always pushing the ring magnets around, like a merry-go-round that never stops."

I'm sure you've all heard of perpetual motion machines. Now contrary to popular belief, the US Patent office will not reject the filing of a patent just because it is for a perpetual motion machine. However, it does stipulate that a working model must be provided before the patent will be granted. Needless to say, that has never happened.

Here's the thing. It is possible to build a "perpetual" motion machine with magnets. The reason is magnets do have energy in them, so as the machine moves it will slowly weaken the magnets. This obeys Law 1. However, taking the final step and trying to generate electricity from it can be a tricky step. Law 2 says that every time you try and change the form of energy, you piss some of that energy away. So the very act of hooking up a generator to your spinning 13 magnet science project will cause it to either spin slower or maybe weaken the magnets faster. In any case, you are just using the magnets like batteries and they will eventually die out, requiring you to get more magnets.

You may have been waiting for the money and prison part. Here it is. My co-worker told me about this incredible invention and asked me if I wanted to invest in it. His brother-in-law was selling stakes in the company, which could be "worth millions". I explained how perpetual motion machines were impossible without an energy source. My co-worker looked at me, and then tried to explain the 6 magnet / 7 magnet configuration again. He even produced a sketch on some graph paper which "proved" it. Did I mention this co-worker had a degree in Engineering? I politely looked at his sketch and explained that you couldn't violate the first or second law of thermodynamics, which this idea clearly did. I warned him that he should not invest, and should explain thermodynamics to his brother-in-law next time they meet. "Well, I won't be seeing him for a while. He's in prison on fraud charges." I got up and slowly backed out of his office, which was a surprisingly awkward way to leave an office.

Moral of the story: There is no thermodynamic law against being a moron.

PS. I swear to dog this story is true.

Sunday, May 29, 2011

Creating my first Android app, Part 3

Go here to read Part 1 and Part 2. (Note: I have slightly edited the previous posts, changing the name of one textbox to TextBoxMessage instead of TextBoxNote.)

Blogger is being a jerk, so I had to d/l Google Chrome to compose this. What's that? You don't care? You just came here to eat my brains and gain my app knowledge? Okay, on with the meager meal.

We will be doing something very complicated today: storing notes in a database which can then be retrieved using the ListPicker component. We will be building the functionality behind the [Save Note] button and the [Load Note] "button". The latter is an air quote "button" because it is actually a listpicker element that looks like a button.

One of the components we put into our app was a TinyDB (which we named DatabaseNotes). This database works by storing stuff under a tag. For example, you could store your age ("39" in my case) under the tag "age". The nice part about TinyDB is that it stores stuff even after you turn your app off.

We will store our notes, which consist of a title and a message, to the database using the title as the tag. That way, we can search the database for the title and reload our note.

Let's start with the [Save Note] button. When we press it, we need to save the note in the database (using the title as the tag). But we need to think further ahead. How are we going to get the note back out? There is no easy way to pull out all the tags from the database, so we need to keep a list of all the tags we put in. The way to do this is with a list.

A list is an 1-dimensional array. If that description made things more unclear, then a list is a list of things. So a list can be a list of numbers or a list of names or a list of titles. We will create a list of note titles and store it in the database, so we can pull it out, choose a title of a note, and then load the note.

I think I've talked too much. Let's do some programming. I'm assuming you've opened up your app in App Inventor and opened up the Blocks Editor. First, define our list of note titles:

  1. Click [Built-In]. This is where all the build-in blocks are.
  2. Click [Definitions].
  3. Click [def variable as] and drag it to the editor.
  4. Click on the "variable" and type "ListNoteTitles".
  5. Click on [Built-In], click on [Lists], click on [call make a list], and drag it to [def ListNoteTitles as] and plug it in. This will define a list called "ListNoteTitles" which we can later store our list of note titles in.
Next, the [Save Note] button.
  1. Click [My Blocks], click [ButtonNoteSave], click [when ButtonNoteSave.Click] and drag it to the editor. This will allow us to define what happens when the [Save Note] button is pressed.
  2. Click [My Blocks], click [DatabaseNotes], click [call DatabaseNotes.StoreValue] and drag it to the editor. There is a notch at the top of it. Fit this into the spike on the [when ButtonNoteSave.Click] block.
  3. Click [My Blocks], click [TextBoxTitle], click [TextBoxTitle.Text], and drag it and plug it into the "tag" slot.
  4. Click [My Blocks], click [TextBoxMessage], click [TextBoxMessage.Text], and drag it and plug it into the "valueToStore" slot.
This will save the note to the database, but we also need to save the note title to the list of titles, and then save that list of titles to the database.
  1. Click [Built-In], click [Lists], click [call add items to list], drag it, and put it below the [call DatabaseNotes.StoreValue].
  2. Click [My Blocks], click [My Definitions], click+drag [global ListNoteTitles] to the "list" slot.
  3. Click [My Blocks], click [TextBoxTitle], click+drag [TextBoxTitle.Text]to the "item" slot.
Unfortunately, there is really no way to test this to see if it is working. We need to build the [Load Note] button first. There are two parts: before picking from the list and after. Before we pick from the list, we need to define what the list is.
  1. Click [My Blocks], click [ListNoteLoad], click+drag [when ListNoteLoad.BeforePicking] to the editor.
  2. Click [My Blocks], click [ListNoteLoad], click+drag [set ListNoteLoad.Element to] and attach it to the notch in [when ListNoteLoad.BeforePicking].
  3. Click [My Blocks], click [My Definitions], click+drag [global ListNoteTitles] to the "to" slot.
This populates the list with all our note titles. After we choose which note we want to load, we need to copy the note from the database to the text boxes.
  1. Click [My Blocks], click [ListNoteLoad], click+drag [when ListNoteLoad.AfterPicking] to the editor.
  2. Click [My Blocks], click [TextBoxTitle], click+drag [set TextBoxTitle.Text to] and attach it to the notch in [when ListNoteLoad.AfterPicking].
  3. Click [My Blocks], click [ListNoteLoad], click+drag [ListNoteLoad.Selection] to the "to" slot.
  4. Click [My Blocks], click [TextBoxMessage], click+drag [set TextBoxMessage.Text to] and attach it below [set TextBoxTitle.Text to].
  5. Click [My Blocks], click [DatabaseNotes], click+drag [call DatabaseNotes.GetValue] to the "to" slot.
  6. I'm going to show you a short cut. Click on the [ListNoteLoad.Selection] block, press CTRL+C, and press CTRL+V. This created a duplicate! Click and drag the duplicate to the "tag" slot below.
Test out the app on your phone. Press the [Record] button on your phone and say "test". Press the [Copy to Title] and [Copy to Message]. The text "test" should show up in both text boxes. Now press the [Save Note] button. Nothing should happen: SUCCESS! Next press the [Load Note] button. The screen should go black and you should see the word "test". Click on it and you should go back to your app and everything will look the same. Again, SUCCESS! Okay, to really test if things are working, repeat all those steps except say "best". Now when you press [Load Note], you'll see "test" and "best". Pressing "best" will load that into both text boxes.

My eyes are going blurry looking at all this code. I'll show you how to email a note to someone next time.

Go here for Part 4.

Monday, May 23, 2011

Creating my first Android app, Part 2

Go here to read Part 1.

Now that all the components have been created in App Inventor, it is time to open the Blocks Editor and make the App actually work. Remember, the first part of App Inventor is like the clock-face, creating the look of the app. The second part is the Blocks Editor which creates the clock-mechanism, or how the app functions.

Before you do that, you can clean up the look of the apps by using Screen Arrangements to group buttons together. I grouped mine together like this:
[Record] [Play]
[Copy To Title] [Copy To Message]
[New Note] [Save Note] [Load Note]
[Email Note] [Play Note]

Now, click the [Open the Blocks Editor] button. This will download and run a Java program. You can connect to your phone by clicking the [Connect to Device...] button and selecting your phone. This will allow you to demo your app in real time and make sure it is working.

The blocks editor is like a sand box where you can create blocks of code which do different things. If you are familiar with coding with programs like Pascal or Visual Basic, this is going to look weird. There is no where to type out the code! Not very powerful but very user friendly.

Let's start with a simple one. What happens when we push the [Record] button in our app? We want to open up the SpeechRecognizer app, record some text, and then put that text into a text box. Here are the steps:
  1. Click on [My Blocks]. This is where all the components you defined in App Inventor are. Now it should be clear why I named everything the way I did: because all your blocks are in alphabetical order. So all the buttons are grouped together, all the text boxes are grouped together, etc.
  2. Click on [ButtonRecord]. For component [ButtonRecord] there is a bunch of stuff you can do to interact with it. These different things are called "blocks". They are colored green, purple, dark blue, and grey. Green blocks allow you to do stuff when the component is interacted with (e.g., press a button). Purple blocks call other programs. Dark blue blocks set the properties of components (and have a puzzle piece shape on the right). Grey blocks are variables which represent the current properties of components (and have a puzzle piece on the left).
  3. Click on [when ButtonRecord.Click]. This is one of the green blocks. When the [Record] button is pressed in our app, this block tells the app what to do. Click the block and drag it to the editor.
  4. Click on [AppSpeechRecognizer]. Click on the purple block named [call AppSpeechRecognizer.GetText] and drag it to the editor. Notice there is a notch at the top of it. That should fit into the spike on the [when ButtonRecord.Click] block. They should click together. Now when the [Record] button is pressed, the Android built in app which translates speech-to-text should run. Try it now on your phone.
What happened? It should have worked. Except where did the text go? We have to do a few more things before the text goes somewhere. Go back to the block editor:
  1. Click on [My Blocks]. Click on [AppSpeechRecognizer]. Click on [when AppSpeechRecognizer.AfterGettingText] and drag it to the editor. Notice that there is something called "result" on the right which has a value of "result". The text that the voice-to-text created is stored in a variable called "result".
  2. Click on [TextBoxVoice]. Click on [set TextBoxVoice.Text to] and drag it to the editor. Attach it to [when AppSpeechRecognizer.AfterGettingText].
  3. Click on [My Definitions]. The value "result" is here. This is where stuff that isn't specifically associated with any one component is stored, like global variables. Drag [value result] and plug it into [set TextBoxVoice.Text to]. Try the [Record] button on your phone again.
Now what you say should appear in the Voice Textbox.

For the end of Part 2, create the functionality of the [Play], [Copy to Title], and [Copy to Message] buttons. Below is what the blocks editor should look like.

Go here for Part 3.

Sunday, May 22, 2011

Creating my first Android app, Part 1

I have an android phone (Samsung Galaxy S - model SGH-I896). I love all the app's that can be downloaded, for practically anything purpose you can think of. Google recently came out with an app creator called App Inventor. I created an app for my phone which I find really useful. I was thinking about uploading it to the Android Market, but that would cost me $25. Instead, I'll write some blog post that will be very very boring to any normal person, but maybe some budding programers will enjoy it.

First, you must install App Inventor. This requires a google email address. (These first few steps are going to be pretty sketchy, because since I have now installed everything, I can't remember what to do.) App Inventor is a two-part program. First, it is a web-based app creator which allows you up create the look of your app (images, buttons, text boxes, etc.) Second, it calls a Java program which downloads and runs. This program allows you to program the logic behind your app. Think of them as the clock face and the clock mechanics.

The most difficult part to creating your app is actually downloading and installing all the appropriate drivers for your phone. This took me several days to do. I had to update my phone to the latest android version (2.2). After much google searching, I found all the drivers for my phone (both 32- and 64-bit) and saved them to a directory called c:\drivers\. Everything finally worked.

So you've installed App Inventor and have all the drivers for you phone. Now it's time to start creating an app. (Don't forget to set your phone to development mode in Settings->Applications->Development.)

If you've never programmed before, you may want to stop reading right now. Sorry I didn't put this earlier. Wow, you are tenacious. Next step is to do all the tutorials. These will help you understand how App Inventor works.

The app I created is called VoiceBox. The reason I created it is I haven't found a notepad app I like. Android has voice-to-text and text-to-voice features which I thought would be great for an app. Imagine creating a grocery list by talking, and then play it back to yourself. What? Why would you want to play back a grocery list when it is just as easy to look down and read the list? This is a great question. I'll save it as a note in VoiceBox and play it to myself later.

You will need these components:
  • Eight (8) Buttons named ButtonRecord, ButtonCopyToTitle, ButtonCopyToMessage, ButtonPlay, ButtonNoteNew, ButtonNoteSave, ButtonEmail, ButtonPlayNote.
  • One (1) ListPicker named ListNoteLoad.
  • Four (4) TextBox named TextboxVoice, TextboxTitle, TextboxMessage, TextboxEmail
  • One (1) TinyDB named DatabaseNotes.
  • One (1) ActivityStarter named AppEmail.
  • One (1) SpeechRecognizer named AppSpeechRecognizer.
  • One (1) TextToSpeech named AppTextToSpeech.
Drag all these components to the viewer and name them as above. Your app inventor should look like the screen shot below. I've realized these series is going to take several blog posts, so I'm going to leave it here. Stay tuned for more "exciting" slash "incredibly boring" posts in this series!

Go here for Part 2.

Sunday, March 27, 2011

College FUN'd

A recent Macleans article stated 32 per cent of Canadians said their retirement would be partially funded by a lottery win. I, of course, put that Macleans magazine in a vacuum sealed bag, where I will store it for 30 years until it becomes valuable. When I finally do remove it from storage, I'll chuckle at all those dummies waiting for their LottoMax win.

Here is a list of other items which will pay for my retirement:
- Dungeons & Dragons action figures, including a Shambling Mound(TM),
- a box of comics, including the complete run of Power Pack,
- one silver suit, one purple shiny shirt, and one purple sock tie, worn to a Grade 9 dance.

Wait. What was that? Okay, my wife has just informed me that the silver suit has been donated to Goodwill. Good job, honey! Some hobo is cruising in the Mediterranean right now!

To be perfectly frank, I'm still mad at my parents for allowing me to open my toys. I would not have to work right now if I had all my Micronauts in their original cases. Which brings me to the point of this post: my son's college fund. We keep it in a plastic container in the basement marked "Broken Glass and Poison" (to deter and confuse any would-be robbers).

The college fund contains: Two mint condition Darth Maul figures (with a commtech(TM) chip so Darth Maul can yell at you if you tease him about his tribal tattoos!); One slightly melted bar of Fight Club soap, obtained from a screening of said movie; One sealed Pokeball from a McDonald's happy meal (I hope its you, Charizard!!!); One wind-up elephant from the Disney movie Tarzan, again, from a McDonald's happy meal.

I know what you are thinking and I totally agree. I'm too heavily invested in McDonald's products. I had a Burger King cardboard crown in the collection, but it was damaged when the Fight Club soap melted. Note to investors: do not put your investments near a heating vent!

Oh, and I think I put $30 in RRSPs this year too. See you on the beach!

Sunday, March 20, 2011

Broken Windows ...

When I was 11, I was playing croquet at a friends house and I put a ball right through their basement window. I was goofing around and decided to pretend to hit the ball on my backswing. "Haha, look, he can't even hit a croquet ball!" I neglected to look behind me and the ball ended up in the basement. I remember sitting in my room later that night, listening to my dad talk to my friends dad, apparently discussing how much this was going to cost.

There is no doubt that breaking that window removed wealth from the world, but not all the world. The glazier that my friend's dad later called gained some wealth, exactly the same wealth that my dad lost. However, this is not the only cost. There was an "opportunity cost" that my dad also endured, as he had to forgo something else (perhaps a delicious steak dinner at Mr. Mikes) to pay for my foolishness.

Some (thankfully very few) commentators have commented that the recent earthquake may be just what Japan needs to "stimulate" its economy. This is a classic example of the Broken Window Fallacy. They could be forgiven for this error because the typical measure of a country's economy is the Gross Domestic Product (GDP). The GDP is a measure of all wealth generation but not of wealth destruction. This leads to the paradox that building a house, burning it to the ground, and building it again creates a higher GDP than just building it once.

Let's go back to that cursed croquet game. Imagine that instead of breaking the window, the ball duplicated it. Sitting on the ground is the wayward ball and an exact duplicate of the window, frame and all. Since this is the exact opposite of the above situation, it is easy to see what economic results are. We can sell the free window and pocket the money (hello Mr. Mikes!) Unfortunately, the glazier will not be happy when he finds out about our magic window duplication scheme. Wealth is created in the world, but not all the world.

Which leads to my final thought ... on copyright infringement. Copying a CD, a movie, a book, or a photo will indirectly remove some wealth from the owner of the content, just like it the glazier in the second universe. But this will not remove wealth from the economy. It cannot. Just like a broken window cannot add wealth overall, a duplicate window must add wealth.

Friday, January 21, 2011

Diet and exercise ... and diet

Just in case you weren't convinced that  is full of idiots, along comes Jennifer R. Scott with this "nugget" of wisdom:
Experts agree that it's easier to exercise than to cut the same number of calories that exercise shaves off. In other words, it's just plain easier for us to be a little more active than to do without more food to achieve the same calorie reduction.
I'm sorry, but W.T.F.A.Y.T.A? Not one sentence above, we get this:
For example, a 180-pound person who walks at a brisk 3 mph will burn just over 250 calories in 45 minutes.
Guess what else is 250 calories? A chocolate bar. How long does it take to eat? A few minutes. So what is more effective for losing weight? Jennifer, put your hand down. Let the adults answer.

Why is exercise associated with weight loss? The two have very little to do with one another. For example, whenever they show ads for The Biggest Loser, they show an obese person jogging on the beach and then chowing down on a sub. The only thing that jogging will do for an obese person is destroy their knees. The only reason the two are linked, that I can think of, is very active people tend to be skinny. But correlation does not equal causation.

If common sense wasn't enough, how about some studies. After a brief 24.8 second search on the Internet, I found this link which outlines several studies, all of which show that exercise "is not a major factor" in weight loss. I would look further, but I'm losing Rant Energy.

So next time you see an ad or a news story on weight loss and they show people exercising, do what I do, shake you fist at the TV. And think about how dumb Jennifer is.

P.S. I don't know Jennifer and the quality of her other post. She may or may not be an idiot*.

*Note: she is an idiot.

Tuesday, January 11, 2011

Monkey and who, now with more cats!

Guess who's back for another year of misadventures. That's right, it is the calendar that makes every dumber, "Monkey" & me.
I had a big list of things to blog about, and I even wrote them down. I can't find the list, so I'll have to wing it.

"You stole my idea!"
I watched The Social Network. I thought it was pretty good, but, like Monkey and Me, in contains a line that will infect peoples' brains for years to come.

"You stole my idea!" has its history in grade school. Being a "copycat" is bad. What the teacher wasn't telling the hundreds of snot-nosed kids coloring pictures of horses and spaceships, doing reports on the solar system and natives, etc. is she's seen it all before. Hundreds of times.

Nothing is new. I think it was in college that I realized how dumb I really was. Nothing can be done if you are trying to reinvent the wheel, so the only way to do anything productive is to stand on the shoulders of giants. (I promise not to combine two lame cliches in one sentence again.) You must copy. You must steal. Everything is synthesis. In Engineering, we add things called "References" at the back of technical papers. In art, we call it homage or inspiration. But any creative person knows that they never really create anything new.

I'm interested in screen (and normal) writing. Beginning writers are nervous about discussing story ideas with others. They are worried people will "steal their idea". They soon learn no one cares about ideas. They care about the concrete expression of those ideas. The actual lines of dialog, the descriptions of scenes. That is where the difficulty is. Google and Lycos are both "search engines".

Copyright law recognizes this, therefore only actual expressions are subject to copyright, not ideas. More than that, if ideas were subject to copyright, it could infringe on free speech. Copyright is a government granted monopoly given to creators to make "copies" of their work. Its purpose to encourage creators to make more work and therefore enrich society. The ultimate measure is society's benefit, not whether a given creator is making a living.

Copyright is not a property right. If I make a mix tape and give it to a friend, I'm not stealing anything. I am "infringing" on the creators right to make copies. Some people like to stretch definitions and say I'm stealing some of the creators potential revenue, because the friend may have bought the original CD.

A friend tells you a joke while at coffee. That night, you tell the same joke to a group of acquaintances. Your friend overhears and is upset with you. "That was my joke!" My reaction is to tell him to buzz off. If he didn't want people to hear the joke he should have kept it a secret.

Culture is a conversation. Copyright law must be a balance between encouraging people to speak in the conversation and allowing people to respond.