Code
Contents |
A whiteboard for Code snippets, notes, etc. that might otherwise be lost or might be useful down the road, etc.
Console!
ruby script/console <environment>
Add a number of empty lots
$person_id = 2 $proj_id = 51 @proj = Proj.find(51) r = 0 while r < 800 do l = Lot.new(:otu_id => 8222, :key_specimens => 999, :rarity => "", :source_quality => "", :notes => 'Auto-created for ETOH move.') l.save! r += 1 end
Krishna's notes on setting up MySQL/Mongrel/Apache2 on OS 10.3.9
this is largely based on chapter 27 of AWDwR, 2nd ed.
follow the macports installation instructions here: http://trac.macosforge.org/projects/macports/wiki/InstallingMacPorts except i set $PATH in /etc/profile with
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
then
sudo port selfupdate
sudo port install gperf
(ran into errors with "gperf: invalid option -- m" before doing this)
sudo port install rb-termios
(crashed installing ruby, but not needed)
sudo port install autoconf
(ran into old version issue before doing this)
sudo port install apache2
add the following line to /etc/hostconfig as instructed
APACHE2=-YES-
added following to /etc/profile
PATH="/opt/local/apache2/bin:$PATH"
copied httpd.conf.example to httpd.conf added proxy section:
in httpd.conf, uncomment
Include conf/extra/httpd-vhosts.conf
and add
<Proxy balancer://mongrel_cluster> BalancerMember http://127.0.0.1:8000 # put as many members here as you have mongrels </Proxy>
in conf/extra/httpd-vhosts.conf
<VirtualHost *:80> ServerName merced.ent.msu.edu ServerAdmin webmaster@dummy-host.example.com DocumentRoot /Users/krishna/dev/mx/trunk/public ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common <Directory "/Users/krishna/dev/mx/trunk/public"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> RewriteEngine On RewriteRule ^/$ /index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L] </VirtualHost>
presuming rails and rake are installed, do:
sudo gem install --include-dependencies termios sudo gem install --include-dependencies capistrano sudo gem install --include-dependencies mongrel sudo gem install --include-dependencies mongrel_cluster
Note: if capistrano hangs, try reinstalling ruby as described here: http://weblog.jamisbuck.org/2005/9/24/switchtower-on-osx
if you get 'command not found' errors, try setting the ssh env as in: http://forum.textdrive.com/viewtopic.php?id=12629
sudo mongrel_rails cluster::start -C /Library/Rails/mx/current/config/mongrel_cluster.yml