Snow Leopard Install, Ruby on Rails MySQL dev machine
Here are some helpful notes if you’re upgrading to Snow Leopard (SL), and you do Ruby on Rails / MySQL development.
From a dev perspective, there are a number of things that changed with the update to Leopard.
On the Snow Leopard DVD, under “Optional Installs”, install “Xcode.mpkg”. Use all default options.
If you were using MacPorts,it will need to be updated.
Install the latest for SL (1.8.0): http://www.macports.org/install.php
Then, follow this guide to update MacPorts – I suggest doing the manual method to make sure you don’t install stuff you don’t really need. I installed coreutils, and it installed pretty much everything else I needed. If you’re running MySQL through MacPorts, don’t add it back. You’ll be guided by the Ruby on Rails guide to install the 64-bit version next.
The user will probably want wget… installing that gets you openssl, zlib.
http://trac.macports.org/wiki/Migration
Ruby on Rails__
This is an excellent guide, do follow this:
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard Before you read this post and give up, look up your errors in the comments. I had 2 or 3 issues and what do you know? Others had the same issues, I followed a few of the comments where people address others’ issues and viola… working nicely now. Another tip for MySQL: When you install MySQL from mysql.org, be sure to pick the right one.. I kept getting the PowerPC one because it was at the end and had a “64″ on it… I realized I needed the other one.
This should get you through most of the changes for Ruby on Rails, and a good start on developer machines in general.
Post any questions you have.
Cheers,
Richard
64-bit OS X Snow Leopard defaults to 32-bit kernel
Why?
It defaults to the 32-bit kernel on bootup because not all software you may have may be compiled / designed for 64-bit. Moving from 32 to 64 is a gradual process. 64-bit applications can still take advantage of being 64-bit and using multiple cores, but the kernel itself is still 32-bit by default. Only Snow Leopard Xserve boots into 64-bit kernel by default.
How do you change this?
If you have a machine capable of 64-bit processing, and you’re bold enough to go 64 only, hold down 6 and 4 on boot up. It will make the machine boot up in 64-bit kernel mode – but be ready for 32-bit applications to break.
Here’s how you find out if you’re machine is capable of 64-bit processing:
http://support.apple.com/kb/HT3696
Snow Leopard upgrade, Exchange 2007, PlugSuit, VPN
The main reason for me to upgrade is to start using Mail and iCal and leave the daily torture of using Entourage.
Mail and iCal work great. I had a little tweaking to do to make it check Exchange mail through our external URL (webmail). Just had to use the full UPN (UserPrincipalName) for the username, AD password, and the external URL for both internal and external servers.
The PlugSuit is incompatible (particularly with Quicktime I think). Here is how you disable it (you might have to enable and then disable it for the disabling to take).
When trying to start VPN, I got the horrible CiscoVPN Error 51 I complained and solved here.
But this time, I couldn’t fix it. It seems the CiscoVPN folder I referenced was removed. After some investigation, I found that Apple has included VPN capabilities into the OS. You just go to your System Preferences, Network, and hit the + to add a new network interface, select VPN. Then select whatever VPN parameters you need to – check with your pleasant and always helpful IT Admin for the params.
Cheers,
R
“Bad CPU type in executable” MySQL upgrade for 64-bit following Snow Leopard install
Recently, like many others, I upgraded to Snow Leopard on my MBP. I do lots of development on my machine (Ruby on Rails, MySQL, Java, .NET over VMWare + Vista Ultimate, etc.).
I’ll post my thoughts on the whole experience, but in this post, I want to highlight an issue I ran across.
I was previously running 32-bit MySQL 5.0 installed over Mac Ports. After I ran through this great post on upgrading to SL, I found I started getting this error in my RoR log:
Bad CPU type in executable…
As it turns out, I actually had installed “Mac OS X 10.5 (PowerPC, 64-bit)” from MySQL, instead of what I should have installed: Mac OS X 10.5 (x86_64).
The solution:
Just download the right one and install it. I have a 64-bit capable, Intel Core 2 Duo processor, so this was the right one for me. Here’s how you find out what you have.
Good luck!
Ruby / Rails: Remove Extra Space
…or anything else you want from a string.
" myemail @ address. co m ".gsub(/\s/, '')
gsub() substitutes all instances found (g = global), if you just want to substitute the first instance use sub()
Or, if you want to trim the whitespace from each end:
result = " myemail@address.com ".strip
To just trim the whitespace on the left or the right, use these (respectively):
lstrip()
rstrip()
MySQL: Reset ID Auto-Increment
ALTER TABLE tablename AUTO_INCREMENT = 1
Auto-increment is the thing that makes the primary key (integer) increment by 1 each time a record is inserted. Say you have 10 records (1..10). If you delete 9 and 10, the next ID is going to be 11, not 9. However, if you run the SQL command above, you can reset it to the last record ID, plus 1 – making the next record in this example, 9.
If you happen to want to do this in a migration file, just use “execute.”
def self.up
execute 'ALTER TABLE tablename AUTO_INCREMENT = 1'
# then go on to populate the right way
Skill.create(:id => 1, :name => 'Ajax')
...
end
def self.down
Skill.find(:all).each { |s| s.destroy }
end
Mirroring script for SQL Server / Sharepoint
http://spadmin.spaces.live.com/blog/cns!F030C52B8E5517C3!352.entry
I was working in one of my SharePoint test labs this weekend, and decided to write a script that would recycle, stop or start all of the SharePoint Key services. Copy the text and save it as ManageServices.bat
Enjoy
@ECHO OFF
:CHOICE
CLS
ECHO.
ECHO **********************************************************************
ECHO.
ECHO ** Recycle, Stop, Start SharePoint Key Services
ECHO.
ECHO ** Created April 23 2008
ECHO ** Gene Magerr
ECHO ** genemagerr@hotmail.com
ECHO ** Version 1.0 – April 23 2008
ECHO ** 1.1 -
ECHO ** 1.2 -
ECHO **
ECHO **
ECHO ** You have a royalty-free right to use, modify, reproduce, and
ECHO ** distribute this script file in any way you find useful, provided that
ECHO ** you agree that the creator, owner above has no warranty, obligations,
ECHO ** or liability for such use.
ECHO.
ECHO ** This batch file will Recycle, Stop or Start all of the key
ECHO ** SharePoint 2007 services. It will also do an IISRESET /NOFORCE
ECHO ** after each of the tasks.
ECHO.
ECHO **********************************************************************
ECHO.
ECHO Please choose a menu option.
ECHO.
ECHO Recycle all services …………………. 1
ECHO Stop all services ……………………. 2
ECHO Start all services …………………… 3
ECHO Quit (without affecting services) ……… 4
ECHO.
CHOICE /C:1234 /N /T:180 /D:4
ECHO.
IF ERRORLEVEL == 4 GOTO END
IF ERRORLEVEL == 3 GOTO START
IF ERRORLEVEL == 2 GOTO STOP
IF ERRORLEVEL == 1 GOTO RECYCLE
:RECYCLE
ECHO Stopping and restarting key services
ECHO.
net stop oSearch
net stop SPAdmin
net stop SPTimerv3
net stop SPTrace
net start oSearch
net start SPAdmin
net start SPTimerv3
net start SPTrace
PING 1.1.1.1 -n 1 -w 2000 >NUL
ECHO Recycling IIS
ECHO.
IISRESET /NOFORCE
PAUSE
GOTO CHOICE
:STOP
ECHO Stopping key services
ECHO.
net stop oSearch
net stop SPAdmin
net stop SPTimerv3
net stop SPTrace
PING 1.1.1.1 -n 1 -w 2000 >NUL
ECHO Stopping IIS
ECHO.
IISRESET /STOP
PAUSE
GOTO CHOICE
:START
ECHO Starting key services
net start oSearch
net start SPAdmin
net start SPTimerv3
net start SPTrace
PING 1.1.1.1 -n 1 -w 2000 >NUL
ECHO Starting IIS
ECHO.
IISRESET /START
PAUSE
GOTO CHOICE
:END
Using SQL Alias for failover with Sharepoint (SPS 2007)
SPS 2007 does not have any support for automatic failover to the mirror server.
Microsoft suggested using a SQL Alias or the following approach:
The approach for failover is
Ø If the SQL server falls over, use the stsadm command RenameServer to change the db server name, then stop & restart IIS & the timer service.
Ø If a single db other than configdb falls over, detach & reattach the db using the UI or via stsadm commands.
Ø If configdb falls over, the admin must use PSConfig.exe’s configdb command, or the renameserver command. If they use the latter, they’ll have to detach & reattach the other db’s on the same server, to move those back to their original sql server location.
The above approach seemed to be pretty complicated so I decided to use the SQL Alias approach and have written a windows service to monitor the things, here is an overview of the process:
* using cliconfg.exe, create an alias on each SharePoint server in the farm with a name of the currently configured SQL Server that SharePoint is pointed to. Set the value of the alias to the same server name. Example, if SharePoint is using server1 as the database server, create an alias called server1 and set the value of the alias to server1.
o the cliconfg.exe creates a registry value called server1 with the name of the alias in the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo
The data for the server1 value will be DBMSSOCN,server1
* My service periodically queries the database_mirroring_witnesses catalog of the witness server to see what the principal server is for the SharePoint_Config database. This object resides in the master database. Once you query this catalog there is a column that has the current principal server information.
* Remotely query the registries of all the SharePoint servers in the farm to see what database server the SQL alias created above is pointing to. If the alias is pointed at a different server than what the witness server thinks is the principal, remotely update the alias’s value in the registry and run IISRESET.exe /noforce.
The account that runs my service needed to have select access to the databse_mirroring_witnesses catalog on the Witness server.
Also, since I am only querying the witness server to see what the principal server is for the SharePoint_Config database, I am assuming that if this database fails over to the mirror, all the databases have failed over and I am redirecting SharePoint via the alias on all SharePoint servers in the farm.
** I took this from a comment on some site for my own permanent reference **
Howto install DBD::mysql on Mac – OS X 10.5.5

Not used with permission.
I ran into this while trying to run a Perl DBI script on a relatively new Mac (OS X 10.5.5, 2.33 GHz Intel Core 2 Duo MB Pro).
The Perl DBI script, since you asked, is something I’m using to read a tab-delimited file line-by-line, look up some data against my mysql server, and write a Ruby on Rails migration file. The migration file is just a bunch of creates based on the data from the text file. It’s a Rube Goldberg concoction for sure but that’s a testament to the versatility of the (Perl | Python | Ruby) DBI. Python’s the fastest, but I cut my teeth on Perl so that’s what I’m using this time.
I digress… when I tried to run the script, it complained about not having the DBD::mysql installed. So, here’s how I installed it on my machine.
You’ll need X Code tools installed and MySQL Server / Client installed before this… I’m assuming you have it working already. Make sure MySQL is running already.
1. open terminal and attempt to install DBD::mysql from CPAN. Type this: (” :; ” is my terminal prompt)
:; sudo perl -MCPAN -e 'install Bundle::DBD::mysql'
This will likely fail because it needs some building config you need, but it will help get us to the point we need to to finish installing it (make sense?).
2. cd to your CPAN folder:
:; cd ~/.cpan/build/DBD-mysql-[version]
3. Next, type this in to configure the build: Note… for me, I installed MySQL using mac ports, so my mysql install is in /opt/local. You should find out where your mysql install is before entering the paths below.
You can find out typing this in your terminal assuming mysql is running:
:; ps aux | grep mysql
:; sudo perl Makefile.PL \
--cflags="-I-I/opt/local/include/mysql5/mysql" \
--libs="-L/opt/local/lib/mysql5/mysql -lmysqlclient -lz -lm -lcrypt -lnsl" \
--mysql_config=/opt/local/bin/mysql_config5
4. Build and install it (you may or may not have to run this first command with a ’sudo’, try without first of course).
:; make
no errors? proceed...
:; sudo make install
Should be golden now. If you ran into any issues, review the steps, look up errors … good luck!