MacBook Pro and the SMC cure

2017-07-11  |   |  apple   Mac OS X  

The physical parts of your MacBook (fans, ports etc) behaves erratically? I might have a cure.

A story of crashes

My MacBook Pro was getting on my nerves lately. When plugged to my Thunderbolt dock and thus my external monitor, my laptop would crash randomly. Sometimes, once every 2 weeks, sometimes several times a day. I tried many things, like not starting all of the utilities one usually uses to verify that they were not involved but I could not find a culprit.

Then one day, I saw that one of my Thunderbolt port would not accept my Thunderbolt-Ethernet adaptor while the other did (the connection did not show up). I was convinced my laptop had a faulty hardware and needed repair.

System Management Controller to the rescue

So I called Apple and the support person told me to try something first: reset the SMC (System Management Controller) by pressing Shift+Control+Option on the left side and the power button for 10 seconds while starting the computer (after a full shutdown) - full procedure here.

And voila, all my problems are gone.

What is SMC anyways?

It turns out that there is a chip that manages a lot of hardware inside your laptop: fans, LEDs, IO ports, external displays, battery, etc. So slapping that chip on the face (figuratively) might make a lot of things go better.


Homebrew formulae for Mutt with sidebar and trash patches

2016-03-15  |   |  Mac OS X   tool  

Homebrew's Mutt formulae is in a bit of a disarray. I can't blame them as Mutt has a bunch of not quite maintained patches not quite fully compatible with one another.

The problem is that some of these patches are very very useful. I have created a tap to maintain Mutt with the two key patches I use:

  • sidebar
  • trash

At the time of writing, it uses Mutt 1.5.24 but I might update it. To use the formulae, do:

brew tap emmanuelbernard/mutt
brew install emmanuelbernard/mutt/mutt

// or alternatively

brew install https://raw.githubusercontent.com/emmanuelbernard/homebrew-mutt/master/Formula/mutt.rb

I personally build them with the following options

brew install emmanuelbernard/mutt/mutt --with-sidebar-patch --with-trash-patch --with-gpgme --with-s-lang

s-lang supposedly has better support for color schemes like Solarized.

You can find the code at https://github.com/emmanuelbernard/homebrew-mutt.


Unstuck the unread count of Apple Messages app on Mac OS X

2015-02-20  |   |  apple   Mac OS X  

The text message synchronization between iOS and Mac OS X devices is very useful. That is until one of the unread count is stuck. There is nothing more irritating than a false unread badge.

It has happened to me on Apple Messages (iMessages) in Max OS X Yosemite. The message would "unread" itself in front of my eyes. I deleted the message, that solved that part.

But the unread count remained at 1. I fumed for a couple of days until I found the solution. Open your Terminal application (in Applications/Utilities) and type

killall Dock

The incorrect unread count disappeared. I can sleep now.


Fixing Page Up and Page Down in Mac OS X Terminal.app

2013-12-12  |   |  Mac OS X   tool  

I am currently trying to move from iTerm to Terminal.app.

Terminal.app maps the Page Up/Down action to move around its buffer. This is quite annoying when you use text applications with their own buffer like mutt, vim, weechat etc).

Fortunately, there are two solutions, one easy and one more permanent.

Use Shift + Page Up

The easy one is to use Shift + Page Up instead of Page Up. Page Down works the same. The inconvenient is that you need to train your muscle memory.

Update the Terminal.app mapping

The more permanent one is to change the Terminal.app behavior.

Go in Preferences->Settings, select the right profile and go in the Keyboard tab. Find the Page Up entry and edit it to send text. Then type the ESC key followed by [5~. For good measure, I mapped Shift + Page Up to the Scroll Page Up action.
Do the same for page down with the following text ESC key followed by [6~.

You're all set.


No more Java Preferences for you!

2012-10-31  |   |  Java   Mac OS X  

Java on Max OS X is a moving target to say the least since stewardship has moved from Apple to Oracle. I had a lot of trouble to make Eclipse run on my machine making me feel like a customer of The Soup Nazi in Seinfeld.

Let me explain some changes.

The failure

I tried to run Eclipse Juno on my machine and got the following encouraging error

The JVM shared library /Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64 does not contain the JNI_CreateJavaVM symbol

Eclipse always uses the system default JVM on Mac OS X and as far as I know you can't change that. In theory that's not a big deal, you just have to change the default JVM to use via the Java Preferences application.

No more Java Preferences application

Apple recently removed the Java Preferences application from Mac OS X as they deemed it to be useless. In a sort of twisted way - aka we don't care about developers - they were right.

It has been replaced in the Java Oracle distribution by a panel in System Preferences under the Other category. Well except that this panel only deals with Oracle JVMs. So if you happen to have OpenJDK or any other JVM installed, you can not choose (or "unchoose") them.

The side effect for me was that OpenJDK was selected as the default JVM and this created this user friendly error when starting Eclipse.

Hats off to Henri Gomez for helping me find a way out. You basically need to go to /Library/Java/JavaVirtualMachines and remove OpenJDK

sudo rm -fR openjdk-1.7-x86_64

In my case I actually moved it somewhere else. What if I want to use OpenJDK too? F**k you! told me Orapple.

The combination of:

  • Apple stopping bundling the JVM
  • Oracle coming up with an Oracle only replacement
  • Apple removing a useful tool

makes the open JDK community at large feel quite unwelcome. So much for an open source project and community where both Apple and Oracle are major stakeholders.

By the way that's not the only glitch I've experienced when moving from the Apple VM to Oracle VM. JAVA_HOME now points to the JDK instead of the JRE.

Anyways, moving along.


Installing po2xml and xml2pot on Mac OS X

2012-10-31  |   |  tool   Mac OS X  

Hibernate documentation system uses po2xml and xml2pot to build translations. Unfortunately, Homebrew does not have a formula for it and I don't think I have the knowledge to work on such thing.

The solution is to install Macport. There is a nice UI installer. Make sure to chose the one specific to your Max OS X version.

MacPort does change your .bash_profile. Because I want to give Homebrew's executable priority, I make sure to put Macport changes after homebrew in the PATH variables.

Update Macport

sudo port -v selfupdate

Then install po2xml. Unfortunately, po2xml does not come as standalone package, you have to install all of KDE

sudo port install kdesdk4

Then wait for freaking ever for everything to compile. By the way, source packaging is not eco-friendly. Think about the amount of CPU needed every time you update some package...

Once that is done, add po2xml and xml2pot to your path

PATH=$PATH:/Applications/MacPorts/KDE4/po2xml.app/Contents/MacOS
PATH=$PATH:/Applications/MacPorts/KDE4/xml2pot.app/Contents/MacOS

And you are good to go!


Customize titles of your terminal window

2012-02-28  |   |  Mac OS X   tool  

If you are like me, you use many many tabs in your command line terminal. By the way, iTerm2 is a very nice improvement over the vanilla OS X Terminal app.

To recognize tabs, I like to display the name of the current directory and add the directory it is contained in if more space are left. Open your .bash_profile or .profile file and add the following

function local_dir_and_within {

__LAST="${PWD##*/}"

__IN="${PWD%/*}"

__IN="${__IN/#$HOME/~}"

TITLE_TAB="$__LAST in $__IN"

echo -n $TITLE_TAB

}

export PROMPT_COMMAND='echo -ne "\033]0;$(local_dir_and_within)\007"'

Your tab title will now look like hibernate-search in ~/code.


iTunes vs incoming connection and VPN vapors: fixes for unApple behaviors

2011-10-28  |   |  apple   Mac OS X  

I've just found solutions to two nagging problems I had on Mac OS X.

iTunes and incoming connection requests

Some times ago, iTunes has started to ask me every time it launches "Do you want the application “iTunes.app” to accept incoming network connections?". It gets quickly annoying.

There is a very simple solution. Move iTunes.app (from /Applications) to your trash, download iTunes and install it. The first time you start it, iTunes will ask you to change your firewall settings. Do so and you will be good to go.

If you want to know the tiny details, somehow your iTunes package got changed or corrupted and the firewall was not trusting iTunes anymore.

VPN connection after sleep

Another problem I had was that after the laptop goes to sleep, it is sometimes impossible to reconnect to a VPN. If that happens, you need to restart the right daemon. Open a terminal and run

sudo launchctl stop com.apple.racoon

sudo launchctl start com.apple.racoon

You are now able to connect to your VPN again.


Automatically lock your computer when you go away

2010-04-01  |   |  apple   Mac OS X  

If you are like me, your colleagues like to pown you when you leave your laptop unlocked. Here is a super easy solution to lock your Mac automatically when you leave it: if your cellphone is out of bluetooth range, lock your computer. Easy, efficient.

Here is how to do it:

  • Download Proximity: this application does detect bluetooth devices and lets you launch scripts upon detection or absence of detection (download page here).
  • Copy Proximity.app in /Applications
  • Start the Proximity.app and open its preference panel (the application adds itself to the menu bar next to your clock)
  • Reduce the device monitoring to 30s or so (less time for your colleagues to mess around)
  • Add the device (the device needs to be linked with your computer bluetooth, you can do that in System Preference)
  • Add an AppleScript that will be run when your cellphone goes out of range (see below)
  • Optionally add an AppleScript that will be run when your cellphone goes back in range

The AppleScript to lock your computer is pretty simple. Create a file name out-of-range.scpt and add:

-- out-of-range.scpt

tell application "ScreenSaverEngine" to activate

You can do many more things in these AppleScripts like:

  • change your Adium and Skype status
  • unlock your screen when you come back in range

This other blog entry has a fairly compete setting example. I personally purposely do not unlock the screen when I come back in range. It's safer to ask for the password explicitly incase someone... borrows your cellphone.

Unlike some more complex apps, Proximity is pretty simple and does not let you decide at which range a bluetooth device is considered out-of-range. The good thing is that it is pretty soft on your cellphone battery.


JarInspector on Mac OS X

2008-08-29  |   |  java   Mac OS X  

There is a tiny little utility that let's you inspect JAR/WAR/EAR files on the Mac OS platform. The software is available here. Install it. To open a JAR, simply right click and chose JarInspector as the application. I personally did not set JarInspector as my default .jar application to let the default JAR launcher kicks in but I have been very close to.

Amongst the useful features:

  • navigate in your jars recursively
  • edit/view files (useful for MANIFEST.MF)
  • decompile a class
  • find a file/class by name

By the way, this utility also opens zip files.

Enjoy.


Name: Emmanuel Bernard
Bio tags: French, Open Source actor, Hibernate, (No)SQL, JCP, JBoss, Snowboard, Economy
Employer: JBoss by Red Hat
Resume: LinkedIn
Team blog: in.relation.to
Personal blog: No relation to
Microblog: Twitter, Google+
Geoloc: Paris, France

Tags