Hello, I’m a web craftsman with a passion for the modern web. I build web applications and play with social services and communities.
Since Xcode 4.2 Apple doesn’t ship a normal GCC anymore, but instead packages LLVM. While it was possible to compile Ruby with LLVM before, the result was error prone. Not anymore! Since 1.9.3-p125 Ruby is fully compatible with LLVM and here is how you can install it without the need of any additional GCC installation.
- Install Xcode 4.3 or the new stand-alone command line tools
- Install rbenv and ruby-build
# install rbenv $ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile $ echo 'eval "$(rbenv init -)"' >> .bash_profile # You may be using Zsh or any other shell. # I presume you know how to adopt the previous two lines then. # install ruby-build $ mkdir -p ~/.rbenv/plugins $ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # reload bash (alternatively close and re-open Terminal) $ source ~/.bash_profile
- Compile Ruby 1.9.3-p125 and make default ruby
$ env CC=/usr/bin/gcc rbenv install 1.9.3-p125 $ rbenv global 1.9.3-p125 $ rbenv rehash
- Done. Check everything is ok now
$ ruby -v # => ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
Sweet. Leave a note in the comments if this helped you. Happy coding!
There is still plenty of interest in my old article “Develop memcached web apps with XAMPP under Mac OS X” so I decided to write a little follow up.
XAMPP for OS X hasn’t seen any updates in quite a while so I decided to go with MAMP after upgrading to Mac OS X Lion (10.7.2 as of now). Quite ironic since I originally changed from MAMP to XAMPP because of the lack of updates from MAMP. However, both are quite similar when it comes to installing extensions from pecl or pear so you may have some luck applying the following steps to either dev environment.
Also while I am installing the mongo driver for php here, the very same steps should work for other pecl packages such as memcache, uploadprogress or xdebug. So let’s get started!
- Install XCode (I’m on 4.2 at the moment)
- Install MAMP (2.0.5)
$ brew install mongodb
- Start the MongoDB server
Now it’s time to install the mongo php extension:
- Download the matching version of the php source code from php.net (MAMP 2.0.5 comes with PHP 5.3.6)
- Create an include-folder in your MAMP php installation
$ mkdir /Applications/MAMP/bin/php/php5.3.6/include
- Extract the php source code into that new folder. The extracted folder is called php-5.3.6.
- Rename that folder to just php, then the php source code should be located here:
- Change into that directory and configure php:
$ cd /Applications/MAMP/bin/php/php5.3.6/include/php
- MAMP comes with a weird pear config file that causes issues, let’s remove it:
$ rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
- Now install the mongo driver with pecl:
$ cd /Applications/MAMP/bin/php/php5.3.6/bin
$ ./pecl install mongo
- Activate the extension in your php.ini:
And that’s all. From now on you only need the last two steps to install other extensions.
In the past months I have been confronted with a few web projects requiring scalable file storage solutions. One of them is my very own service comemories, which stores user-uploaded photos. Those photos are stored in original size as well as a few generated thumbnails.
To deal with file uploads, most developers seem to use Amazon S3 these days, so did I. Surely it’s a great service that pretty much just works, but with increasing traffic on comemories I started to feel a little uncomfortable about the way Amazon charges me. Basically they let a month pass and then sum up how much storage I use, how much traffic I used and how many API calls my app did.
So far so good, but what if my app sees some tremendous success suddenly and many more people upload photos than I anticipated? S3 would scale just fine and handle all the traffic with no issues at all… And by the end of the month I would get the big surprise in form of a credit card bill.
Of course it depends a lot on what you are trying to do, but if you are anything like me and you are running a web service more or less for fun and because you are learning about technology, you should really reconsider if S3 is the right choice.
Let’s have a look at their pricing for a little example application:
Image we run a web service with 10.000 users who uploaded 100 photo each at 5MB per photo. This would sum up at about 5TB of storage needed.
- Amazon charges $0.14 per GB for the first TB leading to $140
- then the other 4TB cost $0.125 per GB summing up at +$500
- every image has to be transferred in once: +$500
- and for simplicity let’s say every images is transferred out once: +$750
A total of $1890 for the month the images are uploaded. Now let’s imagine no more photos are uploaded from this point on but every photo is accessed once per month again. This means we would keep paying $1390 month to month.
Wow! 5TB is not even that much. You could buy three 2TB HDDs for 210€ altogether to get 6TB of storage and this would only be a one time cost instead of monthly charges. But ok, just buying plain HDDs is not really comparable to the service Amazon offers. But what about rented dedicated servers?
Hetzner Online offers the EQ9 for 99€ per month and the server has 4500GB storage installed. Coming to 0.022€ per GB. So I could just get two of them and have 9TB storage for less than 200€ per month. Now Amazon offers some redundancy. So let’s just get 4 of those servers and have everything stored twice. Voilà, redundant storage for under 400€ per month.
Let’s not forget that we actually have 4 powerful machines here with Core i7 and 12GB of RAM each! Those make some pretty good app servers too. If we ran this on Amazon EC2 instead, it would cost us another fortune.
Don’t get me wrong here. I know getting a bunch of dedicated servers is no cool and fancy cloud with unlimited automatic scaling capabilities and also requires quite a bit of operations know how and work, but for web applications of small to medium size with just 1-2 people working on them this may just be the better solution. Big enterprises on the other hand could see some benefits from outsourcing all storage worries to a over-priced 3rd party. But really, who can count themselves to those?
When running rake tasks (that are related to the database) in Rails apps I ran into the following error a couple of times on different OS X Snow Leopard machines:
uninitialized constant MysqlCompat::MysqlRes
The mysql gem is installed but got compiled for a wrong architecture for some reason. I’m not 100% sure when this happens but if you run into the problem uninstall the mysql gem
$ sudo gem uninstall mysql
and reinstall it with this flag
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql
if you are using rvm you can skip the “sudo” on all commands.
On June 17 I was talking about some stories from my social community the-reality.net at Pecha Kucha Night Salzburg. Pecha Kucha Nights are happening all around the world and allow presenters to talk about any topic they like. There is only one rule for presentations: Each presentation has exactly 20 different slides and each slide is displayed for exactly 20 seconds. This means each talk is 6 minutes and 40 seconds long. So in case a presenter choose a topic you don’t like you will only have to waste 6:40min of your life listening to it!
I choose to speak about some funny and interesting stories from my social network the-reality.net to give people a little understanding of whats happening behind the walls of social networks. My talk is in German, so if you understand a little German have a look!