RSS

    follow me on Twitter

    Recent Comments

    Powered by Disqus
    Mar
    12th
    Fri
    permalink
    Trust me, you’re not, and no matter how much you think you know about what it’s going to be like, when that first jab comes, you’ll begin to truly understand for the first time.
    Comments (View) Bookmark and Share
    permalink

    301 redirect for base domain to www subdomain on Passenger + Apache2 + Rails

    I can’t really remember all the reasons why its a bad idea to have both the base domain and the www subdomain point to the same rails app. I know sessions is one reason, if a user logs in on mydomain.com and then visits www.mydomain.com he is not logged in there. Consistency is also nice. I can’t be sure but it might even affect SEO.

    So the best way I found to do this is to simply add another site in apache2 with the following:

    <VirtualHost *:80>
      ServerName mydomain.com
      Redirect permanent / http://www.mydomain.com/
    </VirtualHost>

    And have the rails application only respond to www.mydomain.com

    Other random notes

    • sudo a2dissite [sitename] - does not make changes to sites in /etc/apache2/sites-available 
    • you should not make changes to the vhost configs in sites-enabled, instead make changes to the configs in sites-available and then just do a sudo a2ensite even its already loaded, it will replace the old file. Then just reload apache to activate changes.
    Comments (View) Bookmark and Share
    permalink

    X-sendfile + Rails + Passenger/Apache2

    I installed this a while back but never really gave it much thought, until today. I wanted to be sure that it was working. I don’t think I’ll say much about why you should be using it, but I’ll say this unless you don’t have to serve any relatively large static files, you should really be using it, relatively easy to install and good returns.

    Basically what it does it frees your rails processes which are memory hogs and delegates the static file serving to apache (or nginx) which you can have many more processes of because of the smaller memory footprint. This is very useful especially on small slice VPSes where you only have so much memory.

    To convince myself that it was working I finally tested it by requesting a big file and and see how many requests I can get started until it locks up. With x-sendfile off, I could get 3 requests, then the server locked up, and it could not serve any more requests to the rails app. Imagine that, 3 people download a file (~20mins to complete) and your app is basically offline for that whole duration. With x-sendfile on, I got up to 8 simultaneous downloads and the rails app could still take requests. I could probably increase more but I felt convinced that it was working well enough.

    Where is the X-sendfile header?

    Why I investigated in the first place was because I didn’t really know how it worked so I was looking for the the “X-sendfile: path/to/file” header in the response. After much reading and testing, I still could not find any clear article/documentation on this. So what I believe is happening is that when you request a file from the rails app, it makes a request with the”X-sendfile: path/to/file” header to apache2 which then discards the response contents and basically streams the path/to/file to the requester.

    So the requester will not see any “X-sendfile” header which is good cause it actually contains the path of the file on the server. All they get is the file.

    For < Rails v2.3  you’ll need a plugin. Else its built right into send_file.

    Comments (View) Bookmark and Share
    Mar
    4th
    Thu
    permalink
    The problem is that coding isn’t fun if all you can do is call things out of a library, if you can’t write the library yourself. If the job of coding is just to be finding the right combination of parameters, that does fairly obvious things, then who’d want to go into that as a career?
    Comments (View) Bookmark and Share
    Mar
    3rd
    Wed
    permalink

    This was pretty awesome. Live acapella looping. Amazing stuff you can do with the iphone.

    EveryDay Looper - Les Ramens - (via eulgadjo)

    Comments (View) Bookmark and Share
    permalink
    Distribution of income by religion. Jews and Hindus come out top.
GOOD.is | The Almighty Dollar (Raw Image)

    Distribution of income by religion. Jews and Hindus come out top.

    GOOD.is | The Almighty Dollar (Raw Image)

    Comments (View) Bookmark and Share
    permalink
    Comments (View) Bookmark and Share
    permalink
    Comments (View) Bookmark and Share
    Mar
    2nd
    Tue
    permalink
    It doesn’t matter if you go running every morning, or you’re a regular at the gym. If you spend most of the rest of the day sitting — in your car, your office chair, on your sofa at home — you are putting yourself at increased risk of obesity, diabetes, heart disease, a variety of cancers and an early death. In other words, irrespective of whether you exercise vigorously, sitting for long periods is bad for you.
    Comments (View) Bookmark and Share
    permalink

    They did not lie to us. This is the future.

    Ray flys Martin Jetpack for a VIP (via MartinJetPack)

    Comments (View) Bookmark and Share