Recent Posts by Itamar Ostricher

Use cpplint to Check Your C++ Code Against Google’s Style Guide

By Wednesday, November 12, 2014 0 , , Permalink 1

cpplint is an automated checker for C++ code. It checks the style of an input C++ source file against Google’s C++ style guide.

If you’re writing C++ code, and trying to follow the said style guide, I strongly recommend using this tool!

Endless rants can be written on programming style and style-guides. This is not one of them 🙂 .

At the end of the day, my personal opinion is that it doesn’t really matter what conventions you choose to follow. What does matter is that if you collaborate with a team on a common codebase, it’s extremely important to obtain and sustain consistency. To that goal, as long as one consistent style guide is followed by all collaborators – the specifics of the style guide are not too important.

When choosing a style guide to follow, having an automated tool available for collaborators to check themselves has great value. Without it, code reviews end up revolving around style issues instead of the logic being reviewed (you are practicing code reviews, right?). This is the main reason that I default to Google’s C++ style guide.

One of the things I like most about Google’s cpplint tool is that it prefers false negatives over false positives. This means that, while it misses some “style issues”, it usually doesn’t mistakenly produce warnings for compliant code. From my experience, developers are quick to ditch tools that generate lots of cruft. It’s much better that the developer fixes some reported issues instead of ignoring all.

The cpplint tool is available on this official Subversion repository, as well as from my GitHub fork of it. I forked it to make some changes. They might be specific to how I work, but maybe others may benefit from them. Checkout the cpplint tag for more on my changes and other cpplint-related stuff. See also the google-styleguide project.

How To Migrate a WordPress Blog

By Monday, November 10, 2014 2 , Permalink 1

One of things I love about WordPress it that it’s an open content platform. Being open, the platform understands that the user owns the content within. Truly owning your content means you should be able to take it out of the platform, and do whatever you want with it. WordPress makes it easy!

This post is a how-to guide on migrating a WordPress site. It covers:

  1. Exporting all your content from a hosted WordPress.com site.
  2. Importing the content to a self hosted WordPress site.

The export part applies also to self-hosted WordPress sites. I write specifically about a WordPress.com-hosted site because this is what I use for the example.

Continue Reading…

Weekly Review, November 8

By Saturday, November 8, 2014 2 Permalink 1

In January this year, I bought coupons for a movie night at a close by movie theater. This week, about 10 months later, Oogi and I finally used up those coupons. Hurray babysitters!

With all the bad movies around most of the time, I’m really happy we decided to watch Gone Girl! Really, great movie. Go watch it too, if you haven’t! 🙂

Also this week, Google ran a 1-day Cloud Platform Live event. Sadly, it took place in San Francisco, which made it somewhat difficult for me to attend. With the timezone difference, it wasn’t even reasonable for me to watch the live stream…

If you’re into cloud development, you’d probably be interested in what came out of it.

  • Google Container Engine is exciting, with Kubernetes and Docker – so much potential! Maybe I can use it to cross off my DayJob todo about “better cluster management” 🙂 .
  • Managed VMs in App Engine goes into beta. Also adds auto-scaling support, and Docker-based runtimes. This makes me want to move my WordPress to App Engine! Anyone put together a Docker AppEngine image with WordPress stack? 🙂
  • The Compute Engine gets auto-scaling powers! Neat.
  • Some network stuff, Firebase integration, cloud debugger.
  • Another price reduction.

I recently read another article on financial independence. I can agree with the premise that financial independence is a worthy goal, in the sense that trading (work) time for money is entirely optional. I, too, would love to choose what to do with my time based solely on personal joy, without worrying about income.

I can’t understand, though, why most of these articles go on about “suffering for a decade or two” to achieve said financial independence. Isn’t it generally better to work in something that you enjoy most of the time for 40 years and maintain and reasonable lifestyle, instead of living like a dog for 15 years so you can have 25 years of watching TV after that?

For a living, I write code for a company that pays me to do it, and I enjoy it. If I had “financial independence” today, I’d probably write less code for the company. With the freed up time, I would most likely just write other code (and blog posts 😉 ) for myself. Maybe I could have written code for other companies that would pay me much more for it (e.g. algo-trading etc.), and get to financial independence sooner. But I don’t think it’s worth it! Why would I “sell my soul” now for more free time later?

Maybe I’m missing something. Maybe I’m in a special position that my skills, hobbies, and job intersect. Maybe most people hate their jobs. Go figure.

What would you do if you could stop worrying about money today? What does it worth to you? I’d love to know, so head to the comments! 🙂

Continue Reading…

Preparing My Nexus 5 For Lollipop: Apps Cleanup

I love a clean start. There’s nothing like the feel of a smartphone (or PC) after a factory reset.

I’m using my Nexus 5 for almost a year now. For a while, I’ve been wanting to do a factory reset and start clean. The upcoming Lollipop upgrade is exactly the push I needed to do it.

My game plan:

  1. Before upgrading:
    1. Perform general app cleanup, so I upgrade only with the apps I want.
    2. Document my settings and configuration (system and apps), so I can re-apply it if needed.
    3. Backup data.
  2. Upgrade.
  3. After upgrading:
    1. Restore apps, data, settings and configuration, as needed.
    2. Explore what new built-in features can replace 3rd party apps I’m using. I always prefer built-in over 3rd party.

In this post, I document the app-cleaning step. Over time, I installed more than a few apps (112 to be sort-of-exact). I’m sure many of them go unused, or even worse – unused and also run in the background. Before upgrading, I want to cut down the installed apps to those that I actually want installed.

I’m sort-of relying on the Google Play feature that reinstalls apps after a factory reset. If it works, I get only the apps I want restored. If it doesn’t work, I have a list of apps I want to reinstall.

Continue Reading…

Shell Foo: Brace Expansion

It might be common knowledge, but personally I didn’t know that most shells expand braces to generate all possible combinations!

The scenario for this is when you’re writing a command that takes multiple similar arguments or flags. You can use brace expansion to just write the “schema”, and the shell will generate all the arguments for you!

For example, say you want to create a directory layout for a project. You might use something like mkdir proj/req proj/spec proj/design proj/impl proj/finanes proj/docs. Not too bad, but much nicer to write this instead:

mkdir proj/{req,spec,design,impl,finances,docs}

How about printing all 2-digit hexadecimal numbers? Piece of cake!

$ echo 0x{{0..9},{A..F}}{{0..9},{A..F}}
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8A 0x8B 0x8C 0x8D 0x8E 0x8F 0x90 0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 0x99 0x9A 0x9B 0x9C 0x9D 0x9E 0x9F 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 0xA6 0xA7 0xA8 0xA9 0xAA 0xAB 0xAC 0xAD 0xAE 0xAF 0xB0 0xB1 0xB2 0xB3 0xB4 0xB5 0xB6 0xB7 0xB8 0xB9 0xBA 0xBB 0xBC 0xBD 0xBE 0xBF 0xC0 0xC1 0xC2 0xC3 0xC4 0xC5 0xC6 0xC7 0xC8 0xC9 0xCA 0xCB 0xCC 0xCD 0xCE 0xCF 0xD0 0xD1 0xD2 0xD3 0xD4 0xD5 0xD6 0xD7 0xD8 0xD9 0xDA 0xDB 0xDC 0xDD 0xDE 0xDF 0xE0 0xE1 0xE2 0xE3 0xE4 0xE5 0xE6 0xE7 0xE8 0xE9 0xEA 0xEB 0xEC 0xED 0xEE 0xEF 0xF0 0xF1 0xF2 0xF3 0xF4 0xF5 0xF6 0xF7 0xF8 0xF9 0xFA 0xFB 0xFC 0xFD 0xFE 0xFF

Isn’t it cool? 🙂

I believe this feature is available in many shells, if not all. The examples above were tested on bash on OS X 10.10 and Ubuntu Linux 14.0.4.1.

Shell-Foo credit for this one: Eyal Fink.

Shell-Foo is a series of fun ways to take advantage of the powers of the shell. In the series, I highlight shell one-liners that I found useful or interesting. Most of the entries should work on bash on Linux, OS X and other UNIX-variants. Some probably work with other shells as well. Your mileage may vary.

Feel free to suggest your own Shell-Foo one-liners!

Continue Reading…

Side Projects and Blog Posts

In a previous post I described my workflow for side projects in general. I wrote that throughout the project I publish blog posts describing my thoughts, plans, progress, etc.

In this post I describe in further detail the technicalities of side-project-related blog posts. I explain my guidelines and considerations for some of the common blog posts that accompany side projects. I also describe how I use WordPress features and plugins to generate project index pages and lists of active and archived projects. These features include custom fields, page hierarchies, and queries, with a couple of plugins and template modifications.

Continue Reading…

App Highlights: Our Groceries

Our Groceries is a super-useful app that keeps multiple lists synchronized between multiple devices and users.

The obvious use-case, as hinted by the name of the app, is sync’ing grocery lists between family members. This apps does it in a simple and intuitive way!

App Highlights is a recurring series. From time to time, I highlight one Android app that I found useful. Feel free to suggest apps for me to highlight, but be advised that I focus on apps that I actually use.

Continue Reading…

Weekly Review, November 1

By Saturday, November 1, 2014 0 Permalink 1

Wow, this week I posted every day! Most of it consisted of “spontaneous” posts, outside my planned project-posts and series.

I postponed some of the planned posts I prepared in favor of the more “timely posts” of this week. There’s an interesting distinction between “timely posts” and “timeless posts”. It wasn’t explicitly clear in my mind before thinking about it this week.

I try to write mostly “timeless posts”. Posts that I consider to have value now as well as in the future. Posts of this kind can be published now or next month, and it wouldn’t matter much.

On the other hand, “timely posts” usually have short shelf-lives. They may be super relevant today, and completely useless next week. I don’t specifically object those. I assume that my potential contribution to topics of transient short-lived value is limited. I’m not a large tech-site with a team of (pseudo?) geeks constantly looking for the next buzz.

This week was interesting, because almost daily I had something to say on some transient subject (Google Inbox buzz, OS X Yosemite upgrade, etc.). Did you notice the difference? What kind of content type I produce you enjoy more, and why? I’d love to know, so drop a comment, or tell me personally!

In case you missed it, I started this week a new series, dubbed Shell-Foo. I’m excited about it! I love “elegant” (read “brutal”) ways to do complex things from the command line! It’s something I wanted to learn more about for a long time, and a similar new internal mailing list in DayJob helps a lot. It’s nice that I can shamelessly rip off that mailing list.. 🙂

Also this week, I finished “reading” my first audio book from Audible. It was Flash Boys by Michael Lewis (also available on Amazon as a real book), at total play time of 10 hours 18 minutes. I didn’t like it much, but I can’t say if it’s the story or the format. I guess I’ll see how it goes with the next books.

The Weekly Review is (hopefully) a recurring summary, reviewing highlights from the last week.

Continue Reading…

Some More Google Inbox Feedback

Following up on my earlier Inbox thoughts and feedback, I wanted to share new feedback from the last 3-4 days.

This time I’ll jump straight to to feedback:

  1. When I get an email that was auto-forwarded from one of my aliases (e.g. Google Apps email), the default “Reply” behavior in Inbox is to “reply to all” (including myself). This is not desired, and not consistent with Gmail, where the default behavior was “reply to sender” (and set “from address” to the alias).
  2. In Gmail, I used to apply labels using the keyboard. L would open the label menu, and I could type a label prefix to filter the labels list and apply it. This doesn’t work in Inbox. I had to use the mouse to click “Move To”, and scroll and select the label / bundle to apply. When I forget that typing doesn’t filter the list, I accidentally perform unexpected operations on the item…

The last, most painful one:

  1. No more multiple labels support?!?! There’s only “Move To”! Moving to a bundle / label replaces the existing bundle / label. OMG, why???

If you agree with any of these – please submit it too, so the issue gets the attention it needs! To submit feedback, scroll to the bottom of the sidebar, click “Help & Feedback”, and “Send Feedback”.

I also encourage you to share your feedback that I didn’t cover!

Continue Reading…

Fixing Homebrew on OS X Yosemite

Homebrew is “The missing package manager for OS X”. It’s pretty great. Unfortunately, upgrading to OS X Yosemite might break it, as it did for me.

There are several paths for fixing it, depending on when you realize it’s broken. Here are a few possible fixes that you can use.

If you just want the bottom line, here it is:

  1. If you still haven’t upgraded to OS X Yosemite, run brew update before the OS X upgrade.
  2. If you already upgraded OS X and your Homebrew is broken, run git pull from /usr/local, and then run brew update.

Read on for more details on my experience with the break and fix.

Continue Reading…