One OS-X Tip and One MySQL Dev Tip

I’ve downloaded and installed MySQL recently. I was doing a few things to make it easier to work with and thought, “I ought to document this, it isn’t real intuitive without pages of documentation being read.” So here’s some tips.

1. Make sure you can view all of your files in OS-X, especially if you intend to do development. What I’ve found to be the easiest way to do this, is to setup a script application on the desktop. Open up the AppleScript Editor, quickest way is to press the ⌘ + Space Bar and type in applescript and hit enter. In the editor enter the following code:

[sourcecode language=”bash”]
set dotVisible to do shell script "defaults read com.apple.Finder AppleShowAllFiles"
if dotVisible = "0" then
do shell script "defaults write com.apple.Finder AppleShowAllFiles 1"
else
do shell script "defaults write com.apple.Finder AppleShowAllFiles 0"
end if
tell application "Finder" to quit
delay 1
tell application "Finder" to activate
[/sourcecode]

Then save the file with the following options in the save as dialog selected.

AppleScript Editor Save As Dialog w/ Appropriate Settings
AppleScript Editor Save As Dialog w/ Appropriate Settings

The only thing you really need to set is the File Format to “Application” and be sure nothing is checked. Now whenever you double click the file on the desktop, the finder will automatically be restarted with all the files visible, and double clicking again will hide all of the files from view.

2. Setup MySQL and when done, make sure to add the appropriate aliases to the .bash_rc file for the bash shell. These include setting these two aliases:

[sourcecode language=”bash”]
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
[/sourcecode]

That’s it for now, more tidbits to come and a write up of my extended weekend PDX hacking sessions with Geoloqi.

Bash, Ruby, and Such Console Installation Version Management Bits for OS-X

I went to reinstall RVM (Ruby Version Manager) and got a message that the command wasn’t available. I realized, after fiddling around for a while that I didn’t have bash setup, and I had tried to run the standard quick install of:

[sourcecode language=”bash”]
bash < [/sourcecode]

…I had not setup bash shell as my shell on this Mac?! Oops. So since I’m a virtual noob sometimes, and I have no idea how to setup bash, I did some searching and came up with this solution.

First, switch to bash.

[sourcecode language=”bash”]
chsh -s bash
[/sourcecode]

Then create yourself a .bash_profile so that you’ll be able to initiate variables and such that you’ll need in the shell. These are used when working with Ruby, Rails, and a whole host of other things. To create a .bash_profile you can follow these commands.  (Snagged from this find)

[sourcecode language=”bash”]
cd ~/
touch .bash_profile
open -e .bash_profile
[/sourcecode]

Then add this to the bash file.

[sourcecode language=”bash”]
# place in ~/.bash_profile as the very last line
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
[/sourcecode]

Now run the install (usually you’re told to setup this bash file afterwards, but figured we might as well get it done).

[sourcecode language=”bash”]
bash < [/sourcecode]

Next exit (or whatever your restart of bash technique is) and open your bash terminal back up. Type this command to be sure we’re on the right path.

[sourcecode language=”bash”]
type rvm | head -n1
[/sourcecode]

Now to install the latest Ruby on Rails bits you can issue a command like this.

[sourcecode language=”bash”]
rvm install 1.8.7
[/sourcecode]

However, OS-X already comes with 1.8.7, so you’d probably want to install 1.9.2. I issued the 1.8.7 install since I knew, previously, I’d dorked up the install a few days ago. So it is also a good way to make sure your install is cleaned up. I’m sure though, it could possibly mess things up if you’ve tweaked things the wrong way – but it sure seems to be the case that Ruby, Rails + RVM just works. 🙂

[sourcecode language=”bash”]
rvm install 1.9.2
[/sourcecode]

Once those are installed you’ll want to set one as default. I’m went with 1.9.2 for now. This can be changed later if need be.

[sourcecode language=”bash”]
rvm use 1.9.2 –default
[/sourcecode]

Anyway, that’ll get you started on OS-X if you’ve run into the “I’m only running the Terminal in its default setup, I need some bash” situation. 🙂

Happy coding, hacking, and gem installing!

References:

Some references are included above as links, but these below didn’t fit exactly in context at any point, I however used them none the less.