Rush was fantastic I just wanna talk about it okay


Rush was fantastic I just wanna talk about it okay

Setting up a custom domain on appfog

Recently, I had a hard time configuring my domain on appfog. There were two seperate problems along the way.
One was properly setting up the a record along with the cname and the other was redirecting naked urls to www urls.
This is how I did it.

Set up appfog

Setting up appfog is a piece of cake. Just dowload their ‘af’ gem and login into appfog. From there, push and update your app in the desired infrastructure.

Set up your domain

For this post, I will be using the www domain name. It doesn’t matter whether your domain starts with www or non-www(usually called a canonical domain) so just decide beforehand which type of domain do you prefer.

Unlike other hosting providers, appfog doesn’t provide a dns server. So you need to set up an A record and a CNAME record with your domain provider.

For the A record, add the domain in appfog’s console. Like this :

See the second domain? That’s mine. The third one is min too but I will explain it later on. You will be provided a default domain which is the first one in the screenshot. Add your domain and click on update.

Now see the two ip addresses next to the A record on the screenie? You need to add those as two different A records on your domain provider’s console(or whatever it is called)

Next, add the CNAME record. The C in CNAME stands for canonical btw. I bought my domain from bigrock which is pretty nifty. My settings page looks like this :

Remember to NOT add the www when adding the A record. Now when adding the CNAME record, add the url next to the CNAME record in the appfog console as your CNAME value and add the www version of your url in CNAME. One last thing. I added the third domain because I couldn’t redirect from my domain provider’s console. So I set up the non-www url and redirected all the non-www traffic to the www-domain from my app itself.

Done? Dns propogation for A and CNAME records usually take between 1-4 hours so go outside and chill out.

Now your www-yourdomain-com will be working. That’s fine but when you type yourdomain-com without the www, it won’t work. That’s because you need to add a 301(it means permanent) redirect from your .yourdomain-com to www-yourdomain-com There are a couple of ways to do this.

  • Your domain provider has a facility to redirect domains. Simply set the redirect from your domain provider’s console.

  • If you are using apache, checkout the online guides on how to add redirects in .htaccess

  • Or if you are like me and hack around in nodejs, add this snippet of code before all your other routes.

app.get('*', function(req, res, next) {
        if (req.headers.host.slice(0, 3) != 'www') {
            res.redirect('http://www.' + req.headers.host + req.url, 301);
        } else {

This code snippet is meant for expressjs but it can work on standard nodejs http as well. The best part about this snippet is that it will redirect all paths to the correct domain.

That’s all for now folks. Setting up domains on appfog can be a bit of a pain but I hope this post helps.

Switching over to gulpjs

gulpjs is a new kind of taskrunner. It is like gruntjs but much better. The work of a taskrunner is to automate simple tasks like minifying files, compiling preprocessor css like less, etc.

This is how I started using gulpjs


As I said before, gulpjs is a taskrunner. It is based on streams the technicalities of which are beyond me but that means it is extremely fast.
But better than this, the api of gulpjs is straightforward meaning you can get up and started within minutes.

This is how my gulpfile looks like :

var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');

gulp.task('compress', function() {

gulp.task('default', ['compress']);

Pretty simple huh? gulpjs is much easier to use and this was one of the main reasons I started using it instead of gruntjs

Getting started

First, you will need nodejs. Once installed, start npm via the command prompt and install gulpjs globally. This is because you can start calling it anywhere.

npm install -g gulp

Done? Now, add devDependencies in your package.json which should be in your project’s root. For this example, I am using gulp-uglify and gulp-concat. The required task is to minify and then concat all javascript files.
package.json :

	"name": "example",
	"version": "0.1.0",
	"author": "shash7",
	"devDependencies" : {
		"gulp-uglify": ">= 0.2.0",
		"gulp-concat": ">= 2.1.7"

Now give the command ‘npm install’ inside the project root (where you package.json will be residing) After installing, make a file named gulpfile.js inside the project root.

// Dependencies
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');

// The actual task. Note the pipe function
gulp.task('compress', function() {

// The default task
gulp.task('default', ['compress']);

After adding the dependencies, you will need to create a task. I have named my task compress which is exactly what it does. gulpjs needs a task called default which will be executed when you run the file. Inside the default task, call your task inside an array. If you want, you can also bind a callback function.
When everything is done, simply call gulp in your project’s root


That’s it. gulpjs will now check for js files inside a folder called js and then will minify and concat them all and place them inside a folder called dist and will name the new file as all.js
That’s all for now. I hope you find gulpjs as awesome I did.

Say hi to aim_solar

aim_solar is a counter-strike 1.6 map which is published by me after a long time. Initially, this map was supposed to be a weekend project by ended up getting delayed by two months.

For all you cs 1.6 players, check this map out. It is hosted on gamebanana.
It supports 24 players only considering how small it is and is make for small pub matches.

Modelled after popular maps like fy_poolday, solar takes the aim map type to another level by removing all the extra bits and pieces and tries to keeps the polygon level to a bare minimum.

Check this crazy shit out

I never knew anything about cowsay. Now check this out :

Yes, its a crazy comment generator for brackets.
Brackets.io Ftw!!!

In case you are wondering, cowsay is a brackets extension.

Introducing capbar.js

Quite some time ago, I made a small library which shows a progress bar showing how much length of an input field is left.
Here is the project page.