Awesome OS X Command Line

A curated list of shell commands and tools specific to OS X.

“You don’t have to know everything. You simply need to know where to find it when necessary.” (John Brunner)

Camel case transforms

/**
  * Credit: sidharthkuruvila
  * Source: http://ift.tt/29KXOcU
  * Takes a camel cased identifier name and returns an underscore separated
  * name
  *
  * Example:
  *     camelToUnderscores(“thisIsA1Test”) == “this_is_a_1_test”
  */

def camelToUnderscores(name: String) = “[A-Z\\d]”.r.replaceAllIn(name, {m =>
  “_” + m.group(0).toLowerCase()
})

/*
 * Takes an underscore separated identifier name and returns a camel cased one
 *
 * Example:
 *    underscoreToCamel(“this_is_a_1_test”) == “thisIsA1Test”
 */

def underscoreToCamel(name: String) = “_([a-z\\d])”.r.replaceAllIn(name, {m =>
  m.group(1).toUpperCase()
})

Bristle template: when you don’t have time to do your Moustache

Usually I generate my pages with Velocity. Recently I had a project where even implementing Velocity was not worth the time. I tried both MessageFormatter and StringTemplates and both had problems with some portion of HTML/Javascript markup.

So I did what we, engineers always do in this situation: run your own. Good news, it took just over an hour and I ended with a single very small file. It  can only variable substitution but that was enough for me. Here it is:

http://codebistro.googlecode.com/svn/trunk/misc/src/main/java/org/codebistro/util/BristleTemplate.java

The best part: it has no dependencies so you can just copy file into your project and template away.

Of course you can Maven just as well:

    <repositories>
        ...
        <repository>
            <id>codebistro-open</id>
            <name>codebistro-open repo</name>
            <layout>default</layout>
            <url>http://codebistro.googlecode.com/svn/repo/</url>
        </repository>
        ...
    </repositories>
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>org.codebistro.util</groupId>
            <artifactId>misc</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
     <dependencies>

Microframeworks are popular these days. This thing doesn’t even qualify to be called micro- or even nano- but I got a feeling I am going to use Bristle template in the future…

Google+: “Oops, you need a google profile to use this feature” and a workaround

Update: This is no longer relevant. Google+ allows to log in with a Google Apps account.

I use my custom domain name Google Apps account as my primary email. I still have Google account and Google profile but I am not logged into this account by default.

So when I go to http://google.com/+ I get this dreaded error message:

Oops, you need a google profile to use this feature

Oops, you need a google profile to use this feature

I found a workaround to this problem. The solution requires that a) you have a “regular” Google Account (…@gmail.com) and b) this account should be enabled the “Sign in to multiple Google Accounts” feature (thanks Paul for the tip) :

1. Go to any profile page on Google plus:

Go to your Google Profile

2. Click on the Account -> Switch Accounts menu:

Switch accounts menu

3. Select the Google Account (not the Google Apps account) or log into your Google Account:

Switch to Google Account

Bingo! Your Google plus is now working!