Tag Archives: 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.

 

 

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?)

 

 

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.

 

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.

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]

 

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.

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]