Posts Tagged Os X
Setting up Rails on a Clean Install of Mac OS X Lion
Posted by John in Ruby and Rails on October 25, 2011
I realise that OSX does not have a registry to clog up but I have just reinstalled Lion on my Macbook Air; probably a hang up from Windows. This is a checklist for installing Homebrew >> Rails.
- Install XCode 4.1 (There are issues with the 4.2 compiler and certain rubies and gems)
- Install Homebrew
- https://github.com/mxcl/homebrew/wiki/installation
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
- Ensure Homebrew apps are in path before Mac apps
export PATH=/usr/local/bin:$PATHor edit /etc/paths
- Install Git
brew install git(thanks Brendan)
- Install SSH keys
- Generate or copy from ~/.ssh from a backup.
- Install RVM
- https://rvm.beginrescueend.com/rvm/install/
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )- Add
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.to bash_profile - Restart shell
- Run
rvm | head -1
- Install latest Ruby and set as default
rvm install 1.9.3(make sure you are using Xcode 4.1)rvm --default use 1.9.3
- Install Rails
gem install rails
I keep all my .config files in Dropbox and run a bash script to create aliases in my home folder.
Installing WordPress on your Mac for Development
The Stack
To run WordPress locally you will need Apache, MySQL, and PHP installed. Although OS X comes with some of these it is more convenient to use MAMP. MAMP comes in a free version and a Pro version, for my purposes the free version should be fine.
Installation is just copying a folder from the disc image to your applications folder and removal is just a case of deleting the folder. Once the folder has been copied just start MAMP which will start the servers and open the home page on port 8888.
From the preferences > Apache pane set the document root to wherever you want to put your sites. I set mine to ~/dev/sites/.
The Database
Click on open start page on the MAMP dialogue then click on phpMyAdmin, enter a database name for your WordPress database then click on create. Click on privileges and create a new user with full privileges for the database.
WordPress
Create a subdirectory for your new web site in your sites directory, download WordPress from wordpress.org and unzip the contents of the download into the subdirectory.
Rename the file wp-config-sample.php to wp-config.php then edit it to fill in the database details and change the salts and keys.
Navigate to http://localhost:8888/ and you should see the subdirectory, click the link and you should get taken to the WordPress install page (if you get error connecting to database it is likely that either your database server is not running of there is an error in your wp_config.php). Fill in the blog title, username, password, and email, hit submit and you are done.
Learning Ruby (on Rails)
Posted by John in Ruby and Rails on December 15, 2010
Most of my programming career has revolved around Microsoft technologies, starting with Visual Basic 3, up through the various versions to VB.Net, then switching to CSharp shortly after DotNet came out of beta.
I think I know the MS development stack fairly well and I like the direction they are moving in with the likes of MVC3 and Razor, Nuget etc. but it seems a fair amount of this ‘direction’ may be coming from the Rails community.
I have decided to give myself 2 weeks to ‘learn’ Rails, although I may get distracted by the Christmas holidays (and the fact that we will have an extra 6 kids and 3 adults staying with us for 2 weeks) and will record some of it here.
I have done a little research in preparation and bought a couple of ebooks from the prags:
They seem to be considered ‘definitive’ and cover the current versions of Rails (3.0.3) and Ruby (1.9.2).
The only other purchase I am likely to make is an IDE or editor. I code on a Mac, even when using Visual Studio so I have a few more options than most Windows users. The recommendation seems to be that, if you are on Windows, install a Linux VM for Ruby development. The favourite environment for the Mac looks to be Textmate although there are a few IDEs available such as JetBrain’s RubyMine and Aptana Studio, both of these are available for Windows, OS x, and Linux. I am a fan of JetBrain’s Resharper so will try RubyMine, the trial is 30 days so no need to make a purchase decision yet.
Other references that I expect to find useful over the next 2 weeks are:
Macs, Parallels and Keyboard Layouts
I am currently developing on a Mac, running Visual Studio on a Windows 7 VM courtesy of Parallels. There are a number of issues to resolve the first of which is the key mappings.
I am using the Mac bluetooth keyboard and a few keys are mapped incorrectly:
| Pressing this key | Results in this output |
| § | ` |
| ± | ¬ |
| @ | “ |
| “ | @ |
| \ | # |
| | | ~ |
When using OS X alt + 3 produces a # and alt + 2 produces a €. Unfortunately in Windows alt key combinations are normally used to launch menu items.
The answer to this is a free program from Microsoft called Keyboard Layout Creator.
Download and install this (on your Windows VM) then you can use it to create a correct layout. Once you have the layout you can create an installer to install your keyboard layout on however many VMs you like.
You can download the layout I created and open the file in the layout creator to build your own installer. I have also uploaded the installer I created (mostly for my own reference, I make no guarantees it will not fry your system, please use a good virus scanner etc.).
Once you have installed the layout open Keyboards and languages:
Then change the default input language and keyboard:
Any applications that are open need to be restarted, but then you should have all keys working correctly.
I have mapped # to Ctrl + alt + 3 and € to ctrl + alt + 2 which should work as long as the application you are in is not using them as shortcut keys.