I won’t say anything, just see the numbers:

all tests run 3-4 times:

Small EC2 EBS added 16GB volume $50-80/month
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 11.5874 s, 23.2 MB/s

Small EC2 Root FS EBS
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 32.8698 s, 8.2 MB/s

Linode 1.5GB $54-60/month
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 2.25564 s, 119 MB/s

Tilaa.nl 1GB $30/month
# dd bs=1M count=256 if=/dev/zero of=swapfile oflag=dsync
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 4.66885 s, 57.5 MB/s

see dd benchmark information

Ec2 vs Linode vs Tilaa

Ec2 vs Linode vs Tilaa

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

If you need to use the Rails API offline, you can download it here:

rails311.tar.bz2 1.4M Nov 15 08:04

The package contants multiple gems rdoc: railties-3.1.1 rails-3.1.1 actionmailer-3.1.1 activemodel-3.1.1 activeresource-3.1.1 actionpack-3.1.1 activerecord-3.1.1 activesupport-3.1.1 sass-3.1.10 coffee-rails-3.1.1 coffee-script-2.2.0

You can browse online if you wish so : /rails311/index.html

Generated by sdoc

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

This is a ruby on Rails demo app using Address autocomplete with google places API.

I was experimenting with google places and I found it to be quite awesome.

In this app you can search for a geocode address or establishments, move the marker and get the the GPS coordinates, and also get the gps coordinates out the search results.

it’s also possible to restrain the autocomplete results by limiting it to bounds:

autocomplete.setBounds(defaultBounds);

here is the demo app: http://electric-sunrise-8410.heroku.com/
source: https://github.com/fred/google_places_autocomplete

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Installing mwforum on Debian Lenny 5.0 and 6.0

There are many perl packages required by MWForum, Im not totally sure if all of them are required, but here is the list of packages that will get MWForum fully working with Image Uploading, Image resizing, attaching image, Avatar, text quote and email support.

Install required debian packages with aptitude:

# aptitude install libgd-gd2-perl libgd2-xpm imagemagick libimage-base-bundle-perl libimage-magick-perl libimage-info-perl libimage-exif-perl libimage-base-perl libimage-imlib2-perl libimage-size-perl libgeo-ip-perl libgeo-ipfree-perl libemail-mime-perl libmail-sendmail-perl libmail-rfc822-address-perl libmail-sender-perl libmail-perl libnet-cidr-lite-perl libtext-reform-perl libtext-quoted-perl mysql-server libdbd-mysql-perl libdbi-perl libcompress-zlib-perl libwww-perl liburi-perl libxml-perl libxml-regexp-perl libxml-sax-expat-perl libxml-sax-perl libxml-xslt-perl perl-modules perlmagick libtext-iconv-perl libsocket6-perl  libtimedate-perl libnet-daemon-perl libmailtools-perl libhtml-clean-perl libhtml-format-perl libhtml-parser-perl libhtml-tree-perl libcflow-perl libdata-flow-perl apache2-mpm-prefork libapache2-mod-perl2 libapache2-mod-apreq2 libapreq2 libapache2-request-perl -V

Now check latest version for download from http://www.mwforum.org/forum/topic_show.pl?tid=4222
In this setup I will put mwforum in /var/www/mwforum/htdocs/ (gentoo style folder)

Download MWforum and extract

# mkdir -p /var/www/mwforum/
# cd /var/www/mwforum/
# wget http://www.mwforum.org/dl/stable/mwforum-2.24.1.tar.gz
# tar xpf mwforum-2.24.1.tar.gz
# mkdir htdocs
# cp -a mwforum-2.24.1/script/* htdocs/
# cp -a mwforum-2.24.1/data/* htdocs/

Setup Configuration files

# cd ./htdocs
# mv MwfConfigGlobalDefault.pm MwfConfigGlobal.pm
# mv MwfConfigDefault.pm MwfConfig.pm

Edit config file with your mysql username/password, site name and url.

# vi MwfConfig.pm

Inside Mysql shell create database and username/password for mwforum:

mysql> CREATE DATABASE mwforum CHARSET=utf8;
Query OK, 1 row affected (0.30 sec)

mysql> GRANT ALL ON mwforum.* TO mwforum@localhost IDENTIFIED BY 'sk8hg4I2mxW';
Query OK, 0 rows affected (0.60 sec)

mysql> flush privileges;

Install MWForum database:

# perl install.pl

Activate Apache modules:

# a2enmod perl
# a2enmod apreq
# a2enmod headers

Add the apache Virtualhost config file:

# vi /etc/apache2/sites-availables/mwforum
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<VirtualHost *:80>
    ServerName myforum.com
    ServerAlias www.myforum.com
    ServerAdmin webmaster@myforum.com
    DocumentRoot /var/www/mwforum/htdocs
    DirectoryIndex forum_show.pl
    #XSendFile on
    #XSendFileAllowAbove on
    ScriptAlias /cgi-bin/ "/var/www/mwforum/htdocs/"
    <Directory "/var/www/mwforum/htdocs">
        Options +ExecCGI FollowSymLinks -Indexes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    RewriteEngine On
    # Uncomment to force redirect to https, but you need to create https vhost
    # RewriteCond %{HTTPS} off
    # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

Add PerlSwitches:

# vi /etc/apache2/conf.d/mwforum
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PerlSwitches -I/var/www/mwforum/htdocs
<Directory /var/www/mwforum/htdocs/>
    DirectoryIndex forum.pl
    Options -Indexes
    <Files "*.pl">
        Options +ExecCGI
        SetHandler perl-script
        PerlResponseHandler ModPerl::Registry
        PerlOptions -SetupEnv -ParseHeaders
    </Files>
    <Files "*.pm">
        Deny from all
    </Files>
</Directory>

Now activate mwforum and check for configurations

# a2ensite mwforum
# apache2ctl configtest
Syntax OK

If syntax OK, then restart

# /etc/init.d/apache2 restart

Security and Cleanup:

# rm install.pl upgrade.pl
# cat ./mwforum-2.24.1/example/script.htaccess >> htdocs/.htacess
# cat ./mwforum-2.24.1/example/attach.htaccess >> htdocs/.htacess
VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Bye Bye Macports, Welcome Homebrew

Definition
Homebrew: The missing package manager for OS X

Why? well, the reality is, macports is not that good anymore.
Once you have many packages installed and start updating, everything start to break apart, lot’s of failing packages.

Homebrew is very easy to install, it’s fast and simple. That means you can make your own homebrew formula for your package so easily. oh, and homebrew is in ruby! :)

Back to topic, this is you how you get rails with mysql up and running with homebrew and rvm.

Clean up

To make sure to have a clean install, I recommend removing any previous .rvm installation and previous Xcode.

# rm -rf ~/.rvm/
# sudo rm -rf /Developer

1. Xcode

Install Xcode from AppStore. it’s 3 GB download so it may take a while.
after it’s downloaded it will not install automatically, you need to open Applications and install again from there. the name will be “Install Xcode”

Update: If you don’t want to download and install huge XCODE (3.0GB) :
https://github.com/kennethreitz/osx-gcc-installer
It allows you to install the essential compilers, GCC, LLVM, etc.
PS: I have not tested it
Thanks JP for the tip.

2. Install HomeBrew

UPDATE: in the comments some people recommended to do create the folder “/usr/local/Cellar” before hand, due to some bug on homebrew.

mkdir -p /usr/local/Cellar
#  /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

Installation instructions: https://github.com/mxcl/homebrew/wiki/installation

3. install RVM

#  bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

then after RVM is installed run this 'one-line' command.

# echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

Details instructions: http://beginrescueend.com/rvm/install/

4. Install ruby 1.9.2

OS X Lion comes with Ruby-1.8.7-p249, but we all want ruby 1.9.2 right?

# rvm install 1.9.2
# rvm use ruby-1.9.2
# gem install rails thin bundler
....

I tested both ruby-1.9.2-head and ruby-1.9.3, latest sources from git, and it works well with all my apps.
With Ruby-1.9.3-head, Rails booted a lot faster.
If you wish to try 1.9.3:

# rvm install 1.9.3-head

Optionally you might want to install GIT, wget,
ack, imagemagick
and other mighty software tools for daily use.

# brew install git ack wget curl redis memcached libmemcached colordiff imagemagick

5. Install Mysql

# brew install mysql

one-line command:

# mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Once mysql is installed you might want it to load automatically each time you start your mac.

# mkdir -p ~/Library/LaunchAgents
# cp /usr/local/Cellar/mysql/5.5.14/com.mysql.mysqld.plist ~/Library/LaunchAgents/
# launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

*check that the version I use here is 5.5.14

6. Troubleshooting:

if you have problems with mysql "cannot connect to /tmp/mysql.sock"
then create a file /usr/local/etc/my.cnf and add this:

[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock

if encounter errors with homebrew run this command and follow recommendations:

# brew doctor

update: If you end up with Segmentation fault or cannot install Ruby-1.8.7, you might want to try this solution:

# export CC=/usr/bin/gcc-4.2
# rvm install ruby-1.8.7

by the way this is my /usr/local/etc/my.cnf optimized file, when using this file you may have to recreate your db

# mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
[client]
port = 3306
socket = /tmp/mysql.sock 

[mysqld]
event_scheduler = ON
skip-character-set-client-handshake
collation_server = utf8_unicode_ci
character_set_server = utf8 

bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
max_connections = 20

table_open_cache = 256
max_allowed_packet = 32M
binlog_cache_size = 1M
max_heap_table_size = 64M 

read_buffer_size = 2M
read_rnd_buffer_size = 4M
sort_buffer_size = 8M
join_buffer_size = 512k

thread_cache_size = 2
thread_concurrency = 2
query_cache_size = 16M
query_cache_limit = 2M 

default-storage-engine = INNODB
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M 

# MyISAM Options 

key_buffer_size = 64M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1
myisam_recover 

# INNODB Options
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 128M
innodb_thread_concurrency = 2
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 8M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 120
innodb_file_per_table 

[mysqldump]
quick
max_allowed_packet = 16M 

[mysql]
no-auto-rehash 

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 16M
write_buffer = 16M

[mysqlhotcopy]
interactive-timeout 
VN:F [1.9.11_1134]
Rating: 7.9/10 (7 votes cast)
VN:F [1.9.11_1134]
Rating: +1 (from 3 votes)

Small tips for securing a server with from SSH login

1. Disable Password Login

edit /etc/ssh/sshd_config and set the following

PasswordAuthentication no

now you can only login via ssh keys.
generate your local keys using ssh-keygen -t rsa
then put your id_rsa.pub in the user account on the server
i.e. /root/.ssh/authorized_keys

2. Random Passwords

Set all user passwords to large pseudo-random strings.
i.e. I set all users on all servers with different passwords looking like this:
Z4Q7H6pI53Xtsbgs8qKC
20 random alpha-numeric characters (a-z, A-Z, 0-9)

see here for more passwords https://www.grc.com/passwords.htm
you can test the password with the brute force search space calculator with https://www.grc.com/haystack.htm

3. Login alerts by email

Everytime a user has logged in the system, you should get an email alert.
For that I do put login_alert.sh and appended it to the end of /etc/profile

At the end of the file /etc/profile add this line:

sh /etc/login_alert.sh

then create a file /etc/login_alert.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
SERVER_NAME=`hostname -f`
SEND_TO="myemail@gmail.com"
LOGIN_WHO=`who -m | cut -d"(" -f2 | cut -d")" -f1 | tr -d \r`
 
echo "
Shell Login Access to ${SERVER_NAME}
From: ${LOGIN_WHO}
Date: `date`
 
Active Users:
 `who`
 
Uptime: 
 `uptime`
 
" | mail -s "Alert: SSH Login to ${SERVER_NAME} from ${LOGIN_WHO}" $SEND_TO

so you will get an email like this every time someone login to the server.

Subject: Alert: Shell Login to 'hostname' from ppp-122-122-122-122.evip2.xxxxxx.xx.xx

Shell Login Access to mail9.hostname.net
From: ppp-122-122-122-122.evip2.xxxxxx.xx.xx
Date: Fri Jul 29 18:23:19 UTC 2011

Active Users:
 root     pts/0        2011-07-29 17:57 (ppp-122-122-122-122.evip2.xxxxxx.xx.xx)

Uptime:
  18:23:19 up 189 days,  2:38,  1 user,  load average: 0.05, 0.08, 0.07

4. System Updates

Always keep updated. I run “aptitude full-upgrade” everyday on all debian machines.
also goes for Mac and Windows.

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

© 2011 Ruby, Rails, OSX and Linux fun Suffusion theme by Sayontan Sinha

Switch to our mobile site