Sunday, August 21, 2016

Why is the programming language you choose important?

The topic of programming languages inevitably comes up when you've got a group of programmers talking to each other. What language do you use? What's your favorite language? Omg I fucking hate PHP too. 

Why do so many programmers care about what language they use? If you're a programmer and you don't really pay much attention to the languages you're using to write code, why should you care?

This line in the Structures and Interpretations of Computer Programs does an excellent job explaining why programming languages are so important:


A powerful programming language is more than just a means for instructing a computer to perform tasks. The language also serves as a framework within which we organize our ideas about processes. Thus, when we describe a language, we should pay particular attention to the means that the language provides for combining simple ideas to form more complex ideas

I love this line: A powerful programming language is more than just a means for instructing a computer to perform tasks. 

Yes, computers interpret programming languages to do things. That's pretty important. But who's writing these languages? We are. And who's reading these programs when they don't lead to the behavior we intend? We are. So yeah, the language absolutely matters. This is why "high-level" programming languages like Python and Ruby were invented. It's far easier to organize our ideas about processes using something that resembles natural language than using ones and zeros.

TinyHabits is not a magic pill

A couple of years ago I was interested in learning about habit development (mostly because I wanted to develop new habits myself) and came across a behavior change method called Tiny Habits by a behavioral psychology research at Stanford named BJ Fogg.

The method is simple. Pick a very small and specific habit. Visualize it. Next, identify ways you can make that small and specific behavior easy to do. Lets say the behavior you chose was to pick up and practice hitting a chord on your guitar after you get home from work. What would make that easier? Well, maybe you can try leaving your guitar next to the door! Finally, you pick a trigger and a reward in order to sustain the behavior.

That sounds pretty simple right? Well, yeah. It is. It's an excellent framework - but that's all it is. A framework. It does not prescribe what the habits should be, what the triggers should be or what the rewards should be. It offers a scaffolding for you to build on. An outline for you to expand upon. That's the hard part that companies spend many years and dollars trying to figure out.

In other words, even though the general mechanics of the habit loop is pretty well understood at this point, the question of how to make a specific behavior stick - namely, what triggers and rewards need to be in place - depends on the person and the behavior. For example, for practicing the guitar, it's not clear what the reward should be. What motivates one person to pick up a guitar is different from what motivates another person. For some, maybe just playing the guitar is reward enough and this whole system is just unnecessary.

Saturday, August 13, 2016

The Slipper Room Show





I just went to a burlesque variety show with my friend tonight. First of all, they need to add more seating because I think a good half of the people who bought tickets were forced to stand. That's just not cool. Also, they said the show would start at 9:30 but it didn't start until like 9:50. We were both pretty pissed before the show even got started.

This was a variety show with mostly burlesque performances. But really, it's a burlesque show. There was some comedy, some satirical magic, and lots of burlesque dancing. The host was the comedian James Habacker and for the whole time I wasn't sure if he was playing himself or a specific character. He had a drink on one hand for every every act and told pithy logic jokes like "I'm not a heavy drinker ... I'm only a hundred and thirty five pounds" and "so ... corduroy pants are making headlines". I thought he was pretty funny but it did bother me that he seemed to forget (disregard?) his hosting role during the show by constantly asking the audience "do you guys want me bring out the next female dancer?" - as if he was the main act. He was clearly in character and was joking but it really didn't do much to amp up the audience for the actual dance performance.

The first performance by the dancer Harvest Moon was breathtaking. She started out doing the typical, sensual burlesque stuff and then transitioned into aerial silks. One moment she was slow dancing and the next moment she was practically flying in the air! It was really an incredible show of both strength and elegance. My favorite move was when she wrapped herself in the silk on her climb up, then let go and dropped down just far enough to catch herself before the silk she was wrapped in completely unraveled.

Then there was also a comedian magician Chipps Cooney. Habacker (the host) introduced him as the world most famous illusionist. At that point I should've known better to know that Habacker was being sarcastic. This guy was not an actual illusionist. It's a comedy act of a pretend-illusionist setting up tricks as if he was going to do a real illusion. For example, in one act he took out a plastic bottle for his magic wooden chest and displayed it to the audience and then violently crumples it. Hmmm, I wonder what he's going to do with that! He then turns around and blows air into the bottle with about as much force and tada! The bottle is back! Yeah, that kind of magic. I especially liked the one where he brings out a snow globe that was not snowing, covers it with a red handkerchief, and then gently shakes the snow globe before pulling it off to show you the show that just magically appeared.

I don't think I'd go to one of these again. I was hoping for more performances like Moon's where there was a combination of both burlesque and stunts. I guess I was hoping to walk away amazed by some of the performances but I don't think this was that kind of show. The comedic portions by the host had a good number of funny short jokes (and one very long bestiality joke that ended in a confusing way) but felt too lengthy, too misogynistic, and too discursive.


Thursday, August 11, 2016

Jia Duo Bao Herbal Tea?

My mom keeps insisting that I drink this thing called Jia Duo Bao because of its many "health benefits". I was very skeptical. Here's what it looks like:


My girlfriend and I looked at the ingredients on the nutritional label the other night and we could not recognize most of the ingredients. The only two ingredients that we knew were water and sugar. She looked at the sugar amount and said "this is just sugar water!". There's 28 grams of sugar and I wasn't sure whether or not that's a lot. Is it? Well, I know that one teaspoon holds about 4 grams of sugar. So there's about 7 teaspoons in this drink.

Okay, that seems like a lot if I imagine myself just putting sugar in my mouth. But is it? According to an article published by the American Heart Association, the recommended upper limit for men is about 150 calories of sugar, which is 9 teaspoons. For women, it's 100 calories, which is 6 teaspoons. So if I have this one drink, I'm already close to 80% of your daily limit. That doesn't seem very good. I'm a pretty active guy, so I wouldn't get too worried having a soft drink every now and then. However, this make me less confident about the "health benefits" that my mom refers to.

In addition to water and sugar, there's seven additional ingredients that neither of us were familiar with. So I looked them up.
  1. Mesona - https://en.wikipedia.org/wiki/Platostoma_palustre
  2. White Frangipani - http://www.allthingsfrangipani.com/frangipanis.html
  3. Microcos - https://en.wikipedia.org/wiki/Microcos
  4. Chrysanthemum - https://en.wikipedia.org/wiki/Chrysanthemum
  5. Japanese Honeysuckle - https://en.wikipedia.org/wiki/Lonicera_japonica
  6. Heal All - https://en.wikipedia.org/wiki/Prunella_vulgaris
  7. Chinese Licorice - https://en.wikipedia.org/wiki/Glycyrrhiza_uralensis
Turns out, all of these are plants, which is probably where the "herbal" part of this drink comes from. In the front of the can, you see this line of text:

JiaDuoBao Herbal Tea - Made from prime herbal ingredients

I did some research on the company behind this product, Hangzhou Jiaduobao Drinks Co, and found that they've actually surpassed coca-cola in terms of sales in China with this product. They market the drink as a sweet drink with many health benefits from the herbal ingredients. In other words, it's like coke, but supposedly good for you. Good in what way? Lowering your internal heat, for example. I don't really know what that means so I can't really say whether or not this is even a real thing (as in can it actually lower your internal heat, whatever that is?), let alone one whether that has any health benefits whatsoever. I mean, maybe you don't need your internal heat lowered, I don't know. 

I'll probably dig into this some more. In the meantime, I think I'll be staying away from this sugar water.

How much money did I save by making a sandwich for dinner?

I recently started making sandwiches for dinner instead of eating out. As I was preparing my sandwich tonight, I wondered how much money I was really saving. So I decided to look at the cost per serving for all of the ingredients in my sandwich. By serving I mean the measure of how much I actually eat rather than what's defined on the nutrition label. For the cost calculations, I'm rounding to the nearest tenths.

Cost of ingredients


Price: $4.49
Total slices: 16

The nutrition label defines one slice as a serving. Like most people, I eat two slices.

Cost per serving of bread = (4.49 / 16) * 2 = 0.56

Price: $5.50
Total slices: 16

I use about four slices for each sandwich. 

Cost per serving of ham = (5.50 / 16) * 4 = 1.38

Price: $5.99
Total slices: 12

I use two slices. 

Cost per serving of cheese = (5.99 / 12) * 2 = 1.00

Price: $4.79
Total amount: 30 tbsp

I use about one table spoon. 

Cost per serving of mayonnaise = (4.79 / 30) = 0.16

Price: $2.99
Total amount: ???

I just finished up this lettuce and I've had it for quite a while. I think it's been used for about 12 - 13 sandwiches. Lets say it's 12. 

Cost per serving of lettuce = (2.99 / 12) = 0.25

Total cost of my sandwich


Total cost = (0.56 + 1.38 + 1.00 + 0.16 + 0.25) = $3.35

Holy shit. 

How much do I typically spend on dinner when I'm eating out? $10 - $12. Lets say $11. That means I just saved $7.65 tonight!

If I ate out every night for a month, I'd spend $330 on dinner alone for that month. If I ate a sandwich (with equivalent cost to this one) every night, it would only cost me $100.5 a month. So in theory (I say theory because I cannot eat sandwiches every single day for a month), if I ate these sandwiches for a month instead of eating out, I'd save more than 200 dollars!


Tuesday, August 9, 2016

Launching Sublime Text 3 from the Mac OSX Command Line

Both Sublime Text 2 and 3 ships with a command line tool called subl that allows you to open the editor from your terminal. Most instructions online teach you how to symlink the tool in a directory that's on the PATH so that you can run it simply by typing subl.

Unfortunately, lots of the instructions that I came across hard coded the tools path for Sublime 2. This failed for me because it turns out Sublime Text 3 uses a different path. To save you a few seconds, here's the symlink command for Sublime Text 3.

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Wednesday, August 3, 2016

How to connect an external monitor using ThinkPad Onelink ProDock

I just got an external monitor displaying using my Onelink dock! The dock is connected to my Lenovo ThinkPad Carbon X1.

Here's how I got it setup:
  1. Connected the dock to my X1.
  2. Connected my external display to my dock using an HDMI cable that came with my external monitor and a Rocketfish HDMI to DVI-D adapter.
  3. Scratched my head in frustration because my computer was not detecting the display. I exchanged my adapter thinking that maybe it was faulty, tried a VGA cable and VGA to DVI-D adapter, and plugged / unplugged the connectors a few dozen times. Still nothing.
  4. Thought it might be a software issue and used my Google-Fu. Learned that computers that were recently upgraded to windows 10 had issues detecting external displays with the dock.  
  5. Installed the latest dock driver as recommended.
  6. Dance.