a few links: FIFA, racism, and homophobia; same-sex marriage and wedded bliss; James Comey
Mood: energetic
Posted on 2013-05-31 14:08:00
Tags: gay links
Words: 194

- FIFA announced tougher penalties for racism today. A few thoughts:
  * It blows my mind a little that racism is still a problem in soccer. Maybe I have my blinders on but I don't think it's really a problem in US sports, right?
  * The proposal sounds reasonable, although punishing a team based on what its fans do seems like inviting false flag operations.
  * Racism is bad, but FIFA seems perfectly content to hold the 2022 World Cup in Qatar, where "homosexual activity" is illegal. Apparently Sepp Blatter (FIFA president) was asked about this and his response was less than encouraging. And yes, I'm still mad that Qatar got the 2022 World Cup over the US, and I suspect foul play...

- The Gay Guide to Wedded Bliss - you're welcome!

- Obama nominated James Comey to be FBI director. I vaguely remembered that name from the Bush presidency - turns out he was Deputy Attorney General under John Ashcroft and told this amazing story to Congress. (here's a text summary)

- Apparently in World War II German soldiers were issued a precursor of crystal meth to keep them alert...and this continued until 1988 in East Germany!


link friday: 3D printed food and airway splints!, full scale lego X-Wing
Mood: happy
Posted on 2013-05-24 14:04:00
Tags: links
Words: 146

- The audacious plan to end hunger with 3-D printed food - oh man I hope this happens! There's a video of a chocolate printer, which is as delicious as it sounds.

- Doctors Save Ohio Boy By ‘Printing’ An Airway Tube - wow. The future is getting closer!

- Cleared of Charges of Setting Off a School Explosion, Florida Honor Student Heads to Space Camp - I do like stories with largely happy endings! (only "largely" because she's still suspended from school...)

- This Incredible Full Scale Lego X-Wing Is the Largest Model In History - obvious geek link bait, but it is pretty awesome. And the engines glow!

- The Steve Jobs emails that show how to win a hard-nosed negotiation - be in a strong position and don't budge. (optionally: be Steve Jobs)

- Surprise! Mozilla can produce near-native performance on the Web - a detailed look at asm.js, which is an extremely cool idea.


link friday: seven minute workout, math proofs, supreme court <3's corporations
Mood: content
Posted on 2013-05-17 14:05:00
Tags: links
Words: 270

- The Scientific 7-Minute Workout - sounds promising?

- The Paradox of the Proof - very nice article about the possible proof of the ABC Conjecture.

- Corporations Find a Friend in the Supreme Court - I hadn't realized this, but

While the current court’s decisions, over all, are only slightly more conservative than those from the courts led by Chief Justices Warren E. Burger and William H. Rehnquist, according to political scientists who study the court, its business rulings are another matter. They have been, a new study finds, far friendlier to business than those of any court since at least World War II.

- Charity can't fill holes in aid to poor - the idea that private charities can step in to help the poor instead of the government just isn't borne out by the numbers.

- What's next Google? Dropping SMTP support? - Google seems to be stepping away from open standards, which makes me a sad panda. (also, they seem to really dislike Windows Phone => sad panda x 2)

- Infographic: Is Your State's Highest-Paid Employee A Coach? (Probably) - nice work by Deadspin.

- A Simple Graph That Should Silence Austerians and Gold Bugs Forever - it's not exactly a scientific experiment (wish that we could do those in economics!), but it's pretty convincing.

- Shaking Off Loneliness - being lonely is pretty bad for you healthwise. (and what matters is how you see yourself, not your raw number of friends or connections)

- Caught you red-handed: 9 games with creative copy protection - prompted by the recent Game Dev Tycoon story, but there are some blasts from the past in there!

- Check out the web cartoonists continuing Calvin And Hobbes - good stuff!


Minnesota passes same-sex marriage
Mood: happy
Posted on 2013-05-14 13:10:00
Tags: gay politics
Words: 101

That makes three states (with Rhode Island and Delaware) in the past few weeks - the map will be getting bluer in July and August!

I was going to write something about how remarkable it was that just two years ago the Minnesota legislature passed a constitutional amendment prohibiting same-sex marriage, although it was defeated at the polls 53-47% last year. But it turns out both the amendment and the same-sex marriage bill votes were largely along party lines - the difference is that the House and Senate went from being controlled by the Republicans to the Democrats in the 2012 election. So...yeah.


Hospital price data - now in a handy SQLite database!
Mood: excited
Posted on 2013-05-12 15:27:00
Tags: windowsphone projects wpdev
Words: 73

Well, I got so excited at the hospital prices data released by the government that I wanted to make it easier for people (myself included!) to write apps with it. So: here's the data in an SQLite database which includes geocoding data and some basic calculations.

I would love to see some cool apps based on this data. Let me know (ext-greg.stoll@nokia.com) if you're going to be working on something for Windows Phone!


New government data on hospital pricing - somebody please make an app!
Mood: hopeful
Posted on 2013-05-08 22:22:00
Tags: windowsphone
Words: 117

Today the government released a bunch of data about how much hospitals charge for various procedures - there's good coverage by the New York Times and by the Huffington Post. It seems like a big step for health care pricing transparency. (see the health care pricing articles from February)

But of course, the data itself is in a giant Excel/CSV file, and it's hard to know what to make of it. This would make a great app! Somebody please make a good app out of this - the tricky part will be aggregating the data and giving each hospital a "cost score", but after that you can just the hospitals on a map with their score.

Somebody do this!

1 comment

same-sex marriage map in a textbook!
Mood: excited
Posted on 2013-05-06 22:42:00
Tags: gay projects
Words: 49

My same-sex marriage map is in a print textbook! Here's "The Gendered Society" textbook by Michael Kimmel:

and on page 181, we find:

Thanks to the good people at Oxford University Press for sending me a copy!

(this is the real-life application that spawned the "red dot" problem, FWIW)


Adventures in math: finding a red dot in a book, Marilyn vos Savant is wrong!
Mood: geeky
Posted on 2013-05-05 11:43:00
Tags: math
Words: 567

Let's consider the following problem, which is based on reality and caused a 15 minute argument lately: You're given a book and told it has a 90% chance of having one red dot in it (and a 10% chance of having no red dot). If you read the first half of the book and don't find a red dot, what is the probability the red dot is in the second half of the book?

To join in our argument, your choices are 90% or something less than 90%.

My stance (which I think is correct!) was that the chances go down the more you read. There are two equivalent ways to think about this:

- Assuming the location of the red dot is distributed uniformly throughout the book, before you start reading the book the chances that the red dot is in the first half of the book are 45%, in the second half 45%, and not at all is 10%. Once you know it's not in the first half of the book you can eliminate that first 45% chance, so the chances it's in the second half are (.45)/(.45+.1) = .45/.55, or around 82%.

- You can formalize this by using Bayes' theorem. Let's set up our events:
A = red dot is in book
B = red dot is not in first half of book

So the probability we want is P(A|B). (meaning the probability that A is true given that B is true)
Some values we're going to need:
P(A) = .9
P(B|A) = .5 (this is where the assumption that the distribution of the red dot is uniform comes in)
P(B|not A) = 1 (if the red dot isn't in the book, it's not in the first half!)
P(B) = P(B|A)*P(A) + P(B|not A)*P(not A)
= .5*.9 + 1*.1
= .55

So, by Bayes' theorem, P(A|B) = (P(B|A) * P(A))/(P(B)) = .5*.9/.55=.45/.55, which is the same result as we got above. You can see that Bayes' theorem is really just formalizing the logic we were using in the first case!

You can generalize this - if the red dot isn't in the first x of the book (for x between 0 and 1), then P(B|A) = 1 - x, and we end up with
((1-x)*.9)/((1-x)*.9 + .1)

So for x = 0 this is .9, as we expect (since we haven't read anything) and for x = 1 this is 0 (since we know it's not in the book). And here's the Wolfram Alpha plot of the function!


I was reading Parade this morning, and Marilyn Vos Savant's column had a math problem, which made me say goody! Here's the column. Unfortunately her answer is wrong. The problem with counting the combinations this way is that we're overcounting some of them. In her example, 5 is the number that you know is in the combination, and in step 1 we count the numbers 5000-5999. But then in the next step we count 0500-9599, keeping the 5 constant, and this double counts the numbers from 5500-5599. Similarly the third and fourth steps overcount, and the combination 5555 is counted four times!

The correct way to do this problem in the general case is to use the Inclusion-exclusion principle, but an even easier way is to read "at least one 5" as "everything except no 5's". So there are 10^4 total combinations, and 9^4 of them have no 5's, so the number of combinations that have at least one 5 is 10^4-9^4=3439, significantly less than 4000.


long-overdue links: sexism in the tech industry, torture v. diversity, money wins elections
Mood: cheerful
Posted on 2013-05-03 15:06:00
Tags: politics links
Words: 355

It's been a while, so some of these are out of date, but they're interesting, dang it!

- Caroline Shaw, a fellow Philharmonics singer at Rice, just won the 2013 Pulitzer Prize in Music! Congratulations to her! A short article about the piece at Slate.

- The Biggest Problem in Technology - a good synopsis of the sad episode that happened at this year's PyCon. Best sentence:

Given the advantages of time, distance, and a rational mind, it is relatively easy to see that basically everybody involved erred (though some far more severely than others).

- John Yoo Criticizes Liberals for Caring More About Torture Than Diversity - when I read the headline, I thought "oh, there might be a valid point here but the headline is clearly exaggerating"...and I was wrong, the headline is dead-on. Sheeeeeesh!

- After the Jason Collins came out, these Onion articles seem especially relevant: Gay NFL Players Must Be Unknown Special Teams Guys, Says Homophobic Man, and my favorite NFL Players Support Player Coming Out, Getting Absolutely Obliterated During Games. These were published a month ago amidst rumors that a few active NFL players were going to come out - we'll see what happens!

- Ten Practical Things to Make with a 3D Printer

- Money Wins Elections - a cool visualization page in support of the American Anti-Corruption Act, which you should definitely support!

- Abusing hash kernels for wildly unprincipled machine learning - It seems almost magical that something as crude as the hash kernel he describes actually kind of works.

- Carmen Sandiego's Africa map: television's invisible, impossible shuttle run - the Africa map did seem impossible as a kid :-)

- How a banner ad for H&R Block appeared on apple.com—without Apple’s OK - an excellent reason for HTTPS everywhere!

- Pope Francis supported same-sex civil unions in Argentina in 2010 - certainly it was just a reaction to Argentina being about to approve same-sex marriage, but...wow!

- Paramount Hopes New ‘Star Trek’ Is a Global Crowd-Pleaser - I love me some Star Trek, but this article made me a lot less excited about it. Something about seeing how the sausage is made, and how they changed the plot, etc. to appeal more to international audiences.


First athlete playing in a major American team sport comes out!
Posted on 2013-04-29 11:25:00
Tags: gay
Words: 43

It's Jason Collins, an NBA player, and his article is touching. (it goes without saying to not read the comments, right? This was made harder by a stupid widget in the bottom right that kept showing new comments...) More commentary from Sports Illustrated.


Arrested Development: a word of caution
Posted on 2013-04-28 17:24:00
Tags: essay
Words: 148

The new Arrested Development episodes come out in less than a month (May 26, to be exact), and it is exciting. But! Here are some reasons to temper your optimizm:

- It went off the air 7 years ago. That's a long time, and while it's pretty impressive they managed to get all the cast back, I'm not sure about the writers and such.

- Each episode is going to focus on one character. (presumably because it was hard to schedule everyone) This sounds sad to me, because I really enjoyed the interaction between the characters.

- Arrested Development was great; but inevitably we look back at it with rose-colored glasses. (even if the new episodes are as good as the old ones, they'll probably take a few viewings to fully appreciate...)

- Regression to the mean!

So, my advice is to keep your expectations low, and maybe we'll be pleasantly surprised.


Windows Phone: Visual Studio templates for creating a new app
Mood: cheerful
Posted on 2013-04-14 17:30:00
Tags: windowsphone wpdev
Words: 259

Edit: I've updated this template to make it a Universal app and added a first-run tutorial!

Some of my articles about Windows Phone development have been focused implementing things that every app needs, like settings that are easily set in a UI. A similar article that I haven't gotten around to is writing a proper About page. I figured instead of writing an article I'd make a Visual Studio template with an About page, so when you're creating a new app you can use it and get it easily. So...here you go!

- AppWithAbout71.zip - template for WP 7.1 apps
- AppWithAbout80.zip - template for WP 8.0 apps

Create the directory Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#\Windows Phone, and download the templates to that directory. Next time you start Visual Studio and create a new project, you should see two new choices: "Windows Phone App with About page (7.1)" and "Windows Phone App with About page (8.0)". After creating from one of those templates, follow the instructions in README.txt.


- UserSettings class and settings page:

- About page with contact info and review button:

- Tips page:

- Page for linking to other apps

Problems? Feedback? More things you'd like to see in the template? Let me know at @gregstoll or ext-greg.stoll@nokia.com!


See all my Windows Phone development posts.

I'm planning on writing more posts about Windows Phone development - what would you like to hear about? Reply here, on twitter at @gregstoll, or by email at ext-greg.stoll@nokia.com.


Interested in developing for Windows Phone? I'm the Nokia Developer Ambassador for Austin - drop me a line at ext-greg.stoll@nokia.com!


Top Dog: The Science of Winning and Losing review
Posted on 2013-04-09 20:39:00
Tags: reviews books
Words: 247

Top Dog: The Science of Winning and LosingTop Dog: The Science of Winning and Losing by Po Bronson
My rating: 3 of 5 stars

The book is all about competition and how it's generally a good thing - it makes most people perform better. Some tidbits:

- Apparently the "home field advantage" is a real thing, and covers a lot of weird situations - preschoolers playing a game are more likely to win if they're playing in their own classroom, for example.

- In general, it hurts to have people watching/cheering you on while you're learning a skill, but it helps after you've mastered it.

- In sports tournaments (i.e. golf and racing), the bigger the reward and the higher the spread between the 1st place and 2nd place rewards, the more aggressive they are.

- There's a specific genetic codon (COMT) that controls how well your brain handles stress, and thus what your optimal stress level is to get your best performance.

- There's a big difference between men and women when deciding to run for Congress - men will run if there's any chance of winning, while women won't unless they have at least a 20% chance or so.

- Girls tend to handle highly-competitive schools better than boys, because boys are more discouraged by repeatedly competing and losing.

Anyway, the book was decent, but I think it overgeneralized a bit. (there was a short bit about software development that I just rolled my eyes at) I think I might move on from neurotrash for a while.

View all my reviews


Storing data on Windows Phone
Mood: excited
Posted on 2013-03-28 22:06:00
Tags: windowsphone wpdev
Words: 925

This post is adapted from a presentation I gave at the University of Texas IEEE Computer Society on March 6, 2013

Storing data on a device is one of those things that is different on every platform, but it's crucial to most apps. (especially if you want to make them work offline) Windows Phone has a lot of good options for storing data - let's look at four of them:
- Resource packaged with the app - an ideal way to ship data with your app
- Isolated Settings - best for lightweight and small data, such as app settings
- Isolated Storage File - best for storing full files
Serializing to/from JSON - a brief aside; useful when packaging a resource with the app or storing data in an Isolated Storage File
- Local database - best for fully structured data that needs to be high performance

Resource packaged with the app
This is a great way to ship static data with an app. For example, in my Marriage Map app, I ship a static version of the marriage data so that if the phone is offline during first launch of the app, we can still show some data. (if the phone is online, it downloads the current data and saves it to Isolated Storage)

Anyway, this is pretty straightforward. Add the file to your project, select the file, and in the Properties window set the Build Action to Content. After this, you can read the file with:

var resource = System.Windows.Application.GetResourceStream(
new Uri(@"Data\stateData.js", UriKind.Relative));
using (StreamReader sr = new StreamReader(resource.Stream))
string allDataString = sr.ReadToEnd();
If you're going to be storing data in this file, I'd recommend using JSON format - see Parsing JSON for details.

Isolated Settings
Isolated Settings are great for storing very small bits of data, like user preferences. If you want to make a settings page and have that data automatically stored in Isolated Settings, see my previous posts on adding settings to your app and adding enum settings to your app.

The class we'll be using is System.IO.IsolatedStorage.IsolatedStorageSettings - it's implements a simple Dictionary<TKey,TValue> interface to read and write. To write data, use

IsolatedStorageSettings.ApplicationSettings["NumQuizzes"] = 3;
and to read it, use

int nQ = (int)IsolatedStorageSettings.ApplicationSettings["NumQuizzes"];
Isolated Settings are backed by an Isolated Storage File, which we'll talk about next!

Isolated Storage File
For more complex data, you can move up to using the full Isolated Storage API to store data in files. There's a full filesystem you have total control over. (which is only accessible to your app, of course!) I use this in FlightPredictor to store the user's flights.

The main class we'll use is System.IO.IsolatedStorage.IsolatedStorageFile. To write to a file, use

using (var store = IsolatedStorageFile.GetUserStoreForApplication())
using (var stream = store.OpenFile("flights.json", System.IO.FileMode.Create))
using (var streamWriter = new StreamWriter(stream))
streamWriter.Write("{\"flights\": []}");
and to read from it, use

using (var store = IsolatedStorageFile.GetUserStoreForApplication())
using (var stream = store.OpenFile("flights.json", FileMode.Open))
using (var streamReader = new StreamReader(stream));
string flightsString = streamReader.ReadToEnd();

There are other methods on IsolatedStorageFile like CreateDirectory() and GetFileNames() if you want to really use isolated storage as a filesystem.

Serializing to/from JSON
See this post for comparing parsing time for different file formats, including JSON
Note that these APIs let you read and write text to files. Usually, you'll want to store more structured data, and I'd recommend using the JSON format because Json.NET makes it very easy. Here's how!

First, you can use the DataContract and DataMember attributes on an existing class. For example, here are the first few lines of my Flight class:

public class Flight : INotifyPropertyChanged, IComparable<Flight>
public string AirlineName;
public int Number;
public DateTime DepartureTime;
Then, to turn a list of Flights into a string, use:

List<Flight> flights = new List<Flight>();
string flightsString = JsonConvert.SerializeObject(flights);
and to read a list of Flights, use:

List<Flight> newFlights =
If you'd rather not create a whole class, you can also deserialize "raw" JSON, which is very handy when you're getting results from a webservice. For example:

JObject o = JObject.Parse(responseString);
JObject flightsJson = (JObject)o["flights"];
int numFlights = (int)flightsJson["total_entries"];
JObject flightJson = (JObject)((JArray)flightsJson["array"])[0];

Local database
You can also store data in a full database. This takes a bit more coding, but is useful if you need to do queries, etc. I use this in PhotoNotes - each photo gets a row in the database with a caption and audio filename. (which are stored in Isolated Storage Files!) Here's the topic on MSDN about a local database, but briefly, the steps you need are:
First, declare your DataContext:

public class PicturesDataContext : DataContext
// Specify the connection string as a static, used in main page and app.xaml
public static string DBConnectionString = "Data Source=isostore:/PictureNotes.sdf";

// Pass the connection string to the base class.
public PicturesDataContext(string connectionString)
: base(connectionString) { }

// Specify a single table
public Table PictureNotes;
Then on your table class, you need the Table attribute:

public class PictureNote : INotifyPropertyChanged, INotifyPropertyChanging
and then member fields with the Column attribute are columns in the table:

public string FileName
Now, to insert rows, you can create new instances of the PictureNote class and call InsertOnSubmit() on the table:

_noteLensDB.PictureNotes.InsertOnSubmit(new PictureNote()
{ FileName = shortFileName, NoteText = noteText,
NoteAudioFileName = _lastSavedAudioFileName });
And to query the table, you can use the totally cool LINQ to SQL. For example:

var query = from n in _noteLensDB.PictureNotes
where ((n.NoteText != "" && n.NoteText != null) || n.NoteAudioFileName != null)
select n;
var numPictures = query.Count();
foreach (var note in query)
string name = note.FileName;


See all my Windows Phone development posts.

I'm planning on writing more posts about Windows Phone development - what would you like to hear about? Reply here, on twitter at @gregstoll, or by email at ext-greg.stoll@nokia.com.


Interested in developing for Windows Phone? I'm the Nokia Developer Ambassador for Austin - drop me a line at ext-greg.stoll@nokia.com!


same-sex marriage at the Supreme Court, and a ton of links
Posted on 2013-03-26 22:31:00
Tags: gay politics links
Words: 337

The Prop 8 case was argued today, and here's the transcript. (a reminder: as with all things politics, you probably don't want to read the comments...I say this not having read them myself, of course) The DOMA case is tomorrow. Relatedly, the Onion was on fire today: Supreme Court On Gay Marriage: 'Sure, Who Cares', and Kim Jong-Un Comes Out In Support Of Gay Marriage: 'I'm Not A Monster', and most hilariously I Feel Very Strongly About The Issue Of Same Sex Marriage Because I Have A Gay Son (an editorial by God)

Relatedly, Nate Silver looks at the percentage of people that support same-sex marriage (it seems to be growing at around 1.5% a year), and even at CPAC (the Conservative Political Action Conference) it seems they recognize same-sex marriage is the future.


- Invading Iraq: What We Were Told at the Time - hey, it's been ten years since the Iraq war! And it cost lots and lots and lots of money! (much more than people said at the time)

- In Mississippi, the Mysterious Murder of a Gay, Black Politician - (a long read) it's still mysterious, but there's more to the story than the headline.

- NPR did a long story on the growing number of people on disability...it's something I haven't heard about, and the numbers surprised me.

- A long story about how De Beers cornered the diamond market and how they're ridiculously more expensive than they should be...nothing I haven't read before, but a good summary.

Tech stuff:

- New Reasons to Change Light Bulbs - LED bulbs are cheaper now - I guess it's time to switch away from CFLs? (or, at least, when they go out, replace them with LEDs?)

- Hyperkin is making a console that can play NES, SNES, Genesis, Famicom, and Game Boy games. And all for less than $100. Pretty nifty!


- Ask A Banker: Why Do People Keep Trying To Give Me Money? - it's economics _and_ it's humor! How do they do that?

- If PHP Were British

- Death Star Truthers

1 comment

Quiet: The Power of Introverts in a World That Can't Stop Talking review
Mood: happy
Posted on 2013-03-24 22:00:00
Tags: reviews books
Words: 628

Quiet: The Power of Introverts in a World That Can't Stop TalkingQuiet: The Power of Introverts in a World That Can't Stop Talking by Susan Cain
My rating: 4 of 5 stars

My friend Dan Hedges dubbed this category of books as "neurotrash", which I think is an excellent term. And yet, I keep reading and enjoying them, and I enjoyed this one more than most.

The gist of the book is that although the American ideal seems to be a friendly, extroverted person, introverts have a lot to offer. Here are some things I found interesting:

- The definition of an introvert is a bit fuzzy. Generally, introverts prefer less stimulation than extroverts, tend to work more slowly and deliberately, and enjoy having fewer, but closer, friends. They also need time alone to recharge, as opposed to extroverts who recharge by being around people.

I was pretty sure that I was an introvert before reading the book, and that's still the case. I do enjoy going out a little more than some others I know, and I enjoy traveling and meeting people, but only if there's a well-defined relationship between us. For example: going to NI events is good, because I can talk about LabVIEW with people and ask how they use it. Going to a bar is bad, because I don't know what on earth to talk about. (I am also extremely conflict-averse, another introverted trait)

- The book covers a lot of studies where introverts can be more effective than extroverts. One showed that it seems that introverts are better leaders when the people they're leading are initiative-takers, because they tend to be better listeners.

- I've read this before, but: group brainstorming is less effective than individual brainstorming. One reason is the fear of public humiliation, even if you try to defuse that by saying "all ideas are good ideas", etc. Interestingly, online brainstorming seems to work the best of all.

- The book talked about the study where if a person is in a group with three other actors, and the group is asked a question and the actors answer deliberately incorrectly, the person is more likely to give the wrong answer. (in one version, the person gave the correct answer 95% of the time when there were no actors, but only 25% of the time if all the actors confidently gave the wrong answer!) They then did a followup with an fMRI machine to try to figure out whether the people were knowingly giving wrong answers because of peer pressure, or whether their perception was actually being altered...and it seems like their perception was being altered! Crazy.

- Babies who are "high-reactive" (who react more strongly to new sights and sounds) tend to grow up to become introverts.

- A helpful tip for introverts and extroverts is to try to find your sweet spot for how much stimulation you like, and work to stay near it. Just keeping in mind that you have a sweet spot is helpful.

- It seems like what makes an extrovert an extrovert is a tendency to seek rewards (economic, political, hedonistic), because they experience more pleasure and excitement than introverts do. They get an extra buzz from achieving their goals.

- A study found that men who are shown erotic pictures just before they gamble took more risks than those shown neutral pictures. This surprises me not at all. (the lesson is: when making a big decision...don't look at erotic pictures?)

- It's a good idea to create "restorative niches" for yourself where you can relax and be yourself. (these can be physical places or specific times throughout the day)

- In general, introverts like people they meet in friendly contexts, while extroverts prefer those they're in competition with.


I enjoyed the book a lot and would recommend it if you're into neurotrash! :-)

View all my reviews

1 comment

mini-link friday: compound interest, marriage happiness
Mood: busy
Posted on 2013-03-15 16:32:00
Tags: links
Words: 240

- If The Catholic Church Were A Business, How Would You Fix It? - I heard this story on NPR and immediately thought "this is going to be a stupid story". It ended up being OK, but the most interesting part in the radio version was the guy who pointed out the church started out with 11 people 2000 years ago and is now at a size of 1.2 billion, which is an annual growth rate of 1%. I immediately thought "that doesn't sound right, that's too small", but it turns out it's actually a little less (0.93%). Compound interest wins again!

- Rob Portman, a senator from Ohio, is now for gay marriage after his son came out to him. It's a little disappointing that he didn't change his mind until someone close to him came out, but that's the power of knowing a gay person. It's progress, and I'll take it!

- The Difference Between a Happy Marriage and Miserable One: Chores - interesting article, with examples.

- SXSW and Reddit’s Introspection Problem - this is extremely depressing. She raised some good points about problems with Reddit, and then she got personally attacked in terrible ways. Somehow trolls on twitter bother me more than anonymous comment trolls.

- The Professor, the Bikini Model and the Suitcase Full of Trouble - a well-told story by the New York Times.

- A video of a fan accompanying Billy Joel; it will warm your heart, especially after the last two links!

1 comment

Google Reader is closing - try Newsblur instead!
Mood: busy
Posted on 2013-03-14 09:59:00
Tags: endorsements
Words: 133

Google announced yesterday that Google Reader is shutting down July 1. If you're looking for a replacement, I'd recommend Newsblur - it's run by an indie dev (Samuel Clay), it's open source, there are apps for phones (although I haven't tried any of them), and it works great! It has a lot of neat features (intelligence training, social-y stuff, etc.) but honestly I use it just as a normal RSS reader and I'm happy with it. (I also sent in some feedback and the developer sent me a T-shirt!)

One nice thing about it is that Samuel works on Newsblur full-time, and so he charges $2/month for the "premium" Newsblur experience. I like paying for stuff I don't want to die, since there's a stronger incentive to keep it alive. (unlike, say, Google Reader...)


SimCity screenshots: mostly destruction
Mood: cheerful
Posted on 2013-03-11 21:20:00
Tags: pictures simcity
Words: 102

(click for full size)
My city got hit by a meteor attack, which is pretty destructive!

Lots of people seem to get sick. I'm not exactly sure what to do about this, although I did build a better sewage system, which might help?

To make the neighborhood happy, I built a soccer field! I love being able to zoom in and watch people playing.

...and then, another meteor attack. This one managed to take out the nearby fire station, which was especially bad. But, as the citizens of Linesville are used to hearing: we will rebuild!

(I'm gregstoll on Origin - friend me!)


link friday: simcity!, health care costs, jose canseco explains gravity
Mood: tired
Posted on 2013-03-01 14:05:00
Tags: links
Words: 103

- SimCity comes out next week! Fun experiments with it: SimCity vs. The Suburban Sprawl and Using SimCity to diagnose my home town's traffic problem

- We Found Our Son in the Subway - all together, now: Awwwwwwww!

- Bitter Pill: Why Medical Bills Are Killing Us - very long and depressing Time article, but worth reading. All those nonprofit hospitals are...surprisingly profitable! Related: America’s Overpaid Doctors

- Jose Canseco explains gravity (in 8 tweets! science!)

- Reddit thread of random facts about Austin

- This comment thread on the AV Club is pretty awesome if you're into Law & Order (see the comment that starts "No, we're not offering a plea")


India trip: all the posts/pictures
Mood: sick
Posted on 2013-02-22 21:25:00
Tags: travel
Words: 19

For your reading/viewing convenience:

India, weekend 1
India, week 1
India, weekend 2
India, week 2 (the final week!)


India, week 2 (the final week!)
Mood: sick
Posted on 2013-02-22 21:21:00
Tags: pictures travel
Words: 1064

<- click for full album

Monday 2/11 late evening

Pretty uninteresting day. I got home a bit late and didn't feel like going out, but hopefully I will tomorrow, at least to the park or something. I am planning on meeting people for breakfast at a small café - here's hoping I don't get sick!

Random India topic: (well, random India building topic) The elevators in the NI building are crazy. On one side of the room are two elevators, and on the other side is another one, but they operate independently! So whenever anyone wants to go up, they press "up" on both sides and whichever shows up first they get on, thus guaranteeing that almost half of all elevator stops are wasted. ("almost" because it's possible someone else enters the lobby in between and catches the second one) This is somewhat mitigated by the fact that the "close door" buttons actually work, and work quickly!

(I was told that they operate independently because the one elevator is the service elevator, while the other two are regular ones. But no one seems to treat the service elevator as special in any way...)

It's also possible there's some sort of crazy elevator algorithm going on. This evening as I was leaving, my driver pressed down on both sides. Both "regular" elevators were above us, and proceeded to go all the way down to the ground floor without stopping for us. The service elevator started at the ground floor and eventually made its way up to our floor and picked us up. So...I don't know?

Wednesday 2/13 morning

Not having a good 12 hours or so. Last night I got the inevitable case of traveler's diarrhea (taking meds for it now), and then I tried to download movies for the trip home but I can't because I'm in the wrong country (gonna try on VPN, I guess?). Then this morning I got locked out of my Nokia account, the lights in the bathroom didn't work, forgot my water bottle when I went up to breakfast, had a frustrating conversation with a hotel worker about the bathroom lights, finished my last Kindle book while waiting for the car so I bought a few new ones only to have trouble downloading them (which I did eventually fix), and now my laptop can't get on the WiFi here.

Traveling, especially to a foreign country, requires a lot of patience - you have to be very flexible. Usually I'm good at that, but I think I've used up my patience for the day already and it's only 10:30 AM...

Thursday 2/14 evening

OK, things are better now. Went out to lunch and dinner yesterday with work folks, which was fun, although I think I way overate. (and the antibiotic I'm still on bothers my stomach some) Today I did my last presentation-type thing at work, which went better than I expected. This evening I had the driver drop me off at Bangalore Central, and ate at the food court there. (grilled paneer for dinner and gelato for dessert!) Then I walked home. I think one of the big mistakes I made the first week was not getting out of the hotel more - to be fair, I was worried about traffic, but it's really not that big a deal if you cross at lights and are extremely careful :-)

I also got to play some table tennis today at work (in the table tennis room!) - unsurprisingly I'm pretty rusty, but I had a good time!

Hard to believe tomorrow is my last day here (my flight leaves at 8 AM Saturday morning = getting up super-early :-/ ) - I've gotten to know people here and generally had a good time, despite days like yesterday. It's going to be weird readjusting myself to "normal" life and not having someone drive me around everywhere!

(still irritated I can't rent movies for the plane rides home, though...)

Saturday 2/16 morningish

On my way back to Austin! Got up crazy early, checked out, and rode to the airport. I remember just two weeks ago thinking the drive from the airport to the hotel was crazy. Now I think "Lane markers! Nice!" even if they aren't universally respected. Although I did learn that instead of stopping at a red light, another option is to lay on the horn and just drive through.

At the airport there were two security lines separated by sex - it looks like the women's one (which was empty, incidentally) had more privacy for pat-downs. And I guess it's a good thing, because the metal detector beeped for every single person, so everyone got pat-downs. Did a little duty-free shopping to try to spend my last rupees, and then we boarded where my backpack was inspected again.

Been alternately watching movies and napping - seen "Looper" and "The Candidate" so far, and there's still 6 hours to go! Movie selection is pretty good, and we're flying close to Iran - maybe I should watch "Argo" :-) (Ed: I did, in fact, watch Argo!)

Random bits:
- While we were waiting to board, a British Airways person went around and gave candy to the kids that were around. (I wanted candy!)
- I was served breakfast by a flight attendant named Jean Luc! Awesome.
- When I checked in I was offered an upgrade for the equivalent of $250. I was briefly tempted (it is an 11 hour flight!), but that's still $22/hour, and all I seemed to get was a few extra inches of legroom.


I wandered around Heathrow for a while and had some sort of meal. (I think that was my fourth or fifth of the day...) I was starting to feel kind of crappy near the end of the flight, but getting up and off the plane helped a lot. (I think the smells were getting to me)

I'm on the Chicago flight now, and I hit the seating jackpot - window seat with an empty seat next to me! Really digging the extra legroom. Entertainment system isn't on-demand, but they still have a good selection of movies - watching "Arbitrage" now and about to eat another meal...


I made it home. I don't mean to be overdramatic, but maaaaaaan I felt pretty terrible afterwards. I'm getting old! And then jet lag, etc., etc. But that notwithstanding, it was a good trip, and I know some things to do differently next time!


links from India! Annotated State of the Union, naps, virtues, kangaroos
Mood: relaxed
Posted on 2013-02-15 14:44:00
Tags: links
Words: 210

It's my last day in India - had a great time, and boy am I not looking forward to another long day of travel. But, until then:

The Annotated 2013 State of the Union - may want to grab a cup of tea before reading; it's a bit long, but it's a very good read!

Relax! You’ll Be More Productive - or Hey, Naps Are Good for You!

Ten Virtues for the Modern Age - billed as part of "A Manifesto For Atheists", but I don't see any reason these shouldn't apply to non-atheists as well.

xkcd: Workflow - aaaaa it's so true! I'm putting this up at my desk when I get back.

Why a Transaction Fee Matters to You - a financial transaction fee really does seem like a good idea. Hopefully the bill has some chance of passing?

There Was A Kangaroo Delay At The Australian Open - the picture really is worth 1000 words. (thanks Jessica!)

The Law and Order Database: All 20 Seasons - an interesting look at guilty/not-guilty rates over the seasons. Also: data!

Declassified: America's Secret Flying Saucer - it worked great until it got more than four feet off the ground. It does look cool, though!

Finally, a Valentine's Day appropriate article from the Onion: Romantic-Comedy Behavior Gets Real-Life Man Arrested


India, weekend 2
Mood: okay
Posted on 2013-02-12 23:30:00
Tags: pictures travel
Words: 756

<- click for full album

Saturday 2/9 late evening

Whew, what a day! Kevin and I went to Mysore, which is only around 90 miles away, but took 3 hours to get there. On the way we stopped in Shrirangapattana and saw a temple there.

As soon as we got out of the car in front the temple, there were a bunch of very pushy street vendors that bugged us. Check out my bargaining skills: first I got this pair of elephants for Rs 1000 (~$20), down from 1200:

Then I inadvertently learned if you say "no" twenty times, you can get all this stuff for the same price!

Then I had to say no fifty times to get this one guy to leave us alone.

We walked through the temple and then walked around the city some - it felt very much like a small town (once we got away from the temple). Kevin had a Flat Stanley with him, and he was very successful at getting adults and kids to hold him. Actually, a lot of kids weren't shy and would wave at us. Eventually I started waving at them and they'd wave back, which was fun :-)

After that, we went into Mysore and saw the railway museum (which took about 10 minutes :-) )

And then on to the main event - Mysore Palace, which was the seat of power for the Kingdom of Mysore until 1947. It's breathtakingly beautiful inside, but unfortunately no pictures :-(

Then we walked around a bit to the city market which was fun but crowded. (and somewhat pushy vendors, although having survived the temple in Shrirangapattana I was an old pro at saying "no" dozens of times) We also discovered the latest scam: a kid would walk up to me, say hi, and ask what my name was and where I was from. Then they'd ask for a coin from my country "for a school project" :-) I did happen to have a dime on me, so I gave in one time...

Finally we went up to Chamundi Hill which overlooks the city. Unfortunately by the time we found a good view of the city it was getting dark and the pictures weren't that exciting.

Headed back to Bangalore and I got some evening tea at Café Coffee Day right next to the hotel (which is apparently the Starbucks of India...based on what I've seen, this seems accurate) and now I'm collapsed in bed. I got 21K steps today, and...ow! Going to sleep in a bit tomorrow.

Sunday 2/10 evening

Slept in a bit! I had breakfast at Café Coffee Day just to shake things up (and because I slept past breakfast time in the hotel), and had my laundry picked up. After that I spent some time relaxing, posting pictures/blog entry for the week, and watched the last hour of "The Dark Knight" on TV. (in English!)

After playing a bit of WoW, it was high time to leave the hotel room as I was going a bit stir-crazy. One unfortunate part of this hotel ishere's nowhere to go (other than the two hotel restaurants) if you want to stay in the hotel but not in your room. So I walked to the east, where I thought I had seen some places to shop while driving by. It was a little further away than I thought, but I did find a kind of mini-mall - it had a department-like store on the bottom two floors, then some other random stores, then a food court, arcade, and cinema. I got some gelato as a snack, and then took a look at the cinema to see if there was a movie I could watch. Unfortunately, the thing that displayed what played at what times was kinda broken, and the website was hard to use, in that I couldn't even figure out what location I was in. Apparently Lincoln and Life of Pi were playing at some theatres in English, but I don't think they were at that one. Oh well!

Café Coffee Day also lived up to "the Starbucks of India": there were two of them in the mall, and it really wasn't that big...

I also realized after the fact that there was a McDonald's there and I totally missed a chance to check out the price of a Big Mac. Nooo!

Walked back, and the rest of the day was pretty uneventful except for room service. I did get to watch some cricket and English Premier League soccer, which was fun. Now, to bed!


Windows Phone: writing a pinch and zoom image control
Mood: happy
Posted on 2013-02-10 22:20:00
Tags: windowsphone wpdev
Words: 989

When I was working on FlightPredictor and was working on showing airport maps, I was surprised there was no builtin "pinch and zoom image control" in the Windows Phone SDK. (to be fair, there wasn't one in Android either, and I'm not sure about iOS) So I had to implement my own, with some help from the Internet.

If I were doing this today, I'd just use the PanAndZoom control from Telerik's RadControls for Windows Phone. (which comes with the Nokia Premium Developer Program! Just sayin') But I did go through the trouble to implement it, so hopefully it will help someone out. Ed: another good solution is the SharpGIS ImageViewer - I haven't tried it, but it looks like it works well and you don't have to type in a bunch of code :-)

To see an example of how this works, you can download a trial version of FlightPredictor, download the airport maps and then play with them. This code supports pinching to zoom, panning, a maximum zoom level, and double-tap to zoom in or out.

XAML code
Here's the relevant part of the XAML:

<Image x:Name="MapImage" Stretch="Uniform"
RenderTransformOrigin="0,0" CacheMode="BitmapCache"
ScaleX="1" ScaleY="1"
TranslateX="0" TranslateY="0"/>

Note that the GestureListener is from the Windows Phone Toolkit, which is a (free!) must-have. It also requires you to have this inside the PhoneApplicationPage XML element:


C# code
First, some variables to declare in your PhoneApplicationPage:

private bool _needToUpdateMaxZoom = false;
private int _imageHeight = 0;
private int _imageWidth = 0;
// Reference
// these two fields fully define the zoom state:
private double _totalImageScale = 1.0;
private Point _imagePosition = new Point(0, 0);

private double _maxImageZoom = 1;
private Point _oldFinger1;
private Point _oldFinger2;
private double _oldScaleFactor;

Now you need to get a BitmapImage containing the image to display. How you do this depends on where you're getting the image from, but here's how I do it for files stored in IsolatedStorage:

byte[] data;

// Read the entire image in one go into a byte array
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
// Open the file - error handling omitted for brevity
// Note: If the image does not exist in isolated storage
// the following exception will be generated:
// System.IO.IsolatedStorage.IsolatedStorageException was unhandled
// Message=Operation not permitted on IsolatedStorageFileStream
using (IsolatedStorageFileStream isfs = isf.OpenFile("/airportMaps/" +
info.Url, FileMode.Open, FileAccess.Read))
// Allocate an array large enough for the entire file
data = new byte[isfs.Length];

// Read the entire file and then close it
isfs.Read(data, 0, data.Length);

// Create memory stream and bitmap
MemoryStream ms = new MemoryStream(data);
BitmapImage bi = new BitmapImage();

// Set bitmap source to memory stream

After you've set up your BitmapImage, add the following code right afterwards:

_imageHeight = bi.PixelHeight;
_imageWidth = bi.PixelWidth;
_imagePosition = new Point(0, 0);
_totalImageScale = 1;

// set max zoom in
if (MapImage.ActualWidth == 0.0 || MapImage.ActualHeight == 0.0)
_needToUpdateMaxZoom = true;
UpdateImagePosition(new Point(0, 0));

// Assign the bitmap image to the image’s source
MapImage.Source = bi;

Now, all that's left is to implement the GestureListener events, as well as a few utility methods:

private void MapImage_SizeChanged(object sender, SizeChangedEventArgs e)
if (_needToUpdateMaxZoom)
if (MapImage.ActualHeight != 0.0 && MapImage.ActualWidth != 0.0)

private void UpdateMaxZoom()
// this is already stretched, so this gets tricky
_maxImageZoom = Math.Min(_imageHeight / MapImage.ActualHeight,
_imageWidth / MapImage.ActualWidth);
_maxImageZoom *= Math.Max(1.0,
Math.Max(_imageHeight / MapImage.ActualHeight, _imageWidth / MapImage.ActualWidth));
const double MAX_ZOOM_FACTOR = 2;
_maxImageZoom *= MAX_ZOOM_FACTOR;
_maxImageZoom = Math.Max(1.0, _maxImageZoom);
_needToUpdateMaxZoom = false;
UpdateImagePosition(new Point(0, 0));

private void GestureListener_PinchStarted(object sender, PinchStartedGestureEventArgs e)
_oldFinger1 = e.GetPosition(MapImage, 0);
_oldFinger2 = e.GetPosition(MapImage, 1);
_oldScaleFactor = 1;

private void GestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
var scaleFactor = e.DistanceRatio / _oldScaleFactor;
if (!IsScaleValid(scaleFactor))

var currentFinger1 = e.GetPosition(MapImage, 0);
var currentFinger2 = e.GetPosition(MapImage, 1);

var translationDelta = GetTranslationDelta(currentFinger1, currentFinger2,
_oldFinger1, _oldFinger2, _imagePosition, scaleFactor);

_oldFinger1 = currentFinger1;
_oldFinger2 = currentFinger2;
_oldScaleFactor = e.DistanceRatio;


private void GestureListener_DragDelta(object sender, DragDeltaGestureEventArgs e)
var translationDelta = new Point(e.HorizontalChange, e.VerticalChange);

if (IsDragValid(1, translationDelta))

private void GestureListener_DoubleTap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
if (Math.Abs(_totalImageScale - 1) < .0001)
const double DOUBLE_TAP_ZOOM_IN = 3;
double imageScale = Math.Min(DOUBLE_TAP_ZOOM_IN, _maxImageZoom);

Point imagePositionTapped = e.GetPosition(MapImage);
// we want this point to be centered.
double x = imagePositionTapped.X * imageScale - (MapImage.ActualWidth / 2);
double y = imagePositionTapped.Y * imageScale - (MapImage.ActualHeight / 2);
Point imageDelta = new Point(-1*x, -1*y);
// FFV - animation?

private Point GetTranslationDelta(Point currentFinger1, Point currentFinger2,
Point oldFinger1, Point oldFinger2, Point currentPosition, double scaleFactor)
var newPos1 = new Point(currentFinger1.X + (currentPosition.X - oldFinger1.X) * scaleFactor,
currentFinger1.Y + (currentPosition.Y - oldFinger1.Y) * scaleFactor);
var newPos2 = new Point(currentFinger2.X + (currentPosition.X - oldFinger2.X) * scaleFactor,
currentFinger2.Y + (currentPosition.Y - oldFinger2.Y) * scaleFactor);
var newPos = new Point((newPos1.X + newPos2.X) / 2, (newPos1.Y + newPos2.Y) / 2);
return new Point(newPos.X - currentPosition.X, newPos.Y - currentPosition.Y);

private void UpdateImageScale(double scaleFactor)
_totalImageScale *= scaleFactor;

private void ApplyScale()
((CompositeTransform)MapImage.RenderTransform).ScaleX = _totalImageScale;
((CompositeTransform)MapImage.RenderTransform).ScaleY = _totalImageScale;

private void UpdateImagePosition(Point delta)
var newPosition = new Point(_imagePosition.X + delta.X, _imagePosition.Y + delta.Y);
if (newPosition.X > 0) newPosition.X = 0;
if (newPosition.Y > 0) newPosition.Y = 0;

if ((MapImage.ActualWidth * _totalImageScale) + newPosition.X < MapImage.ActualWidth)
newPosition.X = MapImage.ActualWidth - (MapImage.ActualWidth * _totalImageScale);

if ((MapImage.ActualHeight * _totalImageScale) + newPosition.Y < MapImage.ActualHeight)
newPosition.Y = MapImage.ActualHeight - (MapImage.ActualHeight * _totalImageScale);

_imagePosition = newPosition;


private void ApplyPosition()
((CompositeTransform)MapImage.RenderTransform).TranslateX = _imagePosition.X;
((CompositeTransform)MapImage.RenderTransform).TranslateY = _imagePosition.Y;

private void ResetImagePosition()
_totalImageScale = 1;
_imagePosition = new Point(0, 0);

private bool IsDragValid(double scaleDelta, Point translateDelta)
if (_imagePosition.X + translateDelta.X > 0 || _imagePosition.Y + translateDelta.Y > 0)
return false;
if ((MapImage.ActualWidth * _totalImageScale * scaleDelta) +
(_imagePosition.X + translateDelta.X) < MapImage.ActualWidth)
return false;
if ((MapImage.ActualHeight * _totalImageScale * scaleDelta) +
(_imagePosition.Y + translateDelta.Y) < MapImage.ActualHeight)
return false;
return true;

private bool IsScaleValid(double scaleDelta)
return (_totalImageScale * scaleDelta >= 1) &&
(_totalImageScale * scaleDelta <= _maxImageZoom);

and that's it! Some things you can tweak:
- The maximum you can zoom in is 2x of the original image size. You can change this by modifying MAX_ZOOM_FACTOR in UpdateMaxZoom().
- When you double-tap on the image, if it's currently zoomed out it zooms in to 3x. You can change this by modifying DOUBLE_TAP_ZOOM_IN in GestureListener_DoubleTap.

I'm also not entirely sure the math is right in various places, but it works well enough on the size of images I tend to deal with. It would also be nice to add inertial scrolling...

Hope this is helpful! I took a lot of this code from this blog post.


See all my Windows Phone development posts.

I'm planning on writing more posts about Windows Phone development - what would you like to hear about? Reply here, on twitter at @gregstoll, or by email at ext-greg.stoll@nokia.com.


Interested in developing for Windows Phone? I'm the Nokia Developer Ambassador for Austin - drop me a line at ext-greg.stoll@nokia.com!


Go earlier/later

This backup was done by LJBackup.