Lately I was working on some projects which had videos running in the background.The original videos that I received where high quality but extremely large(1080p videos).Using the chrome debugger, loading a single video on the browser would take atleast 1 hour to download on 250kbps.So I was tasked with re-rendering the video to reduce size.
To re-render the videos, I used ffmpeg.Its a free software available on all platforms and can we easily accessed via terminal.After tweaking around with the couple of settings I could reduce the video size down significantly.I would also like give a hand of applause to google for moving the web forward.The webm format had the smallest size less than half of the size of the mp4.
To get ffmpeg installed type

brew install ffmpeg


Here are the configurations I used for rendering the videos

ffmpeg -i time.mp4 -c:v libvpx -c:a libvorbis -pix_fmt yuv420p -quality good -b:v 2M -crf 5 -vf "scale=trunc(in_w/2)*2:trunc(in_h/2)*2" output.webm



ffmpeg -i time.mp4 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -preset slower -crf 18 -vf "scale=trunc(in_w/2)*2:trunc(in_h/2)*2" output.mp4


Just replace time.mp4 with the name of your original video.

Ruby is a dynamic and a true Object oriented language.Due to which ruby has a lot of ways to compare two objects.To be exact it has 4 different ways to compare objects that I am aware of.To understand Ruby objects and equality comparison works lets create a class.
Since I have been playing a bunch of iPad games.Lets create a game object
Lets get some game instances to work with.Now comparing with the == operator.
As you can see creating two game object with the same title and comparing them gives you a false result.
This is because the == comparator compares the object’s identity.To get the objects identity.Send the object_id message to it.
Now comparing with the equal? operator.
The equal? operator works the same way as the == operator.But unlike the == operator the equal? operator must never be overwritten as it is used internally by ruby to compare object identity.

The eql? operator
The eql operator works a bit differently compared the above two comparators.It compares the hashes between two objects.Even though the final result tends to be similar to ==. Lastly we have the === operator.
The triple equal operator is used in case statement comparison.

So now which operator do I use and when.
1. Double Equal operator:According to ruby conventions, if you want to compare two objects which you own ,you can override the == operator to make it compare properties in your object.

class Game
  attr_reader :title
  def initialize(title)
    @title = title
  def ==(other)
    other.is_a?(self.class) && @title == other.title


When you try to compare 1 == 1.0 you will get true because ruby casts 1 as to a Numeric class and then compares with the 1.0.

2. Triple Equal operator: Like double equal you can use the triple equal operator to compare two objects and also override it to get your desired result.

3.equal?: The equal? operator is used by ruby so use it carefully and never override it.

4.eql?: Like the equal? operator it is better not to override the eql operator and use it to compare both the class and equality of two objects.

Nginx is a really powerful server with lots of room for customisation.Just a couple of days ago I worked on a website which delivered a lot of assets to the browsers and performance was of utmost important for the client.

Nginx stores its configuration file in the /etc/nginx/nginx.conf file.

location ~* .html$ {
	expires 3d;
location ~* .(mp4|mp3|ttf|css|rss|atom|js|jpg|jpeg|gif|ogg|ogv|svg|svgz|eot|otf|woff|png|ico|zip|tgz|gz|rar)(?ver=[0-9.]+)?$ {
	access_log off; 
	log_not_found off; 
	expires max;

Since the assets dont change we set the Cache-Control to max time.

For html pages we let it expire every 3 days.Since its updated regularly.

        gzip on;
        gzip_disable "msie6";

        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;


gzip on – This is probably the simplest of all.It just turns on the GZIP module which is part of nginx.

gzip_disable “msie6” – Since IE 6 doesnt support gzip we disable sending gzip in the header of the response.

gzip_vary on – Many proxies/cdns require this option so it can serve both the compressed and non compressed version of the content.More info at maxcdn

gzip_proxied any – It enables gzip on all proxy requests.
gzip_comp_level 6 – This sets the compression level.Level 6 is a sweet spot as the value ranges from 1 to 9.Higher the compression more cpu cycles will be eaten.
gzip_buffers 16 8k – Not really sure.I think they are default values.
gzip_http_version 1.1 – Mininum http version to be supported by the browsers.
gzip_types – Enable gzip for the following files.

Elixir is a ruby like language built on top of the Erlnag VM.It has some really nice features which makes writing recursive functions a breeze.Here is a defacto example to write a factorial program in elixir.

As we can see having guards and pattern matching makes recursive functions a breeze

Comparing that too ruby,the LOC are more but the code is more readable.

Comparing it to some ugly javascript.

Amazon S3 is a really powerful data store.S3 works by grouping content in buckets. If you have a lot of buckets on amazon it is not feasible or secure to use your own security access key with the buckets(Especially if you have to handover the project).
Moreover there is no official way to transfer s3 buckets from one aws account to another.The best way is to create a bucket on the clients account and only provide the appropriate permission on the bucket.
Amazon lets you define permission through their iam policy.IAM policy has 3 keys which define your permission.
These where take right from the amazon docs.

Actions: what actions you will allow. Each AWS service has its own set of actions. For example, you might allow a user to use the Amazon S3 ListBucket action, which returns information about the items in a bucket. Any actions that you don’t explicitly allow are denied.

Resources: which resources you allow the action on. For example, what specific Amazon S3 buckets will you allow the user to perform the ListBucket action on? Users cannot access any resources that you have not explicitly granted permissions to.

Effect: what the effect will be when the user requests access—either allow or deny. Because the default is that resources are denied to users, you typically specify that you will allow users access to resource.

Here is the IAM Policy that  I use to restrict a user to a particular bucket.It gives user all the permission over the bucket ie to Add,Delete,List…

  "Version": "2014-10-17",
  "Statement": [
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": [
Just replace <bucket-name> with your s3 bucket name.