Javascript Modifying the Url of a Page Without Refreshing It

Back in Jan, I was trying to understand different ways of modifying the url of a page without actually having to refresh it. A typical case is search pages. If you pull your results in through Ajax -as you modify the search parameters- you also want the url to be modified/constructed to reflect your refined search.

Previously modifying the url of a page by way of js would force a refresh:

1
2
    // The old way
    window.location.href = window.location.href.replace(/\&ni\=on/ig, '');

There are a whole bunch of posts up now on the subject, but this particular one caught my eye as it was one of the early ones and really did a great job explaining the concept with a nice tutorial.

1
2
3
4
    // The HTML5 way:
    url = window.location.pathname
    url += "?max_id=" + tweet.attr('data-id') if tweet
    window.history.replaceState({}, document.title, url)

Other nice resources:

POW

POW is a zero config Rack server from the maker of rbenv. It’s brilliant for quick local development. If you’re into developing Rails applications, definitely check it out. Oh and Octopress works with pow as well (Score!).

A Developer’s Life

This is by far the funniest stuff I’ve read this year. Never fails to crack me up…

Advice From Chetan Bhagat

Chetan Bhagat is from my alma-mater. I think he’s a really really smart guy who occasionally says mildly immature and stupid things (in the media). This is one of those times where his advice is simply pure gold:

Don’t just have career or academic goals. Set goals to give you a balanced, successful life. I use the word balanced before successful. Balanced means ensuring your health, relationships, mental peace are all in good order. There is no point of getting a promotion on the day of your breakup. There is no fun in driving a car if your back hurts. Shopping is not enjoyable if your mind is full of tensions.

One last thing about nurturing the spark – don’t take life seriously. One of my yoga teachers used to make students laugh during classes. One student asked him if these jokes would take away something from the yoga practice. The teacher said – don’t be serious, be sincere.

We are like a pre-paid card with limited validity. If we are lucky, we may last another 50 years. And 50 years is just 2,500 weekends. Do we really need to get so worked up? It’s ok, bunk a few classes, goof up a few interviews, fall in love. We are people, not programmed devices.

[Courtesy: doctorzhivago]

Elo Rating System - Explained in Code

I find it amusing that the simplest and quickest explanation I could find for how the Elo Rating system works, was one written in code. You know you’re a software engineer when you find the code easier to understand than documentation (an adaptation of the Elo Rating system is used for rating chess grandmasters).

Outgrowing Religion Quote - Swami Muktananda

You mustn’t believe in your own religion; I don’t believe in mine. Religions are like the fences that hold young saplings erect. Without the fence the sapling could fall over. When it takes firm root and becomes a tree, the fence is no longer needed. However, most people never lose their need for the fence.

Swami Muktananda

by way of Andres Sullivan

On Code Refactoring

A friend/craftsmanship-sensei passed on these videos on refactoring. I think these are by far some of the best talks I’ve ever seen on refactoring: