Tag: Databases

Just a Typical Rails Testing Session

Goal: Find out how fast this code runs.

Solution: Write a performance test using Rails’ built-in script/generate performance_test

Steps:

  1. script/generate performance_test homepage
  2. edit test/performance/homepage_test.rb
  3. Oh wait, I don’t have a test database set up
  4. ssh dev
  5. pg_dump -Fc devdb > db.dump
  6. exit
  7. scp dev:~/db.dump .
  8. Wait for 700Mb compressed dump file to download over wi-fi connection
  9. pg_restore -d testdb db.dump
  10. errors: could not access $libdir/pg_trgm, $libdir/uuid-ossp, $libdir/fuzzystrmatch, tons of no relation errors
  11. Search Google: what is all this stuff?
  12. uuid-ossp depends on http://www.ossp.org/pkg/lib/uuid/
  13. Download, untar, configure, make, make install
  14. Oops, forgot to build with postgres support
  15. GOTO 13 and return
  16. That didn’t work; GOTO 11 and return
  17. Oh, compiling uuid-ossp on Mac has problems: http://cvs.ossp.org/tktview?tn=81
  18. Try running one user’s suggestion of renaming uuid_t
  19. rgrep -l uuid_t | grep -v ChangeLog | xargs perl -i -pe 's/uuid_t/ossp_uuid_t/g'
  20. rgrep: command not found
  21. GOTO 11 and return
  22. sudo port install rgrep (nope)
  23. Is rgrep source available? (nope)
  24. Ah, rgrep is part of the jed text editor
  25. sudo port install jed (installs slang and jed)
  26. GOTO 19, 20, (swear once), 21
  27. What was my goal again?
  28. locate rgrep (nope)
  29. locate jed (nope)
  30. How do you update the locate db again? GOTO 11 and return
  31. sudo /usr/libexec/locate.updatedb (receive warning, “the Lord will kill you for running as root”)
  32. Why am I doing this?
  33. I know, I’ll write a funny post on how great it is to be a programmer and how 90% of your time is debugging your system or your code (because no one’s ever written about that before)
  34. Let’s go over the steps again, start from the beginning
  35. rake test:benchmark (database structure loads with errors, but the test runs; what?!)
  36. “rake aborted: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class"
  37. edit test_helper.rb: replace Test::Unit::TestCase with ActiveSupport::TestCase
  38. rake test:benchmark (it works: “wall_time: 5 ms”)
  39. GOTO 32 and return
  40. Why are memory, objects, gc_runs, and gc_time all zero?
  41. GOTO 11 and return
  42. Oh, I need to patch Ruby with a GC patch
  43. cd /usr/local/src/ruby-1.8.6-p369
  44. curl http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch | patch -p0
  45. “8 out of 28 hunks FAILED”
  46. Does it compile? ./configure; make (error)
  47. Oh well
  48. GOTO 27 and return

MySQL Error #2002 with PHPMyAdmin on Mac OS X 10.5 Leopard

Attempting to login to my local installation of PHPMyAdmin on Mac OS X Leopard for the first time, I received this message:

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

Assuming the server is installed and running, these problems are almost always caused by incorrect path issues. A Google search brought up this solution.

Solution:

  1. Open the terminal
  2. sudo mkdir /var/mysql
  3. sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
  4. Reload the login page and login

Solution found on Friends of Ed forum.