Tag Archive os x

Maximize a Window in OS X 10.10 (Yosemite)

One of the changes in Yosemite is that the green maximize button on windows no longer maximizes, but puts the window into full screen mode. For how I work, this is a productivity killer. I don’t see any setting to revert this behaviour. However there is a workaround.

Hold down the Option key when clicking on a window’s green button to maximize. This will take a little time to build a new habit.

Update

Apparently one can also double-click the window’s title bar, which I’m quite happy to see.

 

 

Tags, , , , ,

Getting MySQL Working After OX 10.10 Yosemite Upgrade

I updated my development computer to OS X 10.10 (Yosemite) and found MySQL was dead. These are notes on what I did to get MySQL running again.

Update the latest MySQL off of their website. At the time of this writing, that is Mac OS X 10.9 (x86, 64-bit), DMG Archive from the MySQL download site.

I found that MySQL would run but MySQL Workbench couldn’t connect. It turns out that the data directory is kept under each version. Thus, when I updated from 5.6.17 to 5.6.21 MySQL was pointing to a fresh new database.

The new version is installed in /usr/local/mysql-5.6.21-osx10 algo similar al viagra.8-x86_64, with the MySQL data files in the data subdirectory. I renamed the data subdirectory to ensure I have a backup and made a copy of the old directory.

sudo cp -rp ../mysql-5.6.17-osx10.7-x86_64/data .

It appears that MySQL is working fine now. Note that this will only work for incremental revisions. If you’re reaching across minor version numbers (such as 5.5 to 5.6), the changes in structure will probably not work. (You did make a backup of the original data directory, didn’t you?)

 

 

Tags, , , ,

Control VMware Fusion from the Command Line

Background

Virtualization has been a key technology for me as a contractor. Because I have multiple clients, keeping their projects sequestered from each other is a snap: one or more VMs (virtual machines) per project. Development, testing, and in some cases deployment is all on separate VMs.

I’ve been using VMware Workstation since it first came out 1999. The ability for me to seamlessly move VMs between Windows, Linux, and OS X has been a key reason I’ve stuck with them for so long.

Automating tasks via scripting one of many reasons I insist that my workstation run  Un*x of some flavour. I’ve been using OS X for quite a while quite happily as a software developer, however VMware Fusion (for OS X) doesn’t present the full set of features available on VMware Workstation (for Linux and Windows). Fortunately hidden under the hood are the same tools.

The Executable vmrun

VMware provides a tool called vmrun that allows common operations to be performed on VMs — starting, suspending, taking snapshots, etc. On OS X it’s tucked away in the VMware Fusion bundle under Contents/Library.

In my shell startup I add the directory to PATH:

[bash]
# VMware Fusion
if [ -d "/Applications/VMware Fusion.app/Contents/Library" ]; then
export PATH=$PATH:"/Applications/VMware Fusion.app/Contents/Library"
fi
[/bash]

Find the Virtual Machine’s .vmx File

To use vmrun you need to have the path to the .vmx file that resides inside of the VM bundle on OS X. For example, I have a VM with an install of RedHat Enterprise Linux 7:

RHEL7 VM

This is actually not a single file, but a directory called RHEL7.vmwarevm. The contents can be seen in the Finder by right clicking:

Show Contents

This will open up the directory and show the various files that make up the virtual machine.

Inside the Bundle

As can be seen, the .vmx file is prominently displayed.

Put the Pieces Together

To start the VM from the command line one uses the “start” parameter. For example, if the above virtual machine were in one’s home directory one can type:

[bash]
$ vmrun start ~/RHEL7.vmwarevm/RHEL7.vmx
[/bash]

vmrun Commands

If one runs vmrun without parameters it gives a farily long summary of commands that it accepts. One can:

  1. control the power state of the VM,
  2. control snapshots,
  3. perform various operations inside a running VM, and
  4. other operations such as installing tools and cloning.

A short list of common operations:

Description Command Parameters
List running VMs list
Start a VM start /path/to/vmx/file
Suspend a VM suspend /path/to/vmx/file
Take a snapshot snapshot /path/to/vmx/file snapshot name

 Additional Information

VMware has a PDF on vmrun here.

 

Tags, , , ,

Python 2.7, Django, and MySQL on OS X

For some reason, getting Python and MySQL talking on OS X has been an annoyance. These are my notes for getting the two to talk to each other in a Python 2.7 virtual environment for a Django project.

The Django 1.6 docs recommend using the MySQLdb package. Its installation uses the mysql_config executable.

I have the following set up:

  1. MySQL 5.6.16
  2. Python 2.7.3
  3. PyCharm 3.1.1, which was used to create
  4. a Python virtual environment with pip located in $HOME/upharm27

[code]
$ locate mysql_config

/usr/local/mysql-5.6.16-osx10.7-x86_64/bin/mysql_config

$ export PATH=$PATH:/usr/local/mysql-5.6.16-osx10.7-x86_64/bin
$ ~/upharm27/bin/pip install mysql-python
[/code]

I have gcc 4.7.2 available, but curiously, the installer gave the following message:

[code]
Installing collected packages: mysql-python
Running setup.py install for mysql-python
gcc-4.2 not found, using clang instead
[/code]

The install succeeded using clang, so it’s nothing more than a curiosity at this point.

I was able to verify that the package was installed with:

[code]
$ ~/upharm27/bin/python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
[/code]

 

Update

I just followed these notes using the latest XCode 5.1 on OS X 10.9 and the mysql-python install failed. Apparently the clang Apple ships produces errors on unknown flags by default. I was able do get around this by:

[code]
$ export CFLAGS=-Qunused-arguments
$ export CPPFLAGS=-Qunused-arguments
$ ~/upharm27/bin/pip install mysql-python
[/code]

Thanks to the good folks at StackOverflow. More details may be found here.

Tags, , ,

Little Schemer on OS X

I’ve joined a local study group that’s going through The Little Schemer. I learned LISP in the early ’80s but never pursued it deeply. (I certainly used Emacs, but never fully embraced it.) My purpose now is as a refresher on recursion.

For a quick useful IDE on OS X, the Dr. Racket IDE seems to fit the bill nicely. (Racket is in the LISP family.)

To use Dr. Racket, the upper portion is an editor, and when run, provides an interactive command prompt below. (Dr. Racket will probably complain about needing a language. Simply select Racket.)

To use Dr. Racket with The Little Schemer, one will need to add the definition for atom? immediately after this opening line, then run the script to bring up the command line.

[lisp]

#lang racket

(define atom? (lambda (x) (not (list? x))))

[/lisp]

Also, one should note that Scheme requires literals such as atom as lists to be quoted:

[lisp]

(list? (quote ()))

(list? ‘())

(atom? (quote abc))

(atom? ‘abc)

[/lisp]

 

Tags, , ,

Install wget on OS X

These notes assume Xcode and the command-line tools are installed.

Get the current wget from the GNU FTP site. As of the date of this article, wget 1.14 is current. (Update: As Alex notes in the comments, 1.15 is available.)

Building is the typical GNU build sequence, but use the –with-ssl=openssl option with configure.

[code lang=”bash”]
curl -O ftp://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
tar xvzf wget-1.15.tar.gz
cd wget-1.15
./configure –with-ssl=openssl
make
sudo make install
[/code]

And it’s done.

Tags, , ,

How to Install gcc 4.7 on Mac OS X

XCode installs gcc 4.2 which has some bugs that prevent me from running skeinforge. This is how I installed gcc 4.7.

First install MacPorts. Then use the port command to install and activate the new gcc.

[code language=”bash”]
sudo port install gcc47
sudo port select gcc mp-gcc47
hash gcc
[/code]

To make the previous gcc active, use

[code language=”bash”]
sudo port select gcc none
hash gcc
[/code]

Tags, , , ,

Fixing Mountain Lion Runaway parentalcontrolsd

We upgraded a machine to Mountain Lion (10.8.2), but found that parentalcontrolsd was running constantly with high CPU usage. The steps to correct the problem were found on the Apple Support Forums.

  1. Disable parental controls on all users.
  2. Delete the folder /Library/Application Support/Apple/ParentalControls
    Please note that this command is a little dangerous.[code lang=”sh” light=”true”]$ sudo rm -rf "/Library/Application Support/Apple/ParentalControls"[/code]
  3. Restart Mac.
  4. Enable parental controls again.

Tags, , ,

Installing gitolite on a Mac

I’ve come to love gitolite for hosting private git repositories. It’s very easy to administer and trouble-free.

On one project, I needed to share a very large git repository between two virtual machines. I didn’t want the overhead of using a private git repository out on the Internet, just something local, like my workstation that runs OS X.

I used the System Preferences to create an account named git, and followed the gitolite install instructions.

I ran into a couple of problems that were easily resolved.

Path for Installer

First, to address gitolite complaining about not being able to find itself, I created a .bash_profile with the following:

[bash light=”true”]
export PATH=/Users/git/bin:$PATH
[/bash]

Now I could run the gitolite install cleanly. I would recommend doing this first thing after creating the git account to host gitolite.

Help gitolite Find git

I installed git from the link on the front page of the git web site. This installs git in /usr/local/git/bin, which gitolite doesn’t like out of the box. The fix is easy. When gitolite installs, it brings up the config file (~/.gitolite.rc) in an editor for you to tweak.

Find the line

[bash light=”true”]
$GIT_PATH=””;
[/bash]

and change it to

[bash light=”true”]
$GIT_PATH=”/usr/local/git/bin”;
[/bash]

This will prevent error messages such as

[bash light=”true”]
$ ssh git@localhost
PTY allocation request failed on channel 0
Can’t exec “git”: No such file or directory at /Users/git/bin/gitolite.pm line 562.
Use of uninitialized value $git_version in substitution (s///) at /Users/git/bin/gitolite.pm line 563.
hello Yourkey, this is gitolite v2.2-4-the gitolite config gives you the following access:
Use of uninitialized value $git_version in concatenation (.) or string at /Users/git/bin/gitolite.pm line 564.
R W gitolite-admin
@R_ @W_ testing
Connection to localhost closed.
[/bash]

from appearing and preventing gitolite from working.

Update 1 September 2013

These instructions seem to still work with gitolite 3, with additional commentary:

If you ssh into your OS X machine, you might see the message:

[bash light=”true”]
$ ssh git@localhost
PTY allocation request failed on channel 0
[/bash]

gitolite is still working. There is simply a collision between ssh versions. You an get a list of the repositories you’re allowed to access by one of these two commands:

[bash light=”true”]
$ ssh -T git@localhost
$ ssh git@localhost info
[/bash]

Tags, , , ,

OS X, Apache, Tomcat, and mod_jk

I spent some time with a colleague from South Africa yesterday. He’s a long-time Windows user that writes in Java. He has a new MacBook Pro, and we scratched our head why Apache+mod_jk+Tomcat was blowing up on him.

JAVA_HOME

The first thing we had to get right was the JAVA_HOME variable. If it’s not set right when compiling mod_jk, you’re out of luck. On OS X there is a program that spits out the right value. We put the following in his ~/.profile. Please note the back ticks (accents graves) to run the java_home program.

export JAVA_HOME=`/usr/libexec/java_home`

mod_jk

With $JAVA_HOME set correctly, compiling mod_jk was straightforward. Download the mod_mod_jk tarball, unpack it, and change directories to the native subdirectory. The following should work cleanly.

$ ./configure --with-apxs=/usr/sbin/apxs
$ make clean ; make
$ sudo make install

Apache Configuration File

Be aware that OS X Lion has some lines (commented out) for support for mod_jk. Be sure to uncomment those lines. Previous versions of OS X don’t have these lines, so you’ll just add the load module directive and Jk* commands in the usual places.

That’s it, really. Once JAVA_HOME and the Apache configuration file were straightened out, things worked.

Tags, , , , , ,

%d bloggers like this: