Archive for October, 2007

PHP & MySQL on Leopard

Edit /etc/apache/httpd.conf and comment out

LoadModule php5_module # (on line 114)

If you installed the binary mysql5 edit/add /usr/local/mysql/my.cnf and add/change:

[client]
socket = /var/mysql/mysql.sock
[mysqld]
socket = /var/mysql/mysql.sock

then do (with sudo -s)

/bin/sh /usr/local/mysql/support-files/mysql.server stop
mkdir /var/mysql
chown -R _mysql:wheel /var/mysql/
/bin/sh /usr/local/mysql/support-files/mysql.server start

(update this also in your rails app’s database.yml)

Migration MySQL 4 to 5

Fist a dump of all current databases

mysqldump \
  --all-databases -u httpd -p \
  --default-character-set=latin1 > alldb.tmp_sql

Stop mysql

/bin/sh /usr/local/mysql/support-files/mysql.server stop

and move the old datadir

sudo mv /usr/local/mysql/data /usr/local/mysql/data_4
sudo mkdir  /usr/local/mysql/data
chown -R _mysql /usr/local/mysql/data

Then split the datadump into seperate files

split -p "-- Current Database" alldb.tmp_sql

To prepend special params mysql dump provided, prepend the first file (probably xaa) and edit SET NAMES latin1 to SET NAMES utf8

for file in `ls x*`
do
 new=`head -1 $file | \
   sed -e 's/-- Current Database: //' -e 's/\`//g' -e 's/ /_/g'`
 cat xaa > $new.sql
 cat "$file" >> $new.sql
done

Then restart without checking the user privileges (so we can alter the usertable)

/usr/local/mysql/bin/safe_mysqld --skip-grant-tables &

Then finally do the import and watch for errors to fix

for file in `ls *.sql`
do
 echo "Importing $file"
 cat "$file" | sed -e \
   's/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/' | mysql
done

Restart the processes:

/bin/sh /usr/local/mysql/support-files/mysql.server restart

Locomotive for Leopard

To take advantage of the build-in rails of leopard i’ve changed the locomotive bundle usr_local to use the Leopard rails.
Download it here: Leopard.locobundle.zip. Next read how to activate mysql.

Synchroniseren folders op je mac

Omdat ik een beetje paranoide begon te worden over mijn harddisk (Disk Utility gaf enkele fouten) toch maar eens de optie overwogen om een backup strategie in elkaar te zetten…. Maar op welke manier?

Enkele vereisten zijn er natuurlijk wel, het moet eenvoudig en sim-pel zijn. moet niet 10x klikken en het moet snel zonder dat ik er veel last van heb als ik aan het werk ben. Dus op zoek naar de ultieme backup applicatie totdat OSX Leopard (met time machine) om de hoek komt kijken.

(more…)

Safe boot your mac to repair startupdisk

Just hold the shift key after the startup tone to repair your startupdisk.
What is Safe Boot, Safe Mode? and Starting up in Safe Mode

How Many Germs Live On Your Keyboard?

Studies have shown that your keyboard and mouse are some of the most germ-ridden devices you own, surpassing even doorknobs and toilet seats. Take this short quiz to see how many germs lovingly call your keyboard home.

2,741,340How Many Germs Live On Your Keyboard?

RSpec & Growl

Oef…. ff rspec opzetten was niet zo gemakkelijk als de screencast op railsenvy doet geloven. Er is hier en daar wat veranderd in de library’s en deze kun je overrulen met een .autotest bestand. Helemaal zelf bedacht heb ik het niet maar het een en ander van andere weblogs geplukt.

# -*- ruby -*-
require 'autotest/growl'
require 'autotest/redgreen'

module Autotest::Growl
  # save the name of the working directory (e.g., the app name)
  # to be used as a key to identify this particular run of autotest
  # so the same growl notification will be reused for updates,
  # instead of a new growl window for every posting.
  @@current_directory_name = Dir.pwd.match(/([^\/]+)\z/).to_s

  def self.growl title, msg, pri=0, img=""
    title += " in #{@@current_directory_name}"
    msg += " at #{Time.now}"
    system "growlnotify -n autotest #{pri > 0 ? '-s ' : ''}--image #{img} -p #{pri} -d '#{Dir.pwd}' -m #{ msg.inspect} #{title}"
  end

  Autotest.add_hook :ran_command do |autotest|
    results = [autotest.results].flatten.join("\n")
    output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
    if output  =~ /[1-9]\sfailures?/
      growl "FAIL:", "#{output}", 2, "~/Library/autotest/rails_fail.png"
    elsif output  =~ /[1-9]\spending?/
      growl "PENDING:", "#{output}", 1, "~/Library/autotest/rails_pending.png"
    else
      growl "PASS:", "#{output}", 0, "~/Library/autotest/rails_ok.png"
    end
  end
end

Get the pictures from here:

rails_ok.png

rails_pending.png

rails_fail.png

Noot: Bij het schrijven van deze blogentry kwam ik een andere .autotest tegen op http://pastie.caboo.se/96573/download. Met logging, stripping van color codes, uitgebreidere foutafhandeling. wat ik er nog bij heb getikt is de extra optie voor reuse van de notificatie:

system "growlnotify -n autotest --image #{img} #{pri > 0 ? '-s ' : ''}-p #{pri} -d '#{Dir.pwd}' -m #{msg.inspect} #{title} #{stick}"