Tokens — Page 48

Milletvekilleri Sigara Yasağına Uyacaklar Mı?

Televizyonum olmadığı için haberleri internetten okuyorum. Milliyet sırf magazin olduğu için artık sadece ntvmsnbc’den haberleri takip ediyorum. Bugün okuduğum haber beni düşündürdü:
<blockquote>Meclis Sağlık Komisyonu Başkanı Cevdet Erdöl, 19 Mayıs’ta uygulanacak sigara yasağı öncesinde milletvekileri arasındaki yapılan anketin sonuçlarını açıkladı. Meclis’teki milletvekillerinin yüzde 26’si sigara içiyor.

Milletvekillerinin demeçlerine göre, vekiller yasak hatırlatıldığında “benim dokunulmazlığım var” demeyecek. Vekillerin yüzde 80’e yakını yasak hatırlatıldığında uyacağını söylüyor. Ancak anket sonuçlarına göre, yasak sonrası milletvekileri odalarında sigara içecek ya da içilmesine izin verecek.</blockquote>
Kaynak: http://ntvmsnbc.com/news/446042.asp

Haberin altına yazdığım ama bazen NTV tarafından yayınlanmadığından buraya da alıntıladığım yorumum şöyle:

Bu nasıl bir haber ya. Tabii ki uyacaklar. Ne yani milletvekilleri yasaların üstünde mi? Nerde hukuk devleti olmak, nerde yasaların üstünlüğü ve herkesin yasalar karşısında eşit olması?

Sırf böyle bir haber bile, yani bazı “daha eşitlerin” yasalardan muaf olmasını ima eden haberler bile, ülkemizin ne kadar geri kaldığını gösteriyor. Gidin bakın bakalım gerçek demokrasilerde, gelişmiş ülkelerde böyle bir tartışma yapılıyor mu? Üzerinde konuşmak bile çok saçma.

Barındırma hizmetleri (web hosting)

Bir süredir hosting işleri ile uğraştığım için biraz bilgi sahibi oldum. Dreamhost yurtdışından alınacak en iyi firmalardan biri gibi. Sunucularin özellikleri çok iyi ( https://dreamhost.com/hosting.html ) ve sunucularının hızı da fena değil. Daha önce netfirms’den aldığım barındırma hizmeti için verilen sunucu acaip yavaştı. Bazı firmalar bir sunucuya çok fazla müşteri veriyorlar. Dreamhost’ta benim bulunduğum sunucunun rakamları şöyle:

$ cat /etc/passwd | wc -l
497


Yaklaşık 500 kişi, çift işlemcili opteron bir sunucuya. RAM miktarı ise 4 GB. Çok iyi olmasa da verdiğin ücrete göre fena değil sanırım. Tabii sunucudaki elemanların iş yoğunlukları da önemli.

Internetten birsey alacağım zaman genel olarak indirim kuponu araştırması yaparım. Dreamhost’ta da bunu yaptım ve sanırım oldukça iyi bir fırsat sahibi oldum. Benim de kullandığım indirim kuponlarından biri Dreamhost icin 3DOMAINS4FREE , bununla ilk seferde 50 dolar indirim kazanıyorsun ve 3 tane de alan adı bedavaya geliyor (toplam 4 alan adın barındırma hizmeti aldığın süre için bedava oluyor).

Barındırma hizmeti satın alacakların ilk belirlemeleri gereken şey ihtiyaç. Dreamhost’un 500 GB alan ve 5 TB bağlantısına ihtiyacınız olmayabilir. Ben alanı çok bulup rapidshare klonu bir sayfa yaptim ( http://www.saklabana.com ) ama şu anda pek kullanılacak şekilde değil. Ruby on Rails desteği verdiğini söylüyor Dreamhost ama en fazla iki tane FastCGI işlemine izin veriyor. İki kişiye aynı anda dosya yollandığında benim uygulama bloklanıyor. Uygulamayı bir şekilde optimize etmem gerekiyor, zaman bulduğum bir ara bakacağım. Yani paylaşımlı barındırma hizmetlerinde her soylenilene kanmayın, sanal özel sunucular (VPS) ise çok pahalı (doğru düzgün bir VPS aylık 20 dolardan başlıyor). Bu yüzden yeni bir uygulama yazanlar için önermiyorum. Özel bir ihtiyacınız yoksa (ruby on rails gibi) veya cok fazla ziyaretçiniz olmayacaksa VPS’e gerek yok. PHP kullanacaksanız veya önbelleklenecek miktarda sayfanız varsa pek sorun yaşayacağınızı sanmıyorum. Mephisto (ruby on rails uygulaması) kullanarak kurduğum blog sayfasında önbellekleme iyi miktarda yapılıyor (blog.saklabana.com) ve bu sayede çok yoğun durumlara bile cevap verebiliyor (curl-loader stress testine göre saniyede 200 istek).

Bunun dışında söylemeden edemeyeceğim, Dreamhost’un güzel özelliklerinden biri derleyicilere ve kütüphanelere erişebiliyor olmanız. Kendi hesabıma git derledim ve şimdi projelerim için repository olarak kullanıyorum. Bu özellik hoş bir olay.

Deploying your Rails Application to Dreamhost

Well I recently bought hosting from Dreamhost and had to go through setting it up on the server. I thought it might be useful for others who are following the same path. So here is my $0.02.

How to deploy your application in 8 easy steps:

1. First make sure that your domain has FastCGI enabled. You can do this by the panel, this option is located at Manage Domains -> Edit.

2. Create MySQL databases for your application. This is located at Goodies -> Manage MySQL.

This is probably related to DH taking some time to update my databases, but when I tried to access my database, I received an error:

$ mysql -u username -p -h myserver.mydomain.com mydb
Enter password:
ERROR 1130 (00000): Host 'myhost.dreamhost.com' is not allowed to connect to this MySQL server


This error went away after an hour or so.

3. I’ll be continuing as if you are moving an existing rails application that you developed somewhere to the Dreamhost server you have just gotten hold of. There are somethings you need to do before deploying your application. First of all, create a dummy rails project by issuing the command:

$ rails dummyapp -d mysql

The -d flag there tells rails to create the database configuration file stub, database.yml, according to MySQL as the database.

4. Copy your application to the Dreamhost server (I recommend sftp as it is secure). I’ll use “myproject” as the name of your own application. Now we’ll be copying the dispatch.fcgi that has been created to our own application:

$ cp dummyapp/public/dispatch.fcgi myproject/public/

5. And then we’ll be changing the file .htaccess inside the public directory:

$ vim myproject/public/.htaccess

Look for the line

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

and change it so that it uses dispatch.fcgi, so it will be:

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

6. Change all permissions if need be:
$ cd myproject
$ chmod 755 public
$ chmod 755 public/dispatch.*


7. Now you can copy the database.yml file from the dummy application to your own application and change the database settings. After that, we do not need the dummyapp anymore, you can safely delete it:

$ rm -rf dummyapp

8. Now the housekeeping stuff.

You should uncomment the RAILS_ENV variable in config/environment.rb so that your application runs in production. If you do not set this your application might be really really slow, or not work at all.

If you have any site specific variables in config/environment.rb, then change it to suit your needs. If you have used Action Mailer to send mails to your users, then you need to configure that as well.

You now have to run “rake db:migrate” to set up the DB and set your applications public directory as your root directory for your domain. That’s all folks.


Some DRY Rules That Might Be Useful

If you don’t want to create a dummy rails application each time you want to migrate your application to Dreamhost, just copy the needed files to a directory. I copied dispatch.fcgi, .htaccess and database.yml files.


Coupon Code for Dreamhost

If you are ever going to buy anything, don’t forget for searching coupon codes on the Internet. You might be amazed how much discount you can get with those. For Dreamhost, the best discount you can get is a 50$ plus you can get other goodies such as free domains or IPs. If you want to get a 50$ discount and 3 lifetime domains for free, use 3DOMAINS4FREE coupon code. I think its the best offer out there. I plan to write a review of using Dreamhost for Rails hosting but probably after some experience with more heavier loads for my application (Turkish only). I think it will be interesting once Dreamhost starts supporting mod_rails also. Shared hosting for rails might just start to be feasible after all.

Rails tip - Deleting unneeded files

If you want to remove all files associated with a model of yours, that is removing the controller, migration, tests etc. than you can use the script/destroy command to do just that. The argument to remove all the files is “scaffold” so that:
ruby script/destroy scaffold pages
would do.
Run destroy with -p flag to see which files would be affected.

Note that if you already have set up an application than you would need a little more work to reconfigure your database. You would have a lot of data in your other tables so you cannot drop the database and re-migrate it again. In that case, it’s better to connect to the database directly and drop the unneeded table.

[UPDATE: It seems that sometimes destroy script is unable to delete the related line in routes.rb file. In that case, you’ll notice it because your application won’t work, edit the file and put it in correct form.]

Otomobil mi, insan mı?

Dünya Bankasının 2008 Dünya Gelişim Raporuna göre 4 çekerli bir aracın deposunu biyoyakıtla doldurmak için gereken mısır bir insanı bir sene boyunca doyurabilir:

<blockquote>The 2008 World Development Report “Agriculture for Development” provides a compelling example of the food-for-fuel debate: over 240 kilograms (or 528 pounds) of corn – enough to feed one person for a whole year – is required to produce the 26 gallons, or 100 liters of ethanol needed to fill the gas tank of a modern sports utility vehicle.</blockquote>
[Raporun özeti]

Afrika’daki insanları bir düşünsenize.

Otomobillere daha fazla önem verildiği için insanlar ölüyor.