Tuesday, October 6, 2015

El Capitan, Homebrew and Java

It's a good idea to upgrade to El Capitan.

As usual, with major updates things break.

In this post we'll look at how to get homebrew and Java functioning properly.


The first thing you may notice is that any application you use, e.g., IntelliJ, that require Java does not work.

Let's fix that by updating Java for El Capitan.

Go Here and click the Download button

Java for OS X 2015-001

After the javaforosx.dmg file is downloaded into your ~/Downloads folder, just double click it from the Finder and follow all the prompts to install it.

Update Java

Next, you'll want to go to your system preferences and update Java:

Now, you can verify it and see where El Capitan puts Java:


If you're like me and use jenv, you'll need to update that, too.

Note: jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable.

brew info jenv - Error

If you get an error like the following when attempting to run brew info...

$ brew info jenv
jenv: stable 0.4.3 (bottled), HEAD
Manage your Java environment
/usr/local/Cellar/jenv/20130917 (62 files, 260K) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/jenv.rb
==> Caveats
To enable shims and autocompletion add to your profile:
  if which jenv > /dev/null; then eval "$(jenv init -)"; fi

To use Homebrew's directories rather than ~/.jenv add to your profile:
  export JENV_ROOT=/usr/local/opt/jenv
~ $ brew update
error: unable to unlink old '.travis.yml' (Permission denied)
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master

Fix Permissions

... then you should fix the permissions in the /usr/local directory:

sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local

Note that the previous commands will fix a good number of other homebrew issues.

Update jenv shim

You'll want to update line 21 in $HOME/.jenv/shims/java

For me, I had to change this...

exec "/usr/local/Cellar/jenv/20130917/libexec/libexec/jenv" exec "$program" "$@"

...to this:

exec "/usr/local/Cellar/jenv/0.4.3/libexec/libexec/jenv" exec "$program" "$@"

Set Global jEnv Java Version

If you see this...

$ jenv versions
jenv: version `oracle64-' is not installed

... then, run this:

$ jenv global oracle64-

$ jenv versions
* oracle64- (set by /Users/lex/.jenv/version)

Check Java Version

Finally, you can verify that Java is now happy:

$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


Homebrew needs some love, too.

Just keep running brew update and doing what it says until you see this:

$ brew update
Already up-to-date.

Then, run brew doctor to be sure you're all good with brew:

$ brew doctor
Your system is ready to brew.


Java for OS X 2015-001 jEnv

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Wednesday, September 23, 2015

Mac iCloud and Spontaneous System Reboots

The other day when rebooting from a system update I was presented with the option of using an iCloud account, instead of my normal system login account.

I figured, why not? What's the worst that can happen?

What did happen was unpredictable spontaneous system reboots. (Over 6 in one day).

I studied the syslog messages for what could be happening (and there were a lot to scan through).

There were a lot of messages pertaining to iCloud resources and authentication.

I reverted to my normal system login account and disabled the iCloud hooks that I could find.

It's been over 60 hours and I have experienced 0 spontaneous system reboots since disabling iCloud on my Mac.

See screenshots below:

Do NOT choose iCloud

Uncheck Anything iCloud Related

Uncheck Anything iCloud Related


  • I do not appreciate Apple's attempt to force me to use their paid iCloud services.
  • If Apple continues down this road, I will dump my Mac OSX systems and develop soly on Linux-based systems
  • I don't think I'm alone in this. I am a developer. I paid good money for my Mac system and use it for development and don't have time for these marketing hassles.

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Monday, September 14, 2015

Regex - Contains THIS String But Not THAT String

Here's a regular expression that will return lines that have THIS string but not THAT string:



This could be useful if you are searching for tables that do not have the id attribute:


This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Friday, August 28, 2015

Difference between Map and Filter


  • You can prettify your JSON output by passing null and the number of spaces to indent.
  • Another useful high order function you can use is reduce which combines the elements of an array to a single value.
  • The logic that each function (map, filter reduce) calls to manipulate the original array of data is called a closure. Note that there is no formal function declaration and no function name for a closure.

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Wednesday, August 12, 2015

Revert Commit into a Branch

Suppose you accidentally push file changes in the form of a git commit to your master branch, but you intended to first create a branch of those changes and push the branch.

Here's how to fix that....

git reset HEAD~1 --hard                                        # move the head back before your commit
git push -f                                                    # make git accept it
git fetch                                                      # get latest 
git reset origin/master                                        # undo non-pushed commit
git checkout -b NEW_BRANCH_NAME                                # create new branch for file changes
git stash save 'moving committed changes to NEW_BRANCH_NAME'   # workstation looks like it did before you made changes
git cherry-pick COMMIT_HASH                                    # grab your changes via cherry-pick
git push -u origin NEW_BRANCH_NAME                             # push NEW_BRANCH_NAME with changes to remote repo

You will probably want to run make note of the git hash created by the original commit BEFORE running these commands. You can run the following to get that hash value: $ git log

This assumes you want to push your changes into a NEW_BRANCH_NAME, which will likely get merged into the master branch after a pull request and code review.

Assuming this works, you should delete the stash you made using $ git stash drop


Is it possible to retroactively turn a set of commits into a branch?
Squash my last X commits together using Git

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Friday, July 17, 2015

Regex for example.com (not www.example.com)

I had a failing test that indicated that I had some sample code in my source.

So, I needed a nifty regex to find it.

Failing Test

A test failed with the following message:

Authenticate User and get his Role
cookies: [ 'name=undefined; Domain=.example.com; Path=/admin; Secure',
  'session=7bi4j6U2VYleeAC_kLseiA.IBKutIFH6iuag66-hrWwyVf175J6NaJICEkgMLC1gl9OrWpvpNTpv-SQ3QJCJe_VfB4MBwjIkpwNgwEM8R99qp6qNm0CXYqbdjaq6_R7PB-O2Vm-cFavjZEohzkNVVnYjlu3BDWFU17y4ENZaMNADXiZ150Pf_nGvdoVZmNFiZh2ysiIk0eRmSOiLEJtkWyj84btuBew0ylUKLn0ywRlnFBllKm4X8_GrCaWxRCFG6iS9T76r_X9PDb9BQKC6eZB2hQRKsykidJ3OY-G5PC_GJwS_LGlgYwP25-0BP8V1524LCvEZ3w5qZBX2kmCxrpwVA4ycls1F4fz3XSDLCyOnxO9rYpP2JYwjfYhkgV71-JNBogeVdVDL_JqWDTjZJZLDPrOp4ZmESrh6kI3n_f6zuxaWvuYK-c31_icvWm_g1eXmpKo4CVB0-Vv6EYuDuh5tS9y4yybr9mMrnZaSwHpyTp6YBsd9i0H6cyHZ7YiyIQCVa30We0iTa335arKG2zG.1437151277357.3600000.UePJmiwfcRyceI0eQ32BbXyekHbzvQ1tk5tP2_8O7T8; path=/; expires=Fri, 17 Jul 2015 17:41:18 GMT; httponly' ]

Searching for ".example.com"

Searching for ".example.com" yielded too many results because there were a lot of "www.example.com" strings found.

Magic Regex

This regular expression did the trick:


It says, "Give me everything that matches "example.com" but does not also contain "www".

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Wednesday, July 15, 2015

The Philosophy of Success at Work


Here are some related quotes from some notable people:

“To be is to do.” — Socrates
“To do is to be.” — Jean-Paul Sartre

“The way to be is to do.” — Dale Carnegie
“The way to do is to be.” — Leo-tzu, Chinese philosopher

“We act as though comfort and luxury were the chief requirements of life. All that we need to make us happy is something to be enthusiastic about.” —  Albert Einstein

“Success consists of going from failure to failure without loss of enthusiasm.” — Winston Churchill

“Nothing great was ever achieved without enthusiasm.” — Ralph Waldo Emerson

I think they are all correct.


You need to be in at least two of the circles above to stay employed.

You need to be in all three of the circles to thrive at work.

At the heart of success in your endeavors is your enthusiasm.

So, find what you truly enjoy doing, deliver good work and be nice and you will be successful at it.

This work is licensed under the Creative Commons Attribution 3.0 Unported License.