[typerush] Upgraded framework

So in the latest change-set, I’ve upgraded our framework CodeIgniter to 3.0.4. Wasn’t hard since the custom code footprint was relatively small and nothing was changed in the core files.

Next I want to complete the multiplayer part as soon as possible. Before that some challenges, that I can see are:

  1. How would someone keep track of all the rooms that he has been in
  2. What happens when a user exits a room. Do we save the room data? If yes, then how is that accessible.
  3. Need a proper sanity process of the real time feature so that nothing is breaking.

Also in my list are some infra changes

  1. Doing JS and CSS versioning during deployment.
  2. Keeping environment related config items separate from the common config items.

There are some feature addons as well :

  1. A performance card at the end of every run.
  2. An option to mark a track as difficult or easy.
  3. The progress meter to be based on characters instead of words.
  4. Better UI

Security Measures:

  1. Applying continuous sync with server to prevent hacking of score.
  2. Setting a max value for speed, just to make sure data does not get corrupt.

[typerush] A new beginning

This is the first post of many to come in the TypeRush Series. In here, I’ll be writing on my learnings and logs of developing typerush.com as a product.

I’ll be trying to use the three step production development cycle : build, measure, learn. I’ll try to focus on things that matter instead of building a “complete” product. I’ll need help in getting feedback and am not sure at this stage how I am gonna do that.

What prompted the development of this product?
I think seeing someone keying into the computer at high speeds leaves me impressed. I wanted to be like them; to be able to type superfast. When a friend introduced me to typeracer.com during college, I was pretty much addicted. I wanted to create a better version of the same.

Who is the target audience?
At this point, typing enthusiasts is what I’ll say. Ideally, everyone who has working on a computer as part of their daily job routine. And kids and teenagers who have a gaming instinct and like to measure themselves against others.

What problem are you trying to solve?
At present it’s just a game. In the next phase, I want it to help people type better and faster.

If you want to take a pilot run at the current product, hop on to http://www.typerush.com

Type Rush




The framework I am working on right now is like a framework inside a framework which has a framework inside it, which turns out to be made up of other frameworks. I just can’t think of going deeper, afraid that i might never come out.

You ..are an Entrepreneur!

Your eyes close. Your imagination roams. An idea forms. You start typing furiously. Time passes without seeming to pass. Suddenly, a new product is born. Cue whiteboards, pitch meetings, investors. Launch! Your first customer. You hire your first employee. You … are a success. You … are an entrepreneur.

Installing ftp server on an ubuntu ec2 instance




So we recently had this requirement to give ftp access to a third party client on our staging server. They did not want the hassle of sshing in and making changes or committing changes to git and then making the changes live. Now, installing an ftp with a username-password access might seem like a daunting task initially, but here is how I managed to do it.

Step 1 : Installing vsftpd server

vsftpd ( very secure ftp daemon ) is one of the popular ftp servers out there. After logging in to the ec2 instance, the following command will install vsftpd

sudo apt-get install vsftpd

Step 2 : Make the following changes to the vsftpd conf file 

The configuration file can be opened up for editing at

sudo vim /etc/vsftpd/vsftpd.conf

And change/add the following flags:

pasv_address=[public dns from the amazon EC2 instance]

After doing the above, we need to boost up or daemon again.

sudo service vsftpd restart

Step 3 : Opening up port from the ec2 dashboard

Hop on to aws.amazon.com, login and go to your ec2 dashboard. Over there, for our particular instance, check the security group that it is a part of. Then hop on to that security group section and edit the rules of that particular security group as follows :

EC2 Management Console

Notice that I’ve added the “All TCP” rule which will open up a range of ports for connection. Also note that we did not have a very strict security requirement, but if you are looking for that, then I would recommend opening up selective ports only.

Step 4 : Create a user and make him owner of the root directory

In the ec2 instance console, just add a new user by

sudo adduser ftpuser

It will prompt you to enter details including the password. After we are done with that, we need to make this user the owner of the directory which we want him to be able to read/write. In my case it was the document root for apache, hence the following command :

sudo chown -R ftpuser:ftpuser /var/www/html/

Yep, that’s about it. To login via FileZilla, the host needs to be the public dns of the ec2 instance; username and passswords will be the same as that of the newly created user. I took help from the following posts as a reference :


CodeIgniter 3.0 and How I use it!

So, we recently upgraded our framework version from 2.2.3 to 3.0.0 at Seenit.in. The latest version is more around bug fixes and making the session library more secure. There is a huge debate these days over other frameworks, mostly Laravel vs CodeIgniter. Majority of the people are of the opinion that CI is now the granny PHP framework and we should be moving towards younger and better frameworks. But I’ve been a big fan of CodeIgniter from the beginning and don’t want to lose hope all that soon.

Screen Shot 2015-05-28 at 9.49.44 AM

So after upgrading CI to 3.0, I decided to change some of my practices so that I gradually move towards a more modern style of coding. Here are some of my changes:

1. config_item() : This function was available in the previous version as well but I only found about it after upgrading. ( from the up-gradation steps ) I think it is a very handy shorthand for $this->config->item() function. Although the official user guide says that the latter is the preferred method over the earlier, but it also says that there is no harm in using it for retrieving single key values. So unless we are dealing with multiple config files with name conflicts, we should be fine.

2. [] for array definition : This shorthand is pretty handy in my opinion. ( not exactly a 3.0 change ). Traditionally in documentations and online tutorials, arrays have been used using the array()  syntax for both indexes and associative types. But in my opinion a

$temp = [ '1' => 'apple', 'two' => 'orange']


$arr = ['mumbai', 'delhi'];

are much more easier to type. The only limitation here is that this syntax was introduced in PHP 5.4. So as long as we are using a PHP with a higher version, we should be good.

3. $config[‘reuse_query_string’] = true : This new config value in the pagination library in 3.0 has been a huge help. So the way pagination links work in CI is that they append the offset to the url itself. So page 2 of the url http://abc.com/list will be http://abc.com/list/40 where 40 is the number of items you show on each page and url for page 3 will be http://abc.com/list/80 and so on. But if my page has some query params which I want to retain, like for the url : http://abc.com/list?q=php, the pagination url will ignore the GET params, like so : http://abc.com/list/40. But with the above config variable this is now possible. http://abc.com/list/40?q=php



CodeIgniter Cache library for Redis

So I’ve been trying to setup a Redis library inside CodeIgniter3.0. My first attempt was to search on git hub which landed me on joelcox’s repo. It seemed promising with enough number of commits and contributors, but as it said it has been deprecated, I had to look further. Now since Codeigniter also provides a Caching library out of the box, I decided to give it a try.

As illustrated in the documentation fairly well, to initiate the cache on needs to write :

$this->load->driver('cache', ['adapter'=>'redis']);

The only difference is the additional array argument that I passed to driver() without which I was not able to get it to work. The redis config needs to be put in a file at location application/config/redis.php. Mine looks like this :

$config['socket_type'] = 'tcp'; //`tcp` or `unix`
$config['socket'] = '/var/run/redis.sock'; // in case of `unix` socket type
$config['host'] = '';
$config['password'] = NULL;
$config['port'] = 6379;
$config['timeout'] = 0;

This is enough to get it to work, and for simple key value pairs the following two statements can be used to set and get the value :

$this->redisObj->save($key, $value, null); // save the data with infinite TTL

$this->redisObj->get($key); // get the value of the key

This is pretty handy. Although it does not provide more redis functionalities like increment or selecting all keys ( keys * ), it does the job for basic key setting/getting requirements. Looking further for a more feature rich Redis Library for CodeIgniter.