You just gotta see this..

ruby -le '33.times{|y|print" "*(32-y),(0..y).map{|x|~y&x>0?" .":" A"}}'
Posted on April 23, 2008 at 1:11 pm

Starting Mysql on Slackware 12

So the other day I decided to upgrade to Ubuntu Hardy Heron, and after a few days of testing it out I was getting some very strange memory leaks. Also, there were “zombie” processes hanging under “sh” that I couldn’t probe. Fed up with current circumstances in the bloated-Linux-world, I decided to switch back to the tried and true - after all I really had no reason to not switch back other then my undeniable hatred for the Lilo bootloader.

I got over it, and got it up and running late last night. This morning I got the latest nvidia drivers running, as well as my adjusted my sound card levels. Much to my suprise this sound card (Audigy 2) works great under slack.

My first hurdle was getting mysql to start.. I kept getting a nohup error and it wasn’t allowed to connect to the mysql socket. First things first, permissions and users.. make sure the server isn’t running:

ps xa | grep mysql

You should only see your grep process in the list of processes and you’re good to move on.

sudo chown -R mysql:mysql /var/lib/mysql/
sudo chown -R mysql:mysql /var/run/mysql/

Next we need to get our config in place:

sudo mv /etc/my-small.cnf /etc/my.cnf

After that we can run the database installer:

sudo /usr/bin/mysql_install_db

Once that is complete, we can start up the server:

sudo /usr/share/mysql/mysql.server start

We’ll also want to move the mysql script to our rc.d folder so that it can be started upon boot:

sudo cp /usr/share/mysql/mysql.server /etc/rc.d/rc.mysql
sudo chmod 644 /etc/rc.d/rc.mysql

Lastly we’ll create a new password for the root user in mysql:

sudo /usr/bin/mysqladmin -u root password 'your password here'

That’s all, you should now be able to connect to the server just fine. If you need any help with Mysql commands and command-line syntax check this out.

Posted on April 21, 2008 at 1:44 pm

Benchmarking RadiantCMS on ModRails

After initially testing ModRails with my supreme hosting partner, I decided to try out a common application on the system. I still amazed at how fast this system is.. see for yourself:

zscott@Lian:~$ ab -n 1000 http://zak.railsplayground.net/
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
 
Benchmarking zak.railsplayground.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
 
 
Server Software:        Apache/2.0.59
Server Hostname:        zak.railsplayground.net
Server Port:            80
 
Document Path:          /
Document Length:        47 bytes
 
Concurrency Level:      1
Time taken for tests:   176.54368 seconds
Complete requests:      1000
Failed requests:        2
(Connect: 0, Length: 2, Exceptions: 0)
Write errors:           0
Total transferred:      481156 bytes
HTML transferred:       85390 bytes
Requests per second:    5.68 [#/sec] (mean)
Time per request:       176.054 [ms] (mean)
Time per request:       176.054 [ms] (mean, across all concurrent requests)
Transfer rate:          2.66 [Kbytes/sec] received
 
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:       64   82  16.9     78     191
Processing:    65   92  72.8     80    1251
Waiting:       64   90  59.9     79    1164
Total:        135  175  75.4    161    1324
 
Percentage of the requests served within a certain time (ms)
50%    161
66%    170
75%    180
80%    186
90%    206
95%    236
98%    290
99%    401
100%   1324 (longest request)
Posted on April 16, 2008 at 7:42 pm

Benchmarking ModRails

Today Joe set-up beta testing for modrails on railsplayground, and a test account for me to play around with.

I quickly setup a basic Contact manager using Rails 2.02 scaffolding and added some test data. After the initial bump of forgetting to configure for production we were under way.

These are the results of benchmarking the application under 1,000 requests, looks good so far.

zscott@Lian:~$ ab -n 1000 http://zak.railsplayground.net/contacts
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
 
Benchmarking zak.railsplayground.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
 
Server Software:        Apache/2.0.59
Server Hostname:        zak.railsplayground.net
Server Port:            80
 
Document Path:          /contacts
Document Length:        2357 bytes
 
Concurrency Level:      1
Time taken for tests:   151.627619 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      3060000 bytes
HTML transferred:       2357000 bytes
Requests per second:    6.60 [#/sec] (mean)
Time per request:       151.628 [ms] (mean)
Time per request:       151.628 [ms] (mean, across all concurrent requests)
Transfer rate:          19.71 [Kbytes/sec] received
 
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:       55   69  13.8     66     288
Processing:    60   81  36.4     75     739
Waiting:       59   77  29.2     71     586
Total:        118  151  39.2    144     808
 
Percentage of the requests served within a certain time (ms)
50%    144
66%    151
75%    156
80%    160
90%    174
95%    191
98%    222
99%    264
100%    808 (longest request)
Posted on April 13, 2008 at 1:23 pm

Exception Model Saving

Although there are many way’s to test whether or not your model has saved, this is a fool-proof way that I’ve come to love.

begin
  object.save!
rescue Record Invalid => error
  # failed
end
Posted on April 11, 2008 at 9:39 pm

Are you sure?

def are_you_sure?
  while true
    print "Are you sure? [y/n]: "
    response = gets
    case response
      when /^[yY]/
      return true
      when /^[nN]/
      return false
    end
  end
end

I’m rather enjoying this.. ;)

Posted on at 8:01 pm